akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n); for(long long i = 0;i < (n);i++)
typedef long long ll;
typedef vector<long long> vl;

ll can2(ll x){
	if(x%2 == 1)return 1;
	else return 1 + can2(x/2);
}
ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
int main(){
	ll n,m; cin >> n >> m;
	vl a(n); rep(i,n)cin >> a[i];
	vl a_(n); rep(i,n)a_[i] = a[i]/2;
	bool r = false;
	vl a2(n); rep(i,n)a2[i] = can2(a_[i]);
	rep(i,n-1){
		if(a2[i] != a2[i+1]){
			r = true;
			break;
		}
	}
	if(r)cout << 0 << endl;
	else{
		ll x = 1
		rep(i,n){
			x = lcm(x,a_[i]);
			if(x > m){
				cout << 0 << endl;
				break;
			}
		}
		if(x <= m){
			ll y = m/x;
			cout << (y+1)/2 << endl;
		}
	}
}


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

using namespace std;

typedef pair<double, double> pii;
#define rep(i, n) REP(i, 0, (n))
#define REP(i, a, n) for(int i=(a); i<(n); i++)

struct Vec2D {
    double x, y;
    Vec2D() : x(0.0), y(0.0) {}
    Vec2D(double x, double y) : x(x), y(y) {}
    Vec2D operator=(const Vec2D& v) { x=v.x; y=v.y; return *this; }
    Vec2D operator-() { return Vec2D(-x, -y); }
    Vec2D operator+(const Vec2D& v) { return Vec2D(x+v.x, y+v.y); }
    Vec2D operator-(const Vec2D& v) { return Vec2D(x-v.x, y-v.y); }
    double operator*(const Vec2D& v) { return x*v.x + y*v.y; }
    Vec2D operator*(double k) { return Vec2D(x*k, y*k); }
    Vec2D operator/(double k) { return Vec2D(x/k, y/k); }
    double norm() { return sqrt(x*x + y*y); }
    Vec2D normalize() { return Vec2D(x, y)/norm(); }
    Vec2D normal() { return Vec2D(y, -x).normalize(); }
};
ostream& operator<<(ostream& os, const Vec2D& v) {
    os << "Vec2D [ x: " << v.x << ", y: " << v.y << " ]";
    return os;
}
istream& operator>>(std::istream& is, Vec2D& v) {
    is >> v.x >> v.y;
    return is;
}

int N;
Vec2D ps[300];

int main() {
    while(cin>>N, N) {
        rep(i, N) cin >> ps[i];
        
        int ans = 1;
        rep(i, N-1) {
            REP(j, i+1, N) {
                Vec2D d = ps[i]-ps[j];
                if(d.norm() > 2.0001) continue;
                double x = sqrt(1 - pow(d.norm()/2.0, 2));
                Vec2D n = d.normal(), m = (ps[i]+ps[j])/2.0;
                Vec2D o;
                int cnt_p = 0;
                o = m + (n*x);
                rep(k, N) if((ps[k]-o).norm()<1.0001) cnt_p++;
                int cnt_n = 0;
                o = m - (n*x);
                rep(k, N) if((ps[k]-o).norm()<1.0001) cnt_n++;
                ans = max(ans, max(cnt_p, cnt_n));
            }
        }
        cout << ans << endl;
    }
}




Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#define rep(i,n) for(int i=1; i<n; i++)
using namespace std;
int main(void){
  unsigned int a, b, k;cin>>a>>b>>k;
  int cnt=0,ans[101]={0},len=0;
  rep(i,101){
    if(a%i==0 && b%i==0)
      ans[len++]=i;
    else
      continue;
  }
  sort(ans,ans+101,greater<int>());
  cout<<ans[k-1];
  return 0;
}

Measured memory_bytes: 256
def dot(a,b):
    return a.real*b.real+a.imag*b.imag

x1, y1, x2, y2 = map(int, input().split())
p1=x1+y1*1j
p2=x2+y2*1j
l=p2-p1
l_norm=dot(l,l)         #lの大きさの２乗を計算
q=int(input())

for x3, y3 in (map(int, input().split()) for _ in [0]*q):
    p3=x3+y3*1j
    a=p3-p1
    k=dot(a,l)/l_norm
    projection_vector=k*l
    print(x1+projection_vector.real,y1+projection_vector.imag)


Measured memory_bytes: 5644
import math
x = int(input())

#sqrt = math.sqrt(x)
#floor = math.floor(sqrt)
#print(floor ** 2)

if x == 1:
    print(1)
