akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;

pair<int, int> edge[100005];

pair<int, int> col[100005];
pair<int, int> ncol[100005];
vector <pair<pair<int, int>, pair<int, int> > > q;

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i=0 ; i<m ; i++) {
		scanf("%d%d", &edge[i].x, &edge[i].y);
	}
	int Q;
	scanf("%d", &Q);
	for (int i=1 ; i<=Q ; i++) {
		int v, d, c;
		scanf("%d%d%d", &v, &d, &c);
		q.pb(mp(mp(d, v),mp(c, i)));
	}
	sort(q.rbegin(), q.rend());
	int pos = 0;
	for (int i=10 ; i>=0 ; i--) {
		/*cout <<"----\n";
		for (int j=1 ; j<=n ; j++) {
			printf("%d, %d\n", col[j].x, col[j].y);
		}
		cout <<"\n\n";*/
		for (int j=0 ; j<m ; j++) {
			int x = edge[j].x;
			int y = edge[j].y;
			if (col[x].y > ncol[y].y) ncol[y] = col[x];
			else if (col[y].y > ncol[x].y) ncol[x] = col[y];
		}
		for (int j=1 ; j<=n ; j++) {
			col[j] = ncol[j];
		}
		while (pos<Q and q[pos].x.x == i) {
			int v = q[pos].x.y;
			int c = q[pos].y.x;
			int t = q[pos].y.y;
			pos++;
			if (col[v].y > t) continue;
			col[v] = mp(c, t);
			ncol[v] = col[v];
		}
	}
	for (int i=1 ; i<=n ; i++) {
		printf("%d\n", col[i].x);
	}
	return 0;
}

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

int main(){

  int n, k, x;
  int sum = 0;
  cin >> n >> k;
  for(int i = 0; i < n; i++){
    cin >> x;
    sum += min(x, abs(x-k));
  }
  cout << sum*2 << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
zoros = [False,False]
res = "No"
for n in range(N):
    Ds= list(map(int,input().split()))
    if Ds[0] == Ds[1]:
        zoros.append(True)
        if zoros[n] and zoros[n+1] and zoros[n+2]:
            res = "Yes"
    else:
        zoros.append(False)

print(res)



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

div=10**9+7
n=1
m=1
diff=abs(N-M)
for i in range(1,N+1):
    n=n*i%div
for i in range(1,M+1):
    m=m*i%div

if diff>1:
    ans=0
elif diff==0:
    ans=(2*n*m)%div
elif diff==1:
    ans=(n*m)%div
print(ans)

Measured memory_bytes: 3064
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(0,a+1):
    if x < 500 * i:
        break
    if x == 500 * i:
        ans += 1
        break
    for j in range(0,b+1):
        if x < 500 * i + 100 * j:
            break
        if x == 500 * i + 100 * j:
            ans += 1
            break
        for k in range(0,c+1):
            if x < 500 * i + 100 * j + 50 * k:
                break
            if x == 500 * i + 100 * j + 50 * k:
                ans += 1
                break

print(ans)


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

ll n, a[100005], b[100005];
ll s = 0, t = 0;

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < n; ++i)
		cin >> b[i];
	for (int i = 0; i < n; ++i) {
		s += b[i]-a[i];
		if (b[i] >= a[i])
			t += (b[i] - a[i])%2;
		else
			t += a[i] - b[i];
	}

	if (s >= t)
		cout << "Yes\n";
	else
		cout << "No\n";
}

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


using namespace std;

int main()
{long long int A,B,C;
cin>>A>>B>>C;
if(A%2==0||B%2==0||C%2==0){
    cout<<0<<endl;
}else{
    cout<<min(A*B,min(B*C,A*C))<<endl;
}
}


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

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  ll N;
  cin >> N;
  vector<ll> A(N+1);
  for(ll i = 1;i<=N;i++){
    cin >> A[i];
  }
  A.push_back(0);

  ll ans = 0;
  //iのカードを使い切るようにしていく
  for(ll i = 1;i<=N;i++){
    if(A[i]%2){
      ans += A[i]/2;
      if(A[i+1] >= 1){
        ans ++;
        A[i+1]--;
      }
    }
    else ans += A[i]/2;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORC(i,a,b,c) for(ll i=(a);i<(b);i+=(c))
#define pb(x) push_back(x)
#define ff first
#define ss second
#define dd double
#define mod 1000000007

template<class K,class other=null_type,class cmp=less<K>> using ordered_set=tree<K,other,
cmp, rb_tree_tag, tree_order_statistics_node_update>;

inline ll md(ll x){
    return x<mod?x:x%mod;
}

ll power(ll x, ll y){
    if(y==0){
        return 1;
    }
    ll x_=power(x,y/2);
    if(y & 1){
        return md(md(x_*x_)*md(x));
    }
    else{
        return md(x_*x_);
    }
}

ll mod_inverse(ll x){
    return power(x,mod-2);
}
ll m;

ll gcdE(ll a, ll b, ll *x, ll *y){
    if(a==0){
        *x=0;
        *y=1;
        return b;
    }
    ll x1,y1;
    ll gcd=gcdE(b%a,a,&x1,&y1);
    *x=y1-(b/a)*x1;
    *y=x1;
    return gcd;
}
ll inf=1e12;
ll modI(ll a){
    ll x,y;
    gcdE(a,m,&x,&y);
    return (x+inf*m)%m;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll k;
    cin>>k;
    if(k%2==0 || k%5==0){
        cout<<-1<<endl;
        return 0;
    }
    if(k%7==0){
        k/=7;
    }
    m=9*k;
    ll num=1;
    ll flag=0;
    for(ll i=1;i<m;i++){
        num=(num*10)%m;
        ll x=modI(num);
        if(x==1){
            flag=i;
            break;
        }
    }
    if(flag) cout<<flag<<endl;
    else cout<<-1<<endl;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;
#define debug(x) cerr << #x << ": " << (x) << "\n";

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  rep(i, 0, n) ret *= x;
  return ret;
};

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

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};
const int MAX = 100005;
const ll INF = 1ll << 60;
// cost, node
vector<pair<ll, int>> adj[MAX];
vl dist(MAX, INF);
vector<bool> visited(MAX, false);

