akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
bool f(int a,int b,int c,int d,int e=0){
    if(a>=5&&b>=5){
        return false;
    }
    if(c>=5&&d>=5){
        return true;
    }
    bool res;
    if(e==0){
        res=false;
        if(a<5){
            if(c<5){
                res|=f(a,b,c+a,d,1);
            }
            if(d<5){
                res|=f(a,b,c,d+a,1);
            }
        }
        if(b<5){
            if(c<5){
                res|=f(a,b,c+b,d,1);
            }
            if(d<5){
                res|=f(a,b,c,d+b,1);
            }
        }
    }
    else{
        res=true;
        if(c<5){
            if(a<5){
                res&=f(a+c,b,c,d,0);
            }
            if(b<5){
                res&=f(a,b+c,c,d,0);
            }
        }
        if(d<5){
            if(a<5){
                res&=f(a+d,b,c,d,0);
            }
            if(b<5){
                res&=f(a,b+d,c,d,0);
            }
        }
    }
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c,d;cin >> a >> b >> c >> d;
    cout << (f(a,b,c,d)?"ISONO":"NAKAJIMA") << endl;
}



Measured memory_bytes: 3212
import java.util.Scanner;

public class Main {
    public static Scanner in = new Scanner(System.in);

    public static void main(String[] args) {
        int points = in.nextInt();
        long dist = in.nextLong();
        dist = dist * dist;

        int answer = 0;
        for (int i = 0; i < points; i++) {
            long p = in.nextLong();
            long q = in.nextLong();
            long d = (p * p) + (q * q);
            if (d <= dist) answer += 1;
        }

        System.out.println(answer);
    }
}

Measured memory_bytes: 59404
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, ans = 0;
	cin >> N;
	vector<int> h(N);
	for (int i = 0; i < N; ++i) {
		cin >> h[i];
	}
	ans = h[0];
	for (int i = 1; i < N; ++i) {
		ans += max(h[i] - h[i - 1], 0);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x,a,b;
	int n,m;
	scanf("%d %d %d",&x,&a,&b);
	if(x>a){
		n=x-a;
	}
	else{
		n=a-x;
	}
	if(x>b){
		m=x-b;
	}
	else{
		m=b-x;
	}
	if(n<m){
		printf("A\n");
	}
	else{
		printf("B\n");
	}
	return 0;
}


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

#define M 100001
#define INF 100000000

int gcd(int m, int n) {
	int r = m%n;
	return r==0 ? n : gcd(n, r);
}

