akhauriyash/Code-Regression huggingface dataset:
N=int(input())
F=[list(map(int,input().split())) for _ in range(N)]
P=[list(map(int,input().split())) for _ in range(N)]
from itertools import product
gain=[]
for p in product([0,1,2,3],repeat=5):
    C=[0 for i in range(N)]
    for i in range(5):
        for j in range(N):
            am=F[j][2*i]
            pm=F[j][2*i+1]
            if p[i]==1:
                C[j]+=am
            elif p[i]==2:
                C[j]+=pm
            elif p[i]==3:
                C[j]+=am+pm
    g=0
    for j in range(N):
        g+=P[j][C[j]]
    
    flag=False
    for i in range(5):
        if p[i]!=0:
            flag=True
    if flag:
        gain.append(g)

print(max(gain))


Measured memory_bytes: 43868
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 100002;

int n, m, u[maxn], v[maxn], fa[maxn];
long long ans[maxn];

int getfa(int x) {
	if (fa[x] < 0)
		return x;

	fa[x] = getfa(fa[x]);
	return fa[x];
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
		cin >> u[i] >> v[i];

	memset(fa, -1, sizeof(fa));

	ans[m-1] = (long long)n * (n-1) / 2;
	for (int i = m-2; i >= 0; --i) {
		int x = getfa(u[i+1]), y = getfa(v[i+1]);

		if (x == y)
			ans[i] = ans[i+1];
		else {
			long long a = -fa[x], b = -fa[y];
			fa[x] += fa[y];
			fa[y] = x;

			ans[i] = ans[i+1] - a * b;
		}
	}

	for (int i = 0; i < m; ++i)
		cout << ans[i] << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
#include <list>
using namespace std;
#define INF 100000000
typedef long long int lli;
typedef pair<int,int> P;

void QuickSort(vector<int>& vi,int begin,int end){
	int i=begin;
	int j=end;
	int pivot;
	pivot=vi[(begin+end)/2];
	while(1){
		while(vi[i]<pivot){++i;}
		while(vi[j]>pivot){--j;}
		if(i>=j) break;

		swap(vi[i],vi[j]);
		++i;
		--j;
	}
	if(begin<i-1){ QuickSort(vi,begin,i-1); }
	if(j+1<end){ QuickSort(vi,j+1,end); }
}

int main (){
	int n;
	while(cin >> n&&n){
		long long int ans=0;
		long long int result=0;
		vector<int> guest(n);
		for(int i=0; i<n; ++i){
			cin >> guest[i];
		}
		QuickSort(guest,0,guest.size()-1);
		/*for(int i=0; i<guest.size(); ++i){
			cout << guest[i] << "\n";
		}*/
		for(int i=0; i<guest.size(); ++i){
			result+=ans;
			ans+=guest[i];
		}
		cout << result << "\n";
	}
	return 0;
}

Measured memory_bytes: 1228
S = list(input())
for i in range(2 ** 3):
  op = ['+'] * 3
  for j in range(3):
    if ((i >> j) & 1):
      op[j] = '-'
  ans = ''
  for s, p in zip(S, op+['']):
    ans += (s + p)
  if eval(ans) == 7:
    print(ans + '=7')
    break

Measured memory_bytes: 9120
//28/03/2020
#include<bits/stdc++.h>
#include<cmath>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define debug printf("Debug\n");
#define en '\n'


#define ll long long
#define ull unsigned long long

#define pi acos(-1.0)
#define mod 1000000007

#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define in_fre  freopen("in.txt", "r", stdin);
#define out_fre freopen("out.txt", "w", stdout);

struct Node{
    ll val,pos;
};
struct OverloadedNode{
    ll val,pos;
    bool operator < (const OverloadedNode &rhs) const {
        if(val==rhs.val) return pos<rhs.pos;
        else return val<rhs.val;
    }
};
//Algos
template<typename T> using Pbds=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//typedef tree<OverloadedNode,null_type,less<OverloadedNode>,rb_tree_tag,tree_order_statistics_node_update>OverloadedPbds;

//Number Theory
template <typename T> T BigMod (T b,T p,T m){if (p == 0) return 1;if (p%2 == 0){T s = BigMod(b,p/2,m);return ((s%m)*(s%m))%m;}return ((b%m)*(BigMod(b,p-1,m)%m))%m;}
template <typename T> T ModInv (T b,T m){return BigMod(b,m-2,m);}
template <typename T> T gcd(T a,T b){if(a<0)return gcd(-a,b);if(b<0)return gcd(a,-b);return (b==0)?a:gcd(b,a%b);}
template <typename T> T lcm(T a,T b) {if(a<0)return lcm(-a,b);if(b<0)return lcm(a,-b);return a*(b/gcd(a,b));}

//Geometry
template <typename T> T Dis(T x1,T y1,T x2, T y2){return sqrt( SQR(x1-x2) + SQR(y1-y2) );}
template <typename T> T Angle(T x1,T y1,T x2, T y2){ return atan2( double(y1-y2) , double(x1-x2));}


/*Containers*/
//vector<ll>v;
//deque<ll>dq;
//stack<ll>stk;
//map<ll,ll>mp;
//unordered_map<ll,ll>ump;
//set<ll>st;
//multiset<ll>mst;
//unordered_set<ll>ust;
//unordered_multiset<ll>umst;
//priority_queue<ll,deque<ll>,greater<ll>>pq;
//Pbds<ll>ost;
/*OverLoaded Containers*/
//vector<OverloadedNode>v;
//deque<OverloadedNode>dq;
//stack<OverloadedNode>stk;
//map<OverloadedNode,OverloadedNode>mp;
//set<OverloadedNode>st;
//multiset<OverloadedNode>mst;
//priority_queue<OverloadedNode>pq;
//OverloadedPbds oost;
/*Global Variables*/

int main(){
    _fastio
    ll x;
    cin>>x;
    ll ans=0;
    ans+=((x/500)*1000);
    x%=500;
    ans+=((x/5)*5);
    cout<<ans<<en;



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

vector<ll> add(ll k){
    vector<ll>res;
    for(ll i=1;i*i<=k;i++){
        if(k%i==0){
            res.pb(i);res.pb(k/i);
        }
    }
    return res;
}

int main(){fastio
    ll n;cin>>n;
    vector<ll> a;
    rep(i,0,n-1){
        ll k;cin>>k;a.pb(k);
    }
    vector<ll>v,vv;
    v=add(a[0]);vv=add(a[1]);
    for(auto x:vv)v.pb(x);
    ll ans=0;
    for(auto x:v){
        ll count=0;
        for(auto y:a){
            if(y%x!=0){
                count++;
            }
        }
        if(count<=1)Max(ans,x);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
using namespace std;


int main() {
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = min(A, B); i >= 1; i--) {
		if (A % i == 0 && B % i == 0) {
			K--;
			if (K == 0) {
				cout << i << endl;
				return 0;
			}
		}
	}
//	assert(false);
	return 0;
}

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

int P[10010];
void init(int N) {
  for(int i=0;i<N;i++)P[i] = i;
    }
int root(int a){
  if(P[a] == a) return a;
  return (P[a] = root(P[a]));
}
bool is_same_set(int a, int b){
    return root(a) == root(b);
  }
void unite(int a, int b) {
  P[root(a)] = root(b);
}
int main(){
  int n,q;
  cin >> n >> q;
  init(n);
  int c,x,y;
  for(int i=0;i<q;i++){
    cin >>  c >> x >> y;
    if(c){
      cout << is_same_set(x,y) << endl;
    }
    else{
      unite(x,y);
    }
  }
}


Measured memory_bytes: 3240
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
#define all(x) x.begin(),x.end()
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2e5+10;
 
int main()
{
    fastio;
    ll i, j, k, t, n, m;
    vll a;

    cin>>t;
    if(t>=30)
        cout<<"Yes"<<endl;
        else
        {
            cout<<"No"<<endl;
        }
        
    



    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <cstdio>
#include <string>

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

string S;

vector<int> tree;
vector<int> revTree;

signed main() 
{
    cin >> S;

    if(S[S.length()-1] != '0' || S[0] != '1') {
        cout << -1 << endl;
        return 0;
    }
    
    S = "x" + S;

    for(int i = 2; i < S.length()-1; i++) {
        if(S[i] != S[S.length()-1-i]) {
            cout << -1 << endl;
            return 0;
        }
    }

    int N = S.length()-1;
    int nextIndex = 1;
    int nowIndex = 0;
    tree.resize(N, -1);
    
    for(int i = 1; i < N-1; i++) {
        cerr << "i: " << i << endl;
        if(S[i] == '1') {
            cerr << "1 " << nowIndex << " " << nextIndex << endl;
            tree[nowIndex] = nextIndex;
            nowIndex = nextIndex;
            nextIndex++;
        } else {
            cerr << "0 " << nowIndex << " " << nextIndex << endl;
            tree[nextIndex] = nowIndex;
            nextIndex++;
        }
    }
    tree[N-1] = nowIndex;

    // int oldNextIndex = nextIndex;
    // int oldNowIndex = nowIndex;

    revTree.resize(N, -1);
    // nextIndex = N-2;
    // nowIndex = N-1;
    // for(int i = N-1; (N+1)/2+1 < i; i--) {
    //     if(S[i] == '1') {
    //         revTree[nowIndex] = nextIndex;
    //         nextIndex--;
    //         nowIndex--;
    //     } else {
    //         revTree[nextIndex] = nowIndex;
    //         nextIndex--;
    //     }
    // }

    // revTree[nowIndex] = oldNowIndex;

    cerr << "tree" << endl;
    for(int i : tree) {
        cerr << i << endl;
    }
    // cerr << "revtree" << endl;
    // for(int i : revTree) {
    //     cerr << i << endl;
    // }

    for(int i = 0; i < N; i++) {
        if(tree[i] != -1) {
            cout << i+1 << " " << tree[i]+1 << endl;
        } else if(revTree[i] != -1) {
            cout << i+1 << " " << revTree[i]+1 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <map>
using namespace std;

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define SINV(t) greater<t>()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP2(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()

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; }

typedef long long ll;
#define vv(t) vector<t>

template<typename T>
void SV(vector<T> v){
    REP(i,v.size()){
        #ifdef LOCAL
            cout << i << " : " << v[i] << endl;
        #endif
    }
}

int bitCount(int bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >> 16);
}


int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    ll sum = 0;
    vv(vv(int) ) mm(3, vector<int>(N, -1));
    map<char, int> mp;
    mp['R'] = 0, mp['G'] = 1, mp['B'] = 2;
    REP(i, N){
        for(int j=i+1; j<N; j++){
            if(S[i]==S[j])
                continue;
            if(mm[mp[S[i]]][j] != -1){
                sum += mm[mp[S[i]]][j];
                continue;
            }else{
                mm[mp[S[i]]][j] = 0;
            }
            for(int k=j+1; k<N; k++){
                if(S[i]==S[k] || S[j]==S[k])
                    continue;
                sum++;
                mm[mp[S[i]]][j]++;
            }
        }
    }
    for(int j=0; j<N-2; j++){
        REP2(i, (N-j-1)/2){
            if(!(
                S[j] == S[j+i] ||
                S[j+i] == S[j+2*i] ||
                S[j] == S[j+2*i]
            ))
                sum--;
        }
    }

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


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



int main() {
    int N,W;
    cin>>N>>W;
    ll w[N],v[N];
    rep(i,N){
        cin>>w[i]>>v[i];
    }
    
    vector<vector<ll>> dp(N,vector<ll>(W+1));
    //dp[0][w[0]]=v[0];
    for(int i=w[0];i<W+1;i++){dp[0][i]=v[0];}
    rep(i,N-1){
        rep(j,W+1){
            dp[i+1][j]=dp[i][j];
        }
        rep(j,W+1-w[i+1]){
            dp[i+1][j+w[i+1]]=max(dp[i+1][j+w[i+1]],dp[i][j]+v[i+1]);
        }
    }
    ll ans=dp[N-1][W];
    rep(i,W){
        ans=max(ans,dp[N-1][i]);
    }
    cout<<ans<<endl;

    /*rep(i,N){
        rep(j,W+1){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
}

Measured memory_bytes: 79360
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;

fn main() {
    input! {
        a1: i64,
        a2: i64,
        a3: i64
    }

    let sum = a1 + a2 + a3;
    if sum >= 22 {
        println!("bust")
    }else{
        println!("win")
    }



   
}


Measured memory_bytes: 4352
s = input()
a1,a2 = s[0],s[1]
if a1 == a2:
  print(1,2)
  exit()
for k,v in enumerate(s[2:]):
  if v == a1:
    print(k+1,k+3)
    exit()
  elif v == a2:
    print(k+2,k+3)
    exit()
  a1 = a2
  a2 = v
print(-1,-1)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;
 
template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}
 
ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}
 
ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int dp[200020][3] = {0};

int main() {
    string S;
    cin >> S;
    int N = S.size();
    S += "####";
    dp[1][0] = dp[2][1] = 1;
    for(int i = 0;i < N;i++) {
        if(i >= 1 && S.at(i - 1) != S.at(i)) {
            dp[i + 1][1] = max(dp[i + 1][1],dp[i][1] + 1);
        }
        if(i >= 2 && (S.at(i - 2) != S.at(i) || S.at(i - 1) != S.at(i + 1))) {
            dp[i + 2][2] = max(dp[i + 2][2],dp[i][2] + 1);
        }
        dp[i + 2][2] = max(dp[i + 2][2],dp[i][1] + 1);
        dp[i + 1][1] = max(dp[i + 1][1],dp[i][2] + 1);
    }
    cout << max(dp[N][1],dp[N][2]) << endl;
}

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

int p[101] = {0};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i)cin >> p[i];
    int sc = 0;
    for(int i=1;i<=100;++i){
        int cnt = 0;
        for(int j=0;j<n;++j){
            if(p[j] >= i)cnt++;
        }
        if(cnt >= i && i > sc)sc = i;
    }
    cout << sc << endl;

    return 0;
}


Measured memory_bytes: 3092
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("faild to read char") as char)
        .take_while(|c| !c.is_whitespace())
        .collect();
    token
        .parse()
        .ok()
        .expect("faild to parse token")
}

fn main(){
    let k: usize = read();
    let k1 = k - 1;
    let mut q: VecDeque<u64> = VecDeque::with_capacity(k / 10);
    for i in 1..10 {
        q.push_back(i);
    }

    for _ in 0..k1 {
        let a = *q.front().unwrap();
        q.pop_front();

        if a % 10 != 0 {
            q.push_back(a * 10 + (a % 10) - 1);
        }
        q.push_back(a * 10 + (a % 10));

        if a % 10 != 9 {
            q.push_back(a * 10 + (a % 10) + 1);
        }
    }

    println!("{}", q.front().unwrap());
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int ans=0;
  int size=s.size();
  for(int i=0;i<size;i++){
    ans+=(s.at(i)-'0');
    ans%=9;
  }
  if(ans==0){
    cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

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

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

    int ans = 0;
    for (int i = n-3; i >= 0; i--) {
        if (s.substr(i, 3) == "ABC") ans++;
    }

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


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

using namespace std;

using ll = long long;

template<typename T>
bool is_prime(T n) {
    if (n % 2 == 0) return n == 2;
    for (T i = 3; i * i <= n; i += 2) {
        if (n % i == 0) return false;
    }
    return n != 1;
}

template<typename T>
vector<T> divisor(T n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.emplace_back(i);
            if (i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

template<typename T>
map<T, int> prime_factor(T n) {
    map<T, int> res;
    for (T i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }
    if (n != 1) res[n] = 1;
    return res;
}

template<typename T>
vector<T> sieve(T n) {
    vector<T> res;
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for (T i = 2; i <= n; i++) {
        if (!is_prime[i]) continue;
        res.emplace_back(i);
        for (T j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x;
    cin >> x;
    for (int i = x; ; ++i) {
        if (is_prime(i)) {
            cout << i << "\n";
            return 0;
        }
    }
    return 0;
}


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

typedef long long ll;

int main() {
    ll N, M, V, P; cin >> N >> M >> V >> P;
    vector<ll> A(N); for (auto &x : A) cin >> x;
    sort(A.begin(), A.end(), greater<ll>());
    ll ok = 0, ng = N;
    while (ng - ok != 1) {
        ll med = (ok + ng) / 2;
        ll obj = A[med];
        ll temp = 0;
        bool flag = true;
        int t = 0;
        for (int i = 0; i < N; i++) {
            if (t < P-1 || obj + M < A[i]) {
                temp += M;
                t++;
            } else {
                temp += min(obj + M - A[i], M);
            }
        }
        if (temp >= M * V && t < P) ok = med;
        else ng = med;
    }
    cout << ok + 1 << endl;
}


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

using namespace std;

int n, a[200003], un;

int main() {
	//freopen("C.in", "r", stdin);
	//freopen("C.txt", "w", stdout);
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) scanf("%d", &a[i]);
	sort(a, a + n);
	un = unique(a, a + n) - a;
	if(un == 2) return printf("%d %d", a[1], a[0]), 0;
	int mid = (mid & 1) ? (a[un - 1] + 1 >> 1) : (a[un - 1] >> 1);
	//cout<<mid<<endl;
	int xa = lower_bound(a, a + un, mid) - a;
	int xb = xa - 1;
	//cout<<xa<<" "<<xb<<" "<<a[xa]<<" "<<a[xb]<<endl;
	if(xb < 0) return printf("%d %d", a[un - 1], a[xa]), 0;
	if(mid - a[xb] < a[xa] - mid) return printf("%d %d", a[un - 1], a[xb]), 0;
	else return printf("%d %d", a[un - 1], a[xa]), 0;
}

/*
6
1 2 3 4 5 6

4
7 9 8 16

3
4 5 7

7
3 5 2 6 8 3 6

10
0 0 0 0 0 0 0 0 0 0 0
*/

Measured memory_bytes: 640
*l,a=$<.map{|t|t.split.map &:to_i}.sort
r=*0...a[0]
l.map{|_,*i|r-=i}
f=->n{n<0?"":a.map{|j|j<1?" #{n}":f[l[n][j]]}*""}
3.times{|i|a=[1,2];a[i,0]=[0];puts %w(Pre In Post)[i]+"order",f[r[0]]}

Measured memory_bytes: 6140
if __name__ == '__main__':
    a = [int(i) for i in input().split()]

    b = [a[0]*a[2],a[0]*a[3],a[1]*a[2],a[1]*a[3] ]
    if ((a[0]<=0 ) and ( 0<=a[1] )  ) or ((a[2] <=0) and (0<=a[3])):
        b.append(0)
    print(max(b))


Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <string>
#include <cmath>

# define PI 3.14159265358979323846

using namespace std;

int main(void) {
    string a, b;
    cin >> a >> b;

    int n = stoi(a + b);
    int sq = sqrt(n);
    if (sq * sq == n)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, A, B = MAP()

ans = A*(N//(A+B))
N -= (A+B)*(N//(A+B))
ans += min(A, N)
print(ans)


Measured memory_bytes: 5256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll = long long; 
using ld = long double;
#define endl "\n"
//#define int long long
#define all(V) V.begin(),V.end()
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
const int MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const int inf = 1 << 25;
constexpr long double pi = 3.141592653589793238462643383279;
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll fact_mod(ll n, ll mod) {
    ll f = 1; for (int i = 2; i <= n; i++) f = f * (i % mod) % mod;
    return f;
}
ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}
ll keta(ll n) {
    if (n == 0) return 1;
    ll count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll mch(ll n) {
    if (n == 1) return 1;
    else return n * mch(n - 1);
}
ll pow_mod(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % mod;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}
ll inv_mod(ll a, ll mod) {
    ll b = mod, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    return u;
}
bool is_prime(const unsigned n) {
    switch (n) {
    case 0: // fall-through
    case 1: return false;
    case 2: // fall-through
    case 3: return true;
    } // n > 3 が保証された
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (unsigned i = 5; i * i <= n; i += 6) {
        if (n % i == 0) return false; // (6の倍数)-1
        if (n % (i + 2) == 0) return false; // (6の倍数)+1
    }
    return true;
}
//関数とか

//宣言とか

/*signed*/int main(void) {
    ll N;
    cin >> N;
    vector<vector<ll>> a(10, vector<ll>(10));
    for (int i = 1; i <= N; i++) {
        int t = i;
        int b = i % 10;
        while (t > 9) t /= 10;
        ++a[t][b];
    }
    ll ans = 0;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            ans += a[i][j] * a[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<ve>      vve;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************

int main(void) {

	//vi A(3);
	//cin >> A;

	//sortall(A);

	//cout << A[2] - A[0] << endl;

	int N;
	cin >> N;
	vi a(N);
	cin >> a;

	ll ans = 0;
	rep(i, N) ans += a[i];
	cout << ans - N << endl;

	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

int compare_array(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return a1.size() - a2.size();
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return a1.at(i) - a2.at(i);
    }
  }
  return 0;
}

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

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int divide_count(int a, int divider) {
  int r = 0;
  while(a % divider == 0) {
    a /= divider;
    r++;
  }
  return r;
}

bool is_prime(int a) {
  int i = 2;
  while(i * i <= a) {
    if(a % i == 0) {
      return false;
    }
    i++;
  }
  return true;
}

int main() {
  std::cout << std::setprecision(9);
  int n;
  cin >> n;

  vector<int> a(n, 0);
  for(int i=0; i<n-1; i++) {
    int a_i;
    cin >> a_i;
    a[a_i - 1]++;
  }

  for(int i=0; i<n; i++) {
    cout << a[i] << endl;
  }
}

Measured memory_bytes: 4048
class UnionFind:
    def __init__(self, N):
        self.parent = [i for i in range(N)]
        self.rank = [0] * N # 最初はそれぞれのノードが誰ともUnionをつくってないから木の深さが０
        self.count = 0 # unite回数
        self.size = [1] * N
    
    # 根を返す
    def root(self, a):
        if self.parent[a] == a:
            return a
        else:
            # 親を見に行く
            self.parent[a] = self.root(self.parent[a])
            return self.parent[a]
    
    # 同じUnionに属するかどうか
    def is_same(self, a, b):
        return self.root(a) == self.root(b)
    
    # 同じUnionにする
    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return 
        if self.rank[ra] < self.rank[rb]:
            self.size[rb] += self.size[ra]
            self.parent[ra] = rb
        else:
            self.size[ra] += self.size[rb]
            self.parent[rb] = ra
            if self.rank[ra] == self.rank[rb]:
                self.rank[ra] += 1
        self.count += 1
    # Unionの構成要素数を返す
    def get_size(self, a):
        return self.size[self.root(a)]

N,M = map(int, input().split())

AB = [tuple(map(int, input().split())) for _ in range(M)]

ans = []


now = N*(N-1) // 2
ans.append(now)

uf = UnionFind(N)
for i in reversed(range(M)):

    if i == 0: break 
    a,b = AB[i]
    a,b = a-1, b-1

    if not uf.is_same(a,b):
        #print(now, uf.get_size(a) , uf.get_size(b), uf.size)
        now -= uf.get_size(a) * uf.get_size(b)
        #print("---", now)
        uf.unite(a,b)
        #uf.root(a)
        #uf.root(b)

    ans.append(now)

for i in reversed(range(len(ans))):
    print(ans[i])

Measured memory_bytes: 117848
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;


#define EPS 1e-8
using namespace std;
struct point{
  double x, y;
};
int sgn(double x)
{
  if (fabs(x) < EPS)
    return 0;
  return x < 0 ? -1 : 1;
}
double get_distance(const point a, const point b)//两点之间的距离
{
  return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}
point get_circle_center(const point a, const point b, const point c)//得到三角形外接圆的圆心
{
  point center;
  double a1 = b.x - a.x;
  double b1 = b.y - a.y;
  double c1 = (a1 * a1 + b1 * b1) / 2.0;
  double a2 = c.x - a.x;
  double b2 = c.y - a.y;
  double c2 = (a2 * a2 + b2 * b2) / 2.0;
  double d = a1 * b2 - a2 * b1;
  center.x = a.x + (c1 * b2 - c2 * b1) / d;
  center.y = a.y + (a1 * c2 - a2 * c1) / d;
  return center;
}
//p表示定点, n表示顶点的个数, c代表最小覆盖圆圆心, r是半径
void min_cover_circle(point *p, int n, point &c, double &r)//找最小覆盖圆(这里没有用全局变量p[], 因为是为了封装一个函数便于调用)
{
  random_shuffle(p, p + n);//随机函数,使用了之后使程序更快点,也可以不用
  c = p[0];
  r = 0;
  for (int i = 1; i < n; i++)
  {
    if (sgn(get_distance(p[i], c) - r) > 0)//如果p[i]在当前圆的外面, 那么以当前点为圆心开始找
    {
      c = p[i];//圆心为当前点
      r = 0;//这时候这个圆只包括他自己.所以半径为0
      for (int j = 0; j < i; j++)//找它之前的所有点
      {
        if (sgn(get_distance(p[j], c) - r) > 0)//如果之前的点有不满足的, 那么就是以这两点为直径的圆
        {
          c.x = (p[i].x + p[j].x) / 2.0;
          c.y = (p[i].y + p[j].y) / 2.0;
          r = get_distance(p[j], c);
          for (int k = 0; k < j; k++)
          {
            if (sgn(get_distance(p[k], c) - r) > 0)//找新作出来的圆之前的点是否还有不满足的, 如果不满足一定就是三个点都在圆上了
            {
              c = get_circle_center(p[i], p[j], p[k]);
              r = get_distance(p[i], c);
            }
          }
        }
      }
    }
  }
}
point p[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  point c; double r;
  while (~scanf("%d", &n) && n)
  {
    for (int i = 0; i < n; i++)
      scanf("%lf %lf", &p[i].x, &p[i].y);
    min_cover_circle(p, n, c, r);
    printf("%.10lf\n", r);
  }
  return 0;
  return 0;
}

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

int main()
{
    int N;
    int A[210];
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    int res=0;
    while (true) {

        bool exist_odd=false;

        for (size_t i = 0; i < N; ++i) {
            if (A[i]%2!=0) exist_odd=true;
        }
        if(exist_odd) break;
        for (size_t i = 0; i < N; ++i) {
            A[i]/=2;
        }
        ++res;
    }
    std::cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(){
    long long R[MAX],n;

    cin >> n;
    for(int i = 0; i < n; i++) cin >> R[i];

    long long maxv = -200000000000;
    long long minv = R[0];

    for(int i = 1;i<n;i++){
        maxv = max(maxv,R[i]-minv);
        minv = min(minv,R[i]);
    }
    cout << maxv << endl;
}


Measured memory_bytes: 4668
import java.util.*;
import java.io.PrintWriter;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		long ts=26;
		int count=0;
		while(n-ts>0){
			count++;
			n-=ts;
			ts*=26;
		}
		StringBuilder ans=new StringBuilder();
		ts/=26;
		n--;
		for(int i=0; i<count+1; i++){
			ans.append((char)('a'+n/ts));
			n%=ts;
			ts/=26;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35624
#include <iostream>
using namespace std;
int main() {
    int i,a,b,c,count;
    cin >> a >> b >> c ;
    count=0;
    for (i=a;i<=b;i++){
        if (c%i==0){
            count++;
        } 
    }
    cout << count <<endl;
    return 0;
}


Measured memory_bytes: 3096
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

K = 20

@njit((i8[:],i8), cache=True)
def build_sp(X, D):
    INF = 1<<60
    N = len(X)
    X = np.append(X, INF)
    sp = np.empty((K,N+1), np.int64)
    sp_sum = np.empty((K,N+1), np.int64)
    sp[0] = np.searchsorted(X, X + D)
    sp[0,-1] = N
    sp_sum[0] = sp[0] # 移動先の座標の和
    for k in range(1, K):
        for n in range(N+1):
            to = sp[k-1,n]
            sp[k][n] = sp[k-1][to]
            sp_sum[k][n] = sp_sum[k-1,n] + sp_sum[k-1,to]
    return sp, sp_sum

@njit((i8[:,:],i8[:,:],i8,i8), cache=True)
def largest_set(sp, sp_sum, l, r):
    # 要素数と座標の和
    ret = [1,l]
    for k in range(K-1, -1, -1):
        # 2^k 進めるなら進む
        if sp[k,l] <= r:
            ret[0] += 1<<k
            ret[1] += sp_sum[k,l]
            l = sp[k,l]
    return ret

@njit((i8[:],i8,i8[:]), cache=True)
def main(X, D, LR):
    N = len(X)
    spl, spl_sum = build_sp(X, D)
    spr, spr_sum = build_sp(-X[::-1], D)
    for i in range(0, len(LR), 2):
        l, r = LR[i:i+2]
        l, r = l-1, r-1
        cl, sl = largest_set(spl, spl_sum, l,r)
        cr, sr = largest_set(spr, spr_sum, N-1-r, N-1-l)
        sr = (N-1)*cr-sr
        print(cl + sr - sl)

N, D = map(int, readline().split())
X = np.array(readline().split(), np.int64)
Q = int(readline())
LR = np.array(read().split(), np.int64)

main(X,D,LR)

Measured memory_bytes: 241468
#include <bits/stdc++.h>
using namespace std;
set<int> s;
int l[1000001] = {0};

int check(int val) {
    for(int i=1;i*i<=val;i++) {
        if(val%i){
            continue;
        }
        if(s.find(i)!=s.end() && val!=1) {
            return 1;
        }
        if(s.find(val/i)!=s.end() && i>1) {
            return 1;
        }
    }
    return 0;
}

int main() {
    int N;
    vector<int> l2;

    scanf("%d", &N);
    for(int i=0;i<N;i++) {
        int buf;
        scanf("%d", &buf);
        l[buf]++;
        l2.push_back(buf);
        s.insert(buf);
    }

    int ans = N;
    for(auto itr=l2.begin();itr!=l2.end();itr++) {
        int b = *itr;
        if(l[b]>1) {
            ans--;
        }
        else {
            ans-=check(b);
        }
    }
    printf("%d\n", ans);
    
    return 0;
}

Measured memory_bytes: 16300
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();
 
        int n = r * 100 + g * 10 + b;
 
        _out.println((n % 4 == 0 ? "YES" : "NO"));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  rep(i,s.size()){
    if(s[i]==',') cout<<" ";
    else cout<<s[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
N, K, C = map(int, input().split())
S = input()

def greedy(A):
    ret = []
    k = i = 0
    while i < N and k < K:
        if A[i] == 'x':
            i += 1
        else:
            ret.append(i)
            k += 1
            i += C+1
    return ret

L = greedy(S)
R = greedy(S[::-1])
R = [N-1-r for r in R][::-1]
for i, l in enumerate(L):
    if R[i] == l:
        print(l+1)


Measured memory_bytes: 29032
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int main()
{
	// freopen("ARC091-C.in", "r", stdin); 
	int n, m; 
	scanf("%d%d", &n, &m); 
	if (n == 1 && m == 1)
		puts("1"); 
	else if (n == 1 || m == 1)
		printf("%d\n", std::max(n, m) - 2);
	else
		printf("%lld\n", (ll)(n - 2) * (m - 2));
	return 0; 
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
typedef unsigned long long ull ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
int num[100]={0};

int main(){
	string str;
	cin>>str;
	int i=0,n=str.size();
	bool flag=true;
	rep(j,10)str+='x';
	//cout<<str<<endl;
	while(i<n){
		//cout<<i<<endl;
		char c=str[i];
		if(c=='d'){
			if(str[i+1]!='r')flag=false;
			i++;
			if(str[i+1]!='e')flag=false;
			i++;
			if(str[i+1]!='a')flag=false;
			i++;
			if(str[i+1]!='m')flag=false;
			i++;
			if(str[i+1]=='e'){
				if(str[i+2]=='r'){
					if(str[i+3]!='a'){
						i+=2;
					}
				}
			}
			i++;
		}else if(c=='e'){
			if(str[i+1]!='r')flag=false;
			i++;
			if(str[i+1]!='a')flag=false;
			i++;
			if(str[i+1]!='s')flag=false;
			i++;
			if(str[i+1]!='e')flag=false;
			i++;
			if(str[i+1]=='r')i++;
			else if(str[i+1]=='e'){
				if(str[i+2]=='r'){
					if(str[i+3]!='a'){
						i+=2;
					}
				}
			}
			i++;
		}else{
			flag=false;
			i=n;
		}
	}
	if(flag)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 512
#include <cstdio>
using namespace std;
int main(void){
  int n,d[3];
  scanf("%d",&n);
  if(n==2){
    scanf("%d %d",&d[0],&d[1]);
    for(int i=1;i<=d[0]&&i<=d[1];i++){
      if(d[0]%i==0&&d[1]%i==0){
	printf("%d\n",i);
      }
    }
  }
  if(n==3){
    scanf("%d %d %d",&d[0],&d[1],&d[2]);
    for(int i=1;i<=d[0]&&i<=d[1]&&i<=d[2];i++){
      if(d[0]%i==0&&d[1]%i==0){
	printf("%d\n",i);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define pb push_back
vector<vector<int>> graph(101010);
int memo[101010];

// グラフを幅優先探索する.
// https://ja.wikipedia.org/wiki/幅優先探索
// ※bfsの動作確認用.
// @param s: 探索開始の頂点番号.
// @param l: 連結成分番号.
// @return: 特に無し.
void bfs(int s, int l){
    
    // 1. 空のキュー.
    queue<int> q;
    
    // 2. 訪問済みフラグ設定.
    memo[s] = l;
    
    // 3. 探索地点 s をキュー q に追加.
    q.push(s);
    
    // 4. キュー q が 空になるまで, 探索.
    while(!q.empty()) {
        
        // 5. 頂点 u を キュー q から取り出す.
        int u = q.front();
        q.pop();
        
        // 6. 取り出した要素を処理.
        for(auto &e : graph[u]){
            // 7. 頂点u の 隣接する頂点e が, 未訪問だったら, キュー q に追加.
            if(memo[e] == 0 && e != s){
                // 頂点e を キュー q に追加.
                q.push(e);
                // 頂点e を 訪問済みに設定.
                memo[e] = l;
            }
        }
    }
}

int main(){
    
    // 1. 入力情報.
    int N, M;
    scanf("%d %d", &N, &M);
    rep(i, M){
        int a, b;
        scanf("%d %d", &a, &b);
        a--, b--;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    
    // 2. グラフを連結成分に分割.
    int l = 1;
    rep(i, N) if(memo[i] == 0) bfs(i, l), l++;
    // rep(i, N) printf("%d ", memo[i]);
    // puts("");
    
    // 3. 連結成分の情報を整理.
    // 3-1. 頂点1, 2, それ以外の頂点について, 連結している頂点数を確認.
    LL one = 0, two = 0, other = 0;
    rep(i, N){
        if(memo[i] == 1) one++;
        if(memo[i] == 2) two++;
        if(memo[i] >= 3) other++;
    }
    
    // 3-2. 頂点1, 2 の中で, 連結している頂点数が多い方に, 
    // 残りの頂点をマージ.
    if(one >= two) one += other;
    else           two += other;
    
    // 4. 最大で何本の辺を付け足せるか？
    // ※ int -> LL に 修正.
    LL ans = 0;
    ans += one * (one - 1) / 2;
    ans += two * (two - 1) / 2;
    ans -= M;
    
    // 5. 出力.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 6272