akhauriyash/Code-Regression huggingface dataset:
#include<cctype>
#include<string>
#include<algorithm>
#include<iostream>
#include<set>
#include<regex>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<ctime>
#include<vector>
#include<bitset>
#include<cstdio>
#include<numeric>
#include<utility>
#include<sstream>
#include<cstdlib>
#include<iomanip>
#include<cstring>
#include<map>
#include<functional>
#include<unordered_map>
#define _USE_MATH_DEFINES
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define endl "\n"
typedef long long int lli;
typedef unsigned long long int uli;
const uli mod = 1e9 + 7;
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int n, d, x, sum = 0;
    cin >> n >> d >> x;
    for(int i = 0; i < n; ++i) {
        int a; cin >> a;
        if(a ==1)
            sum += d;
        else sum += d / a + 1;
        if(d % a == 0&&a!=1)
            --sum;
    }
    cout << sum + x << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ABC084
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] C = new int[N];
            int[] S = new int[N];
            int[] F = new int[N];
            int[] input;
            for (int i = 0; i < N - 1; i++)
            {
                input = Console.ReadLine().Split().Select(int.Parse).ToArray();
                C[i] = input[0];
                S[i] = input[1];
                F[i] = input[2];
            }

            int[] Res = new int[N];
            int t = 0;
            for (int i = 0; i < N - 1; i++)
            {
                t = S[i] + C[i];
                for (int j = i + 1; j < N - 1; j++)
                {
                    if (t < S[j])
                    {
                        t = S[j] + C[j];
                    }
                    else
                    {
                        if (t % F[j] != 0) t += F[j] - t % F[j];
                        t += C[j];

                    }
                }
                Res[i] = t;
            }

            foreach (var i in Res)
            {
                Console.WriteLine(i);
            }
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=200001;
//int arr[SIZE]={};
//ここまでテンプレ
int main(){
	char A[11],B[11],C[11];
	cin>>A>>B>>C;
	if(A[strlen(A)-1]==B[0] && B[strlen(B)-1]==C[0])
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import deque
N, M = map(int, input().split())
B = [[] for i in range(N)]
C = [0 for i in range(N)]
for i in range(M):
  a, b = map(int, input().split())
  B[a-1].append(b)
  B[b-1].append(a)
d = deque([1])
while len(d):
  p = d.pop()
  for q in B[p-1]:
    if C[q-1] == 0:
      C[q-1] = p
      d.appendleft(q)
print("Yes")
for i in range(1, N):
  print(C[i])

Measured memory_bytes: 98912
#include <string>
#include <sstream>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <queue>
#include <list>
#include <vector>
#include <array>
#include <algorithm>
#include <iterator>


bool compare(const std::string& _lhs, const std::string& _rhs)
{
	for (int i = 0; i < _lhs.size(); i++)
	{
		if (i >= _rhs.size() ) return false;

		if (_lhs[i] < _rhs[i]) return true;
		else if (_lhs[i] > _rhs[i]) return false;
	}

	return _lhs.size() <= _rhs.size();
}

std::vector<std::string> inputVector;
std::ostringstream os;


int main()
{
	int N, L = -1;

	
	std::string first;
	std::getline(std::cin, first);
	std::istringstream ifst(first);

	ifst >> N >> L;

	for (int i = 0; i < N; i++)
	{
		std::string s;
		std::getline(std::cin, s);
		std::istringstream iss(s);
		inputVector.push_back(iss.str());
	}


	//std::sort(inputVector.begin(), inputVector.end(), compare);
	std::sort(inputVector.begin(), inputVector.end());

	std::copy(inputVector.begin(), inputVector.end(), std::ostream_iterator<std::string>(os));
	std::cout << os.str() << std::endl;

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using edge = pair<ll, P>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
using Graph = vector<vector<ll>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N - 1);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];

    ll ans = accumulate(B.begin(), B.end(), 0LL);
    rep(i, N - 1) {
        if (A[i] + 1 == A[i + 1]) {
            ans += C[A[i]-1];
        }
    }
    cout << ans << endl;

}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<(n);i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
ll ans =0;
int N;
vi edge[10];
int dfs(int ow,bool seen[]){
    bool f =true;
    rep(i,N)if(!seen[i])f=false;
    if(f)return 1;
    int sum = 0;
    for(int ne :edge[ow]){
        //if(ne==n)continue;
        if(seen[ne])continue;
        seen[ne]=true;
        sum += dfs(ne,seen);
        seen[ne] = false;
    }

    return sum;

}
int main(){
   cin>>N;int m ;cin>>m;
   rep(i,m){int a,b;
   cin>>a>>b;
   a--;b--;
   edge[a].push_back(b);
   edge[b].push_back(a);
   }
   bool seen[N];
   rep(i,N)seen[i]=false;
   seen[0]=true;
   cout<<dfs(0,seen)<<endl;

}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <deque>
#include <vector>
#include <stdio.h>


