akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reve(a) reverse(a.begin(), a.end())
#define PI 3.14159265359
typedef long long ll;
const ll MOD = 1e9+7;

/*ll gcd(ll a, ll b){
  if(b==0) return a;
  return gcd(b, a%b);
}*/
/*ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}*/

/*ll lcm(ll a, ll b){
  ll g = gcd(a, b);
  b /= g;
  a *= b;
  return a;
}*/
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

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

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


int main(){
  string s; cin >> s; int64_t k; cin >> k;
  int64_t sz = s.size(); int64_t sz2 = sz*2; 
  int64_t q=1; 
  int64_t ans=0LL;
  int64_t ch = 0LL;
  /*rep(z, sz-1){
    if(s.at(z)!=s.at(z+1)) {ch=1; break;}
  }*/

  //if(ch==0) cout << (sz*k)/2 << endl;
  //if(ch==0) printf("%d\n", (sz*k)/2);
  if(s.at(0)!=s.at(sz-1)){
    rep(i, sz-1){
      int64_t j = i;
      while(s.at(j)==s.at(j+1)) {q+=1; j++;if(j==sz-1) break;}
      ans += q/2;
      q = 1; i = j;
    }
    cout << ans*k << endl;
    //printf("%d\n", ans*k);
  }
  else{
    rep(z, sz-1){
    if(s.at(z)!=s.at(z+1)) {ch=1; break;}
  }
  if(ch==0) cout << (sz*k)/2 << endl;
   else{ int64_t p = sz-1, w=1;
    while(s.at(p)==s.at(p-1)){
      //u += t.at(p+1);
      p--; w++;
      if(p==0) break;
    }
    int64_t d=1, e=0;
    while(s.at(e)==s.at(e+1)){
      d++; e++;
      if(e==sz-1) break;
    }
    int64_t h = (d+w)/2;
    //cout << w << endl; 
    //cout << h << " " << 
    int64_t sum=0;
    ans += h*(k-1)+d/2+w/2;
    //int usz = u.size();
    for(int x=e+1; x<p; x++){
      int y = x;
      while(s.at(y)==s.at(y+1)){
        q++; y++; 
        if(y==p-1) break;
      }
      sum += q/2; q=1; x = y;
    }
    ans += sum*k;
    cout << ans << endl;
    //printf("%d\n", ans);
  }
  }
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    d = defaultdict(int)
    for _ in range(N):
        s = input()
        d[s] += 1
    print(len(d.values()))


if __name__ == '__main__':
    main()

Measured memory_bytes: 35588
//******* It's LEVI_17 ***************

#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ff first
#define ss second
#define MP make_pair
#define mset(x,a) memset(x,a,sizeof(x))
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define vvll vector<vector<ll>>  
#define vll vector<ll> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define cases ll t;cin >> t;while(t--)
#define rr return 0
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define deb(a)			std::cerr<<#a<<"="<<(a)<<"\n"
#define deb2(a,b)		std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define deb3(a,b,c)		std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
const int MOD = 1000 * 1000 * 1000 + 7;
const ll INF = 1e18L + 5;
//syntax for priority queue
// max queue -> priority_queue<ll>
// min queue -> priority_queue<ll,vector<ll>,greater<ll>>

//##############################################################################################

ll sum(ll arr[], ll L, ll R)
{
    ll s = 0;
    for (ll i = L; i <= R; i++)
        s += arr[i];
    return s;
}
ll getRes(ll arr[], ll n)
{
    ll dp[405][405];
    // dp[i][j] -> minimum total cost of combining interval [i,j] into one vertex

    for (ll L = n - 1; L >= 0; L--)
    {
        for (ll R = L; R < n; R++)
        {
            if (L == R)
                dp[L][R] = 0;
            else
            {
                dp[L][R] = INF;
                ll s = sum(arr,L, R);

                for (ll i = L; i <= R - 1; i++)
                {
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i + 1][R] + s);
                }
            }
        }
    }
    

    return dp[0][n - 1];
}

void solve()
{
    ll n;
    cin >> n;
    ll arr[405];
    f(i, n)
        cin >> arr[i];

    ll res = getRes(arr, n);

    cout << res << "\n";
}

//###############################################################################################

int main()
{
    fast;
    ll t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    rr;
}


//Watashi wa tsuyoku modotte kimasu

Measured memory_bytes: 4832
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').let {
        it[0].toInt() to it[1].toLong()
    }
    val a = readLine()!!.split(' ').map { it.toInt() }.toIntArray().sorted()
    val f = readLine()!!.split(' ').map { it.toInt() }.toIntArray().sortedDescending()

    var l = 0L
    var r = 1e12.toLong()
    while (l < r) {
        val m = l + (r - l) / 2

        var x = 0L
        for (i in 0 until n) {
            x += Math.max(a[i] - (m / f[i]), 0)
        }

        if (x <= k) {
            r = m
        } else {
            l = m + 1
        }
    }

    println(l)
}