else:
    array = []
    for b in range(1, x // 2):
        previous = 1
        for p in range(2, x // 2):
            if b ** p > x:
                break
            else:
                previous = b ** p
        array.append(previous)
    array.sort(reverse=True)
    print(array[0])
    


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

#include <iostream>
#include <iomanip>
#include <cmath>
 
using namespace std;
 
int main(){
    int m, n;
    while(cin>>n>>m && m|n){
        vi p(n);
        int free = 0;
        int sum = 0;
        rep(i,n){
            cin >> p[i];
            sum += p[i];
        }
        sort(all(p));
        // テ」ツ??」ツ?暗」ツ?凝」ツつ?
        for(int i=n-m;i>=0;i-=m)free+=p[i];
        cout << sum - free << endl;
    }
}

Measured memory_bytes: 1212
// Fub0ki
// (づ°ω°)づﾐ★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
#include <bits/stdc++.h>
#include <unordered_map>
using namespace std;
typedef long long             ll;
typedef vector<int>           vi;
typedef vector<ll>            vll;
typedef pair<int, int>        ii;
typedef pair<int, ii>         iii;
typedef vector<ii>            vii;
typedef set<int>              si;
typedef map<string, int>      msi;
typedef map<string, string>   mss;
#define clr(x,v) memset(x,v,sizeof(x))
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define bn begin()
#define nd end()
#define X first
#define Y second
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define NumofDigits(n) ((int)log10(n)+1)
#define sc1(x)  scanf("%d",&x)
#define sc2(x,y)  scanf("%d%d",&x,&y)
#define sc3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define sz(v) (int)(v.size())
#define rep(i,v) for (int i = 0; i < sz(v); i++)
#define lp(i, a, b) for (int i = int(a); i < int(b); i++)
#define lpi(i, b, a) for (int i = int(b); i >= a; i--)
#define watch(x) cout << (#x) << " is " << (x) << endl
#define EPS 1e-9
#define MAX 1000005
#define INF 1e18
#define print_prec(ans,num) cout << fixed << setprecision(num) << (ans) << endl
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL)
const int dx[] = { 1,-1,0,0,0,0 };
const int dy[] = { 0,0,1,-1,0,0 };
const int dz[] = { 0,0,0,0,1,-1 };
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistic*/
/*max_element(all(m),
    [](const ii& p1, const ii& p2) {
        return p1.second < p2.second; });*/
int ant[5];
int k;
int main()
{
    //freopen("read.txt", "r", stdin);
    //freopen("write.txt", "w", stdout);
    IO;
    lp(i,0,5) cin >> ant[i];
    cin >> k;
    lp(i,0,5)
    {
        lp(j,i+1,5)
        {
            if (abs(ant[i] - ant[j]) > k)
            {
                std::cout << ":(" << "\n"; return 0;
            }
        }
    }
    std::cout << "Yay!" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,ans=100,count,tmp;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>tmp;
        for(count=0;tmp%2==0&&tmp!=0;count++)tmp/=2;
        ans=min(ans,count);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <algorithm> //no rotate
#include <vector>

using namespace std;

void judge(int n, int k, int m){
	vector<int> vec(n);
	int i=0;
	for(;i<n;i++)vec[i]=i+1;
  i=(m-1)%vec.size();
	vec.erase(vec.begin()+i);
	while(vec.size()>1){
    i+=(k-1)%vec.size();
    if(i>=vec.size())i-=vec.size();
		vec.erase(vec.begin()+i);
	}
	cout << vec.at(0) << endl;
}

int main(){
	int n,k,m;
	while(true){
		cin >> n >> k >> m;
		if(!n&&!k&&!m)break;
		judge(n,k,m);
	}
	return 0;
}

Measured memory_bytes: 1252
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1e9;

int main() {
	ll a[3];
	for(int i = 0; i < 3; i++) cin >> a[i];
	int ans = INF;
	ll sum = a[0] + a[1] + a[2];
	for(int i = 0; i < 3; i++) {
		debug("---\n");
		int cnt = 0;
		while(1) {
			if(a[i] % 2 == 1) {
				ans = min(ans, cnt);
				break;
			}
			set<ll> S;
			S.insert(a[i]);
			a[i] = (sum - a[i]) / 2;
			cnt++;
			debug(" %lld (%d)\n", a[i], cnt);
			if(S.count(a[i]) == 1) break;
		}
	}
	if(ans == INF) ans = -1;
	cout << ans << endl;
	return 0;
}


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

vector<pair<long long, long long> >vec;
long long memo[1000000];
long long N, K;
string S;

int main(){
	cin >> N >> K;
	cin >> S;

	char ch =  '-';
	long long num = 0;
	for(long long i = 0; i < S.size(); i++){
		if(i == 0){
			ch = S[i];
			num = 1;
		}else{
			if(ch == S[i]){
				num++;
			} else {
				vec.push_back(make_pair(num, ch-'0'));
				ch = S[i];
				num = 1;
			}
		}
	}
	vec.push_back(make_pair(num, ch-'0'));

	for(long long i = 0; i < vec.size(); i++){
		memo[i+1] = memo[i] + vec[i].first;
	}

	long long zerocount = 0;
	for(long long i = 0; i < vec.size(); i++){
		if(vec[i].second == 0){
			zerocount++;
		}
	}
	if(zerocount <= K){
		cout << memo[vec.size()] << endl;
		return 0;
	}

	long long left = 0;
	long long right = 0;
	long long skip = 0;
	long long ans = -1;
	while(true){
		if(skip < K){
			if(vec[right].second == 0){
				skip++;
			}
			right++;
		}
		ans = max(ans, memo[right] - memo[left]);

		if(skip ==  K && vec[right].second == 1){
			right++;
		}
		ans = max(ans, memo[right] - memo[left]);

		if(skip == K){
			if(vec[left].second == 0){
				skip--;
			}
			left++;
		}
		ans = max(ans, memo[right] - memo[left]);

		if(right == vec.size() + 1){
			cout << ans << endl;
			return 0;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2928
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=205;

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

int x,y,m,s,t;
int iter[maxn];
int level[maxn];
bool built[maxn];
vector<edge>G[maxn];

void add_edge(int u,int v,int c) {
	G[u].pb(edge{v,c,int(G[v].size())});
	G[v].pb(edge{u,0,int(G[u].size()-1)});
}

bool bfs() {
	memset(level,0,sizeof(level));
	level[s]=1;
	int qh=0,qt=0,q[maxn];
	q[qt++]=s;
	while (qh!=qt) {
		int u=q[qh++];
		for (edge e:G[u]) {
			if (!level[e.to] && e.cap) {
				level[e.to]=level[u]+1;
				if (level[t]) break;
				q[qt++]=e.to;
			}
		}
		if (level[t]) break;
	}
	return level[t];
}

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

int dinic() {
	int res=0;
	while (bfs()) {
		memset(iter,0,sizeof(iter));
		while (int flow=dfs(s,INF))
			res+=flow;
	}
	return res;
}

int main() {
	cin>>x>>y>>m; s=0; t=x+y+1;
	for (int i=0;i<m;i++) {
		int u,v; cin>>u>>v;
		u++; v+=1+x;
		add_edge(u,v,1);
		if (!built[u]) {
			built[u]=1;
			add_edge(s,u,1);
		}
		if (!built[v]) {
			built[v]=1;
			add_edge(v,t,1);
		}
	}
	cout<<dinic()<<'\n';
}




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

using namespace std;
 
typedef long long ll;
 
const ll mod = 1e9+7; 

int main()
{
    string s;
    cin>>s;
    int ans=0;
    if(s=="RRS"||s=="SRR"){
        ans=2;
    }
    else if(s=="RSR"||s=="SRS"||s=="SSR"||s=="RSS"){
        ans=1;
    }
    else if(s=="SSS"){
        ans=0;
    }
    else if(s=="RRR"){
        ans=3;
    }
    cout<<ans;
}
 

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
  long long a,b,x;
  cin >> a >> b >> x;
  long long ans = b/x - max((long long)0,a-1) / x;
  if(a == 0 ) ans++;
  cout <<  ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

void solvetask(){
    int sum=0;
    string s; cin >> s;
    for (int i=0; i<s.size(); i++) sum += s[i]-'0';
    cout << (sum % 9 == 0 ? "Yes\n" : "No\n");
}
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1; //cin >> t;
    while(t--) solvetask();
}

Measured memory_bytes: 3724
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

int main(int argc, const char *argv[])
{
    int n;
    cin >> n;

    vector<int> v(n);
    for (int i = 0; i < n; i++)
    {
        v[i] = i + 1;
    }

    string a, b, c;
    for (int i = 0; i < n; i++)
    {
        cin >> c;
        a += c;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> c;
        b += c;
    }

    string s;
    int x, y, i = 0;
    do
    {
        for (int j = 0; j < n; j++)
        {
            s += to_string(v[j]);
        }

        if (s == a)
        {
            x = i + 1;
        }
        if (s == b)
        {
            y = i + 1;
        }

        s.clear();
        i++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(x - y) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n,i,j,k,l;
    int dice[24][6];
    int label[24][6]={{1,2,3,4,5,6},{1,3,5,2,4,6},{1,4,2,5,3,6},{1,5,4,3,2,6},{2,1,4,3,6,5},{2,3,1,6,4,5},
    {2,4,6,1,3,5},{2,6,3,4,1,5},{3,1,2,5,6,4},{3,2,6,1,5,4},{3,5,1,6,2,4},{3,6,5,2,1,4},{4,1,5,2,6,3},
    {4,2,1,6,5,3},{4,5,6,1,2,3},{4,6,2,5,1,3},{5,1,3,4,6,2},{5,3,6,1,4,2},{5,4,1,6,3,2},{5,6,4,3,1,2},
    {6,2,4,3,5,1},{6,3,2,5,4,1},{6,4,5,2,3,1},{6,5,3,4,2,1}};
      
    scanf("%d",&n);
    int dices[n][6];
      
    for(i=0;i<n;i++){
        for(j=0;j<6;j++) scanf("%d",&dices[i][j]);
    }
      
    for(i=0;i<n-1;i++){
        for(j=i+1;j<n;j++){
              
            for(k=0;k<24;k++){
                for(l=0;l<6;l++) dice[k][l]=dices[j][label[k][l]-1];
            }
              
            for(k=0;k<24;k++){
                for(l=0;l<6;l++) {
                    if(dice[k][l]!=dices[i][l]) {
                        break;
                    }
                }
                if(l==6){
                    printf("No\n");
                    return 0;
                }
            }
        }
    }
      
    printf("Yes\n");
    return 0;
}


Measured memory_bytes: 2148
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();
    int c = sc.nextInt();
    if((a==7&&b==5&&c==5)||(a==5&&b==7&&c==5)||(a==5&&b==5&&c==7)){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  int n;
  cin>>n;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }
  reverse(all(a));

  vi b(n);
  int ans=0;

  FOR(i,1,n){
    if(a[i]>=a[i-1]) b[i]+=b[i-1]+1;
    ans=max(ans,b[i]);
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 1792
def popularVote():
    n, m = list(map(int, input().split()))
    item_votes = list(map(int, input().split()))
    total = sum(item_votes)

    selected = []
    isSelected = False

    req = 1 / (4 * m)
    for item in item_votes:
        if item / total >= req:
            selected.append(item)

        if len(selected) == m:
            isSelected = True
            print("Yes")
            break

    if not isSelected:
        print("No")


popularVote()

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

int main() {
	int result = 0, N = 0;
	cin >> N;
	vector<int> d(N, 0);

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

	sort(d.begin(), d.end());
	int K_min = (N / 2) - 1;

	for(int i = d[K_min]; i < d[K_min+1]; i++) {
		result += 1;
	}

 	cout << result << endl;
	return 0;
}


Measured memory_bytes: 640
package main

import (
	"fmt"
)

func main() {
	var L, R int

	fmt.Scan(&L, &R)

	if L+2019 < R {
		R = L + 2019
	}

	min := 2019
	for x := L; x <= R-1; x++ {
		for y := x + 1; y <= R; y++ {
			m := (x * y) % 2019
			if min > m {
				min = m
			}

		}
	}

	fmt.Println(min)
}


Measured memory_bytes: 512
S=gets.chomp.bytes
n=S.size
L=[nil]*(n+3)
l=[n]*26
(n-1).downto(0){|i|
	L[i]=l.dup
	l[S[i]-97]=i
}
L[-1]=l
q=[-1]
z={-1=>[nil,0]}
while !q.empty?&&q[0]!=n
	v=q.shift
	l=L[v]
	26.times{|c|
		if !z[l[c]]
			z[l[c]]=[v,c]
			q<<l[c]
		end
	}
end
r=''
while n
	n,c=z[n]
	r<<(c+97)
end
$><<r.reverse[1..-1]

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

int main(){
  string s1,s2,s3;
  cin >> s1 >> s2;
  int n,k;
  cin >> n >> k;
  cin >> s3;
  if (s1==s3) n--;
  else k--;
  cout << n <<" "<< k << endl;
  
    
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define m 1000000007
#define MAXN 1000001
#define satya ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cil(a,b) (((a-1)/b)+1)
//#define init int t;cin>>t;while(t--)
#define in(a) ll a;scanf("%lld",&a)
#define ine(a,b) ll a,b;scanf("%lld lld",&a,&b)



ll spf[MAXN]; 

void sieve1() 
{ 
	spf[1] = 1; 
	for (int i=2; i<MAXN; i++) 

		spf[i] = i; 

	for (int i=4; i<MAXN; i+=2) 
		spf[i] = 2; 

	for (int i=3; i*i<MAXN; i++) 
	{ 
		if (spf[i] == i) 
		{ 
			for (int j=i*i; j<MAXN; j+=i) 

				if (spf[j]==j) 
					spf[j] = i; 
		} 
	} 
} 

ll  getFactorization(int x) 
{ 
	vector<int> ret; 
	long long int p=0;
	while (x != 1) 
	{ 
		ret.push_back(spf[x]); 
		x = x / spf[x]; 
	} 
	sort(ret.begin(),ret.end());
	for(int i=0;i<ret.size()-1;i++) 
	{
	    if(ret[i]!=ret[i+1])
	    p=p+ret[i];
	}
	p=p+ret[ret.size()-1];
	return p;
} 

ll d[1000055],u=0;
void Sieve(int n) 
{ 
	bool prime[n+1]; 
//	ll u=0;
	memset(prime, true, sizeof(prime)); 

	for (int p=2; p*p<=n; p++) 
	{ 
		if (prime[p] == true) 
		{ 
			for (int i=p*2; i<=n; i += p) 
				prime[i] = false; 
		} 
	} 

	for (int p=2; p<=n; p++) 
	if (prime[p]) 
	{
	    d[u]=p;
	    u++;
	}
} 

ll minverse(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return minverse((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*minverse((x*x)%M,(n-1)/2,M))%M;

}
ll prime(ll n){
    ll i;
    if(n==1||n==0)
    return 0;
    for(i=2;i<sqrt(n);i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}
int main() {
       satya;
     //sieve1(); 
     //Sieve(100);
     ll n;
     cin>>n;
     long double a[n],sum=0,p;
     vector<long double>v;
     for(int i=0;i<n;i++){
     cin>>a[i];
            //   cout<<sum<<endl;
     v.push_back(a[i]);
     }
     sort(a,a+n);
     for(int i=0;i<n-1;i++)
     {
         sort(v.begin(),v.end());
         p=(v[0]+v[1])/2;
         v.erase(v.begin(),v.begin()+2);
         v.push_back(p);
     }
    //  cout<<sum<<endl;
     cout<<fixed<<setprecision(8)<<v[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
def productall(a):
    N = len(a)
    if N == 0: return [1]
    A = [1] * N + a[:]
    P = 10 ** 9 + 7
    k = 12
    K = k * 8
    pa1 = (1 << k * 4 + 16) - ((1 << k * 4 + 16) % P)
    pa2 = (1 << k * 2 + 24) - ((1 << k * 2 + 24) % P)
    pa3 = (1 << k + 28) - ((1 << k + 28) % P)
    m1 = int(("1" * (k * 4 - 16) + "0" * (k * 4 + 16)) * 5050, 2)
    m2 = int(("1" * (k * 6 - 24) + "0" * (k * 2 + 24)) * 5050, 2)
    m3 = int(("1" * (k * 7 - 28) + "0" * (k + 28)) * 5050, 2)
    def modP(x):
        x -= ((x & m1) >> k * 4 + 16) * pa1
        x -= ((x & m2) >> k * 2 + 24) * pa2
        x -= ((x & m3) >> k + 28) * pa3
        return x

    for i in range(N)[::-1]:
        A[i] = modP(A[2*i] * A[2*i+1])

    t = bin(A[1])[2:] + "_"
    return [int(t[-(i+1) * K - 1:-i * K - 1], 2) % P for i in range((len(t)+K-2) // K)]
def par(a):
    L = []
    while P[a] != a:
        L.append(a)
        a = P[a]
    for l in L:
        P[l] = a
    return a
def unite(a, b):
    pa = par(a)
    pb = par(b)
    if pa == pb: return
    if LEN[pa] < LEN[pb]:
        a, b, pa, pb = b, a, pb, pa
    P[pb] = pa
    if LEN[pa] == LEN[pb]: LEN[pa] += 1
    CNT[pa] += CNT[pb]
def cnt(a):
    return CNT[par(a)]

N = int(input())
P = [i for i in range(N)]
LEN = [1] * N
CNT = [1] * N
FULL = [0] * N
A = [int(a) - 1 for a in input().split()]
for i, a in enumerate(A):
    if a < 0: continue
    if par(i) != par(a):
        unite(i, a)
    else:
        FULL[i] = 1
for i in range(N):
    if FULL[i]:
        FULL[par(i)] = 1
X = []
Y = []
for i in range(N):
    if par(i) == i:
        if FULL[i] == 0:
            X.append(CNT[i])
        else:
            Y.append(CNT[i])
M = len(X)
mod = 10 ** 9 + 7
ans = (sum(X) + sum(Y) - len(Y)) * pow(N - 1, M, mod) % mod
L = productall([(a << 96) + 1 for a in X])
fa = 1
if M: ans = (ans + M * pow(N - 1, M - 1, mod)) % mod
for i, l in enumerate(L):
    if i == 0: continue
    ans = (ans - l * fa * pow(N - 1, M - i + mod - 1, mod)) % mod
    fa = fa * i % mod
print(ans)

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

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    os << "{";
    for (int i = 0; i < (int)vec.size(); ++i) {
        os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
void dump_func() {
    cerr << "\n";
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&&... tail) {
    cerr << head;
    if (sizeof...(Tail) == 0) {
        cerr << " ";
    } else {
        cerr << ", ";
    }
    dump_func(std::move(tail)...);
}
#define dump(...) cerr << "[" << to_string(__LINE__) << "]"        \
                       << "    " << string(#__VA_ARGS__) << " = ", \
                  dump_func(__VA_ARGS__)

using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<double>;
using VVI = vector<VI>;
using VVL = vector<VL>;
using PI = pair<int, int>;
using PL = pair<ll, ll>;
using VPI = vector<PI>;
using VPL = vector<PL>;
using VS = vector<string>;

#define ln '\n'
#define REP(t, n) for (int t = 0; t < (n); ++t)
#define FOR(t, a, b) for (int t = (a); t <= (b); ++t)
#define FORR(t, a, b) for (int t = (a); t >= (b); --t)
#define ALL(c) (c).begin(), (c).end()
#define CAUTO const auto&

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

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll numc, numd, numcd;
    numc = b / c - (a - 1) / c;
    numd = b / d - (a - 1) / d;
    ll cd = lcm(c, d);
    numcd = b / cd - (a - 1) / cd;
    cout << b - a + 1 - (numc + numd - numcd) << ln;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

int main()
{
	int N;

	cin >> N;

	int x = func(N);

	if(N%x == 0)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import numpy as np

D = int(input())
c = np.array( list(map(int, input().split())) )
s = [[] for i in range(365+1)]
for i in range(D):
  s[i] = list(map(int, input().split()))
#
last = np.array( [-1]*26 )

v = 0
for d in range(D):
  t =  int(input())
  t -= 1
  last[t] = d
  v += s[d][t]
  v -= sum( (d-last)*c )
  print(v)
#


Measured memory_bytes: 27636
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

string a;
string b;

bool judge(lli i){
    for(lli j = 0,k = i;j < b.size();j++,k++){
        if(k >= a.size()) return false;
        if(a[k] != b[j]) return false;
    }
    return true;
}

int main(){
    cin >> a >> b;
    for(lli i = 0;i < a.size();i++){
        if(judge(i)) cout << i << endl;
    }
    return 0;

}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define pw(x) (1LL << (x))
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl

using namespace std;
typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;
const int MOD = (int)1e9 + 7;

void add(int &x, ll y) {
    x = (x + y) % MOD;
}

int bin(int a, ll n) {
    int res = 1;
    while (n) {
        if (n & 1) res = 1LL * res * a % MOD;
        a = 1LL * a * a % MOD;
        n >>= 1;
    }
    return res;
}

int inv(int x) {
    return bin(x, MOD - 2);
}

int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int n;
    while (cin >> n) {
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];

        a.insert(a.begin(), 1);
        a.push_back(0);
        n += 2;

        vector<int> dp(n);
        dp[0] = 1;
        for (int i = 0; i < n - 1; i++) {
            add(dp[i + 1], dp[i]);
            if (i + 1 < n - 1) add(dp[i + 1], dp[i]);
            if (a[i + 1] > a[i]) {
                int mn = a[i + 1];
                for (int j = i + 2; j < n; j++) {
                    if (a[j] < mn) {
                        int y = max(a[i], a[j]);

                        ll sum = 0;
                        //sum += a[i + 1] - y;
                        for (int k = i + 1; k < j; k++) {
                            sum += max(0, a[k] - max(a[k - 1], mn - 1));
                        }

                        //int N = mn - y;
                        //int K = j - i - 1;
                        //cout << N << " " << K << endl;
                        //int cur = 2LL * bin(2, sum) * (bin(2, 1LL * K * N) - 1 + MOD) % MOD * inv(bin(2, K) - 1 + MOD) % MOD;
                        int N = mn - y;
                        int K = 1;
                        int cur = 1LL * bin(2, sum) * (bin(2, N) - 1 + MOD) % MOD;
                        cur = 1LL * cur * dp[i] % MOD;
                        add(dp[j], cur);
                        if (j < n - 1) add(dp[j], cur);

                        mn = a[j];
                        if (mn <= a[i]) break;
                    }
                }
            }
        }
        cout << dp[n - 1] << endl;
    }


#ifdef HOME
    cerr << "time = " << (clock() * 1. / CLOCKS_PER_SEC) << "\n";
#endif
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    print('x'*len(S))


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    array<int, 4> orders;
    orders.fill(0);
    rep(i, 0, 3)
    {
        int a, b;
        cin >> a >> b;
        --a; --b;
        ++orders[a];
        ++orders[b];
    }
    int oddNum = 0;
    for (const int order : orders)
    {
        if (order % 2 == 1)
        {
            ++oddNum;
        }
    }
    cout << (oddNum == 2 ? "YES" : "NO") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int x; cin >> x ;
  Yes(x>=30);

  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  int n, alice = 0, bob = 0;
  cin >> n;
  vector<int> v(n);
  rep(i, n)cin >> v[i];
  sort(All(v), greater<int>());
  for(int i = 0; i < n; i++){
    if(i % 2 == 0){
      alice += v[i];
    }else bob += v[i];
  }
  cout << alice - bob << endl;
  system("pause");
}


Measured memory_bytes: 504
sx,sy,tx,ty=map(int,input().split())

print('U'*(ty-sy)+'R'*(tx-sx)+'D'*(ty-sy)+'L'*(tx-sx)+'LU'+'U'*(ty-sy)+'R'*(tx-sx)+'RDRD'+'D'*(ty-sy)+'L'*(tx-sx)+'LU')

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

// region template
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

ll gcd(ll a, ll b) { return __gcd(a, b); }

ll euclid(ll a, ll b, ll &x, ll &y) {
    if (b) { ll d = euclid(b, a % b, y, x);
        return y -= a/b * x, d; }
    return x = 1, y = 0, a;
}

typedef unsigned long long ull;
typedef long double ld;
ull mod_mul(ull a, ull b, ull M) {
    ll ret = a * b - M * ull(ld(a) * ld(b) / ld(M));
    return ret + M * (ret < 0) - M * (ret >= (ll)M);
}
ull mod_pow(ull b, ull e, ull mod) {
    ull ans = 1;
    for (; e; b = mod_mul(b, b, mod), e /= 2)
        if (e & 1) ans = mod_mul(ans, b, mod);
    return ans;
}

const ll mod = 1000000007;
struct Mod {
    ll x;
    Mod(ll xx) : x(xx) {}
    Mod operator+(Mod b) { return Mod((x + b.x) % mod); }
    Mod operator-(Mod b) { return Mod((x - b.x) % mod); }
    Mod operator*(Mod b) { return Mod((x * b.x) % mod); }
    Mod operator/(Mod b) { return *this * invert(b); }
    Mod invert(Mod a) {
        ll x, y, g = euclid(a.x, mod, x, y);
        assert(g == 1); return Mod((x + mod) % mod);
    }
    Mod operator^(ll e) {
        if (!e) return Mod(1);
        Mod r = *this ^ (e / 2); r = r * r;
        return e & 1 ? *this * r : r;
    }
};
// endregion

int main() {
    cin.sync_with_stdio(0); cin.tie(0); cin.exceptions(cin.failbit);

    while (1) {
        int n, m; cin >> n >> m;
        if (!n) break;

        vector<pair<int, int>> a(n), b(m);
        int suma = 0, sumb = 0;
        rep(i, 0, n) cin >> a[i].first, suma += a[i].first, a[i].second = i + 1;
        rep(i, 0, m) cin >> b[i].first, sumb += b[i].first, b[i].second = n + i + 1;
        sort(all(a)); sort(all(b));

        int best1 = -1, best2 = -1;
        rep(i, 0, n) rep(j, 0, m) if (suma - a[i].first + b[j].first == sumb - b[j].first + a[i].first) {
            if (best1 == -1) best1 = i, best2 = j;
            else if (a[i].first + b[j].first < a[best1].first + b[best2].first) best1 = i, best2 = j;
        }
        if (best1 == -1) cout << -1 << endl;
        else cout << a[best1].first << " " << b[best2].first << endl;
    }
}


Measured memory_bytes: 3120
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;
#define ll long long

int main(){
    string S;
    ll N, A,B;
    ll a,b;
    ll ans = 0;
    cin >> N >> A >> B;
    cout << min(A*N,B) << endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

X = int(input())
for a in range(10**3):
    for b in range(10**3):
        aa = a ** 5
        bb = b ** 5
        if aa - bb == X:
            print(a, b)
            sys.exit()
        if aa + bb == X:
            print(a, -b)
            sys.exit()
        if -aa - bb == X:
            print(-a, b)
            sys.exit()
        if -aa + bb == X:
            print(-a, -b)
            sys.exit()

    

Measured memory_bytes: 27076
count = [[[0 for i in range(11)] for j in range(4)] for k in range(5)]

N = int(input())

for i in range(N):
    b,f,r,v = map(int, input().split())
    count[b][f][r] += v

for i in range(1, 5):
    for j in range(1, 4):
        for k in range(1, 11):
            print(" ",end="")
            print(count[i][j][k],end="")
        print()
    if i != 4:
        print("#"*20)


Measured memory_bytes: 5636
a, b, c, x, y = gets.split.map(&:to_i)
i, j, k = [0, 0, 0]
if c * 2 < a
  k = x * 2
  if c * 2 > b
    j = [y - k / 2, 0].max
  else
    k = [x, y].max * 2
  end
elsif c * 2 < b
  k = y * 2
  if c * 2 > a
    i = [x - k / 2, 0].max
  else
    k = [x, y].max * 2
  end
elsif c * 2 < a + b
  k = [x, y].min * 2
  if x > y
    i = x - k / 2
  else
    j = y - k / 2
  end
else
  i = x
  j = y
end
p i * a + j * b + k * c

Measured memory_bytes: 3836
use std::cmp;

#[allow(dead_code)]
pub struct Scanner<'a> {
    _buf: &'a str,
    iter: ::std::str::SplitWhitespace<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    pub fn new(buf: &'a str) -> Self {
        Scanner {
            _buf: buf,
            iter: buf.split_whitespace(),
        }
    }

    pub fn array<T>(&mut self, n: usize) -> Vec<T>
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        let mut res = Vec::with_capacity(n);
        for _ in 0..n {
            res.push(self.value());
        }
        res
    }

    pub fn value<T>(&mut self) -> T
        where T: ::std::str::FromStr,
              T::Err: ::std::fmt::Debug,
    {
        self.next().parse().unwrap()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.next().chars().collect()
    }

    fn next(&mut self) -> &str {
        self.iter.next().unwrap()
    }
}

fn dist(x1: i64, y1: i64, x2: i64, y2: i64) -> i64 {
    (x1-x2).abs() + (y1-y2).abs()
}

fn main() {
    let mut _input = String::new();
    {
        use ::std::io::Read;
        ::std::io::stdin().read_to_string(&mut _input).unwrap();
    }
    let mut sc = Scanner::new(&_input);

    let n = sc.value::<i64>();
    let mut xs = Vec::with_capacity(n as usize);
    let mut ys = Vec::with_capacity(n as usize);
    let mut hs = Vec::with_capacity(n as usize);
    for _ in 0..n {
        xs.push(sc.value::<i64>());
        ys.push(sc.value::<i64>());
        hs.push(sc.value::<i64>());
    }

    for x in 0..101 {
        'outer:
        for y in 0..101 {
            let mut h    = None;
            let mut hmax = 10_i64.pow(18);
            for i in 0..n {
                let d = dist(x, y, xs[i as usize], ys[i as usize]);
                if hs[i as usize] == 0 {
                    hmax = cmp::min(hmax, d);
                }
                else {
                    let h_cur = hs[i as usize] + d;
                    match h {
                        Some(h) => {
                            if h_cur != h { continue 'outer; }
                        },
                        None => {
                            h = Some(h_cur);
                        }
                    }
                }
            }
            if h.is_none() { continue; }
            if h.unwrap() > hmax { continue; }
            println!("{} {} {}", x, y, h.unwrap());
            return;
        }
    }

    panic!();
}


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

int main() {
  int N , K, A = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
  	int x;
    cin >> x;
    
    if (x*2 <= 2*(K-x)){
    	A += x*2;
    }
    else{
    	A += 2*(K-x);
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int color[100];
	int ans = 0;
	fill(color,color+100,0);
	for(int i=0;i<3;i++){
		int a;
		scanf("%d",&a);
		color[a-1]++;
	}
	for(int i=0;i<100;i++) if(color[i]>0) ans++;
	printf("%d\n",ans);
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  string s;
  cin >> s;
  string c = "CODEFESTIVAL2016";
  int sum = 0;
  rep(i,0,s.size()){
    if(s[i] != c[i])
      sum++;
  }
  P(sum); 
  ret 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main(void) {
    
    int n; cin >> n;
    int a[n+1];
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        if (i == a[a[i]]) ++ans;
    }
    out(ans / 2);

    
    return 0;
}






Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
int w,h,x,y,r;
cin >> w >> h >> x >> y >> r;
bool flag;
flag = ((x - r)>=0)&&((x+r)<=w)&&((y-r)>=0)&&((y+r)<=h);
string s = flag?"Yes":"No";
cout << s<<endl;
return 0;
 }


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,i,check;
  check=0;
  cin>>N;
  int P[N];
  int Q[N];
  for(i=0;i<N;i++){
  cin>>P[i];
    Q[i]=P[i];
  }
  sort(Q,Q+N);
  for(i=0;i<N;i++){
  if(P[i]!=Q[i]) check++;
  }
  if(check<3){
  cout<<"YES"<<endl;

  }else{
  cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		long ans = 0;
		ans += N;
		
		long a = N - X;
		long b = X;
		if(a < b) {
			long t = a; a = b; b = t;
		}
		while(b!=0){
			ans += (a/b) * 2 * b;
			long t = b; b = a%b; a = t;
			if(b == 0) ans -= a;
		}
		Console.WriteLine(ans);
		
	}
	long N,X;
	public Sol(){
		var d = rla();
		N = d[0];
		X = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 2648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie acos(-1)
#define loop(i,a,n) for(int i=a;i<n;i++)
#define trav(a,x) for(auto &a:x)
#define vi vector<int>
#define vl vector<ll>
#define pii pair<ll,ll>
#define endl "\n"
 
void solve()
{
    ll n,w;
    cin>>n>>w;
    vector<ll>weight(n+1),value(n+1);
    loop(i,0,n)
    cin>>weight[i]>>value[i];
    ll sum_value=0;
    for(auto i:value)
    sum_value+=i;
    vector<ll>dp(sum_value+1,1e18L);
    dp[0]=0;
    // dp[i] --> the minimum weight with value as i
    for(ll item=0;item<n;item++)
    {
        for(ll val=sum_value-value[item];val>=0;val--)
        {
            dp[val+value[item]]=min(dp[val+value[item]],weight[item]+dp[val]);
        }
    }
    ll ans=-1;
    for(ll i=0;i<dp.size();i++)
    {
        
        if(dp[i]<=w)
        ans=max(ans,i);
    }
   
    cout<<ans;
}
int main() {
	// your code goes here
	io;
	
    solve();
	return 0;
}

Measured memory_bytes: 1024
from collections import deque

n, m = map(int, input().split())

graph = [[] for _ in range(n+1)]

for i in range(m):
 a, b = map(int, input().split())
 graph[a].append(b)
 graph[b].append(a)

dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

d = deque()
d.append(1)

ans = [0] * (n+1)
while d:
 v = d.popleft()
 for i in graph[v]:
   if dist[i] != -1:
     continue
   dist[i] = dist[v] + 1
   d.append(i)
   ans[i] = v
print('Yes')
print(*ans[2:], sep='\n')

Measured memory_bytes: 36372
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int32_t main(){
    boost;
    int n=1000001;
    vector<char> is_prime(n+1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++) {
        if (is_prime[i] && (long long)i * i <= n) {
            for (int j = i * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    int x;
    cin>>x;
    for (int i = x; i <= n; ++i)
        if(is_prime[i]){cout<<i;return 0;}
    return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 1280