using std::cin;
using std::cout;
using std::endl;
using std::string;

// 操作Aをa回、操作Bをb回、操作CまたはD（どちらでも同じ）を0～最大c回行う場合の最大価値
long score(const std::deque<long>& deq, unsigned int a, unsigned int b, unsigned int& c)
{
	long v = 0;
	std::deque<long> d = deq;	// dequeのコピーを作る
	std::deque<long> mine;		// 手元の宝石の配列
	unsigned int i;

	for (i = 0; i < a; i++) {
		if ( !d.empty() ) {
			mine.push_back( d.front() );
			d.pop_front();
		}
	}
	for (i = 0; i < b; i++) {
		if ( !d.empty() ) {
			mine.push_back( d.back() );
			d.pop_back();
		}
	}
	if (!mine.empty()) {
		std::sort(mine.begin(), mine.end());
	}
	for (i = 0; i < c; i++) {
		if( ! mine.empty() && ( mine.front() < 0 ) ) {
			mine.pop_front();
		} else {
			break;
		}
	}
	c = i;

	while ( ! mine.empty() ) {
		v += mine.front();
		mine.pop_front();
	}

	return v;
}

int main()
{
	unsigned int N, K;
	std::deque<long> deq;
	long ans;
	long v;
	unsigned int a, b, c;	// 操作A,B,Cの回数
	unsigned int i;

	// input
	cin >> N >> K;
	for (i = 0; i < N; i++) {
		cin >> v;
		deq.push_back(v);
	}

	// calc
	ans = 0;
	for (a = 0; a <= K; a++) {
		for (b = 0; b <= (K - a); b++) {
			c = K - (a + b);
			v = score(deq, a, b, c);
			if (ans < v) {
//				printf("! a,b,c=(%d,%d,%d) v=%d\n", a, b, c, v);
				ans = v;
			}
		}
	}

	// output
	cout << ans << endl;

	return 0;
}


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

void solve() {
	int k, x;
	cin >> k >> x;
	if (k * 500 >= x) cout << "Yes" << endl;
	else cout << "No" << endl;
}