void dijkstra(int s) {
  // cost(neg), node
  priority_queue<pair<ll, int>> pq;
  dist[s] = 0ll;
  pq.push(make_pair(0ll, s));
  while (!pq.empty()) {
    auto pu = pq.top(); pq.pop();
    ll cu = -pu.first;
    int u = pu.second;

    if (visited[u]) continue;
    visited[u] = true;

    for (auto pv: adj[u]) {
      ll cv = pv.first;
      int v = pv.second;
      if (visited[v]) continue;
      if (dist[v] > dist[u] + cv) {
        dist[v] = dist[u] + cv;
        pq.push(make_pair(dist[v]*-1ll, v));
      }
    }
  }
};

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

  int n;
  cin >> n;
  int a, b;
  ll c;
  rep(i, 0, n-1) {
    cin >> a >> b >> c;
    a--; b--;
    adj[a].pb(make_pair(c, b));
    adj[b].pb(make_pair(c, a));
  }

  int q, k;
  cin >> q >> k;
  k--;
  dijkstra(k);

  int x, y;
  rep(i, 0, q) {
    cin >> x >> y;
    x--; y--;
    cout << dist[x] + dist[y] << endl;
  }


  return 0;
};


Measured memory_bytes: 11264
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>
 
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 1000000 + 1;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-12;
const double pi = atan2(0, -1);
const int ABC = 26;

inline void add(int &x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

inline void sub(int &x, int y) {
    x -= y;
    if (x < 0) {
        x += MOD;
    }
}

int dp[N];
int pref[N];

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    dp[0] = 1;
    pref[0] = 1;
    rep(i, 1, n + 1) {
        add(dp[i], pref[i - 1]);
        if (i >= 2) {
            sub(dp[i], dp[i - 2]);
        }
        if (i > 1) {
            add(dp[i], (n + 1) - i);
        }
        if (i == 1) {
            add(dp[i], (n - 1));
        } else {
            add(dp[i], 1LL * (n - 1) * (n - 1) % MOD);
        }
        pref[i] = pref[i - 1];
        add(pref[i], dp[i]);
    }
    /*rep(i, 0, n + 1) {
        cout << dp[i] << " ";
    }
    cout << endl;*/
    cout << dp[n] << "\n";
    return 0;
}

Measured memory_bytes: 8064
//
#include <bits/stdc++.h>
using namespace std;
template<size_t SIZE, class T> inline size_t array_size(T (&arr)[SIZE]) {
    return SIZE;
}
int main() {
    int N,K;
    string S;
    cin>>N;
    cin>>S;
    cin>>K;
    auto c = S[K-1];
    for (int i= 0;i<S.length();++i) {
        if (S[i] != c) {
            S[i] = '*';
        }
    }
    cout<<S<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s;
 cin>>s;
 map<int,int> m;
 int i;
 for(i=0;i<s.length();i++)
 {
 	if(m[s[i]-'a']==0)
 	m[s[i]-'a']=1;
 	else
 	m[s[i]-'a']++;
//cout<<m[s[i]-'a']<<endl;
}
 for(i=0;i<26;i++)
 {
 	//cout<<i<<" "<<m[i]<<endl;
 	if(m[i]%2==1)
 	{
 		cout<<"No"<<endl;
 		return 0;
	 }
 }
 cout<<"Yes"<<endl;
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(void){
  int a,b,ans=-1;
  cin>>a>>b;
  if((a+b)%2==0)cout<<(a+b)/2<<endl;
  else cout<<"IMPOSSIBLE"<<endl;

  return 0;
}


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

#define all(x) x.begin(),x.end()
#define LB(V,x) lower_bound(all(V),x)-V.begin()

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using pi = pair<int32, int32>;
using pll = pair<int64, int64>;
using vi = vector<int32>;
using vll = vector<int64>;
using ll = int64;

ll gcd(vll V){
    ll ans=V[0],i=V.size();
    while(i--) ans = __gcd(ans,V[i]);
    return ans;
}

void Main(){
    int N;
    vll A(N);
    cin >> N;
    for(auto &a:A) cin >> a;
    cout << gcd(A) << endl;
}

int main(){cin.tie(0);ios::sync_with_stdio(false);Main();return 0;}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<double> a(n);

  double ans = 0;
  double b = 0;
  for(int i =0; i <n; i++){
    cin >> a[i];
    b += 1.0/a[i];
  }
  
  ans = 1/b;
  cout <<setprecision(10)<< ans << endl;


  return 0;

}


Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 10e9;

