akhauriyash/Code-Regression huggingface dataset:
def add_ans(i,ans,circle):
    if circle[i] == 'o':
        if ans[i] == 'S':
            ans += ans[i-1]

        else:
            if ans[i-1] == 'S':
                ans += 'W'
            else:
                ans += 'S'
            
        
        
    if circle[i] == 'x':
        if ans[i] == 'W':
            ans += ans[i-1]
        
        else:
            if ans[i-1] == 'S':
                ans += 'W'
            else:
                ans += 'S'
            
    return ans
def check_last(ans,circle):
    if circle[0] == 'o':
        if ans[0] == 'S':
            last  = ans[1]

        else:
            if ans[1] == 'S':
                last = 'W'
            else:
                last = 'S'



    if circle[0] == 'x':
        if ans[0] == 'W':
            last = ans[1]

        else:
            if ans[1] == 'S':
                last = 'W'
            else:
                last = 'S'
                
                
    if circle[-1] == 'o':
        if ans[-1] == 'S':
            first  = ans[-2]

        else:
            if ans[-2] == 'S':
                first = 'W'
            else:
                first = 'S'



    if circle[-1] == 'x':
        if ans[-1] == 'W':
            first = ans[-2]

        else:
            if ans[-2] == 'S':
                first = 'W'
            else:
                first = 'S'
                
                
    if (last == ans[-1]) & (first == ans[0]):
        return 1
    else :
        return 0


flag = True
n = int(input())
circle = input()

ans_list = ['SS' , 'SW' , 'WS' , 'WW']
for ans in ans_list:
    for i in range(1,len(circle)-1):
        ans = add_ans(i,ans,circle)


    if check_last(ans , circle) == 1:
        print(ans)
        flag = False
        break

if flag:
    print('-1')

Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
typedef long long ll;

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

int main() {

	ll n, m, x;
	cin >> n >> m >> x;
	vector<ll> C(n);
	ll A[12][12];
	for (int i = 0; i < n; i++) {
		cin >> C[i];
		for (int j = 0; j < m; j++) {
			ll k;
			cin >> k;
			A[i][j] = k;
		}
	}
	ll ans = -1;

	for (int bit = 0; bit < (1 << n); bit++) {
		ll cost = 0;
		vector<ll> abr(m, 0);
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				cost += C[i];
				for (int j = 0; j < m; j++) {
					abr[j] += A[i][j];
				}
			}
		}
		bool flag = true;
		for (int i = 0; i < m; i++) {
			//cout << abr[i] << endl;
			if (abr[i] < x)flag = false;
			//break;
		}
		if (flag == true && ans == -1)ans = cost;
		else if (flag == true && ans != -1) ans = min(ans, cost);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define srt(x) sort((x).begin(), (x).end())
#define rsrt(x) sort((x).rbegin(), (x).rend())
#define g(a, b) __gcd((a), (b))
#define l(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<long long>;
using vllvll = vector<vll>;
using vc = vector<char>;
using vs = vector<string>;
using um = unordered_map<long long, long long>;
template<class T>void print(T x) { cout << '\n' << "== " << x << " ==" << '\n'; }
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T>void precise(T x) { cout << setprecision(21) << x << '\n'; }
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; }
template<class T, class U>T rem(T a, U b) { return a - b*floor(a/b); }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
const long double pi = M_PI;
const long double doublepi = M_PI * 2.0;
const long double halfpi = M_PI / 2.0;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long MOD = 1e9 + 7;



int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    ld ans = -1.0;
    if (a*a*b/2 <= x) {
        ans = atan(2.0*(a*a*b-x)/a/a/a);
    } else {
        ans = atan(a*b*b/2.0/x);
    }
    ans = rad2deg(ans);
    cout << setprecision(21) << ans << endl;
}


Measured memory_bytes: 384
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 5e5 + 5;

int i,n,q,arr[N];

struct Query 
{ 
    int l, r, idx; 
}; 
  
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int n, Query queries[], int q) 
{ 
    int bit[N]; 
    memset(bit, 0, sizeof(bit));
    int last_visit[N]; 
    memset(last_visit, -1, sizeof(last_visit));
    int ans[q]; 
    int query_counter = 0; 
    for(int i=0; i<n; i++) 
    {
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n);
        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n);
        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = query(queries[query_counter].r + 1, bit, n)-query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    }
    for(int i=0; i<q; i++) 
        cout<<ans[i]<<endl; 
} 

void solve()
{
    cin>>n>>q;
    for(i=0;i<n;i++)
    {
    	cin>>arr[i];
    }
    Query queries[q];
    for(i=0;i<q;i++)
    {
    	int l,r;
    	cin>>l>>r;
    	queries[i].l=l-1; 
	    queries[i].r=r-1; 
	    queries[i].idx=i; 
    }
    sort(queries,queries+q,cmp); 
    answeringQueries(n,queries,q); 
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 31180
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Point{
	Point(double arg_x,double arg_y,double arg_z){
		x = arg_x;
		y = arg_y;
		z = arg_z;
	}

	Point(){
		x = y = z = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y,z+p.z); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y,z-p.z);}
	Point operator * (double a){ return Point(a*x,a*y,a*z); }
	Point operator / (double a){ return Point(x/a,y/a,z/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y + z*z; }

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS && fabs(z-p.z) < EPS;
	}
	double x,y,z;
};