int main() {
	ios::sync_with_stdio (false);
	int t;
	t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cctype>
using namespace std;
typedef long long lint;
#define cout cerr
#define ni (next_num<int>())
template<class T>inline T next_num(){
	T i=0;char c;
	while(!isdigit(c=getchar())&&c!='-');
	bool flag=c=='-';
	flag?(c=getchar()):0;
	while(i=i*10-'0'+c,isdigit(c=getchar()));
	return flag?-i:i;
}
template<class T1,class T2>inline void apmax(T1 &a,const T2 &b){
	if(a<b){
		a=b;
	}
}
const int N=200010,INF=0x7f7f7f7f;
int ans=0;
namespace T{
	const int E=N<<2;
	int to[E],bro[E],mhead[N],dhead[N],e=0;
	int fa[N],dep[N],dfn[N],dfe[N],tim=0;
	bool col[N];
	inline void init(){
		memset(mhead,-1,sizeof(mhead));
		memset(dhead,-1,sizeof(dhead));
	}
	inline void ae(int u,int v,int *head){
		to[e]=v,bro[e]=head[u],head[u]=e++;
	}
	inline void add(int u,int v,int *head){
		ae(u,v,head),ae(v,u,head);
	}
	void dfs1(int x){
		dfn[x]=++tim;
		for(int i=mhead[x],v;~i;i=bro[i]){
			if((v=to[i])!=fa[x]){
				fa[v]=x;
				dep[v]=dep[x]+1;
				dfs1(v);
			}
		}
		dfe[x]=tim;
	}
	inline bool cont(int u,int v){
		return dfn[u]<=dfn[v]&&dfe[u]>=dfe[v];
	}
	inline bool gcol(int u,int v){
		if(cont(u,v)){
			return dep[v]-dep[u]>2;
		}
		if(cont(v,u)){
			return dep[u]-dep[v]>2;
		}
		return fa[u]!=fa[v];
	}
	void dfs2(int x,int fa,int stp){
		if(dep[x]<=stp){
			return;
		}
		if(col[x]){
			throw -1;
		}
		apmax(ans,dep[x]);
		for(int i=dhead[x];~i;i=bro[i]){
			if(to[i]!=fa){
				dfs2(to[i],x,stp+1);
			}
		}
	}
}
int main(){
	int n=ni,drt=ni,rt=ni;
	T::init();
	for(int i=1;i<n;T::add(ni,ni,T::dhead),i++);
	for(int i=1;i<n;T::add(ni,ni,T::mhead),i++);
	T::dfs1(rt);
	for(int i=0,ti=T::e>>1;i<ti;i+=2){
		int u=T::to[i],v=T::to[i^1];
		if(T::gcol(u,v)){
			T::col[u]=T::col[v]=true;
		}
	}
	try{
		T::dfs2(drt,0,0);
		printf("%d\n",ans<<1);
	}catch(int ans){
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 17152
using System;
using System.Collections.Generic;

class Program
{
    private const int CRANE_LEGS = 2;
    public static void Main(string[] args)
    {
        int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        Program pg = new Program();
        Console.WriteLine(pg.Exe(input));
    }

    public string Exe(int[] input)
    {
        string answer = "No";
        int animals = input[0];
        int legs = input[1];

        if(legs % 2 == 1) return answer;

        int crane_cnt = animals;
        int num_legs = crane_cnt * CRANE_LEGS;

        if((legs - num_legs) / 2 > animals) return answer;
        if((legs - num_legs) < 0) return answer;
        else answer = "Yes";

        return answer;
    }
}

Measured memory_bytes: 27480
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
vector <pii> events;

pii f(int pos)
{
	int mb = 0, cb = 0;
	int minv = -1, maxv = -1;
	for (int i = 0; i < events.size(); ++i)
	{
		if (events[i].second == 1)
		{
			cb++;
		}
		else
		{
			cb--;
			mb++;
		}
		if (mb < pos && mb + cb >= pos && minv == -1)
		{
			minv = events[i].first;
		}
		if (mb >= pos && maxv == -1)
		{
			maxv = events[i].first - 1;
		}
	}
	return pii(minv, maxv);
}

int main(int argc, char const *argv[])
{
	int n;
	
	cin>>n;
	for (int i = 0; i < n; ++i)
	{
		int a,b;
		cin>>a>>b;
		events.push_back(pii(a, 1));
		events.push_back(pii(b + 1, -1));
	}
	
	sort(events.begin(), events.end());

	if (n%2 == 0)
	{
		pii r1 = f(n/2);
		pii r2 = f(n/2 + 1);


		// cout<<r1.first<<","<<r1.second<<"\n";
		// cout<<r2.first<<","<<r2.second<<"\n";

		cout<<r1.second + r2.second - r1.first - r2.first + 1<<"\n";		
	}
	else
	{
		pii r = f((n + 1) / 2);

		// cout<<r.first<<","<<r.second<<"\n";
		
		cout<<r.second - r.first + 1<<"\n";
	}
	return 0;
}

Measured memory_bytes: 7440
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=1e5+5;
const int mod=1e9+7;
int f;
string s;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
	cin>>s;
    f=1;
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-i-1]){
            f=0;
            break;
        }
    }
    for(int i=0;i<s.size()/2/2;i++){
        if(s[i]!=s[s.size()/2-i-1]){
            f=0;
            break;
        }
    }
    if(f==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
/*  よろしくお願いします
    LEARNING DP:    Coins
        + N Coins
        + Head pi
        + Tail 1-pi
        + The Probability of having more heads than tails.
    CONSTRAINT:
        +2 <= H, W <= 1000
    WHAT WHE SHOULD CARE ABOUT:
        + Which INDEX and HEAD or not
    IF WE KNOW:

    PRE DP:

    TIME COMPLEXITY:
        O(N*M)
*/
#include <bits/stdc++.h>
using namespace std;

#define DB(_x)      cout << #_x << " is " << (_x) << "\n";
#define fs          first
#define sc          second
#define pb          push_back
//#define IOFILE

using LL = long long;
using LD = long double;
using VI = vector<int>;
using PI = pair<int,int>;
const int mod = 1e9 + 7;

// BEG: GLOBAL VARIABLES
    LL n, k;
    LL b[51][51], a[51][51], ans;
// END: GLOBAL VARIABLES

void MUL(LL a[][51], LL b[][51]){
    LL c[51][51];
    for (int i=0; i<n; ++i){
        for (int j=0; j<n; ++j){
            c[i][j] = 0;
            for (int k=0; k<n; ++k){
                c[i][j] += a[i][k] * b[k][j] % mod;
                if (c[i][j] > mod) c[i][j] %= mod;
            }
        }
    }
    for (int i=0; i<n; ++i){
        for (int j=0; j<n; ++j){
            a[i][j] = c[i][j];
        }
    }
}

void BE(){
    while (k){
        if (k&1) MUL(b,a);
        MUL(a,a);
        k >>= 1;
    }
}

void Excalibur(){
    while (cin >> n >> k){
        for (int i=0; i<n; ++i)
            for (int j=0; j<n; ++j){
                cin >> a[i][j];
                b[i][j] = i == j;
            }

        BE();

        ans = 0;
        for (int i=0; i<n; ++i){
            for (int j=0; j<n; ++j){
                ans += b[i][j];
                if (ans >= mod) ans %= mod;
            }
        }

        cout << ans << "\n";
    }
}

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

#ifdef  IOFILE
    freopen("INPUT.in", "r", stdin);
    freopen("OUTPUT.out", "w", stdout);
#endif

Excalibur();
return 0;}


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