int main() {
	int a, b, d, g, sum, sum2, p, q, l, r;
	while(1) {
		cin >> a >> b >> d;
		if(!a&&!b&&!d) break;
		sum = sum2 = INF;
		g = (a>b ? gcd(a,b) : gcd(b,a));
		d /= g; p = a/g; q = b/g;
		for(int i=0; i<=d/q; ++i) {
			if((d-q*i)%p==0) {
				int j = (d - q*i)/p;
				if(i+j<sum || (i+j==sum && j*p+i*q<sum2)) {
					l = j; r = i;
					sum = i+j;
					sum2 = j*p+i*q;
				}
			}
		}
		for(int i=0; i<M/g; ++i) {
			if((q*i+d)%p==0) {
				int j = (q*i + d)/p;
				if(i+j<sum || (i+j==sum && j*p+i*q<sum2)) {
					l = j; r = i;
					sum = i+j;
					sum2 = j*p+i*q;
				}
				break;
			}
		}
		for(int j=0; j<M/g; ++j) {
			if((p*j+d)%q==0) {
				int i = (p*j + d)/q;
				if(i+j<sum || (i+j==sum && j*p+i*q<sum2)) {
					l = j; r = i;
					sum = i+j;
					sum2 = j*p+i*q;
				}
				break;
			}
		}
		cout << l << " " << r << endl;
	}
	return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 10;

int l[N];

void solve() {
  int n, a, b, c; scanf("%d%d%d%d", &n, &a, &b, &c);
  for (int i = 0; i < n; ++i) scanf("%d", l+i);
  int ans = 1e9;
  for (int i = 0, lmt = 1 << (n*2); i < lmt; ++i) {
    int h[4] = {0};
    int z[4] = {0};
    int cur = 0;
    for (int p, x = i, j = 0; j < n; ++j, x /= 4) {
      p = x%4;
      ++h[p];
      if (p == 3) continue;
      cur += 10;
      z[p] += l[j];
    }
    if (!h[0] || !h[1] || !h[2]) continue;
    ans = min(ans, cur+abs(a-z[0])+abs(b-z[1])+abs(c-z[2])-30);
  }
  printf("%d", ans);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

void solve(){
	//code
	int l,r,d,count=0;
	cin>>l>>r>>d;
	
	for(int i=l;i<=r;i++){
		if(i%d==0)
			count++;
	}
	cout<<count;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3652
n = int(input())
a = [int(input()) for _ in range(n)]
m1 = max(a)
mi = a.index(m1)
m2 = max(a[:mi] + a[mi+1:])

for i in range(n):
    if i == mi:
        print(m2)
    else:
        print(m1)

Measured memory_bytes: 14124
#include "bits/stdc++.h"
using namespace std;


typedef long long ll;
typedef pair <int, int> ii;
typedef pair <int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<double, int> pdi;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

#define iINF (1<<30)
#define INF (1LL<<59)
#define forn(i) for(int i = 0;i < n; ++i)
#define form(i,n) for(int i = 0 ;i < n; ++i)
#define NIL -1

const ll mod = 998244353;
int n;
int m;
int ans;
string str;

int main(){
    ans=iINF;
    int a,b,c;
    int ta,tb,tc;
    int fa,fb,fc;
    int flg=0;
    cin>>n>>a>>b>>c;
    int l[10];
    forn(i)cin>>l[i];
    for(;flg<(1<<(2*n));flg++){
        ta=tb=tc=0;
        fa=fb=fc=0;
        int tflg=flg;
        forn(i){
            switch(tflg&3){
                case 0:
                ta+=l[i];
                fa++;
                break;
                case 1:
                tb+=l[i];
                fb++;
                break;
                case 2:
                tc+=l[i];
                fc++;
                break;
            }
            tflg>>=2;
        }
        if(!(fa&&fb&&fc))continue;
        ans=min(ans, 10*(fa+fb+fc-3)+abs(a-ta)+abs(b-tb)+abs(c-tc));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using stkll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    vll a(n);
    rep(i, n) cin >> a[i];
    ll total = 0;
    rep(i, n) total += a[i];
    ll cnt = 0;
    rep(i, n) if(a[i] * 4 * m >= total) cnt++;

    if(cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;} cout << endl;
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;
typedef vector<vector<int>> Graph;

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

    string s;
    cin >> s;
    string t = s;
    reverse(all(t));
    rep(i, t.size()) {
        if (t[i] == 'b') t[i] = 'd';
        else if (t[i] == 'd') t[i] = 'b';
        else if (t[i] == 'p') t[i] = 'q';
        else if (t[i] == 'q') t[i] = 'p';
    }
    cout << (s == t ? "Yes" : "No") << endl;
}


Measured memory_bytes: 512
# dp[i][j]:=(総和がiで長さがjの数列の個数)とする
# このままだとO(s^3)だが、全てのｊに対してΣ(k=0→i-3)dp[k][j]をあらかじめ持っておけばO(s^2)となる
# dpの遷移式立てたときはちゃんと紙に書いて眺めなきゃ（使命感）
s=int(input())
mod=10**9+7
dp=[[0]*(s+1) for _ in range(s+1)]
accum=[0]*(s+1)
dp[0][0]=1
for i in range(3,s+1):
    for j in range(s):
        accum[j]+=dp[i-3][j]
        dp[i][j+1]+=accum[j]
        dp[i][j+1]%=mod
print(sum(dp[s])%mod)

Measured memory_bytes: 61376
# import numpy as np
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

norimono_lis = [a,b,c,d,e]

min_norimono = min(norimono_lis)

if n % min_norimono == 0:
    ans = (n//min_norimono) + 4
else:
    ans = (n//min_norimono) + 5
print(ans)


Measured memory_bytes: 3060
/// In the name of ALLAH
/// I'm THEOVE46
#include<bits/stdc++.h>
using namespace std;

#define gap             " "
#define nn              "\n"
#define pi              2*acos(0.0)
#define db              double
#define ft              float
#define ll              long long
#define ull             unsigned long long
#define pf              printf
#define sf              scanf
#define ff              first
#define ss              second
#define sc(n)           sf("%d",&n)
#define sc2(n, m)       sf("%d%d",&n,&m)
#define scl(n)          sf("%lld",&n)
#define scl2(n, m)      sf("%lld%lld",&n,&m)
#define pc(n)           pf("%d",n)
#define scf(f)          sf("%f",&f)
#define pcf(f)          pf("%f",f)
#define bfs             cin.get()
#define bfc             getchar()
#define gl(s)           getline(cin, s)
#define loop(a,n)       for(ll i=a; i<n; i++)
#define mloop(i,a,n)    for(ll i=a; i<n; i++)
#define rloop(a,n)      for(ll i=a; i>n; i--)
#define tloop(test)     for(ll tl=1; tl<=test; tl++)
#define case1(z)        cout<<"Case "<<z<<": "
#define case2(z)        printf("Case %d: ",z)
#define vi              vector<int>
#define vl              vector<ll>
#define vld(vc,rw)      vector<vector<ll> >vc(rw)
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define pis             pair<int,string>
#define psi             pair<string,int>
#define mls             map <ll,string>
#define msl             map <string,ll>
#define mll             map <ll,ll>
#define mp              make_pair
#define pb              push_back
#define itr             vector<int> :: iterator
#define sz(s)           s.size()
#define sl(s)           s.length()
#define Sort(s)         sort(s.begin(), s.end())
#define SortR(s)        sort(s.rbegin(), s.rend())
#define all(x)          x.begin(),x.end()
#define rall(x)         x.end(), x.begin()
#define MEM(ar,val)     memset(ar, (val), sizeof(ar))
#define IN(A,B,C)       assert(B<=A && A<=C)
#define EPS             1e-9
#define bug1            "**1**"
#define bug2            "****2****"
#define artri(b,h)      0.5*b*h
#define artrap(b1,b2,h) (b1+b2)/2*h
#define arcrl(r)        pi*r*r
#define vlsyl(r,h)      pi*r*r*h
#define vlcone(r,h)     pi*r*r*(h/3)
#define vlsph(r)        (4/3)*pi*r*r*r
#define flush           fflush(stdout);
#define pcn(dg,val)     fixed << setprecision(dg) << val
#define fap(x)          cout << __LINE__ << " says: " << #x << " = " << x << "\n"
#define FastIO          ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define showsort(n, a)  for(int i=0; i<n; i++) cout << a[i] << gap; cout << endl;

///THEOVE46

int main()
{
    //FastIO;
    ll a;
    cin >> a;
    cout << a+a*a+a*a*a << endl;
    return 0;
}

///   check for integer overflow, array bounds
///   check for n=1
///   - - - The Ove 46



Measured memory_bytes: 3624
/* be name khoda */
#include <bits/stdc++.h>
using namespace std;

typedef int ll;
typedef pair<ll, ll> pii;

#define forifrom(i, s, n) for (ll i = s; i < n; ++i)
#define fori(i, n) forifrom(i, 0, n)
#define forirto(i, n, e) for (ll i = (n) - 1; i >= e; --i)
#define forir(i, n) forirto(i, n, 0)

#define F first
#define S second

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

const ll maxn = 100010;
const ll maxa = 1 << 30;

ll n, A[maxn], B[maxn];
map<ll, ll> din, dout, vis, vis2;
map<ll, vector<ll>> g;

void add(ll a, ll b) {
    g[a].emplace_back(b);
    g[b].emplace_back(a);
    din[b]++, dout[a]++;
}

void dfs(ll x) {
    vis[x] = 1;
    for (auto y : g[x]) if (!vis[y]) dfs(y);
}

void halt() {
    cout << "-1\n";
    exit(0);
}

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

    cin >> n;
    ll xr = 0;
    fori (i, n) cin >> A[i], xr ^= A[i];
    fori (i, n) cin >> B[i];
    ll diff = 0;
    fori (i, n) {
        if (A[i] != B[i]) {
            add(A[i], B[i]);
            ++diff;
        }
    }
    if (diff == 0) return cout << "0\n", 0;
    ll that = -1;
    fori (id, maxn * 2) {
        ll i = id < n ? A[id] : B[id - n];
        if (vis2[i]) continue;
        vis2[i] = 1;
        if (din[i] - dout[i] >= 2) halt();
        else if (din[i] - dout[i] == 1) {
            if (that != -1 || i != xr) halt();
            else that = i;
        }
    }
    ll comp = 0;
    fori (id, maxn) {
        ll i = id < n ? A[id] : B[id - n];
        if (!vis[i] && !g[i].empty()) ++comp, dfs(i);
    }
    ll ans = diff + comp - 1;
    if (that == -1 && count(B, B + n, xr) == 0) ++ans;
    cout << ans << '\n';

}


Measured memory_bytes: 43420
def incLcm(a, b, c)
	cnt = 0
	a.upto(b){|i|
		if (c % i == 0)
			cnt += 1
		end
	}
	return cnt
end

input = gets
a, b, c = input.split(' ').map(&:to_i)

puts incLcm(a, b, c)

Measured memory_bytes: 8676
#include <bits/stdc++.h>
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;

long long BIT[100100];

void upd(int ind,long long val) {
	while(ind < 100010) {
		BIT[ind] += val;
		BIT[ind] %= mod;
		ind |= ind + 1;
	}
}

long long get(int ind) {
	long long res = 0;
	while(ind >= 0) {
		res += BIT[ind];
		res %= mod;
		ind = (ind & (ind+1)) -1;
	}
	return res;
}

int lst[100100];
long long s[100100];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int N;
	long long A,B;
	cin>>N>>A>>B;
	if(A < B)
		swap(A,B);
	s[0] = LLONG_MIN;
	bool f = false;
	for(int i = 1;i <= N;i++) {
		cin>>s[i];
		if(i <= 2) {
			lst[i] = 0;
		}else if(s[i-1] - s[i-2] >= B) {
			lst[i] = lst[i-1];
		}else {
			lst[i] = i - 2;
		}
		if(i >= 3 && s[i] - s[i-2] < B) {
			f = true;
		}
	}
	if(f) {
		cout<<"0\n";
		return 0;
	}
	upd(0,1ll);
	for(int i = 1;i <= N;i++) {
		int it = upper_bound(s,s + i,s[i] - A) - s;
		it--;
		if(it < lst[i])
			continue;
		long long ad = get(it) + mod - get(lst[i] - 1);
		ad %= mod;
		upd(i,ad);
	}
	long long res = get(N) + mod - get(N-1);
	res %= mod;
	bool can = true;
	for(int i = N-1;i >= 1;i--) {
		res += get(i) + mod - get(i-1);
		res %= mod;
		if(s[i+1] - s[i] < B) {
			can = false;
			break;
		}
	}
	if(can) { 
		res++;
		res %= mod;
	}
	cout<<res<<'\n';
	return 0;
}
/**/


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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<llong> X;
    rep(i, n) {
        llong x;
        cin >> x;
        X.push_back(x);
    }

    llong ans = 1e9;
    rep(i, n - k + 1) {
        llong left = X[i], right = X[i + k - 1];
        ans = min(ans, min(abs(left), abs(right)) + right - left);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int m;
	cin >> m;
	cout << 48 - m << endl;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;

double log(double base, double value) {
	return std::log2(value) / std::log2(base);
}


void init() {
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
}

void calc() {

	Int N, K; std::cin >> N >> K;
	Int ans = 0;
	while (N > 0) {
		N /= K;
		ans++;
	}

	std::cout << ans;

}


int main() {

	init();
	calc();

	return 0;
}

Measured memory_bytes: 256
/*
    Bismillahir Rahmanir Raheem
    Think Twice Code Once
    author : reaziii
*/
#include<bits/stdc++.h>
#define sc(x)        scanf("%lld",&x)
#define pcase(x)     printf("Case %d: ",x++)
#define pn           printf("\n")
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x,e)   memset(x,e,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define m_v          3000000
#define pii          pair<int,int>
#define pch          pair<char,char>
#define pll          pair<ll,ll>
#define mgraph       map<int,vector<int> >
#define mp           make_pair
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define frx(x,y)     for(int x=0;x<y;x++)
#define deb(x)       cout<<x
#define ideb(i,x)    cout<<i<<" "<<x
#define F            first
#define S            second
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
bool checkbitt(ll num, int pos);
ll setbitt(ll num, ll pos);
ll resetbitt(ll num, int pos);
//.................___Start from here___.................//
//.................._____________________................//
ll const N = 1000009;
ll const mod = 998244353;
vector<int> divisors[N];

void divisor() {
	for (int i = 1; i < N; i++) {
		for (int j = i; j < N; j += i) {
			divisors[j].pb(i);
		}
	}
}

ll sqsum[N];
ll sumsq[N];
ll power(ll n, ll b) {
	if (b == 0) return 1;
	ll p = power(n, b / 2) % mod;
	p = (p * p) % mod;
	return b & 1 ? (p * n) % mod : p;
}
ll modinverse(ll n) {
	return power(n, mod - 2);
}
int ext[N];

int solve() {
	ll n;
	sc(n);


	ll val;
	fri(n) {
		sc(val);
		for (auto x : divisors[val]) {
			sqsum[x] = (sqsum[x] + power(val, 2)) % mod;
			sumsq[x] = (sumsq[x] + val) % mod;
		}

	}

	ll res = 0;
	for (int i = N - 1; i >= 1; i--) {
		ll cur = (power(sumsq[i], 2) - sqsum[i]) % mod;
		cur = (cur + mod) % mod;

		for (ll j = i + i; j < N; j += i) {
			cur -= ext[j];
			cur = (cur + mod) % mod;
		}
		ext[i] = cur;
		res = (res + (cur * modinverse(i)) % mod) % mod;
	}

	res = (res * modinverse(2)) % mod;

	printf("%lld\n", res);





	return 0;
}
int main() {
#ifndef ONLINE_JUDGE
	input;
	output;
#endif
	divisor();
	solve();
}


bool checkbitt(ll num, int pos) {
	return (num >> pos) & 1;
}

ll setbitt(ll num, ll pos) {
	return (1 << pos) | num;
}

ll resetbitt(ll num, int pos) {
	if (!checkbitt(num, pos)) {
		return num;
	}
	else {
		return (1 << pos)^num;
	}
}



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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;
using vd=vector<double>;
int ctoi(char c) {return c-'0';}

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int ans=0,c=0;
string s;
cin>>s;
forn(i,3) {
  if(s[i]=='R')
    c++;
}
if(c==3)
  ans=3;
else {
  if((s[0]==s[1] and s[0]=='R') or (s[1]==s[2] and s[1]=='R')) {
    ans=2;
  }
  else {
    ans=(c>0);
  }
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int ii = a; ii <= (b); ++ii) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	int a, b, c;
	cin >> a >> b >> c;
	cout << ((b - a == c - b) ? "YES" : "NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s, t = "CODEFESTIVAL2016"; cin >> s;
  int count = 0; for(int i = 0; i < s.size(); i++) if(s.at(i) != t.at(i)) count++;
  cout << count << endl;
}

Measured memory_bytes: 256
s = list(input())
flag = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] not in ['R', 'U', 'D']:
            flag = 1
    else:
        if s[i] not in ['L', 'U', 'D']:
            flag = 1
if flag == 1:
    print('No')
else:
    print('Yes')

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

#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using namespace std; 

using ll = long long;
using ii = pair<int,int>;

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

  int a; cin >> a;
  cout << 3*a*a << ende;

  return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
 
    N = int(input())
 
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        G[u].append(v)
        G[v].append(u)
 
    connect = [len(g) for g in G]
 
    #根を0として木を構築
    root = 0
    stack = [root]
    order = []
    lst = [0] * N
    while len(stack) != 0:
        tmp = stack.pop()
        order.append(tmp)
        for to in G[tmp]:
            if to == lst[tmp]:
                continue
            lst[to] = tmp
            stack.append(to)
        
    dp1 = [0] * N
    for v in order[::-1]:
        d = connect[v]
        if v != root and d == 1:
            continue
        x = sum(dp1[c] for c in G[v])
        if v == root:
            dp1[v] = x/connect[v] + 1
        else:
            dp1[v] = x/(connect[v] - 1) + 1
 
    dp2 = [0] * N
    for v in order:
        d = connect[v]
        n_child = d if v == root else d - 1
        S = dp1[v] * n_child
        if v != root:
            S += dp2[v] + 1
        for c in G[v]:
            if c == lst[v]:
                continue
            if d == 1:
                dp2[c] = 0
            else:
                dp2[c] = (S - dp1[c] - 1)/(d - 1)
 
    ans = []
    for v in range(N):
        d = connect[v]
        n_child = d if v == root else d - 1
        S = dp1[v] * n_child
        if v != root:
            S += dp2[v] + 1
        ans.append(S/d)
 
    print (*ans, sep = '\n')
 
    # print (dp1)
    # print (dp2)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 103480
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  else gcd(b, a % b);
}
int main() {
  int N;
  ll X;
  cin >> N >> X;
  vector<ll> x(N);
  REP(i, N) cin >> x[i];
  vector<ll> dis(N);
  REP(i, N) dis[i] = abs(x[i] - X);
  sort(dis.begin(), dis.end());
  int ans = dis[0];
  for (int i = 1; i < N; i++) {
    ans = gcd(ans, dis[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++)
    {
        string t = s.substr(i, 3);
        if(t.size() != 3) break;
        if(t == "ABC") ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>

using namespace std;
#define FOR(it,A) for(auto it = A.begin(); it != A.end(); it++)

int main() {
	int N;
	cin >> N;
	map<int,int> A;
	map<int,int>::iterator it1, it2;
	vector<int> overlapped;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		it1 = A.find(a);
		if(it1 == A.end()) A.insert(make_pair(a,0));
		else {
			overlapped.push_back(a);
		}
	}
	int count = 0;
	int gop; // 1부터 곱해나가 
	int k;
	FOR(it1, A) { // 작은 것
		// Ai가 A 
		// Aj가 B
		if (it1->second == 0) { //1이면 이미 누군가의 배수야 
			k = 0;
			gop = 2;
			while (!(k > A.rbegin()->first)) {
				k = it1->first * gop;
				it2 = A.find(k);
				if (it2 != A.end()) it2->second = 1;
				gop++;
			}
			
		}
	}
	FOR(it1, overlapped) {
		it2 = A.find(*it1);
		it2->second = 1;
	}

	FOR(it1, A) {
		if (it1->second == 0) count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 12888
#include<iostream>
#include<algorithm>
#include<cassert>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

int main()
{
  int Math,Greedy,Geometry,DP,Graph,Other;
  while(cin >> Math >> Greedy >> Geometry >> DP >> Graph >> Other,Math|Greedy|Geometry|DP|Graph|Other)
    {
      int total[3];
      total[0] = Math+DP;
      total[1] = Greedy+Graph;
      total[2] = Geometry+Other;
      assert(total[0]+total[1]+total[2] <= 100000000LL);

      //int Size = min(total[0],min(total[1],total[2]));
      int ans = 0;
        
      rep(i,3)
	{
	  int A = total[0],B = total[1],C = total[2];
	  int preans = i;
	  A -= i;
	  B -= i;
	  C -= i;
	  if(A<0 || B <0 || C<0)continue;
	  preans += A/3;
	  preans += B/3;
	  preans += C/3;
	  ans = max(ans,preans);
	}

      cout << ans << endl;
    }
  return 0;
}

Measured memory_bytes: 1164
import random
import time
import copy
start = time.time()
D = int(input())
s = [[0 for j in range(26)] for i in range(D)]
c = list(map(int, input().split(" ")))
score = [0 for i in range(26)]

result = []
total = -10000000
for i in range(D):
    a = list(map(int, input().split(" ")))
    for j, k in enumerate(a):
        s[i][j] = int(k)
while(1):
    result_tmp = []
    total_tmp=0
    last = [0 for i in range(26)]
    for i in range(D):
        for j in range(26):
            score[j] = s[i][j]
            for k in range(26):
                if j != k:
                    score[j] -= (i + 1 - last[k]) * c[k]
        score_max = max(score)

        tmp = []
        for j in range(26):
            if score_max >= 0 and score_max*0.85 <= score[j]:
                tmp.append(j)
            if score_max < 0 and score_max*1.15 <= score[j]:
                tmp.append(j)

        score_max = random.choice(tmp)

        result_tmp.append(score_max)
        last[score_max] = i + 1
        total_tmp += score[score_max]
        #print(tmp)
    if total < total_tmp:
        total=total_tmp
        result = result_tmp.copy()
    end = time.time()
    if end - start > 1.8:
        break
for i in range(D):
    print(result[i]+1)

Measured memory_bytes: 86256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#define MAX_V 500*500+1
#define INF 501

using namespace std;



struct edge{int to,cap,rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t)return f;
  used[v]=true;

  for(int i=0;i<G[v].size();i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	G[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  for(;;){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0)return flow;
    flow+=f;
  }
}

int lcm(int m,int n){
  int tmp;
  while (m % n != 0)
    {
      tmp = n;
      n = m % n;
      m = tmp;
    }
  return n;
}



int main()
{
  for(;;){
    for(int i=0;i<MAX_V;i++){
      G[i].clear();
    }
    int m,n;
    cin >> m >> n;
    if(m==0)return 0;
    int br[m+n];
    for(int i=0;i<m+n;i++)cin >> br[i];

    for(int i=0;i<m;i++){
      for(int j=m;j<m+n;j++){
	//cout << br[i] << "," << br[j]<< ";" << lcm(br[i],br[j]) <<endl;
	if(lcm(br[i],br[j])!=1){
	  add_edge(i,j,1);
	}
      }
    }
    for(int i=0;i<m;i++)
      add_edge(n+m+1,i,1);
 
    for(int i=0;i<n;i++)
      add_edge(m+i,n+m+2,1);

    cout << max_flow(n+m+1,n+m+2) << endl;
  }
}

      

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

int main() {
  int a,b,h,m;cin>>a>>b>>h>>m;
  double pai=acos(-1);
  double hh=(double)(h*60+m)/720*2*pai;
  double mm=(double)m/60*2*pai;
  double x1=a*cos(hh),y1=a*sin(hh);
  double x2=b*cos(mm),y2=b*sin(mm);
  double dx=x1-x2,dy=y1-y2;
  double ans=sqrt(dx*dx+dy*dy);
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3992
# coding: utf-8
import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def attack(h):
    # 体力hのモンスターを倒す最小回数を返す
    if h == 1:
        return 1
    h //= 2
    return attack(h) * 2 + 1

H = ir()
answer = attack(H)
print(answer)


Measured memory_bytes: 3060
#include<iostream>
#include<stdio.h>

using namespace std;

int main()
{
  int m,f,r;
  while(1){
    cin>>m>>f>>r;
    if(m == -1 && f == -1 && r == -1) break;
    else if(m==-1 || f==-1) cout<<"F"<<endl;
    else if(m+f>=80) cout<<"A"<<endl;
    else if(m+f>=65 && m+f<80) cout<<"B"<<endl;
    else if(m+f>=50 && m+f<65) cout<<"C"<<endl;
    else if(m+f>=30 && m+f<50){
      if(r>=50)
	cout<<"C"<<endl;
      else
	cout<<"D"<<endl;
    }
    else if(m+f<30) cout<<"F"<<endl;
  }
  
  return 0;
}




Measured memory_bytes: 3100
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <functional>
#include <stack>
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 ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  int N;cin>>N;
  VI A(N);
  REP(i,N){
    cin>>A[i];
  }
  REP(i,N){
    if(A[i]%2==0){
      if(A[i]%3==0||A[i]%5==0){
        continue;
      }
      else{cout<<"DENIED"<<endl;return 0;}
    }
    else{
      continue;
    }
  }
  cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 384
S = input()
n = len(S)
p = (n-1)//2
q = (n+3)//2 - 1
A = S[:p]
B = S[q:]
ans = 'Yes'
for i in range(len(S)):
    if S[i] != S[-i-1]:
        ans = 'No'
for i in range(len(A)):
    if A[i] != A[-i-1]:
        ans = 'No'
for i in range(len(B)):
    if B[i] != B[-i-1]:
        ans = 'No'
print(ans)


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

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

const ll mod = 998244353;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

int add(int a, int b) {
    a %= mod;
    b %= mod;
    a += b;
    a %= mod;
    if(a < 0) {
        a += mod;
    }
    assert(a < mod);
    return a;
}

int sub(int a, int b) {
    a %= mod;
    b %= mod;
    a -= b;
    a %= mod;
    if(a < 0) {
        a += mod;
    }
    assert(a >= 0);
    return a;
}

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

    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> segments(k);
    vector<int> dp(n + 2);
    dp[1] = add(dp[1], 1);
    dp[2] = sub(dp[2], 1);
    for(int i = 0; i < k; i++) {
        int l, r;
        cin >> l >> r;
        segments[i] = mp(l, r);
    }
    for(int i = 1; i < n; i++) {
        dp[i] = add(dp[i], dp[i - 1]);
        assert(dp[i] < mod && dp[i] >= 0);
        for(int j = 0; j < k; j++) {
            int lower = segments[j].first;
            int higher = min(n - i, segments[j].second);
            if(lower + i <= n) {
                dp[i + lower] = add(dp[i + lower], dp[i]);
                dp[i + higher + 1] = sub(dp[i + higher + 1], dp[i]);
            }
        }
    }
    cout << add(dp[n], dp[n - 1]) << endl;
    return 0;
}


Measured memory_bytes: 4044
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int countA = 0;
        int countB = 0;
        int countC = 0;
        for (char c : s.toCharArray()) {
            if (c=='a') countA++;
            if (c=='b') countB++;
            if (c=='c') countC++;
        }
        int diff1 = Math.abs(countA - countB);
        int diff2 = Math.abs(countC - countB);
        int diff3 = Math.abs(countA - countC);
        if (diff1 <= 1 && diff2 <= 1 && diff3 <= 1) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 27732
// AtCoder Regular Contest 062
// D - AtCoDeerくんと変なじゃんけん / AtCoDeer and Rock-Paper

#include <cstdio>
#include <cstring>
#define MAX_N 100000
using namespace std;


int N;
char s[MAX_N + 2];
int ans;

int main() {

  scanf("%s", s);
  N = strlen(s);
  ans = 0;
  for (int i = 0; i < N; i++) {
    ans += (i % 2) - (s[i] == 'g' ? 0 : 1);
  }
  printf("%d\n", ans);

  return 0;

}




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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  cin >> n;
  vector<vector<int>> a(n,vector<int>(n));
  char c;
  bool zero=false;
  bool one=false;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> c;
      if(c=='.'){
        a[i][j]=0;
        zero=true;
      }else{
        a[i][j]=1;
        one=true;
      }
    }
  }
  if(!one){
    cout << -1 << endl;
    return 0;
  }
  if(!zero){
    cout << 0 << endl;
    return 0;
  }
  int r=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(!a[j][i]){
        r++;
        break;
      }
    }
  }
  int ans=1000000000;
  int count;
  for(int i=0;i<n;i++){
    count=0;
    for(int j=0;j<n;j++){
      if(a[i][j]==0) count++;
    }
    if(count==n) continue;
    for(int j=0;j<n;j++){
      if(a[j][i]){
        ans=min(ans,r+count);
        break;
      }
    }
    ans=min(ans,r+count+1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,K;cin>>A>>B>>K;
  for(int i=0;i<K;i++){
    if(i%2==0){
      if(A%2!=0)A--;
      B+=A/2;
      A/=2;
    }
    else{
      if(B%2!=0)B--;
      A+=B/2;
      B/=2;
    }
  }
  cout<<A<<" "<<B<<endl;
}

Measured memory_bytes: 256
class UnionFind
  attr :parent

  def initialize(nodes)
    @parent = {}
    nodes.each do |node|
      parent[node] = -1
    end
  end

  def root(x)
    if parent[x] < 0
      x
    else
      parent[x] = root(parent[x])
    end
  end

  def size(x)
    return -parent[root(x)]
  end

  def connect(x, y)
    rx = root(x)
    ry = root(y)
    if rx == ry
      return false
    else
      if size(rx) < size(ry)
        rx, ry = ry, rx
      end

      parent[rx] += parent[ry]
      parent[ry] = rx

      return true
    end
  end
end

n,m = gets.split.map(&:to_i)
as = []

m.times do
  as << gets.split.map(&:to_i)
end

ans = [(n*(n-1))/2]
uf = UnionFind.new((1..n).to_a)
while a = as.pop
  if uf.root(a[0]) != uf.root(a[1])
    ans << ans[-1] - (uf.size(a[0]) * uf.size(a[1]))
    uf.connect(a[0], a[1])
  else
    ans << ans[-1]
  end
end

ans.pop
ans.reverse.each do |a|
  puts a
end

Measured memory_bytes: 18852
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: f64, m: f64, d: u64
    }

    let ret = if d == 0 {
        (m - 1.0) / n
    } else {
        (m - 1.0) * (2.0 * (n - d as f64) / (n * n))
    };
    println!("{}", ret);
}

Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;

  vector<string> ret(S.size(), "No");
  int a = 0;
  int b = 0;
  rep(i,S.size()){
    if(S[i] == 'a'){
      if(a+b < A+B){
        ret[i] = "Yes";
        a++;
      }
    }
    else if(S[i] == 'b'){
      if(a+b < A+B && b < B){
        ret[i] = "Yes";
        b++;
      }
    }
  }

  rep(i,ret.size()){
    cout << ret[i] << endl;
  }
  
  return 0;
}



Measured memory_bytes: 6224
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   for(int i=0;i<(n);++i)
#define SORT(c)    sort((c).begin(),(c).end())
const double EPS = 1e-10;//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);

using namespace std;
#define NIL -1
#define MAX 100005
struct Node {int p,l,r;};
Node T[MAX];
int n,D[MAX];
void print(int u){
  cout<<"node "<<u<<": parent = "<<T[u].p<<", "<<"depth = "<<D[u]<<", ";
  if(T[u].p==NIL)cout<<"root, [";
  else if(T[u].l==NIL)cout<<"leaf, [";
  else cout<<"internal node, [";
  for(int i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i)cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}
void rec(int u,int p){
  D[u]=p;
  if(T[u].r!=NIL)rec(T[u].r,p);
  if(T[u].l!=NIL)rec(T[u].l,p+1);
}
int main(){
  cin>>n;
  rep(i,n)T[i].p=T[i].l=T[i].r=NIL;
  int l=0;
  rep(i,n){
    int v,d;
    cin>>v>>d;
    rep(j,d){
      int c;
      cin>>c;
      if(!j)T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  int r;
  rep(i,n)if(T[i].p==NIL)r=i;
  rec(r,0);
  rep(i,n)print(i);
  return 0;
}


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

int32_t sgn(int32_t val) { return (val > 0) - (val < 0); }

int main() {
  uint32_t n = 0;
  std::cin >> n;
  std::vector<int32_t> A(n);
  for (auto&& a : A) std::cin >> a;

  const int32_t flip = -1;
  int32_t sum = 0, sign = 1;
  uint64_t op_plus = 0;
  for (size_t i = 0; i < A.size(); i++) {
    int32_t diff = (sign == sgn(sum + A[i])) ? 0 : sign - (sum + A[i]);
    op_plus += std::abs(diff);
    sum += A[i] + diff;
    sign *= flip;
  }

  sum = 0;
  sign = -1;
  uint64_t op_minus = 0;
  for (size_t i = 0; i < A.size(); i++) {
    int32_t diff = (sign == sgn(sum + A[i])) ? 0 : sign - (sum + A[i]);
    op_minus += std::abs(diff);
    sum += A[i] + diff;
    sign *= flip;
  }

  std::cout << std::min(op_plus, op_minus) << std::endl;

  return 0;
}

Measured memory_bytes: 640
kosu = [0] * 100
k = 1
while True:
    try:
        n = int(input())
        kosu[n - 1] += 1
    except (EOFError,ValueError):
        ma = max(kosu)
        num = kosu.index(ma) + k
        print(num)
        
        
        kosu.remove(max(kosu))
        while True:
            if ma > max(kosu):
                break
            k += 1
            num = kosu.index(ma) + k
            kosu.remove(max(kosu))
            print(num)
        break

Measured memory_bytes: 7624
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author shivam
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            HashMap<String, Integer> map = new HashMap<>();
            map.put("AC", 0);
            map.put("WA", 0);
            map.put("TLE", 0);
            map.put("RE", 0);
            for (int i = 0; i < n; i++) {
                String s = in.next();
                if (s.equals("AC")) map.put("AC", map.get("AC") + 1);
                if (s.equals("WA")) map.put("WA", map.get("WA") + 1);
                if (s.equals("TLE")) map.put("TLE", map.get("TLE") + 1);
                if (s.equals("RE")) map.put("RE", map.get("RE") + 1);
            }
            out.println("AC" + " " + "x" + " " + map.get("AC"));
            out.println("WA" + " " + "x" + " " + map.get("WA"));
            out.println("TLE" + " " + "x" + " " + map.get("TLE"));
            out.println("RE" + " " + "x" + " " + map.get("RE"));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 49424
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,a[123456],i,t[123456],now=0;
	fill(t,t+123456,-1);
	t[0] = 0;
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> a[i];
		a[i]--;
	}
	while(true){
		if(t[a[now]]>0){
			break;
		}
		t[a[now]] = t[now] + 1;
		now = a[now];
	}
	cout << t[1] << endl;
	return 0;
}

Measured memory_bytes: 1152
def main():
    n = int(input())
    s = input()
    t = input()
    mod = 10 ** 9 + 7

    p = {"||": 2, "==": 3, "|=": 2, "=|": 1, "|": 3, "=": 6}
    ans = 1
    bf = ""
    it = iter(range(n))
    for i in it:
        if s[i] == t[i]:
            nw = "|"
        else:
            nw = "="
            it.__next__()

        ans *= p[bf + nw]
        ans %= mod
        bf = nw

    print(ans % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
main() {
	int n;
	cin >>n;
	vector<int> a(n);
	vector<int> kol(1010101);
	for (int i = 0; i < n; i++)
		cin >>a[i];
	sort(a.begin(), a.end());
	for (int to : a) {
		if (kol[to] != 0) {
			kol[to] = 2;
			continue;
		}
		for (int i = to; i < 1010101; i += to) 
			kol[i]++;
	}
	int ans = 0;
	for (int to : a) {
		if (kol[to] == 1) ans++;
	}
	cout <<ans;
}

Measured memory_bytes: 8012
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
oks = [True]*(n+1)
for i in range(m):
    a = int(input())
    oks[a] = False

dp = [0]*(n+1)
dp[0] = 1
for i in range(n):
    for j in range(i+1,min(n,i+2)+1):
        if oks[j]:
            dp[j] += dp[i]
            dp[j] %= (10**9+7)
print(dp[n])

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

int main(void){
	int x,y,z,n=1;
	scanf("%d %d %d",&x,&y,&z);
	while(x>=y*n+z*(n+1)){
		n++;
	}
	printf("%d\n",n-1);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	int n,k;
	while(cin>>n>>k){
		if(n%k)
			puts("1");
		else
			puts("0");
	} 
	return 0;
}


Measured memory_bytes: 256