typedef Point Vector;


double mult(Vector a,Vector b){
    return a.x*b.x + a.y*b.y+a.z*b.z;
}

double norm(Vector a){
	return a.x*a.x+a.y*a.y+a.z*a.z;
}

double abs(Vector a){
	return sqrt(norm(a));
}

Vector cross(Vector a,Vector b){
	return Point(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}

int main(){

	Point c1,c2,next1,next2;
	Vector X1,X2,Y1,Y2,Z1,Z2,next_Z2;

	scanf("%lf %lf %lf",&c1.x,&c1.y,&c1.z);
	scanf("%lf %lf %lf %lf %lf %lf",&X1.x,&X1.y,&X1.z,&Y1.x,&Y1.y,&Y1.z);
	Z1 = cross(X1,Y1);

	scanf("%lf %lf %lf",&c2.x,&c2.y,&c2.z);
	scanf("%lf %lf %lf %lf %lf %lf",&X2.x,&X2.y,&X2.z,&Y2.x,&Y2.y,&Y2.z);
	Z2 = cross(X2,Y2);

	if(fabs(abs(cross(Z1,Z2))) < EPS){
		printf("NO\n");
		return 0;
	}

	double absX1 = abs(X1),absY1 = abs(Y1),absZ1 = abs(Z1);

	X1.x /= absX1;
	X1.y /= absX1;
	X1.z /= absX1;

	Y1.x /= absY1;
	Y1.y /= absY1;
	Y1.z /= absY1;

	Z1.x /= absZ1;
	Z1.y /= absZ1;
	Z1.z /= absZ1;

	next1.x = mult(X1,c1);
	next1.y = mult(Y1,c1);
	next1.z = mult(Z1,c1);


	next2.x = mult(X1,c2);
	next2.y = mult(Y1,c2);
	next2.z = mult(Z1,c2);

	next_Z2.x = mult(X1,Z2);
	next_Z2.y = mult(Y1,Z2);
	next_Z2.z = mult(Z1,Z2);

	next2.x = next2.x-next1.x;
	next2.y = next2.y-next1.y;
	next2.z = next2.z-next1.z;

	double a = next_Z2.x,b = next_Z2.y,c=next_Z2.z;
	double x2 = next2.x,y2 = next2.y,z2 = next2.z;
	double T = (a*x2+b*y2+c*z2)/b;

	if(fabs(b) < EPS){

		printf("NO\n");

	}else{

		double A = 1.0+(a*a)/(b*b);
		double B = -2*x2-(2*a*T)/b+(2*a*y2)/b;
		double C = x2*x2 + T*T - 2*y2*T + y2*y2 +z2*z2 -1;
		double D = B*B-4*A*C;
		if(D < 0 || fabs(D) < EPS){

			printf("NO\n");
		}else{

			double e = (-B+sqrt(D))/(2*A);
			double f = T-(a/b)*e;

			double g = (-B-sqrt(D))/(2*A);
			double h = T-(a/b)*g;

			double dist1 = sqrt(e*e+f*f);
			double dist2 = sqrt(g*g+h*h);

			if((sqrt(e*e+f*f) <= 1 && sqrt(g*g+h*h) > 1) || (sqrt(e*e+f*f) > 1 && sqrt(g*g+h*h) <= 1)){

				printf("YES\n");

			}else{

				printf("NO\n");
			}
		}
	}

	return 0;
}



Measured memory_bytes: 3276
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    vector<vector<ll>> a(n,vector<ll>(n));
    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
        }
    }
    rep(i,n){
        rep(j,n){
            ll ans = 1000000000;
            rep(k,n){
                ans=min(ans,a[i][k]+a[k][j]);
            }

            if(a[i][j]==ans){
                continue;
            }
            else {
                cout << -1 << endl;
                // cout << i << " " << j << " " << ans << " " << a[i][j] << endl;
                return 0;
            }
        }
        
    }
    bool kun=false;
    ll res=0;;
    rep(i,n){
        rep(j,n){
            kun = false;
            if(i==j){
                continue;
            }
            rep(k,n){
                if (k==j||k==i){
                    continue;
                }
                if (a[i][j]==a[i][k]+a[k][j]){
                    kun = true;
                }
                
            }
            if (!kun){
                res += a[i][j];
                // cout << a[i][j] << endl;
            }
            
        }
    }
    cout << res/2;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int m = scan.nextInt();
		int f = scan.nextInt();
		int r = scan.nextInt();
		int sum = m + f;
		
		while(m != -1 || f != -1 || r != -1)
		{
			if(m == -1 || f == -1){
				System.out.println("F");
			}else if(sum >= 80){
				System.out.println("A");
			}else if(sum >= 65){
				System.out.println("B");
			}else if(sum >= 50){
				System.out.println("C");
			}else if(sum >= 30){
				if(r >= 50){
					System.out.println("C");
				}else{
					System.out.println("D");
				}
			}else{
				System.out.println("F");
			}
			
			m = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
			sum = m + f;
		}
	}
}

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