void Checkpoints(){

	int n,m;
	cin >> n >> m;
	vector<pii> s;
	vector<pii> cp;
	for (size_t i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;
		s.push_back(pii(a, b));
	}

	for (size_t i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		cp.push_back(pii(a, b));
	}

	for (size_t i = 0; i < s.size(); i++)
	{
		int bd = INF;
		int best = -1;
		for (size_t j = 0; j < cp.size(); j++)
		{
			pii from = s[i];
			pii to = cp[j];
			int dest = abs(from.first - to.first) + abs(from.second - to.second);
			if (dest < bd) {
				bd = dest;
				best = j;
			}
		}
		cout << (best + 1) << endl;
	}
}

int main() {
	Checkpoints();
	return 0;
}



Measured memory_bytes: 256
;; D - Handstand 2

(defun first-digit (n)
  (loop for i = n then (floor i 10) while (>= i 10)
        finally (return i)))

(defun solve (n)
  (let ((count-head-tail (make-array '(10 10) :initial-element 0)))
    (loop for i from 1 to n
      do (incf (aref count-head-tail (first-digit i) (mod i 10))))
    (loop for head from 1 to 9       ; aの先頭の桁 (= bの末尾の桁)
      sum (loop for tail from 1 to 9 ; aの末尾の桁 (= bの先頭の桁)
            sum (* (aref count-head-tail head tail)      ; aの個数
                   (aref count-head-tail tail head)))))) ; bの個数

(let ((n (read)))  ; n <= 2 * 10 ** 5
  (princ (solve n)))


Measured memory_bytes: 17124
# input
N, M = map(int, input().split())
G = [list(map(int, input().split())) for _ in range(M)]
edges = [set() for _ in range(N)]

for a, b in G:
    edges[a - 1].add(b - 1)
    edges[b - 1].add(a - 1)

def dfs(start, edges, path):
    path.append(start)
    if len(path) == N:
        path.pop()
        return 1
    ans = 0
    for u in edges[start]:
        if u in path:
            continue
        ans += dfs(u, edges, path)
    path.pop()
    return ans    

print(dfs(0, edges, []))


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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n , m;
    cin >> n >> m;
    int mx , mn , l , r;
    cin >> mx >> mn;
    loop(i,m-1){
        cin >> l >> r;
        mx = max(mx , l);
        mn = min(mn , r);
    }

    cout << max(0 , mn - mx + 1) << endl;

    return 0;
}


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

signed main(){

  int d;
  vector<int> c(26);
  cin>>d;
  for(auto& ci:c)cin>>ci;
  vector<vector<int>> s(d,vector<int>(26));
  for(auto& si:s)for(auto& sij:si)cin>>sij;

  vector<int> last(26,0);

  auto calc_satisfaction_level = [&](int d,int i){
    int res = s[d][i];
    for(int j=0;j<26;++j){
      if(i==j)continue;
      res -= c[j]*(d-last[j]+1);
    }
    return res;
  };

  vector<int> ans(d);

  //-----------------------------------------------------

  auto test_all_get_max = [&](int di)->pair<int,int>{
    // 日付を引数にして全てのコンテストタイプを試してmaxscoreになるタイプを返す
    // 上位k個を返す
    int k = 5;
    int64_t val_max = -(1LL<<58),type_max = -1;
    vector<pair<int,int>> valtype_max(26);
    auto chmax = [](auto& a,auto b){if(a<b){a=b;return true;}return false;};
    for(int type=0;type<26;++type){
      if(chmax(val_max,calc_satisfaction_level(di,type)))type_max=type;
    }
    return {val_max,type_max};
  };

  for(int di=0;di<d;++di){
    auto [vi,type] = test_all_get_max(di);
    assert(type!=-1);
    ans[di] = type;
    last[type] = di+1;
  }
  assert(!all_of(begin(ans),end(ans),[](int x){return x==0;}));

  //-----------------------------------------------------

  for(auto x:ans){
    assert(1<=x+1 && x+1<=26);
    cout<< x+1 <<endl;
  }


}

Measured memory_bytes: 3664
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
 		Scanner scanner = new Scanner(System.in);
 		int n = scanner.nextInt();
 		int R[] = new int[n];
 		int maxv = -2000000000;
 		for (int i = 0;i < n; i++) {
 			int x = scanner.nextInt();
 			R[i] = x;
 			//System.out.println(Number[i]);
 		}
 		int minv = R[0];
 		for (int j = 1; j < n; j++) {
 			if (maxv < R[j] - minv) {
 				maxv = R[j] - minv;
 			}
 			if (minv > R[j]) {
 				minv = R[j];
 			}
 			//System.out.println(maxv);
 		}
 		System.out.println(maxv);
 	}
}