Measured memory_bytes: 115264
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;
int score[14] = {0, 13, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};

int main(int argc, char const* argv[])
{
	int a, b;
	cin >> a >> b;
	if(score[a] > score[b])cout << "Alice";
	else if(score[a] < score[b])cout << "Bob";
	else cout << "Draw";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
// Problem : D - Banned K
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
	#define debug(A,args...) fprintf(stderr,A,##args)
#else
	#define debug(A,args...) printf("")
#endif
#define deb debug("line %d\n",__LINE__)
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void GG(){puts("-1");exit(0);}

	const db eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int MM=5e6+10;
	ll fac[MM],facinv[MM],Inv[MM];ll Comb(int n,int m){return n<0 or n<m?0:fac[n]*facinv[m]%MOD*facinv[n-m]%MOD;}
	void PRE()
	{
		fac[0]=1;fo(i,1,MM-1) fac[i]=fac[i-1]*i%MOD;
		facinv[MM-1]=invm(fac[MM-1]);fd(i,MM-1,1) facinv[i-1]=facinv[i]*i%MOD;
		Inv[1]=1;fo(i,2,MM-1) Inv[i]=(MOD-MOD/i)*Inv[MOD%i]%MOD;
	}

	const int N=1e6+10;
	//------------------FIXED------------------
	int a[N];
	void main()
	{
		int n=qread();map<int,int> ct;fo(i,1,n) ct[a[i]=qread()]++;
		ll ans=0;fo(i,1,n) ans+=ct[a[i]]-1;
		fo(i,1,n) write2( ans/2-(ct[a[i]]-1) );
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("a.in","r",stdin);
	// freopen("z.txt","r",stdin);
	//freopen("a.out","w",stdout);
	#endif
	srand(time(0));
	mine::main();
	//debug("\n------------------------------------------\nTime: %.2lf s\n",1.0*clock()/CLOCKS_PER_SEC);
}

Measured memory_bytes: 8320
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <set>
#include <map>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);

	int a, b;
	scanf("%d%d", &a, &b);
	if (a > b) swap(a, b);
	int d = b - a;
	if (d&1)
		printf("IMPOSSIBLE\n");
	else
		printf("%d\n", a + d/2);
}


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

int main() {
  ll N;
  cin >> N;
  ll target = 1;
  ll targetCount = 0;
  ll count = 0;
  ll a;
  for(int i = 0; i < N; ++i) {
    cin >> a;
    if(a == target) {
      target++;
      targetCount++;
    } else {
      count++;
    }
  }
  if(targetCount == 0) {
    cout << -1 << endl;
  } else {
    cout << count << endl;
  }

  return 0;
}

Measured memory_bytes: 384
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_SHIP_MAX		200000									// 最大定期便数