int main(){
    long n;
    cin >> n;
    long p = 1;
    long r = 1000000007;
    for(long i = 1; i < n + 1; i++)
    {
        p = (p * i) % r;
    }
    cout << p << "\n";
}

Measured memory_bytes: 256
/*author : Yashvardhan
Sunday, May 03, 2020
5:31 PM
*/

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

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	int n,k;
	cin >> n >> k;

	int vis[n + 1];
	initialise(vis, 0);
	for(int i = 1; i <= k; i++){
		int d;
		cin >> d;
		for(int j = 0; j < d; j++){
			int x;
			cin >> x;
			vis[x] = 1;
		}
	}

	int ct = 0;
	for(int i = 1; i <= n; i++){
		if(!vis[i]){
			ct++;
		}
	}

	cout << ct << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << endl;
	
	return 0;
}



Measured memory_bytes: 3656
int main(void) {
	int a,b,i,j,as = 0,bs = 0;
	while(scanf("%d",&j) , j != 0){
		as = 0;
		bs = 0;
		for(i = 1;i <= j;i++){
			scanf("%d%d", &a, &b);			
			if (a > b){
				as = as + a + b;
			}
			else if (a <b){
				bs = bs + a + b;
			}
			else{
				as = as + a;
				bs = bs + b;
			}
		}
		printf("%d %d\n", as ,bs);

	}
	return 0;
}

Measured memory_bytes: 600
from collections import defaultdict
n = int(input())
a = list(map(int, input().split()))

d = defaultdict(int)
for i in range(n):
    d[a[i]] += 1

ans = 0
for x in d:
    cand = d[x]
    if x - 1 in d:
        cand += d[x - 1]
    if x + 1 in d:
        cand += d[x + 1]
    
    ans = max(ans, cand)

print(ans)


Measured memory_bytes: 14564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		if(a <= 8 && b <= 8) System.out.println("Yay!");
		else System.out.println(":(");
	}

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <time.h>
#include <complex>
#include <cmath>
#include <numeric>
#include <limits>
#include <type_traits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
#define TEMP(type,x,y) do {temp temp=x,x=y,y=temp}while(0)
const ll INF = (1LL << 50);

ll gcd(ll x,ll y) {
	return y ? gcd(y, x%y) : x;
}

vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i*i <= n; i++) {
		if (n%i) continue;
		res.emplace_back(i, 0);
		while (n%i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	
	return res;

}

int main() {

	ll a, b;
	cin >> a >> b;
	ll g = gcd(a, b);
	auto f = factorize(g);
	int ans = f.size() + 1;
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 256
N = int(input())
P = list(map(float, input().split()))
# dp = [[0] * (N + 1) for i in range(N + 1)]
# dp[0][0] = 1.0
# for i in range(1, N + 1):
#     for j in range(N):
#         if j < N:
#             dp[i][j + 1] += dp[i - 1][j] * P[i - 1]
#         dp[i][j] += dp[i - 1][j] * (1 - P[i - 1])
#
# num = 0
# for i in range(N // 2 + 1, N + 1):
#     num += dp[N][i]
#
# print(num)


dp = [0] * (N + 1)
dp[0] = 1
for i in range(1, N + 1):
    tmp = dp
    dp = [0] * (N + 1)
    for j in range(N):
        if j < N:
            dp[j + 1] += tmp[j] * P[i - 1]
        dp[j] += tmp[j] * (1 - P[i - 1])

num = 0
for i in range(N // 2 + 1, N + 1):
    num += dp[i]

print(num)


Measured memory_bytes: 56028
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
    int N;
    string tmp;
    vector<string> judge_array = {"AC","WA","TLE","RE"};
    vector<int> count(4, 0);
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> tmp;
        for (int j = 0; j < 4; ++j) {
            if (tmp == judge_array[j]) {
                ++count[j];
                break;
            }
        }
    }
    for (int i = 0; i < 4; ++i) {
        cout << judge_array[i] << " x " << count[i] << endl;
    }
    return 0;
}

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

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
ll _gcd(ll a, ll b) { return b != 0 ? _gcd(b, a % b) : a; }
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll a,b; cin >> a >> b;
  cout << a*b/_gcd(a,b) << endl;
  return 0;
}