#define int long long
#define INF 1000000007
 const int n1=500;

 
int32_t main() 
{
    int n;
    cin>>n;
    int rem;
    int sum=0;
    while(n)
    {
        if(n>=500)
        {
            rem=n/500;
            sum+=rem*1000;
            n=n-(rem*500);
        }
        else if(n>=5)
        {
            rem=n/5;
            sum+=(rem*5);
            n=n-(rem*5);
        }
        else
        {
            n=0;
        }


    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
import numpy as np

NM = list(map(int, input().split()))

count_num = np.zeros((NM[1], 1))

for i in range(NM[0]):
    num = list(map(int, input().split()))
    del num[0]
    for j in num:
        count_num[j-1] += 1

print(np.sum(count_num == NM[0]))

Measured memory_bytes: 12488
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define eb emplace_back
#define MP make_pair
#define pb push_back
#define pf push_front
#define ins insert
#define endl '\n'
#define all(v) (v).begin(), (v).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define tr(c,it) for(auto it=c.begin();it!=c.end();it++)
#define fr(i,n) for(lli i=0;i<(n);i++)
#define inc(i,a,b) for(lli i=a;i<=b;i++)
#define dec(i,a,b) for(lli i=a;i>=b;i--)
#define fr2(i,n) for(int i=0;i<(n);i++)
#define inc2(i,a,b) for(int i=a;i<=b;i++)
#define dec2(i,a,b) for(int i=a;i>=b;i--)
#define ymin(a,b)  (a=min((a),(b)))
#define ymax(a,b)  (a=max((a),(b)))
#define sz(x) (lli)(x).size()
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr<< *it << " = " << a << endl;
	err(++it, args...);
}

typedef long long int lli;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<lli,lli> plli;
typedef vector<lli> vlli;
typedef vector<int> vi;
//typedef  vector<vector<lli> >ncr(1001,vector<lli>(1001,0))
typedef vector<plli> vplli;
long long MOD=1000000009;
#define addm(x,y) (x+y>=MOD? (x+y-MOD):(x+y))
int main()
{
	// 	#ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS
	
	// int t;
	// cin>>t;
	// for(int i=1;i<=t;i++)
	// {
	// 	cout<<"Case #"<<i<<": ";
	// 	solve();

	// }
	string s;
	cin>>s;
	lli n=s.length();
	lli sum=0;
	fr(i,n)
	{
		sum+=(s[i]-'0');

	}
	if(sum%9==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	
	
	
	
}


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

int p[55];

int find(int a){
    if(p[a] == a) return a;
    return p[a] = find(p[a]);
}

void unite(int a, int b){
    int ra = find(a);
    int rb = find(b);
    if(ra != rb) p[ra] = rb;
}

int main()
{
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    for(int i=0; i<m; i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    
    int ans =0;
    for(int i=0; i<m; i++){
        for(int j=0; j<n; j++) p[j] = j;
        for(int j=0; j<m; j++){
            if(j == i) continue;
            unite(a[j], b[j]);
        }
		set<int>s;
		for (int j = 0; j < n; j++) {
			s.insert(find(j));
		}
		if (s.size() !=1 ) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/* Survive. Live. Win. Conquer.*/


#include<bits/stdc++.h>
using namespace std;
typedef long long LL ;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define ook order_of_key
#define fbk find_by_order
#define bug printf("TRUST\n");
#define pf printf
#define sf scanf
#define lp(i, n) for(int i = 0; i < n; i++)
#define rlp(n, i) for(int i = n - 1; i >= 0; i--)
#define bye vector<LL>
#define pb push_back
#define r0 return 0
#define ff first
#define ss second
#define mp make_pair
#define pii pair <int, int>
#define sz(a) ((int)a.size())
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define si(a) scanf("%d" , &a)
#define sl(a) scanf("%lld" , &a)
#define sii(a,b) scanf("%d %d" , &a , &b)
#define siii(a,b,c) scanf("%d %d %d" , &a , &b, &c)
#define sll(a,b) scanf("%lld %lld" , &a , &b)
#define slll(a,b,c) scanf("%lld %lld %lld" , &a , &b, &c)
#define FOR(i,a,b) for(LL i = (a) ; i <= (b) ; i++)
#define mod 1000000007
#define nod 200003

//using namespace __gnu_pbds;
//typedef tree < int, null_mapped_type ,less<int>,rb_tree_tag,tree_order_statistics_node_update > ordered_set;

void func(void)
{
        freopen("input.c","r",stdin);
        freopen("output.c","w",stdout);
}
LL mon[4];
int main(){
//    ios_base::sync_with_stdio(0); cin.tie(0);
  //  system("COLOR F0");
    LL n, q, i,j = 0, temp, t, k, ans = 0, sum = 0, x, y, z, cnt = 0, m, fg = 0, mx = 0, mx1 = 0, mn = 8000000000000000000, mn1 = 8000000000000000000;
    LL a, b, c, d;
    cin >> a >> b >> c >> d >> n;
    mon[0] = a * 8;
    mon[1] = b * 4;
    mon[2] = c * 2;
    mon[3] = d * 1;
    sort(mon, mon + 4);
    ans = n / 2;
    ans *= mon[0];
    LL rem = n % 2;

    mon[0] = a * 4;
    mon[1] = b * 2;
    mon[2] = c * 1;
    mon[3] = 1e18;
    sort(mon, mon + 4);
    ans += mon[0] * rem;
    cout << ans << endl;
}


Measured memory_bytes: 256
class ModCalc:
    mod = 10**9 + 7

    def __init__(self, n):
        self.n = n
        self.inv = [1] * (self.n + 1)
        self.fac = [1] * (self.n + 1)
        self.finv = [1] * (self.n + 1)
        self.inv[0] = 0
        self.inv_table()

    def inv_table(self):
        for i in range(2, self.n+1):
            self.inv[i] = self.inv[self.mod % i] * (self.mod - self.mod // i) % self.mod
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def comb(self, n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0

        return self.fac[n] * self.finv[r] % self.mod * self.finv[n-r] % self.mod

    def perm(self, n, r):
        if n < r:
            return 0
        if n < 0 or r < 0:
            return 0

        return self.fac[n] * self.finv[n-r] % self.mod

    def fact(self, n):
        return self.fac[n]


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

mc = ModCalc(n*m)
mod = 10**9 + 7

ret = 0
for d in range(1, n):
    ret += d * (n - d) % mod * m % mod * m % mod * mc.comb(n * m - 2, k-2) % mod
    ret %= mod

for d in range(1, m):
    ret += d * (m - d) % mod * n % mod * n % mod * mc.comb(n * m - 2, k - 2) % mod
    ret %= mod
print(ret)


Measured memory_bytes: 80792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    string s;
    cin >> s;
    for (char& c: s) {
        if (c == ',')
            c = ' ';
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 764
n, x, y = map(int, input().split())

result = [0 for _i in range(n)]
for i in range(1, n):
    for j in range(i+1, n+1):
        result[min([j-i, abs(i-x)+1+abs(j-y), abs(i-y)+abs(j-y)])] += 1
for i in result[1:]:
    print(i)

Measured memory_bytes: 46300
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#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 IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl;
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a, LL b) {LL s = 1; while (b > 0) {if (b & 1)s = s * a % mod; a = a * a % mod; b >>= 1;} return s;}
LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
typedef pair<int, int> P;
const int maxn = 1e5 + 10;
LL dp[maxn];
LL ans;

vector<int> G[maxn];
int n, k;

void dfs(int u, int fa) {
	int cnt = 1 + (fa != -1 );
	for (auto c : G[u]) {
		if (c == fa) continue;
		// cout << (k - cnt) << endl;
		ans = ans * (k - cnt) % mod;
		++cnt;
		dfs(c, u);
	}
}
int main(void)
{
	cin >> n >> k;
	for (int i = 1; i < n; ++i) {
		int u, v; scanf("%d%d", &u, &v);
		G[u].Pb(v);
		G[v].Pb(u);
	}
	ans = k;
	dfs(1, -1);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    if(b/a>c)cout << c << endl;
    else cout << b/a << endl;


    return 0;

}


Measured memory_bytes: 3580
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int count[4][3][10]={{{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
                    {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}},
                    {{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}}};

int main(void){
   int n,b,f,r,v,i;
   cin >> n;
   for(i=1;i<=n;i++){
       cin >> b >> f >> r >> v;
       count[b-1][f-1][r-1] += v;
   }
   for(b=1;b<=4;b++){
       for(f=1;f<=3;f++){
           for(r=1;r<=10;r++){
               cout << " " << count[b-1][f-1][r-1];
           }
           cout << endl;
       }
       if(b<4) cout << "####################" <<endl;
   }
}


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

#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}


void _main() {
        int n, k; cin >> n >> k;
        vector<int> a(n); cin >> a; a.insert(a.begin(), 0);

        map<int,vector<int>> asa;
        ll sum = 0, ans = 0;
        for (int i = 0; i <= n; i++) {
                (sum += a[i]) %= k;
                auto& cur = asa[((sum - i) % k + k) % k];
                int l = 0, r = cur.size() - 1, x = 0;
                while (l <= r) {
                        int mid = (l + r) / 2;
                        if (cur[mid] > i - k) {
                                r = mid - 1;
                                x = cur.size() - mid;
                        } else {
                                l = mid + 1;
                        }
                }

                ans += x;
                cur.emplace_back(i);
        }

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}

Measured memory_bytes: 25764
#include <bits/stdc++.h>
#define LL long long
#define maxn 500005
using namespace std;
int n, k, a[maxn], B[maxn];
LL ans, s[maxn], b[maxn], c[maxn];
bool cmp(int x, int y) {
	if (b[x] == b[y]) return x < y;
	else return b[x] < b[y];
}
inline void upd(int x) {
	while (x <= n + 1) {
		B[x]++;
		x += x & -x;
	}
}

inline int ask(int x) {
	int ans = 0;
	while (x) {
		ans += B[x];
		x -= x & -x;
	}
	return ans;
}

int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; i++) scanf("%d", a + i);
	for (int i = 1; i <= n; i++) {
		s[i] = s[i - 1] + a[i];
		b[i] = s[i] - 1LL * k * i;
		c[i] = i;
	}
	sort(c, c + 1 + n, cmp);
	for (int i = 0; i <= n; i++) {
		ans += ask(c[i] + 1);
		upd(c[i] + 1);
	}
	printf("%lld\n", ans);
}



Measured memory_bytes: 14208
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<algorithm>
using namespace std;
#define eps 1e-7
#define maxi 50000005
typedef long long ll;
int n,k,avc;
int main()
{
     cin>>n;
     int a,b,c,d;
     a=n/1000,b=(n/100)%10,c=(n%100)/10,d=n%10;
     if((a==b&&b==c)||(b==c&&c==d))
        cout<<"Yes"<<endl;
     else
        cout<<"No"<<endl;
     return 0;
}


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

int main(){
  string S; cin >> S;
  int Q; cin >> Q;
  
  string str[2]={"",""};
  int cur=0;
  for(int i=0; i<Q; i++){
    int T; cin >> T;
    if(T==1){
      cur=(cur+1)%2;
    }else{
      int F;
      string C;
      cin >> F >> C;
      str[(cur+F+1)%2]=C+str[(cur+F+1)%2];
    }
  }
  if(cur==0){
    reverse(str[1].begin(),str[1].end());
    cout << str[0] << S << str[1] << endl;
  }else{
    reverse(str[0].begin(),str[0].end());
    reverse(S.begin(),S.end());
    cout << str[1] << S << str[0] << endl;
  }
}

Measured memory_bytes: 1140
from math import log, floor
from itertools import accumulate, chain, islice, repeat
 
k = int(input())
 
def f(n):
    ds = range(int(log(n+1, 10))+1)
    xs = [(10**(d+1))*floor(n/(10**(d+1)) + 1) - 1 for d in ds]
    return min(xs, key=lambda n:n / sum(map(int, str(n))))
 
snukes = chain(range(1, 9), accumulate(repeat(9), lambda x,_:f(x+1)))
 
for x in islice(snukes, k):
    print(x)

Measured memory_bytes: 3188
#include<cstdio>
const static int H_MAX = 2000;
const static int W_MAX = 2000;

bool grid[H_MAX + 2][W_MAX + 2];
unsigned vertical[H_MAX + 1][W_MAX + 1], horizontal[H_MAX + 1][W_MAX + 1];

int main(){
	int H, W;
	scanf("%d %d", &H, &W);
	for (int i = 0; i <= W + 1; ++i){
		grid[0][i] = grid[H + 1][i] = false;
	}
	for (int i = 1; i <= H; ++i){
		grid[i][0] = grid[i][W + 1] = false;
	}
	for (int i = 1; i <= H; ++i){
		scanf("\n");
		for (int j = 1; j <= W; ++j){
			char tmp;
			scanf("%c", &tmp);
			grid[i][j] = tmp == '.';
		}
	}
	for (int i = 1; i <= H; ++i){
		unsigned left;
		for (int j = 1; j <= W; ++j){
			if(grid[i][j] && !grid[i][j - 1]) left = j;
			if(grid[i][j] && !grid[i][j + 1]){
				for (int k = left; k <= j; ++k){
					horizontal[i][k] = j + 1 - left;
				}
			}
		}
	}
	for (int i = 1; i <= W; ++i){
		unsigned top;
		for (int j = 1; j <= H; ++j){
			if(grid[j][i] && !grid[j - 1][i]) top = j;
			if(grid[j][i] && !grid[j + 1][i]){				
				for (int k = top; k <= j; ++k){
					vertical[k][i] = j + 1 - top;
				}
			}
		}
	}
	unsigned ans = 0;
	for (int i = 1; i <= H; ++i){
		for (int j = 1; j <= W; ++j){
			if(grid[i][j] && ans < horizontal[i][j] + vertical[i][j] - 1) ans = horizontal[i][j] + vertical[i][j] - 1;
		}
	}
	printf("%u\n", ans);
	return 0;
}

Measured memory_bytes: 35328
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int sum[2020];
string s; 
ll ans,now,power;
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	cin>>s;
	power=1;
	sum[0]=1; 
	fore(i,s.size()-1,0)
	{
		now=(now+(s[i]-'0')*power)%2019;
		ans+=sum[now];
		sum[now]++;
		power=power*10%2019;
	} 
	cout<<ans<<endl;
	return 0;
}



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

int main() {
    int n, k;
    cin >> n >> k;
    int snuke[n] = {};

    for(int i = 0; i < k; i++) {
        int d;
        cin >> d;
        int a[d];
        for(int j = 0; j < d; j++) {
            cin >> a[j];
            a[j]--;
            snuke[a[j]]++;
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(snuke[i] == 0) ans++;
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"	
	typedef long long LL;
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define mod2 998244353
	#define INFINITE 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define sz(v) ((ll)(v).size())
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define pb push_back
	#define f first
	#define s second
	#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
	#define forn(i,n) for (ll i=0; i<(n); ++i)
	#define fornd(i,n) for (ll i=(n)-1; i>=0; --i)	
	#define forab(i,a,b) for (ll i=(a); i<=(b); ++i)
	#define read(a) ll a; cin >> a;
	#define reads(s) string s; cin >> s;
	#define readb(a, b) ll a, b; cin >> a >> b;
	#define readc(a, b, c) ll a, b, c; cin >> a >> b >> c;
	#define readarr(a, n) int a[(n) + 1] = {}; forab(i, 0, (n-1)) {cin >> a[i];}
	#define readmat(a, n, m) int a[n + 1][m + 1] = {}; forab(i, 1, n) {forab(j, 1, m) cin >> a[i][j];}
	#define readv(A,n) vll A(n,0); forn(i,n) cin>>A[i]; 
	#define print(a) cout << a << endl;
	#define printarr(a, n) forab (i, 1, n) cout << a[i] << " "; cout << endl;
	#define printv(v) for (int i: v) cout << i << " "; cout << endl;
	#define printmat(a, n, m) forab(i, 1, n) {forab (j, 1, m) cout << a[i][j] << " "; cout << endl;}
	 
	#define INF (1e18+5)
	#define inf (1e9+5)
	int dx[4] = { 0, 0, 1, -1 };
	int dy[4] = { 1, -1, 0, 0 };

	#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
	using namespace std;
	bool isPowerOfTwo(int x) {
    return x && (!(x & (x - 1)));
	}
	int takemod(int x) {
    return (x % mod + mod) % mod;
	}
 
	int fpow(int base, int power, int MOD) {
    int result = 1;
    base = base % MOD;
    while (power) {
        if (power & 1)
            result = (result * base) % MOD;
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result;
	}
 
	int modinv(int x) {return fpow(x, mod - 2, mod);}
	void solve()
	{
		ll n;
		cin>>n;
		vll A(n);
		forn(i,n)cin>>A[i];
		ll mx=0;
		ll ans=0;
		forn(i,n)
		{
			mx=max(mx,A[i]);
			if(i!=0)
			{
				if(A[i]<mx)
				{
					ans+=abs(mx-A[i]);
				}
			}
		}
		cout<<ans<<endl;
	}
	int main()
	{	
		#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		#endif
		fast_io;
		int T=1;
		//cin>>T;
		// cin.ignore(); must be there when using getline(cin, s)
		while(T--)
		{
			solve();
		}
		return 0;
	}

	
	

Measured memory_bytes: 4760
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = (N / (A + B)) * A + min(N % (A + B), A);
    cout << ans << endl; 

    return 0;
}


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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005

int main(){
sp;
int n;
cin>>n;
map<int,int> mp;
int ans=0;
while(n--){
    int x;
    cin>>x;
    ++mp[x];
}
for(auto &it:mp)
    if(it.s>=it.f)ans+=it.s-it.f;
else ans+=it.s;
cout<<ans;
return 0;}


Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main() {
    int a, b;
    string s;
    stack<int> S;

    while (cin >> s) {
        if (s == "+") {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a + b);
        } else if (s == "-") {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(b - a);
        } else if (s == "*") {
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a * b);
        } else {
            S.push(stoi(s));
        }
    }

    cout << S.top() << endl;

    return 0;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<(S)<<endl
#define ck(a,b) (0<=(a)&&(a)<(b))
using namespace std;

int main(){
	int N,H,W;
	cin>>N>>W>>H;
	int tate[100010],yoko[100010];
	REP(i,0,H+1) tate[i]=0;
	REP(i,0,W+1) yoko[i]=0;
	int x,y,w;
	REP(i,0,N){
		cin>>x>>y>>w;
		int mnx=max(0,x-w+1);
		int mxx=min(W+1,x+w);
		int mny=max(0,y-w+1);
		int mxy=min(H+1,y+w);
		yoko[mnx]++;yoko[mxx+1]--;
		tate[mny]++;tate[mxy+1]--;
	}
	bool flag1=true,flag2=true;
	REP(i,1,W+1) {
		yoko[i]+=yoko[i-1];
		if(yoko[i]==0) {
			flag1=false;
			break;
		}
	}
	REP(i,1,H+1) {
		tate[i]+=tate[i-1];
		if(tate[i]==0) {
			flag2=false;
			break;
		}
	}
	if(flag1||flag2) p("Yes");
	else p("No");
	return 0;
}

Measured memory_bytes: 3864
#include<stdio.h>

int main(){
    int n,m1=0,m2=0,m;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        if(m1<=a[i]){
            m2=m1;
            m1=a[i];
            m=i;
        }
        else{
            if(m2<=a[i]){
                m2=a[i];
            }
        }
    }
    for(int i=0;i<n;i++){
        if(i==m){
            printf("%d\n",m2);
        }
        else{
            printf("%d\n",m1);
        }
    }
}


Measured memory_bytes: 2304
#(43)平均点
a=[]
for i in range(5):
    n=int(input())
    a.append(n)
    
for _ in range(5):
    if a[_]<40:
        a[_]=40

sum=0
for l in range(5):
    b=a[l]
    sum+=b

av=sum//5
print(av)


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

ll tpw(int a){
  ll b=1;
  for(int i=0;i<a;i++)
    b*=10;
  return b;
}

int S(ll a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}

int main(){
  int K; cin>>K;
  ll ans=0;
  ll cg=1;
  vector<ll> A;
  for(int i=0;K;i++){
    ans+=cg;
    if(ans>cg*S(ans)){
      ans+=9*cg;
      cg*=10;
    }
    cout<<ans<<endl;
    K--;
  }
}

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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {
    long long N, p;
    cin >> N >> p;
    const auto &res = prime_factorize(p);

    ll ans = 1;
    for (auto x : res) {
        for (int j = 1; x.second >= N * j; ++j) {
            ans *= x.first;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
   ll n;
   cin>>n;
   vl a(n);
   forr(i, n)
   {
       cin>>a[i];
   }
   sort(all(a));
   map<ll, ll> mp1;
   vector<bool> visited(n, false);
   for(ll i=0; i<n; i++)
   {
       if(i)
       {
           if(a[i]==a[i-1])
           {
               visited[i]=true;
               visited[i-1]=true;
           }
       }
       if(!i)
       {
           if(a[i]==a[i+1])
           {
               visited[i]=true;
               visited[i+1]=true;
           }
       }
       if(mp1.find(a[i])!=mp1.end())
       {
           visited[i]=true;
           continue;
       }
       ll num=a[i];
       mp1[num]++;
       for(ll x=num*2; x<=1000000; x+=num)
       {
           mp1[x]++;
       }
   }
   ll ans=0;
   forr(i, n)
   {
       if(!visited[i])
       ans++;
   }
   cout<<ans;
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}


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

map<char, int>notal{
	{ ' ',26 },{ '.',27 },{ ',',28 },{ '-',29 },{ '\'',30 },{ '?',31 }
};
map<int, char>mp{
	{ 26,' ' },{ 27,'\'' },{ 28,',' },{ 29,'-' },{ 30,'.' },{ 31,'?' },
};
string code[]{ "100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000","101","000000","000011","10010001","010001","000001" };
int main() {
	string s;
	while (getline(cin, s)) {
		stringstream ss;
		for (char c : s) {
			if (isalpha(c))ss << bitset<5>(c - 'A');
			else ss << bitset<5>(notal[c]);
		}
		s = ss.str();
		string ans;
		int i = 0;
		bool flag = true;
		while (flag) {
			flag = false;
			rep(j, 32) {
				if (i + code[j].size() <= s.size() && s.substr(i, code[j].size()) == code[j]) {
					if (j < 26)ans += 'A' + j;
					else ans += mp[j];
					i += code[j].size();
					flag = true;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll N,K,S;
    cin >> N >> K >> S;
    REP(i, K){
        cout << S;
        if(i != N-1) cout << " ";
    }
    REP(i, N-K){
        if(S == 1000000000) cout << S-1;
        else cout << 1000000000;
        if(i != N-1) cout << " ";
    }
    cout << endl;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int INF = 1001001001;
const double EPS = 1e-10;

using T = tuple<int,int,int,int>;
struct edge{int to,cost;};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    while(cin>>n>>m&&!(n==0&&m==0)){
        vector<edge> g[n];
        for(int i=0,a,b,c;i<m;i++){
            cin>>a>>b>>c;
            a--; b--;
            g[a].push_back((edge){b,c});
            g[b].push_back((edge){a,c});
        }
        int dp[n+1][2][2];
        for(int i=0;i<n+1;i++)for(int j=0;j<2;j++)for(int k=0;k<2;k++){
            dp[i][j][k]=INF;
        }
        dp[0][0][0]=0;
        priority_queue<T,vector<T>,greater<T>> que;
        que.push(T(0,0,0,0));
        while(!que.empty()){
            T t=que.top(); que.pop();
            int ct=get<0>(t),v=get<1>(t),tic=get<2>(t),cnt=get<3>(t);
            for(auto e:g[v]){
                if(tic){
                    if(dp[e.to][tic][cnt]>ct+e.cost){
                        dp[e.to][tic][cnt]=ct+e.cost;
                        que.push(T(dp[e.to][tic][cnt],e.to,tic,cnt));
                    }
                }else{
                    if(cnt){
                        if(dp[e.to][1][0]>ct){
                            dp[e.to][1][0]=ct;
                            que.push(T(dp[e.to][1][0],e.to,1,0));
                        }
                    }else{
                        if(dp[e.to][tic][cnt]>ct+e.cost){
                            dp[e.to][tic][cnt]=ct+e.cost;
                            que.push(T(dp[e.to][tic][cnt],e.to,tic,cnt));
                        }
                        if(dp[e.to][tic][1]>ct){
                            dp[e.to][tic][1]=ct;
                            que.push(T(dp[e.to][tic][1],e.to,tic,1));
                        }
                    }
                }
            }
        }
        cout<<min(dp[n-1][0][0],dp[n-1][1][0])<<endl;
    }
}


Measured memory_bytes: 3164
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	char a[100];
	int n,s=0,t=0,u=0,h=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		if(a[i]=='Y'){
			s++;
		}
		if(a[i]=='W'){
			t++;
		}
		if(a[i]=='G'){
			u++;
		}
		if(a[i]=='P'){
			h++;
		}
	}
	
	if(t!=0&&s!=0&&u!=0&&h!=0){
		cout<<"Four"<<endl;
	}
	
	else if(t==0||s==0||u==0||h==0){
		cout<<"Three"<<endl;
	}
	
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] arg){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){

	    double[] x = new double[3];
	    double[] y = new double[3];
	    for(int i=0; i<3; i++){
		x[i] = sc.nextDouble();
		y[i] = sc.nextDouble();
	    }

	    double xp = sc.nextDouble();
	    double yp = sc.nextDouble();

	    for(int i=0; i<3; i++){
		x[i] = x[i] - xp;
		y[i] = y[i] - yp;
	    }

	    double[] gaiseki = new double[3];
	    gaiseki[0] = x[0]*y[1] - y[0]*x[1];
	    gaiseki[1] = x[1]*y[2] - y[1]*x[2];
	    gaiseki[2] = x[2]*y[0] - y[2]*x[0];

	    int plus = 0;
	    int minus = 0;
	    for(int i=0; i<3; i++){
		if(gaiseki[i]>0){plus++;}
		if(gaiseki[i]<0){minus++;}
	    }

	    String ans = "NO";
	    if(plus==3 || minus==3){ans = "YES";}

	    System.out.println(ans);
	}
    }
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> o = new ArrayList<>();
        for(int i = 0;i < n;i++){
            o.add(sc.nextInt());
        }
        long min = Integer.MAX_VALUE;
        for(int i = 0;i < n;i++){
            List<Integer> g1 = new ArrayList<>();
            List<Integer> g2 = new ArrayList<>();
            long r1 = 0;
            long r2 = 0;
            for(int j = 0;j < i;j++){
                g1.add(o.get(j));
            }
            for(int j = i;j < n;j++){
                g2.add(o.get(j));
            }
            for(int one : g1){
                r1 += one;
            }
            for(int two : g2){
                r2 += two;
            }
            long r = r1 - r2;
            if(r < 0){
                r *= -1;
            }
            if(min > r){
                min = r;
            }
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 22356
#abc116 b
n=int(input())
a=[]
a.append(n)
i=0
while True:
    if a[i]%2==0:
        x=int(a[i]/2)
        if x in a:
            ans=i+1
            break
        else:
            a.append(x)
    else:
        x=a[i]*3+1
        if x in a:
            ans=i+1
            break
        else:
            a.append(x)
    i+=1
print(ans+1)

Measured memory_bytes: 3060
let rec gcd a b =
  let r = a mod b in
  if r = 0 then b
  else gcd b r

let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a / 2)) in
  let lcm = Array.fold_left
      (fun lcm a ->
        let t = lcm / (gcd lcm a) * a in
        if m < t then 0
        else t
      ) 1 a in
  let b = Array.exists (fun a -> lcm / a mod 2 = 0) a in
  let ans = if b then 0 else (m / lcm - 1) / 2 + 1 in
  Printf.printf "%d\n" ans


Measured memory_bytes: 6672
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
int main() {
  ll N;
  cin>>N;
  vector<ll> vec(N);
  for(ll i=0;i<N;i++){
    cin>>vec.at(i);
  }
  for(ll i=0;i<N;i++){
    if(vec.at(i)%2==0){
      if(vec.at(i)%3==0 || vec.at(i)%5==0){
      }else{
        cout<<"DENIED"<<endl;return 0;
      }
    }
  }
  cout<<"APPROVED"<<endl;
}

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

using namespace std;
int main() {
    int n;
    int k;
    cin >> n >> k;
//    cout<<n<<" "<<k<<endl;

    vector<int> nums(n, 0);
    for (int i = 0; i < n; i++)
    {
        cin >> nums[i];
    }
//    for(int i=0; i<nums.size(); ++i)
//      std::cout << nums[i] << ' ';
//    cout<<endl;

    vector<int> weights(n, 0);
    int curcost, mincost;
    for (int j=1; j< n; j++)
    {
//        cout<<"j="<<j<<endl;
        mincost = weights[j-1] + abs(nums[j] - nums[j-1]);
//        cout<<mincost<<endl;
        for (int ifrom=j-2; (ifrom>=0)&(ifrom>=j-k); ifrom--)
        {
            curcost = abs(nums[ifrom] - nums[j]) + weights[ifrom];
//            cout<<curcost<<" ";
            if (curcost < mincost) mincost = curcost;
        }

//        cout<<"min:"<<mincost;
        weights[j] = mincost;
//        cout<<endl<<endl;
    }
    cout<<weights[n-1]<<endl;
}


Measured memory_bytes: 3984