// 内部変数
static int si1Ship1[D_SHIP_MAX + 5];							// 定期便1
static int siS1Cnt;												// 定期便1数
static int si1ShipN[D_SHIP_MAX + 5];							// 定期便N
static int siSNCnt;												// 定期便N数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// ソート関数 - int昇順
int
fSortFnc(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	int *lipVal1 = (int *)pzpVal1;
	int *lipVal2 = (int *)pzpVal2;

	// 昇順
	if (*lipVal1 >  *lipVal2) {
		return(1);
	}
	else if (*lipVal1 < *lipVal2) {
		return(-1);
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// データ初期化
	siS1Cnt = 0;												// 定期便1数
	siSNCnt = 0;												// 定期便N数

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 目的地・定期便数取得
	int liN, liSCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d%d", &liN, &liSCnt);

	// 定期便取得
	for (i = 0; i < liSCnt; i++) {
		int liFNo, liTNo;
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
		fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
		sscanf(lc1Buf, "%d%d", &liFNo, &liTNo);

		if (liFNo == 1) {
			si1Ship1[siS1Cnt] = liTNo;
			siS1Cnt++;
		}
		else if (liTNo == 1) {
			si1Ship1[siS1Cnt] = liFNo;
			siS1Cnt++;
		}
		else if (liFNo == liN) {
			si1ShipN[siSNCnt] = liTNo;
			siSNCnt++;
		}
		else if (liTNo == liN) {
			si1ShipN[siSNCnt] = liFNo;
			siSNCnt++;
		}
	}

	// 定期便ソート
	qsort(si1Ship1, siS1Cnt, sizeof(int), fSortFnc);
	qsort(si1ShipN, siSNCnt, sizeof(int), fSortFnc);

	// マッチング
	int liRet = -1;
	int liS1No = 0;
	int liSNNo = 0;
	while (1) {

		// 終了チェック
		if (liS1No >= siS1Cnt) {
			break;
		}
		if (liSNNo >= siSNCnt) {
			break;
		}

		// 比較
		if (si1Ship1[liS1No] < si1ShipN[liSNNo]) {
			liS1No++;
		}
		else if (si1Ship1[liS1No] == si1ShipN[liSNNo]) {	// 一致
			liRet = 0;
			break;
		}
		else {
			liSNNo++;
		}
	}

	// 結果セット
	if (liRet == 0) {
		sprintf(lc1Out, "POSSIBLE\n");
	}
	else {
		sprintf(lc1Out, "IMPOSSIBLE\n");
	}

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 1404
/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Tree = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n;
	cin >> n;
	Vec p(n);
	rep(i, n)cin >> p[i];

	ll mini = LINF, ans = 0;
	rep(i, n){
		if(p[i] <= mini) ans++;
		chmin(mini, p[i]);
	}
	co(ans);

	return 0;
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int bit[300001] = {0};

int sum(int i){
  int s = 0;
  while(i > 0){
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

void add(int i, int x, int M){
  while(i <= M){
    bit[i] += x;
    i += i & -i;
  }
}

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> l(N + 1, 0), r(N + 1, 0);
  map<int, vector<pair<int, int>>> len; 
  for(int i = 1; i <= N; i++){
    cin >> l[i] >> r[i];
    len[r[i] - l[i] + 1].emplace_back(l[i], r[i]);
  }

  int n = N;
  for(int i = 1; i <= M; i++){
    int d = i;
    for(pair<int, int> p : len[d]){
      add(p.first, 1, M + 1);
      add(p.second + 1, -1, M + 1);
      n--;
    }
    int s = 0;
    for(int j = 0; j <= M; j+=d){
      s += sum(j);
    }
    cout << s + n << endl;
  }  
}


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

int main() {
  int n,y;
  cin >> n >> y;
  y /= 1000;
  
  int a=-1;
  int b=-1;
  int c=-1;
  
  bool can = false;
  rep(i,y/10+1){
    rep(j,(y-10*i)/5+1){
      int k = n-i-j;
      if(k+5*j+10*i==y&&k>=0){
        can=true;
        a=i;
        b=j;
        c=k;
        break;
      }
    }
    if(can) break;
  }
  
  cout << a << ' ' << b << ' ' << c << endl;
}


Measured memory_bytes: 256
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    int k=0;
    int ans=0;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        if(a>k){
            k=a;
            ans=b;
        }
    }
    cout<<k+ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1'000'000'007;
constexpr ll mod = 998244353;
const double PI = 3.14159265358;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  int sum = 0;
  string S = to_string(N);
  for(int i=0; i<S.size(); i++){
    sum += S[i] - '0';
  }
  if(N%sum == 0){
    cout << "Yes\n";
  }else{
    cout << "No\n";
  }
  return 0;
}

Measured memory_bytes: 3724
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


#define MOD 998244353


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

	int n;
	string s;
	cin >> n >> s;


	long long ans = 1, r = 0, g = 0, b = 0;
	long long vr = 0, vg = 0, vb = 0, pa = 0;

	for (char c : s) {
		if (c=='R') {
			r++;
			vr++;
		}
		else if (c == 'G') {
			g++;
			vg++;
		}
		else {
			b++;
			vb++;
		}

		if (r && g && b) {
			ans *= pa;
			ans %= MOD;
			r--; g--; b--;

			pa--;
			if (c == 'R')vr--;
			else if (c == 'G')vg--;
			else vb--;
		}
		else if(vr && vg){
			ans *= vr * vg % MOD;
			ans %= MOD;
			vr--;
			vg--;
			pa++;
		}
		else if (vr && vb) {
			ans *= vr * vb % MOD;
			ans %= MOD;
			vr--;
			vb--;
			pa++;
		}
		else if (vg && vb) {
			ans *= vg * vb % MOD;
			ans %= MOD;
			vg--;
			vb--;
			pa++;
		}
	}
	rep(i, n)(ans *= i + 1) %= MOD;


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 720
import sys
input=sys.stdin.readline
n=int(input())
s=input().rstrip()
start=['SS','SW','WS','WW']
import sys
for k in start:
    ans=[k[0],k[1]]
    for i in range(2,n):
        if (ans[i-2]=='S' and ans[i-1]=='S' and s[i-1]=='o') or (ans[i-2]=='S' and ans[i-1]=='W' and s[i-1]=='x') or (ans[i-2]=='W' and ans[i-1]=='S' and s[i-1]=='x') or (ans[i-2]=='W' and ans[i-1]=='W' and s[i-1]=='o'):
            ans.append('S')
        else:
            ans.append('W')
    if (s[0]=='o' and ans[0]=='S') or (s[0]=='x' and ans[0]=='W'):
        if ans[1]==ans[n-1]:
            pass
        else:
            continue
    else:
        if ans[1]==ans[n-1]:
            continue
    if (s[n-1]=='o' and ans[n-1]=='S') or (s[n-1]=='x' and ans[n-1]=='W'):
        if ans[0]==ans[n-2]:
            pass
        else:
            continue
    else:
        if ans[0]==ans[n-2]:
            continue
    for i in ans:
        print(i,end='')
    sys.exit()
print(-1)
    




Measured memory_bytes: 65536
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int[] L;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        L = new int[N];
        for (int i=0; i<N; i++) {
        	L[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private int solve() {
        int answer = 0;
       
        for (int i=0; i<N; i++) {
        	for (int j=i+1; j<N; j++) {
        		for (int k=j+1; k<N; k++) {
        			if (L[i]!=L[j] && L[j]!=L[k] && L[i]!=L[k] && isTriangle(L[i],L[j],L[k])) {
        				answer++;
        			}
        		}
        	}
        }
        
        return answer;
    }
    
    //三辺の長さがL[i],L[j],L[k]の三角形が存在するか判定するメソッド
    private boolean isTriangle(int i, int j, int k) {
    	boolean judge = false;
    	if (i+j>k && j+k>i && k+i>j) {
    		judge = true;
    	}
    	
    	return judge;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 36964
N, K = map(int, input().split())
V = list(map(int, input().split()))

def dispose(disposeList, tms):
    disposeList.sort()
    i = 0
    while i < tms:
        if disposeList[i] < 0:
            disposeList[i] = 0
            i += 1
        else:
            return disposeList
        
    return disposeList
    
res = 0
for take in range(min(N,K)+1):
    for left in range(take+1):
        right = take - left
        my_V = [V[i] for i in range(left)] + [V[-i-1] for i in range(right)]
    
        my_V = dispose(my_V, min(take, K-take))
        res = max(res, sum(my_V))
        
print(res)

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

int main(){
  int K ; 
  cin >> K ; 
  int64_t T = 7 ;  
  int cnt = 1 ;

  while( cnt   < 10000000 ){
    if(T%K == 0){
      cout << cnt  << endl ; 
      return 0 ; 
    }
    else if(T > K ){
      T = T%K ; 
    }         
    cnt++ ; 
    T = T*10 + 7 ; 
  }

  cout << "-1" << endl ; 
  
}


Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
//#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int n, a, b, c, l[9], ans = 1001001001;
int main(){
	scanf("%d%d%d%d", &n, &a, &b, &c);
	for(int i=0; i<n; i++)scanf("%d", l+i);
	for(int i=0; i<(1<<2*n); i++){
		int aa=0, bb=0, cc=0, aaa=00, bbb=0, ccc=0;
		for(int j=0; j<n; j++){
			if(((i>>2*j)&3) == 3){
				aa++;
				aaa += l[j];
			}else if(((i>>2*j)&3) == 2){
				bb++;
				bbb += l[j];
			}else if(((i>>2*j)&3) == 1){
				cc++;
				ccc += l[j];
			}
			//printf("%d ", (i>>2*j)&3);
		}
		if(aa*bb*cc){
			ans = min(ans, abs(aaa-a) + abs(bbb-b) + abs(ccc-c) + (aa+bb+cc-3) * 10);
		}
		//printf("%d %d %d %d %d %d\n", aa, bb, cc, aaa, bbb, ccc);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1696
n,k=map(int,input().split())
l=list(map(int,input().split()))
MOD=10**9+7
ans=0
for num,i in enumerate(l):
    n1=sum([j<i for j in l])
    n2=sum([j<i for j in l[num:]])
    ans+=k*n2+k*(k-1)*n1//2
    ans%=MOD
print(ans)

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;

typedef struct{
  int start;
  int goal;
  int height;
}Line;

bool operator>(Line l1,Line l2){
  return (l1.height > l2.height);
}

int main(){
  int n,m,a;
  while(cin>>n>>m>>a,n+m+a){
    vector<Line> vec(m);
    for(int i=0;i<m;i++){
      Line line;
      cin>>line.height>>line.start>>line.goal;
      vec[i]=line;
    }
    sort(vec.begin(),vec.end(),greater<Line>());
    int s=a;
    for(int i=0;i<m;i++){
      if(vec[i].start==s){
	s=vec[i].goal;
      }else if(vec[i].goal==s){
	s=vec[i].start;
      }
    }
    cout<<s<<endl;

  }
  return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;

int main(void) {
    io;
    string s,t;
    cin >> s >> t;
    int count = 0;
    rep(i, (int)s.size()) if (s[i] != t[i]) count++;
    cout << count;
    return 0;
}



Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

ll k, n;
vector<ll> p;

int main(){
	cin >> n >> k;
	p.resize(n);
	
	for ( int i = 0; i < n; i++ )
		cin >> p[i];
	
	sort(p.begin(),p.end());
	
	ll sum = 0;
	for ( int i = 0; i < k; i++ )
		sum += p[i];
	
	cout << sum << endl;
	return 0;
}




Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int a[3][3];
int main(){
    rep(i,3){
        rep(j,3){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    vector<int> b(1100);
    rep(i,n){
        int x;
        cin >> x;
        b[x]=1;
    }
    rep(i,3){
        int cnt = 0;
        rep(j,3){
            cnt+=b[a[i][j]];
        }
        if(cnt==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    rep(i,3){
        int cnt = 0;
        rep(j,3){
            cnt+=b[a[j][i]];
        }
        if(cnt==3){
            cout << "Yes" << endl;
            return 0;
        }
    }
    int cnt = 0;
    rep(i,3){
            cnt+=b[a[i][i]];
    }
        if(cnt==3){
            cout << "Yes" << endl;
            return 0;
        }
        cnt = 0;
    rep(i,3){
        cnt+=b[a[2-i][i]];
    }
        if(cnt==3){
            cout << "Yes" << endl;
            return 0;
        }
        cout << "No" << endl;

    return 0;
}

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

int main(){
  int n, d;
  cin >> n >> d;
  int x[n][2];
  rep(i,n) rep(j,2) cin >> x[i][j];
  two_sat ts(n);
  rep(i,n) {
    for(int j = i+1; j < n; j++) {
      rep(k,2) {
        rep(l,2) {
          if(abs(x[i][k]-x[j][l]) < d) ts.add_clause(i,!k,j,!l);
        }
      }
    }
  }
  if(!ts.satisfiable()) cout << "No" << endl;
  else {
    cout << "Yes" << endl;
    vector<bool> ans = ts.answer();
    rep(i,n) cout << x[i][ans[i]] << endl; 
  }
  return 0;
}


Measured memory_bytes: 3740
fn main() {
    proconio::input! {
        n: usize,
        mut a_s: [usize; n],
    }
    a_s.sort();
    a_s.reverse();
    let mut count = 0usize;
    for i in 1..n {
        count += a_s[i / 2];
    }
    println!("{}", count);
}


Measured memory_bytes: 6288
#include<stdio.h>
#include<stdlib.h>
#define MAX 100000
#define NIL -1
#define N 2
typedef struct {
    int parent,left,right;
}node;
node t[MAX];
int n,d[MAX],h[MAX];

void getdepth(int u,int p){
    d[u]=p;
    if(t[u].right!=NIL)getdepth(t[u].right,p+1);
    if(t[u].left!=NIL)getdepth(t[u].left,p+1);
}

int setheight(int u){
  int h1=0,h2=0;
  if(t[u].right!=NIL)h1=setheight(t[u].right)+1;
  if(t[u].left!=NIL)h2=setheight(t[u].left)+1;
  if(h1>h2)h[u]=h1;
  else h[u]=h2;
  return h[u];
}

int main(){                                                                                  
  int i,id,k,*c,j,df,de,s;                                                                   
  scanf("%d",&n);                                                                      
  for(i=0;i<n;i++) t[i].parent=t[i].left=t[i].right=NIL;                                     
  for(i=0;i<n;i++){                                                                          
    scanf("%d",&id);                                                                    
    c=(int*)malloc(sizeof(int)*N);                                                           
    for(j=0;j<N;j++)scanf("%d",&c[j]);                                                                                                                       
    for(j=0;j<N;j++)t[c[j]].parent=id;
    t[id].right=c[1];
    t[id].left=c[0];                         
  } 

  for(i=0;i<n;i++)if(t[i].parent==NIL)df=i;                                                                                                                                                                                      
  getdepth(df,0); 
  k=setheight(df);                                                                              
  for(i=0;i<n;i++){  
    if(t[i].left!=NIL)de++; 
    if(t[i].right!=NIL)de++;
    for(j=0;j<n;j++){
      if(t[i].parent==NIL)s=NIL;
      else if(t[i].parent==t[j].parent&&i!=j){
        s=j;
        break;
      }
      else s=NIL;
    }                                                                     
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",i,t[i].parent,s,de,d[i],h[i]);                         
    if(d[i]==0)printf("root\n");                                                                                                          
    else if(t[i].left!=NIL||t[i].right!=NIL)printf("internal node\n");                                                                                
    else printf("leaf\n"); 
    de=0;
  }  
  return 0;                                                                                  
}     


Measured memory_bytes: 2104
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
 
 
int main(){
 
    ll A,B;
 
    scanf("%lld %lld",&A,&B);
 
    if(B%A == 0){
 
        printf("-1\n");
 
    }else{
 
        ll num = A*(B/A+1);
 
        if(num%B < A && num/A < num/B+num%B){
 
            printf("%lld\n",num);
            return 0;
        }else{
 
            printf("-1\n");
        }
    }
 
    return 0;
}


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

unsigned long long caracal(unsigned long long h){
    if(h <= 1){
        return 1;
    } else {
        return caracal(floor(h/2)) * 2 + 1;
    }
}

int main() {
  unsigned long long h;
  cin >> h;
  cout << caracal(h) << endl;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if e - a > k:
    print(":(")
    exit()
if d - a > k:
    print(":(")
    exit()
if c - a > k:
    print(":(")
    exit()
if b - a > k:
    print(":(")
    exit()

print("Yay!")

Measured memory_bytes: 3064
import bisect
n = int(input())
A = list(int(input()) for _ in range(n))
B = [A[n-1]]

for i in range(n-2,-1,-1):
    if A[i] >= B[-1]:
        B.append(A[i])
    else:
        B[bisect.bisect_right(B,A[i])] = A[i]
print(len(B))


Measured memory_bytes: 56312
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

ll gcd(ll a, ll b){
  return (b ? gcd(b,a%b) : a);
}

struct Edge{
  int to,weight;
  Edge(int t, int w) : to(t),weight(w){}
};

using Graph = vector<vector<Edge>>;

int n;
Graph G;
vi color;

void dfs(int v, int p, int col = 0){
  color[v] = col;
  for(auto e : G[v]){
    int nv = e.to;
    if(nv == p) continue;

    int w = e.weight;
    if(w%2 == 0) dfs(nv, v, col);
    else dfs(nv, v, 1-col);
  }
}

int main(){
  cin >> n;
  G.resize(n);
  rep(i, n-1){
    int a,b,w; cin >> a >> b >> w;
    a--; b--;
    G[a].pb(Edge(b,w)); G[b].pb(Edge(a,w));
  }

  color.resize(n,0);
  dfs(0, -1);

  rep(i, n) std::cout << color[i] << '\n';
}


Measured memory_bytes: 8960
#include<iostream>
#include<cmath>

using namespace std;

long Q, N;

long multip(long n, long keta){
	long maxn = 0;
	long left ,right;
	for(long i=keta-1;i>=1;i--){
		left = n / pow(10,i);
		right = n - left*pow(10,i);
		long mul = left * right;
		if(mul > maxn) maxn = mul;
	}
	return maxn;
}
		
int getketa(int n){
	int i=0;
	int keta = 1;
	for(i=1;keta>0;i++){
		keta = n / pow(10,i);
	}
	return i-1;
}

int main(){
	cin >> Q;
	for(long i=0;i<Q;i++){
		cin >> N;
		long keta;
		long count = 0;
		while(keta = getketa(N),keta != 1 && count < 10000){
			N = multip(N, keta);
			//cout << N << endl;
			count ++;
		}
		cout << count << endl;
	}
	
	return 0;
}
			

Measured memory_bytes: 3276
H, W, K = gets.split.map(&:to_i)
MOD = 1_000_000_007

pat = [true, false].repeated_permutation(W - 1).reject{|p| p.join.include?('truetrue')} # Row Patterns
rep = pat.map{|p| a = [*1 .. W]; p.each_with_index{|b, i| a[i], a[i + 1] = a[i + 1], a[i] if b}; a} # Replacements
dp = Array.new(H + 1){Array.new(W + 1, 0)} # dp[h][k] => Row h, 1 at k 
dp[0][1] = 1
[*0 ... H].product(rep).each do |h, r|
  r.each.with_index(1){|j, i| dp[h + 1][i] = (dp[h + 1][i] + dp[h][j]) % MOD}
end
puts dp[H][K]

Measured memory_bytes: 2428
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    vector<ll> rui_a(n + 1, 0), rui_b(m + 1, 0);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        rui_a[i + 1] = rui_a[i] + a[i];
    }
    for(int i = 0; i < m; i++) {
        cin >> b[i];
        rui_b[i + 1] = rui_b[i] + b[i];
    }
    ll ans = 0;
    for(int i = 0; i <= n; i++) {
        if(rui_a[i] > k) {
            break;
        }
        ll tmp = upper_bound(all(rui_b), k - rui_a[i]) - rui_b.begin();
        ans = max(ans, i + max(0LL, tmp - 1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 9592
k = int(input())

num_list = [1,2,3,4,5,6,7,8,9]
num_a = ['0', '1']
num_b = ['8', '9']

for i in num_list:
    if str(i)[-1] == '0':
        for j in num_a:
            num_list.append(int(str(i)+j))
    elif str(i)[-1] == '9':
        for j in num_b:
            num_list.append(int(str(i)+j))
    else:
        num = int(str(i)[-1])
        for j in range(num-1, num+2):
            num_list.append(int(str(i)+str(j)))
    if len(num_list) > k:
        break

print(num_list[k-1])

Measured memory_bytes: 7100
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
typedef long long ll;

int main(){
    int n = 0; cin >> n;
    if(n==1) {printf("Yes\n2\n1 1\n1 1\n"); return 0;}
    if(n<3){cout << "No" << endl; return 0;}
    int k = 3;
    while(k*(k-1) < 2 * n) k++;
    if(k*(k-1) != 2 * n){cout << "No" << endl; return 0;}
    vector<vector<int>> s(k);
    rep(i,k) s[i].push_back(k-1);
    s[0].push_back(1); s[0].push_back(2);
    s[1].push_back(1); s[1].push_back(3);
    s[2].push_back(2); s[2].push_back(3);
    int now = 3,num = 3;
    rep(i,k - 3){
        rep(j,i+3) s[j].push_back(j+num+1);
        rep(j,i+3) s[i+3].push_back(j+num+1);
        num += i+3;   
    }
    cout << "Yes" << endl;
    cout << k << endl;
    rep(i,k) { rep(j,k) cout << s[i][j] << " "; cout << endl;}
    return 0;
}

Measured memory_bytes: 2304
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    vector<pair<int, int> > x;
    for (int i = 0; i < n; i++) { int a; cin >> a; x.push_back(make_pair(a, -1)); }
    for (int i = 0; i < n; i++) { int a; cin >> a; x.push_back(make_pair(a, 1)); }
    sort(x.begin(), x.end());
    int c = 0;
    long long ans = 1;
    const int M = (int)1e9 + 7;
    for (auto p : x) {
        if (c != 0 && ((p.second > 0) != (c > 0))) ans = ans * abs(c) % M;
        c += p.second;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2420
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    vector<int> ans(n);
    for (int i = 0; i < n; ++i) {
        ans[i] = i+1;
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            swap(v[i], v[j]);
            if(ans == v) {
                puts("YES");
                return 0;
            }
            swap(v[i], v[j]);
        }
    }
    puts("NO");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string s[2];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin>>s[0]>>s[1];
    if(s[0][0]==s[1][2]&&s[0][1]==s[1][1]&&s[0][2]==s[1][0])
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

template <class T>
inline bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;++i)ans+=(n/i)*(2*i+i*(n/i-1))/2;
	cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3592
<?php

$N = fgets(STDIN);


$MOD = pow(10, 9) + 7;

$a = mypow(10, $N);
$b = mypow(9, $N);
$c = mypow(8, $N);

$ans = ($a - $b - $b + $c);

while($ans < 0){
    $ans += $MOD;
}

$ans = $ans % $MOD;

echo $ans;

function mypow($b, $p)
{
    $mod = pow(10, 9) + 7;
    $res = 1;
    for ($i = 0; $i < $p; $i++) {
        $res = ($res * $b) % $mod;
    }
    return $res;
}


?>


Measured memory_bytes: 16172
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long

int fa[100010],num[100010],n,m,cnt;
bool bo[100010],pd[100010];
ll ans;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline int find(int x)
{
	if (!fa[x]) return x;
	int hh=find(fa[x]);
	num[x]^=num[fa[x]];
	return fa[x]=hh;
}

int main()
{
	n=rd();m=rd();
	for (int i=1;i<=m;i++)
	{
		int x=rd(),y=rd();
		bo[x]=true;bo[y]=true;
		int f1=find(x),f2=find(y);
		if (f1<f2) { swap(f1,f2);swap(x,y); }
		if (f1==f2&&num[x]==num[y]) pd[f1]=1;
		if (f1==f2) continue;
		pd[f2]|=pd[f1];fa[f1]=f2;
		num[f1]=num[x]^num[y]^1;
	}
	for (int i=1;i<=n;i++) if (!bo[i]) cnt++;
	ans=(ll)cnt*(n-cnt)*2+(ll)cnt*cnt;
	cnt=0;
	for (int i=1;i<=n;i++) if (bo[i]&&!fa[i]) cnt++;
	ans+=(ll)cnt*cnt;
	cnt=0;
	for (int i=1;i<=n;i++) if (bo[i]&&!fa[i]&&!pd[i]) cnt++;
	for (int i=1;i<=n;i++) if (bo[i]&&!fa[i]&&!pd[i]) ans+=(ll)cnt;
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main(void)
{
	long long n,k;
	cin>>n>>k;
	n = n % k;
	long long min = n;
	long long pre_min = n;
	if(n > k) min = n - k;
	else min = k - n;
	while(min < pre_min){
		pre_min = min;
		if(min < k) min = k - min;
		else min = min - k;
	}
	
	
	//cout<<"min = "<<min<<", pre_min = "<<pre_min<<endl;
	
	cout<<pre_min<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 200001;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> a(N), cnt(MAX);
    for (int i = 0; i < N; i++) { cin >> a[i]; cnt[a[i]]++; }
    ll sum = 0;
    for (int i = 0; i < MAX; i++) {sum += cnt[i] * (cnt[i] - 1) / 2;}
    for (int i = 0; i < N; i++) { cout << sum - cnt[a[i]] + 1 << '\n'; }
}


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

class Program
{
    public Program() { }


    Scanner cin;

    void myon()
    {
        cin = new Scanner();

        int n = cin.nextInt();
        int k = cin.nextInt();

        int[] a = new int[n];

        for (int i = 0; i < n; i++)
        {
            a[i] = cin.nextInt();
        }
        Array.Sort(a);

        int ans = int.MaxValue;
        for (int i = 0; i <= n-k; i++)
        {
            ans = Math.Min(ans, a[i + k - 1] - a[i]);
        }
        Console.WriteLine(ans);
    }

    static void Main(string[] args)
    {
        new Program().myon();
    }
}


class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

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

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

    int a, b;
    cin >> a >> b;
    if (b % a == 0) {
        cout << a + b;
    } else {
        cout << b - a;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int maxN = 0;
        int maxI = 0;

        for (int i = 0; i <= N; i++) {

            int n = 0;
            int temp = i;
            while (temp % 2 == 0 && temp != 0) {
                temp = temp / 2;
                n++;
            }

            if (n >= maxN) {
                maxN = n;
                maxI = i;
            }
        }

        System.out.println(maxI);

    }


}

Measured memory_bytes: 21716
N,M = (int(i) for i in input().split())
roads = []
for i in range(M):
    X,Y = (int(i) for i in input().split())
    roads.append(X)
    roads.append(Y)
    
for i in range(N):
    ans = roads.count(i+1)
    print(ans)
    
    


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i,j;
	int N;
	long K;
	int *A;
	int *s;
	int sindex;
	int circ, leng;
	int *ord;
	int temp;
	int v;
	int ret;
	
	ret = scanf("%d %ld", &N, &K);
	A = (int *)malloc(sizeof(int)*N);
	s = (int *)malloc(sizeof(int)*N);
	ord = (int *)malloc(sizeof(int)*(N+1));
	for (i =0; i < N+1; i++) {
		ord[i] = -1;
	}
	
	for (i =0; i < N; i++) {
		ret =scanf(" %d", &A[i]);
	}

	v = 1;
	sindex=0;
	circ = 0;
	leng = 0;
	while (ord[v] == -1) {
		ord[v] = sindex;
		s[sindex++] = v;
		v = A[v-1];
	}
	circ = sindex - ord[v];
	leng = ord[v];

	if (K < leng) {
		printf("%d\n", s[K]);
	} else {
		K -= leng;
		K %= circ;
		printf("%d\n", s[leng+K]);
	}


	free(A);
	free(s);
	free(ord);
	return EXIT_SUCCESS;
}


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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    REP(i, n) cin >> a[i];
    REP(i, m) cin >> b[i];
    bool ans = true;
    REP(i, n - m + 1){
        REP(j, n - m + 1){
            ans = true;
            REP(r, m){
                if(a[i + r].substr(j, m) != b[r]){
                    ans = false;
                }
            }
            if(ans == true){
                cout << "Yes" << "\n";
                return 0;
            }
        }
    }
    cout << "No" << "\n";
    return 0;
}


Measured memory_bytes: 256
H, W = [int(i) for i in input().split()]
s = [input() for _ in range(H)]
dirs = [[1,0], [1,1], [0,1], [-1,1], [-1,0], [-1,-1], [0,-1], [1,-1]]

for i in range(H):
    for j in range(W):
        bomb_num = 0
        if s[i][j] == "#":
            print("#", end="")
            continue
        for d in dirs:
            dirx, diry = d
            if 0 <= j+dirx < W and 0 <= i+diry < H:
                if s[i+diry][j+dirx] == "#":
                    bomb_num += 1
        print(str(bomb_num), end="")
    print("")


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

int main(){
    string s;
    cin >> s;
    int N = s.size();
    long long ans;
    for(int bit = 0; bit < (1 << N - 1); bit++){
        long long tmp = 0;
        for(int i = 0; i < N - 1; i++){
            tmp *= 10;
            tmp += s.at(i) - '0';
            if(bit & (1 << i)) ans += tmp, tmp = 0;
        }
        tmp *= 10;
        tmp += s.back() - '0';
        ans += tmp;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc049c()
}

fun abc049c() {
    var s = readLine()!!
    val words = listOf("dream", "dreamer", "erase", "eraser")

    while (s.isNotBlank()) {
        if (words.none { word ->
                if (s.endsWith(word)) {
                    s = s.slice(0..s.lastIndex - word.length)
                    true
                } else false
            }) return println("NO")
    }

    println("YES")
}


Measured memory_bytes: 121156