Measured memory_bytes: 256
//kid_kb//

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
#define ull unsigned long long int
#define lower(str) transform(str.begin(),str.end(),str.begin(),::tolower);
#define upper(str) transform(str.begin(),str.end(),str.begin(),::toupper);
#define mod 1000000007
#define SORT(vec) sort(vec.begin(),vec.end());
#define pb push_back
#define csb __builtin_popcount
#define msb(n) (ll)(log2(n))
#define DIG(n) floor(log10(n))+1
#define kb ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ptr(arr) for(auto i:arr)cout<<i<<" ";
#define ptr2(vec) for(auto i:vec){for(auto j: i){cout<<j<<" ";}cout<<endl;}
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mem(a,val) memset(a,val,sizeof(a))
//cout<<fixed<<setprecision(8)<<endl;
 
int main()
{
    kb
    //                                            Let's Fight !!!!!!!
    ll t;
    t=1;
    // cin>>t;
    while(t--){
        ll n,x,te;
        cin>>n>>x>>te;
        int temp=ceil(double(n)/x);
        cout<<te*temp<<endl;   
    }

    return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,Q;
    Scd2(N,Q);
    ll ans = 1LL*(N-2)*(N-2);

    map<int,int> xs;
    map<int,int> ys;
    xs[N] = N;
    ys[N] = N;

    int r,x;
    int y;
    auto* as = &xs;
    auto* bs = &ys;
    Rep(q,Q){
        Scd2(r,x);
        as = (r==1?&xs:&ys);
        bs = (r==2?&xs:&ys);
        y = as->upper_bound(x-1)->second;
        ans -= y-2;
        if( (*bs)[y] == 0 ) (*bs)[y] = x;
        (*bs)[y] = min((*bs)[y],x);
    }

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

    return 0;
}



Measured memory_bytes: 8332
S=input().strip()
s="R"
cut_l = 0
ss=[]
for i,c in enumerate(S):
    if c!=s:
        if s=="R":
            s="L"
        else:
            ss.append(S[cut_l:i])
            cut_l = i
            s="R"
ss.append(S[cut_l:])
seps = [s.index("L")for s in ss]
ress = []
for s,idx in zip(ss,seps):
    
    l_zero=idx-1
    numrl=[len(s)-len(s)//2,len(s)//2]
    numrl=numrl if idx%2!=0 else numrl[::-1]
    r_zero = len(s)-idx-1
    ress.append(" ".join(map(str,([0]*l_zero)+numrl+([0]*r_zero))))

    
print(" ".join(ress))

Measured memory_bytes: 10980
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>
 
long int calc(long int a, long int b, long int c);
 
//+1+2 +2+1
 
int main(void)
{
	long int i, j;
	long int x, y;
	long int a, b, sum;//a:→b↑
	long int min, max;
	long int ans;
	long int warukazu = 1000000007;
	long int work;
	
	scanf("%ld%ld", &x, &y);
	
	if( (x + y) % 3 != 0) {
		printf("0\n");
		return 0;
	}
	
	if( (x > y * 2) || (y > x * 2) ) {
		printf("0\n");
		return 0;
	}
	
	a = (2 * x - y) / 3;
	b = (2 * y - x) / 3;
	sum = a + b;
	
	if(a > b) {
		min = b;
		max = a;
	} else {
		min = a;
		max = b;
	}
	
	ans = 1;
	
	for(i = 2; i <= sum; i++) {
		ans *= i;
		ans %= warukazu;
	}
	
	for(i = 2; i <= min; i++) {
		work = calc(i, warukazu - 2, warukazu);
		ans *= work;
		ans %= warukazu;
	}
	
	for(i = 2; i <= max; i++) {
		work = calc(i, warukazu - 2, warukazu);
		ans *= work;
		ans %= warukazu;
	}
	
	
	printf("%ld\n", ans % warukazu);
	
	return 0;
}
 
long int calc(long int a, long int b, long int c)
{
	long int x;
	
	if(b == 0) {
		return 1;
	} else if(b % 2 == 0) {
		x = calc(a, b / 2, c);
		return (x * x) % c;
	} else {
		return (a * calc(a, b - 1, c)) % c;
	}
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] R = new int[n];
        int maxAns = Integer.MIN_VALUE;

        R[0] = sc.nextInt();
        int min = R[0];
        int max = -2000000000;
        for(int i = 1; i < n; i++){
            R[i] = sc.nextInt();
            max = R[i];
            if(maxAns < max - min){
                maxAns = max - min;
            }
            if(min > R[i]){
                min = R[i];
            }
        }
        System.out.println(maxAns);
    }
}



Measured memory_bytes: 100428
#include<bits/stdc++.h>
using namespace std;
#define ll int64_t
#define f first
#define sec second
#define pb push_back
#define pf push_front
#define pbb pop_back
#define vi vector<ll>
#define vii vector< pair<ll,ll> >
#define pi pair<ll,ll>
#define map map<ll,ll>
#define set set<ll>
const int m=1e9+7;
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll temp=1;
    //ll result=0;
    for(int i=0;i<n;i++){
       ll x;
       cin>>x;
       if(x==temp)
           temp++;
    }
    if(temp==1)
    cout<<"-1"<<endl;
    else{
        cout<<n-temp+1<<endl;
    }
}
        
        
        
        
        
        
        
        
        