Measured memory_bytes: 101028
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <unordered_set>

using namespace std;

template<typename T> 
void show(T a){
  for(auto i : a){ cout << i << " "; }
  cout << endl;
}
bool isOdd(int a){
  return a%2 == 1;
}
bool isEven(int a){
  return a%2 == 0;
}
int f(int a){
  if(isOdd(a))
    return 3*a+1;
  else
    return a/2;
}


int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  int s;
  cin >> s;
  unordered_set<int> map;
  
  int count = 1;
  int n = s;
  do{
    map.insert(n);
    n = f(n);
    //cout << "n:" << n << endl;
    count++;
  }while(map.count(n) <= 0);
  
  //show(map);
  
  cout << count << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;


int main() {
 
  int64_t N,ans=0,copy;
  cin>>N;copy=N;
  vector<int64_t> A(10000000,0),B(101);

  for(int i=2; i<=10000000; i++){
    while(N%i==0){
      N/=i;
      A[i]++;
     // cout<<N<<endl;
    }
  }
  for(int i=1; i<100; i++){
    int k=i,c=1;
    for(int j=1; j<100; j++){
         if(k-j>j){
           k-=j;
           c++;}
         else break;
    }
      B[i]=c;
      //cout<<c<<endl;
    
  }
  for(int i=2; i<=10000000; i++){
    if(A[i]>0){ans+=B[A[i]];}
  }
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  if(copy==1)cout<<0<<endl;
  else if(ans==0)cout << 1 << endl;
  else if(N!=1)cout<<ans+1<<endl;
  else cout << ans << endl;
}
 

Measured memory_bytes: 81400
package main

import (
	"fmt"
	"sort"
)

type HP struct {
	val int
}

type HPs []HP

func (h HPs) Len() int           { return len(h) }
func (h HPs) Less(i, j int) bool { return h[i].val < h[j].val }
func (h HPs) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	h := make([]HP, n)
	for i := 0; i < n; i++ {
		var hp int
		fmt.Scan(&hp)
		h[i] = HP {
			val: hp,
		}
	}
	if k >= n {
		fmt.Println(0)
	} else {
		var num int
		sort.Sort(HPs(h))
		for i := 0; i < n - k; i++ {
			num += h[i].val
		}
		fmt.Println(num)
	}
}

Measured memory_bytes: 5504
program main
   implicit none
   integer A, B, C, X, Y, countN
   read(*, *) A, B, C, X, Y
   countN = 0
   if(X == Y) then
       if(A+B > 2 * C) then
	       countN = 2 * X * C
	   else
	       countN = (A + B) * X
	   end if
   else if (X > Y) then
       if(A+B > 2 * C) then
	       countN = 2 * Y * C
	   else
	       countN = (A + B) * Y
	   end if
	   X = X - Y
	   if(A > 2 * C) then
	       countN = countN + 2 * X * C
	   else
	       countN = countN + X * A
	   end if
   else
       if(A+B > 2 * C) then
	       countN = 2 * X * C
	   else
	       countN = (A + B) * X
	   end if
	   Y = Y - X
	   if(B > 2 * C) then
	       countN = countN + 2 * Y * C
	   else
	       countN = countN + Y * B
	   end if
   end if
   write(*, *) countN   
end program main

Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[550][550];

int main(){
  vs v,vec;
  cin >> n;
  rep(i,0,n){
    cin >> s;
    v.pb(s);
  }
  cin >> m;
  rep(i,0,m){
    cin >> s;
    vec.pb(s);
  }
  sort(all(v));
  sort(all(vec));
  ll ans = 0;
  rep(i,0,v.sz){
    ll snum = 0;
    rep(j,i + 1,v.sz){
      if(v[i] == v[j])snum++;
      else break;
    }
    ll tnum = 0;
    rep(j,0,vec.sz){
      if(v[i] == vec[j])tnum++;
    }
    ans = max(snum-tnum + 1,ans);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          int a = sc.nextInt();
          int b = sc.nextInt();
          int c = sc.nextInt();
          if(b + c < a){
              System.out.println(0);
          } else {
            System.out.println(b + c - a);
          }
        }
    }

Measured memory_bytes: 21716
//code by lynmisakura.wish to be accepted
/****************************/
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<vector>
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
/***************************/
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<pair<int,int>> vpi;

const long long Mod = 998244353;
const long long mod = 1000000007;
const long long INF = 10000000000000;

#define pb push_back
#define mp make_pair
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
	
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
/***************************/
//最頻値とランレングス圧縮
template<class T>
vector<pair<T,int>> runlength(vector<T> arr) {
	int i = 0;
	int n = arr.size();
	vector<pair<T, int>> run;
	while (i < arr.size()) {
		T t = arr[i];
		int k = 0;
		while (i + k < n && arr[i + k] == t) k++;
		run.push_back(pair<T, int>(t, k));
		i += k;
	}
	return run;
}