Measured memory_bytes: 256
//F - Contrast
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>

#define LL long long
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(int i=A;i<=B;i++)
#define BOR(i,A,B) for(int i=A;i>=B;i--)
#define INF 0x3f3f3f3f
using namespace std;
const int MaxN=2e5+10;

int A[MaxN],B[MaxN];
int Total;

inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}

int main() {
    // File();
    scanf("%d",&Total);
    FOR(i,1,Total) cin>>A[i];
    FOR(i,1,Total) cin>>B[i];
    int j=1,Pre=-1;
    FOR(i,1,Total) {
        if(A[i]!=Pre) j=1;
        if(A[i]==B[i]) 
            for(;j<=Total;j++) if(A[i]!=A[j] && A[i]!=B[j]) { swap(B[i],B[j]); break; }
        if(A[i]==B[i]) { cout<<"No"<<endl; return 0; }
        Pre=A[i];
    }
    cout<<"Yes"<<endl;
    FOR(i,1,Total) cout<<B[i]<<" ";
    // fclose(stdin);
    // fclose(stdout);
  //  system("pause");
    return 0;
}

Measured memory_bytes: 5244
N, M = map(int, input().split())
num_listP = [list(map(int, input().split())) for _ in range(M)]
num_list = [e for row in num_listP for e in row]

ans = []
cnt = 0

for i in range(1, N+1):
    ans.append(cnt)
    cnt = 0
    for j in num_list:
        if i == j:
            cnt += 1

ans.append(cnt)
for i in range(1, N+1):
    print(ans[i])

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

int n;
ll k;
const int N = 2e5+5;
ll a[N],b[N];
map<ll,int> c;

int bit[N];

void ud(int i, int v) {
	for(;i < N; i+=i&-i)
		bit[i] += v;
}

int qr(int i) {
	int b=0;
	for(;i;i^=i&-i)
		b += bit[i];
	return b;
}