template<class T>
int freq(vector<T> arr) { 
	//最頻値の個数を知りたければ,int freq & return first
	//最頻値そのものを知りたければ T freq & return second
	vector<T> vec = arr;
	int n = arr.size();
	sort(all(vec));
	int i = 0;
	vector<pair<int, T>> run;
	while (i < arr.size()) {
	    T t = arr[i];
		int k = 0;
		while (i + k < n && arr[i + k] == t) k++;
		run.push_back(pair<int, T>(k, t));
		i += k;
	}
	sort(all(run));
	reverse(all(run));
	return run[0].first;
}
int ans[100010];
int main(void){
	string s;cin >> s;
	int n = s.size();
	vector<char> st;
	for(int i = 0;i < s.size();i++){
		char x = s[i];
		st.push_back(x);
	}
	auto r = runlength(st);
	
	//(r,__)(l,__) のpairがn個ある
	int lbound = 0;
	for(int i = 0;i < r.size();i+=2){
		int pl = r[i].second; //debug(pl);
		int pr = r[i+1].second; //debug(pr);
		ans[lbound + pl] += (pl+1)/2 + (pr)/2;
		ans[lbound + pl + 1] += (pl)/2 + (pr+1)/2;
		lbound += pl + pr;
	}
	for(int i = 1;i <= n;i++){
		cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 2036
import sys
import numpy as np

MOD = 10 ** 9 + 7

I = np.array(sys.stdin.read().split(), dtype=np.int64)
n, m = I[:2]
x = I[2:2+n]
y = I[2+n:]

def main():
    sx = np.cumsum(x) % MOD 
    sy = np.cumsum(y) % MOD

    sdx = np.sum((sx[n-1] - sx[:n-1]) - x[:n-1] * ((n-1) - np.arange(n-1))) % MOD
    sdy = np.sum((sy[m-1] - sy[:m-1]) - y[:m-1] * ((m-1) - np.arange(m-1))) % MOD

    ans = sdx * sdy % MOD
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 37364
#include <iostream>
#include <vector>

using namespace std;

int pow10(int n) {
    int r = 1;
    for (int i = 0; i < n; i++) {
        r *= 10;
    }
    return r;
}

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

    vector<int> s(m), c(m);
    for (int i = 0; i < m; i++) {
        cin >> s[i] >> c[i];
    }

    int res = -1;
    for (int i = (n == 1 ? 0 : pow10(n - 1)); i < pow10(n); i++) {
        bool r = true;
        for (int j = 0; j < m; j++) {
            if ((i / pow10(n - s[j])) % 10 != c[j]) {
                r = false;
                break;
            }
        }

        if (r) {
            res = i;
            break;
        }
    }

    cout << res << endl;
}


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

int dp[20][20][20][20];
const int INF = (int)1e7;

int main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cout.setf(ios::fixed); cout.precision(20);
    int H, W; cin >> H >> W;
    vector<string> M(H, string(W, ' '));
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            char ch; cin >> ch;
            M[i][j] = ch;
        }
    }

    for (int i = 0; i < 20; ++i)
        for (int j = 0; j < 20; ++j)
            for (int k = 0; k < 20; ++k)
                for (int l = 0; l < 20; ++l)
                    dp[i][j][k][l] = INF;

    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (M[i][j] == '.') {
                dp[i][j][i][j] = 0;
                for (int x = 0; x < 400; ++x)
                for (int k = 0; k < H; ++k) {
                    for (int l = 0; l < W; ++l) {
                        if ((i == k && l == j) || M[k][l] == '#') continue;
                        if (l - 1 >= 0) dp[i][j][k][l] = min(dp[i][j][k][l], dp[i][j][k][l - 1] + 1);
                        if (k - 1 >= 0) dp[i][j][k][l] = min(dp[i][j][k][l], dp[i][j][k - 1][l] + 1);
                        if (l + 1 < W) dp[i][j][k][l] = min(dp[i][j][k][l], dp[i][j][k][l + 1] + 1);
                        if (k + 1 < H) dp[i][j][k][l] = min(dp[i][j][k][l], dp[i][j][k + 1][l] + 1);
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            for (int k = 0; k < H; ++k) {
                for (int l = 0; l < W; ++l) {
                    if (dp[i][j][k][l] < INF) {
                        ans = max(ans, dp[i][j][k][l]);
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
use std::io::Read;

fn main() {
    let mut buf = String::new();

    std::io::stdin().read_to_string(&mut buf).unwrap();

    let mut iter = buf.split_whitespace();
    let s = iter.next().unwrap();
    let ans = s.replace("1","!").replace("9","1").replace("!","9");
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){

	int i,n;
	long long int gusum = 0,kisum = 0;
	long long int gucount = 0,kicount = 0,a;

	scanf("%d",&n);

	for(i = 0; i < n; i++){
		scanf("%lld",&a);
		gusum += a;
		kisum += a;

		if(i % 2 == 0){

			if(gusum <= 0){
				gucount += 1 - gusum;
				gusum = 1;
			}
			if(kisum >= 0){
				kicount += 1 + kisum;
				kisum = -1;
			}
		}
		else{

			if(gusum >= 0){
				gucount += 1 + gusum;
				gusum = -1;
			}
			if(kisum <= 0){
				kicount += 1 - kisum;
				kisum = 1;
			}
		}
	}
	if(kicount > gucount){
			printf("%lld\n",gucount);
		}
		else
			printf("%lld\n",kicount);
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define ii pair<int,int>
#define mod 1000000007
#define endl '\n'
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=((a%mod)*(a%mod))%mod;
		b>>=1;
	}
	return ans;
}

void sieve(int n){
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	for(int p=2;p*p<=n;p++){
		if(prime[p]){
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false;
		}
	}
	for(int p=2;p<=n;p++){
		if(prime[p])
			cout<<p<<" ";
	}
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		ll a,b,n;
		cin>>a>>b>>n;
		n=min(n,b-1);
		cout<<(a*n)/b;
	}
	return 0;
}

Measured memory_bytes: 3620
n = int(input())
output = [""]

for i in range(1, n + 1):
    if i % 3 == 0:
        output.append(i)
    elif i % 10 == 3:
        output.append(i)
    elif str(3) in str(i):
        output.append(i)

print(' '.join(map(str, output)))



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

int main() {
    vector<int> v(5);
    while (1) {
        int a, b;
        cin >> a >> b;
        if (!a && !b) break;
        v[0] = a + b;
        for (int i = 1; i < 5; i++) {
            cin >> a >> b;
            v[i] = a + b;
        }

        int ans = 0, idx;
        for (int i = 0; i < 5; i++) {
            if (ans < v[i]) ans = v[i], idx = i;
        }

        cout << (char)('A' + idx) << " " << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 2984
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

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 REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }

struct Edge {
public:
	int from, to;
	Edge() {}
	Edge(int _from, int _to) {
		from = _from;
		to = _to;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, Q;
	cin >> N >> Q;
	Graph G(N);
	REP(i, N - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(Edge(a, b));
		G[b].push_back(Edge(b, a));
	}
	vll C(N);
	REP(i, Q) {
		int p, x;
		cin >> p >> x;
		p--;
		C[p] += x;
	}
	vll Ans(N, -1);
	queue<int> QU;
	QU.push(0);
	Ans[0] = 0;
	while (!QU.empty()) {
		int v = QU.front();
		QU.pop();
		Ans[v] += C[v];
		for (Edge e : G[v]) {
			if (Ans[e.to] != -1)continue;
			QU.push(e.to);
			Ans[e.to] = Ans[v];
		}
	}
	REP(i, N) {
		if (i != 0)cout << " ";
		cout << Ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 18672
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define FORIT(i,c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define ISEQ(c) (c).begin(), (c).end()
typedef long long ll;

int SURP = 1000000007;

int main(){
	vector<string> subst;
	string s;
	int K;
	cin >> s >> K;

	FOR(i,0,s.length()){
		FOR(j,1,K+1){
			if(i+j <= (int)s.length()){
				string tmp = s.substr(i,j);
				auto itr = find(subst.begin(),subst.end(),tmp);
				if(itr == subst.end()) subst.push_back(tmp);
			}else{
				break;
			}
		}
	}
	sort(subst.begin(),subst.end());

	string ret = subst[K-1];
	cout << ret << endl;
	return 0;
}


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

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

    int x, y, h;
    pair<int, pair<int, int>> p[n];

    for (int i = 0; i < n; i++) {
        cin >> x >> y >> h;
        p[i] = {h, {x, y}};
    }

    sort(p, p + n, [](pair<int, pair<int, int>> a, pair<int, pair<int, int>> b) { return a.first > b.first; });
    int h0 = p[0].first;
    int x0 = p[0].second.first;
    int y0 = p[0].second.second;

    int ansx, ansy, ansh = -1;

    for (int cy = 0; cy <= 100; cy++) {
        for (int cx = 0; cx <= 100; cx++) {
            int ch = h0 + abs(cy - y0) + abs(cx - x0);
            bool ok = true;
            for (auto pp : p) {
                if (pp.first != max(ch - abs(cy - pp.second.second) - abs(cx - pp.second.first), 0)) {
                    ok = false;
                    break;
                }
            }

            if (ok && ch > ansh) {
                ansh = ch;
                ansx = cx;
                ansy = cy;
            }
        }
    }

    cout << ansx << " " << ansy << " " << ansh << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
vector<int> getCycle(int x, const vector<int>& perm) {
	int init = x;
	vector<int> ret;
	do {
		ret.push_back(x);
		x = perm[x];
	} while (x != init);
	return ret;
}
int main() {
	int n;
	scanf("%d", &n);
	vector<pair<int, int>> a(n), b(n);
	vector<int> pos(n), perm(n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i].first);
		a[i].second = i;
	}
	for (int i = 0; i < n; ++i) {
		scanf("%d", &b[i].first);
		b[i].second = i;
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (int i = 0; i < n; ++i) {
		if (a[i].first > b[i].first) {
			printf("No\n");
			return 0;
		}
		pos[b[i].second] = i;
	}
	for (int i = 0; i < n; ++i) {
		perm[pos[a[i].second]] = i;
	}
	auto c = getCycle(0, perm);
	if (c.size() != n) {
		printf("Yes\n");
	} else {
		for (int i = 0; i + 1 < n; ++i) {
			if (a[i + 1].first <= b[i].first) {
				printf("Yes\n");
				return 0;
			}
		}
		printf("No\n");
	}
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin>>N>>K;
  int p[1001];
  int ans=0;
  for(int i=0;i<N;i++)cin>>p[i];
  sort(p,p+N);
  for(int i=0;i<K;i++)ans+=p[i];
  cout<<ans<<endl;
  return 0;
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll ar[81], k = 0;
    for (ll x = 1; x <= 9; x++) {
        for (ll y = 1; y <= 9; y++) {
            ar[k++] = x * y;
        }

    }

    ll n;
    cin >> n;
    for (ll x = 0; x <= 80; x++) {
        if (ar[x] == n) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No";
}

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

int main(){
      double n,d;
      cin>>n>>d;
      double x=(n-(4*d+2))/(2*d+1);
      
      
      
      if(n<=2*d+1){
            cout<<1<<endl;
      }
      else if(n>2*d+1){
            if(n-4*d+2<=0){
                  cout<<2<<endl;
            }
            else{
                  cout<<2+ceil(x)<<endl;
            }
      }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
void Unused(...) {}
#ifndef DEBUG
  #define echo(...) Unused(__VA_ARGS__)
#else
  #define echo(...) fprintf(stderr, __VA_ARGS__)
#endif

const int MaxN = 100 + 7;
const int Way = 4 * 4 * 4;
const int Mod = 1e9 + 7;

int n;
int dp[MaxN][Way];

int get(int stat, int pos)
{
    //return (stat >> (pos * 2)) & 0x3;
    if (pos == 0)
        return stat & 0x3;
    else if (pos == 1)
        return (stat >> 2) & 0x3;
    else
        return (stat >> 4) & 0x3;
}
int comb(int m1, int m2, int m3)
{
    return (m1 & 0x3) + ((m2 & 0x3) << 2) + ((m3 & 0x3) << 4);
}

/*
 * A - 0, C - 1, G - 2, T - 3
 * banned: *AGC AG*C A*GC *ACG *GAC
 */
enum { A = 0, C, G, T, };
int dfs(int pos, int stat)
{
    if (pos > n)
        return 1;
    if (dp[pos][stat] != -1)
        return dp[pos][stat];
    //echo("%d%d%d%d\n", get(stat, 0), get(stat, 1), get(stat, 2), A);
    //echo("%d%d%d%d\n", get(stat, 0), get(stat, 1), get(stat, 2), T);
    dp[pos][stat] = (dfs(pos + 1, comb(get(stat, 1), get(stat, 2), A))
        + dfs(pos + 1, comb(get(stat, 1), get(stat, 2), T))) % Mod;
    // Verify 'C'
    if ((get(stat, 1) == A && get(stat, 2) == G) ||  // *AGC
            (get(stat, 1) == G && get(stat, 2) == A) ||  // *GAC
            (get(stat, 0) == A && get(stat, 1) == G) ||  // AG*C
            (get(stat, 0) == A && get(stat, 2) == G))
        ;
    else
    {
        //echo("%d%d%d%d\n", get(stat, 0), get(stat, 1), get(stat, 2), C);
        dp[pos][stat] = (dp[pos][stat]
                + dfs(pos + 1, comb(get(stat, 1), get(stat, 2), C))) % Mod;
    }
    // Verify 'G'
    if (get(stat, 1) == A && get(stat, 2) == C)
        ;
    else
    {
        dp[pos][stat] = (dp[pos][stat]
                + dfs(pos + 1, comb(get(stat, 1), get(stat, 2), G))) % Mod;
        //echo("%d%d%d%d\n", get(stat, 0), get(stat, 1), get(stat, 2), G);
    }
    return dp[pos][stat];
}

int main()
{
    scanf("%d", &n);
    if (n == 3)
    {
        printf("61\n");
        return 0;
    }
    memset(dp, -1, sizeof(dp));
    int ans = 0;
    // banned: AGC ACG GAC
    for (int i = 0; i < 4; ++i)
        for (int j = 0; j < 4; ++j)
            for (int k = 0; k < 4; ++k)
                if ((i == A && j == G && k == C) ||
                        (i == A && j == C && k == G) ||
                        (i == G && j == A && k == C))
                    ;
                else
                    ans = (ans + dfs(4, comb(i, j, k))) % Mod;
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int i, N, M, x[100001], y[100001];
	scanf("%d %d", &N, &M);
	for (i = 1; i <= M; i++) scanf("%d %d", &(x[i]), &(y[i]));
	
	int flag[100001] = {-1, 1}, num[100001] = {-1}, ans = 0;
	for (i = 1; i <= M; i++) {
		if (flag[x[i]] == 1) {
			if (num[x[i]] == 0) flag[x[i]] = 0;
			flag[y[i]] = 1;
		}
		num[x[i]]--;
		num[y[i]]++;
	}
	
	for (i = 1; i <= N; i++) ans += flag[i];
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

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

#include <boost/rational.hpp>

#define REP(i, n) for (decltype(n) i = 0; i < (n); ++i)
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
using boost::rational;

const i64 MOD = 1000000007;

int main() {
  std::ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  i64 N;
  cin >> N;
  i64 cnt_ab0 = 0, cnt_a0 = 0, cnt_b0 = 0;
  map<rational<i64>, i64> cnt_r;

  REP(i, N) {
    i64 a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) {
      ++cnt_ab0;
    } else if (a == 0) {
      ++cnt_a0;
    } else if (b == 0) {
      ++cnt_b0;
    } else {
      rational<i64> r{a, b};
      ++cnt_r[move(r)];
    }
  }

  set<rational<i64>> rpairs;
  for (auto it = cnt_r.begin(); it != cnt_r.end(); ++it) {
    const auto& r = it->first;
    if (r > 0) {
      rpairs.insert(r);
    } else {
      rpairs.insert(-1 / r);
    }
  }

  vector<i64> pow2(N + 1);
  pow2[0] = 1;
  REP(i, N) { pow2[i + 1] = (pow2[i] << 1) % MOD; }

  i64 ans = 1LL;
  for (const auto& r1 : rpairs) {
    rational<i64> r2 = rational<i64>(-1) / r1;
    i64 p = pow2[cnt_r[r1]] + pow2[cnt_r[r2]] + MOD - 1;
    ans *= p % MOD;
    ans %= MOD;
  }
  i64 p = pow2[cnt_a0] + pow2[cnt_b0] + MOD - 1;
  ans *= p % MOD;
  ans %= MOD;
  ans += cnt_ab0 + MOD - 1;
  cout << (ans % MOD) << endl;
}

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

int main() {
  ll n, k;
  cin >> n >> k;
  ll a = n % k;
  ll ans = min(a, k-a);
  cout << ans << endl;
  return 0;
}

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

int gcd(int p, int q)
{
    if(p%q == 0)
    {
        return q;
    }
    return gcd(q, p%q);
}
int main()
{
    int k;
    cin >> k;
    ll sum = 0;
    for(int i = 1; i <= k; i++)
    {
        for(int j = 1; j <= k; j++)
        {
            for(int l = 1; l <= k; l++)
            {
                sum += gcd(i, gcd(j, l));
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int n;
int a[3]={7,5,3};
int count753(ll x){
  if(x>n) return 0;
  int res=0;
  int y=x;
  bool f7=0,f5=0,f3=0;
  while(y>0){
    int temp=y%10;
    if(temp==7) f7=1;
    else if(temp==5) f5=1;
    else if(temp==3) f3=1;
    else break;
    y/=10;
  }
  if(f7&&f5&&f3) res++;
  REP(i,3){
    if(x==0) res+=count753(x+a[i]);
    else res+=count753(x*10+a[i]);
  }
  return res;
}

int main()
{
  cin>>n;
  cout<<count753(0)<<endl;

  return 0;
}

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

int main(){
  int n;
  while(cin>>n){
    int cn=1;
    if(n==0)break;
    int a[n][n];
    int x=n/2+1, y=n/2;
    for(int i=0; i<n; i++)
      for(int j=0; j<n; j++)
        a[i][j]=0;
    a[x][y]=1;
    while(cn!=n*n){
      x=(x+1)%n; y=(y+1)%n;
      if(a[x][y]!=0){
        x=(x+1)%n; y=(y-1)%n;
        if(x<0)x+=n;
        if(y<0)y+=n;
      }
      a[x][y]=cn+1;
      cn++;
    }
    for(int i=0; i<n; i++)
      for(int j=0; j<n; j++)
        if(j==n-1)printf("%4d\n", a[i][j]);
        else printf("%4d", a[i][j]);
  }
  return 0;
}

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

#define INF 1145141919
#define PI atan(-1)

using namespace std;

#define MAX_N 100005

#define LL long long

int N;
LL A[MAX_N];

vector<LL> V[2];

int main()
{
  cin >> N;
  for (size_t i = 0; i < N; i++) {
    cin >> A[i];
  }

  for (size_t i = 0; i < N; i++) {
    V[i%2].push_back(A[i]);
  }

  sort(V[0].begin(), V[0].end());
  sort(V[1].begin(), V[1].end());

  sort(A, A+N);

  set<LL> S;
  for (size_t i = 0; i < N; i += 2) {
    S.insert(A[i]);
  }

  int ans = 0;
  for (size_t i = 0; i < V[0].size(); i++) {
    if(S.find(V[0][i]) != S.end()){
      S.erase(V[0][i]);
    }
    else{
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var n = IO.GetInt();
            var p = IO.GetIntList();
            var ans = 0;
            for (int i = 0; i < n-2; i++)
            {
                if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])) ans++;
            }
            
            Console.WriteLine(ans);
        }
    }


    static class IO
    {
        static public string GetString() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 11220