int main() {
	scanf("%d%lld",&n,&k);
	for(int i = 1; i <= n; ++i) {
		scanf("%lld",a+i);
		a[i] -= k;
	}
	for(int i = 1; i <= n; ++i) {
		a[i] += a[i-1];
	}
	for(int i = 1; i <= n; ++i) {
		b[i] = a[i];
	}
	sort(b,b+n+1);
	for(int i = 0; i <= n; ++i) {
		c[b[i]] = i+1;
	}
	ll ans = 0;
	for(int i = n; i >= 1; --i) {
		ud(c[a[i]],1);
		// cout << i << " : " << c[a[i]] << " " << c[a[i-1]] << endl;
		ans += qr(n+1) - qr(c[a[i-1]]-1);
		// cout << ans << endl;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 16640
#include<bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
signed main(){
    int n,k;
    cin >> n >> k;
    int bn;
    do {
        bn = n;
        n %= k;
    } while (bn != n % k);
    cout << min({n, n%k, k-n});
}

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

int main(){
	long long int n;
	cin>>n;
	long long int tmp=0;
	long long int a;
	long long int ans=0;
	for(long long int i=0;i<n;i++){
		cin>>a;
		if(a!=0){
			tmp+=a;
		}else{
			ans+=tmp/2;
			tmp=0;
		}
	}
	ans+=tmp/2;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
def d_score_attack(N, M, R, INF=float('inf')):  # ベルマン-フォード法による
    edges = [(a - 1, b - 1, -c) for a, b, c in R]
    dist = [INF] * N
    dist[0] = 0

    for _ in range(N - 1):
        for u, v, w in edges:
            if dist[u] == INF:
                continue
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
    ans_tmp = dist[N - 1]  # 負閉路がなければ、これが解

    # 負閉路がなければここからのループで距離は変わらない
    is_negative = [False] * N
    for _ in range(N):
        for u, v, w in edges:
            if dist[u] == INF:
                continue
            if dist[v] > dist[u] + w:
                dist[v] = dist[u] + w
                is_negative[v] = True

            # ある頂点が負閉路の一部なら、それに隣接する頂点も負閉路の一部
            if is_negative[u]:
                is_negative[v] = True
    # 頂点Nが負閉路に含まれるなら、元のグラフでのスコアは無限大
    return 'inf' if is_negative[N - 1] else -ans_tmp

N, M = [int(i) for i in input().split()]
R = [[int(i) for i in input().split()] for j in range(M)]
print(d_score_attack(N, M, R))

Measured memory_bytes: 3700
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
using namespace std;


int main() {
	int n;
	cin >> n;
	int a[100001];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	int l = 0;
	while(l<n){
		int r1 = l + 1;
		while (r1 < n&&a[r1] >= a[r1 - 1])r1++;
		int r2(l + 1);
		while (r2 < n&&a[r2] <= a[r2 - 1])r2++;
		l = max(r1, r2);
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	string s,t; cin>>s>>t;
  	sort(s.begin(),s.end());
  	sort(t.begin(),t.end(),greater<int>() );
  	
  	//ひとつひとつ見ていく
  	for (int i=0;i<s.size();i++){
    	if(s.at(i)==t.at(i)){
  			if(s.size()-1==i && t.size()-1>i){
            	cout<<"Yes"<<endl;
          		return 0;
            }
			if(s.size()-1==i && t.size()-1<=i){
            	cout<<"No"<<endl;
          		return 0;
            }
          	if(t.size()-1==i){
            	cout<<"No"<<endl;
          		return 0;
            }
        }else if(s.at(i)>t.at(i)){
        	cout<<"No"<<endl;
          	return 0;
        }else if(s.at(i)<t.at(i)){
        	cout<<"Yes"<<endl;
          	return 0;
        }
    }	
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    vector<int> h(n);
    rep(i,n) cin>>h[i];
    int res=0;
    while(true){
        bool jud1=false;
        rep(i,n){
            bool jud2=false;
            while(h[i]>0){
                jud1=true;
                jud2=true;
                h[i]--;
                i++;
                if(i==n)break;
            }
            if(jud2) res++;
        }
        if(!jud1)break;
    }
    cout<<res<<endl;
}


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

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	std::string str;
	std::cin >> str;
	int ans = 0;
	for(auto c : str) {
		ans += c - '0';
	}
	if(ans == 1 && str.size() > 1) {
		ans = 10;
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[27];
  int a[26]={0},b=0,c=1;
  scanf("%s",s);
  while(s[b]!='\0'){
    a[ s[b]-'a' ]++;
    b++;
  }
  for(int i=0; i<26; i++){
    if(a[i]>1){c=0;break;}
  }
  printf(c?"yes":"no");
  return 0;}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    private static final long MAX = 1000000000000000000L;
    public static void main(String args[]) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n =Integer.parseInt(br.readLine());
        long pdt = 1;
        String[] tokens = br.readLine().split(" ");
        long arr[] = new long[n];
        int i=0;
        for(i=0;i<n;i++){
            arr[i] = Long.parseLong(tokens[i]);
        }
        Arrays.sort(arr);
        for(i=0;i<n;i++){
            if(arr[i]!=0 && pdt>MAX/arr[i]){
                break;
            }
            pdt*=arr[i];
        }
        if(i<n)
            System.out.println(-1);
        else
            System.out.println(pdt);
    }


}

Measured memory_bytes: 51484
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
 
int main(){
    int x,y,a,b,c;
    cin >> x >> y >>a>>b>>c;
    vector<int> p(a);
    vector<int> q(b);
    vector<int> r(c);
    rep(i,a) scanf("%d",&p[i]);
    rep(i,b) scanf("%d",&q[i]);
    rep(i,c) scanf("%d",&r[i]);
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    vector<int> d;
    rep(i,x) d.push_back(p[i]);
    rep(i,y) d.push_back(q[i]);
    rep(i,c) d.push_back(r[i]);
    sort(d.rbegin(),d.rend());
    long ans=0;
    rep(i,x+y) ans+=d[i];
    printf("%ld",ans);
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a[128] = {};
  string s;
  while (cin >> s) {
    transform(s.begin(), s.end(), s.begin(), ::tolower);
    for (int i = 0; i < s.size(); i++) {
      a[s[i]]++;
    }
  }
  for (int i = 'a'; i <= 'z'; i++) {
    cout << (char)i << " : " << a[i] << '\n';
  }
  return 0;
}



Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;

std::vector<ll> divisors( ll x )
{
  std::vector<ll> ret;

  for( ll i = 1; i*i <= x; ++i ) if( x % i == 0 )
  {
    ret.emplace_back( i );

    if( i != x/i )
      ret.emplace_back( x/i );
  }

  return ret;
}

int main()
{
  std::cin >> N;

  auto ds = divisors(N);

  ll ans = 0;

  for( auto d : ds ) if( d > 1 )
  {
    ll m = d-1;

    if( N/m == N%m )
      ans += m;
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void)
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d\n", &W, &H, &x, &y, &r);
	
	if(((x-r) >= 0) && ((x+r) <= W) && ((y-r) >= 0) && ((y+r) <= H))
	{
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 //Compiler version g++ 6.3.0
 
 int main()
 {
 	int n, a, b;
 	cin >> n >> a >> b;
 	cout << min(a, b) << ' ' << max(0, a+b-n);
 	return 0;
 }

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;

namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

int dp1[100010];
int dp2[100010];
void mainmain(){
	int n;
	int m;
	while(scanf("%d",&n),n){
		vint hp(n);
		rep(i,n) scanf("%d",&hp[i]);
		scanf("%d",&m);
		vector<pii> one,all;
		bool f=false;
		rep(i,m){
			string s;
			cin>>s;
			int a,b;
			scanf("%d",&a);
			cin>>s;
			scanf("%d",&b);
			if(a==0&&b!=0){
				f=true;
			}
			if(s=="Single"){
				one.PB(mkp(a,b));
			}
			else{
				all.PB(mkp(a,b));
			}
		}
		if(f){
			puts("0");
			continue;
		}
		rep(i,100010){
			dp1[i]=INF;
			dp2[i]=INF;
		}
		dp1[0]=0;
		rep(i,one.size()){
			int t=INF;
			rep(j,100010){
				if(j+one[i].S>=100010){
					if(j==0){
						t=0;
					}
					dp1[100009]=min(dp1[100009],t+one[i].F);
					break;
				}
				if(dp1[j]==INF) continue;
				dp1[j+one[i].S]=min(dp1[j+one[i].S],dp1[j]+one[i].F);
				if(j+one[i].S*2>=100010) t=min(t,dp1[j+one[i].S]);
			}
		}
		int M=INF;
		for(int i=100009;i>=0;i--){
			dp1[i]=min(dp1[i],M);
			M=min(dp1[i],M);
		}
		dp2[0]=0;
		rep(i,all.size()){
			int t=INF;
			rep(j,100010){
				if(j+all[i].S>=100010){
					if(j==0){
						t=0;
					}
					dp2[100009]=min(dp2[100009],t+all[i].F);
					break;
				}
				if(dp2[j]==INF) continue;
				dp2[j+all[i].S]=min(dp2[j+all[i].S],dp2[j]+all[i].F);
				if(j+all[i].S*2>=100010) t=min(t,dp2[j+all[i].S]);
			}
		}
		M=INF;
		for(int i=100009;i>=0;i--){
			dp2[i]=min(dp2[i],M);
			M=min(dp2[i],M);
		}
		int ans=INF;
		rep(i,100010){
			int tmp=dp2[i];
			rep(j,n){
				if(hp[j]<=i) continue;
				tmp+=dp1[hp[j]-i];
			}
			ans=min(ans,tmp);
		}
		printf("%d\n",ans);
	}

}

}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 2040
<?php
fscanf(STDIN, '%d', $N);
$X = array_map('intval', explode(' ', trim(fgets(STDIN))));
$min = min($X);
$max = max($X);
$ans = PHP_INT_MAX;
for ($i = $min; $i <= $max; $i++) {
    $diff = array_sum(array_map(function($t) use($i) { return ($t - $i) * ($t - $i); }, $X));
    $ans = min($ans, $diff);
}
echo $ans;


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 100000;
constexpr ll H_I_MAX = 1000000000;

ll N;
ll H[N_MAX];

void input() {
	scanf("%lld", &N);
	rep(i, N) scanf("%lld", H + i);
}

void solve() {
	ll ans = 0;
	ll t=H[0];
	ll count=0;
	for(ll i=1;i<N;i++){
		debug(t);
		debug(H[i]);
		if(H[i]<=t){
			debug(1);
			count++;
		}else{
			debug(2);
			chmax(ans,count);
			count=0;
		}
		t=H[i];
	}
	chmax(ans,count);
	printf("%lld\n", ans);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 1024
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

m = inp()
d = [0] * m
c = [0] * m
res = 0
for i in range(m):
    d[i], c[i] = inpl()
    res += d[i]*c[i]
tmp = 0
if res % 9 == 0:
    tmp -= 1
print(res//9+tmp+sum(c)-1)



Measured memory_bytes: 70104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

int A, B;

int main(void) {

	cin >> A >> B;

	for (int i = 0; i <= 999999; i++) {
		int a = (int)(0.08*i);
		int b = (int)(0.10*i);
		if (a == A && b == B) { cout << i << endl; return 0; }
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define int long long

using namespace std;

int N;
int f[10101];

signed main()
{
    cin >> N;

    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            for (int z = 1; z <= 100; z++)
            {
                if (x * x + y * y + z * z + x * y + y * z + z * x <= N)
                {

                    f[x * x + y * y + z * z + x * y + y * z + z * x]++;
                }
            }
        }
    }

    for (int i = 1; i <= N; i++)
    {
        cout << f[i] << endl;
    }
}

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

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (2 < ans)
            {
                break;
            }

            if (p[i] != i + 1)
            {
                ans++;
            }
        }

        if (ans <= 2)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}


Measured memory_bytes: 13140