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

int main() {
    int ans = 0;
    for (int i = 0; i < 4; i++){
        char s;
        cin >> s;
        if (s == '+') {
            ans++;
        }
        else{
            ans--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, count = 0;
  cin >> A >> B;
  for (int i = 0; i < B - A + 1; i++) {
    int num = A + i;
    int num_sub = num - num / 10000 * 10000;  
    if (num / 10000 == num % 10  && num_sub / 1000 == num_sub % 100 / 10) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int l;
  scanf("%d",&l);
  int i,j,t,min=10001,num[l],sum=0;
  for(i=0;i<l;i++){
    scanf("%d",&num[i]);
  }
  for(i=0;i<l;i++){
    sum=0;
    for(j=0;j<l;j++){
      if(j<i){
        sum+=num[j];
      }else{
        sum-=num[j];
      }
    }
    if(sum<0){
      sum*=(-1);
    }
    if(sum<min){
      min=sum;
    }
  }
  printf("%d",min);
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  vector<int> a(n), b(n), c(n - 1);
  int ans = 0;
  for(int i = 0; i < n; i++) cin >> a.at(i);
  for(int i = 0; i < n; i++){
    cin >> b.at(i);
    ans += b.at(i);
  }
  for(int i = 0; i < n - 1; i++) cin >> c.at(i);
  
  for(int i = 0; i < n - 1; i++){
    if(a.at(i) + 1 == a.at(i + 1)) ans += c.at(a.at(i) - 1);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;
     
int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector <bool> solved(n + 1, false);
  vector <int> cnt(n + 1, 0);
  int penalty = 0;
  for (int i = 0; i < m; i++) {
    int p;
    string veredict;
    cin >> p >> veredict;
    if (solved[p]) continue;
    if (veredict == "AC") {
      penalty += cnt[p];
      solved[p] = true;
    } else {
      cnt[p]++;
    }
  }
  int cnt_solved = 0;
  for (int i = 1; i <= n; i++) cnt_solved += solved[i];
  cout << cnt_solved << ' ' << penalty << '\n';
  return (0);
}


Measured memory_bytes: 640
def floor_sum(n, m, a, b):
    res = 0
    if b >= m:
        res += n * (b // m)
        b %= m
    while True:
        if a >= m:
            res += (n - 1) * n * (a // m) // 2
            a %= m
        y_max = (a * n + b) // m
        if y_max == 0: break
        x_max = b - y_max * m
        res += (n + x_max // a) * y_max
        n, m, a, b = y_max, a, m, x_max % a
    return res


import sys
input = sys.stdin.readline

for i in range(int(input())):
    n, m, a, b = map(int, input().split())
    print(floor_sum(n, m, a, b))

Measured memory_bytes: 70716
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll A,B,C,D;
  cin>>A>>B>>C>>D;
  if(A+B==C+D) {
    cout<<"Balanced"<<endl;
  }
  else if(A+B>C+D) {
cout<<"Left"<<endl;
  }
else {
cout<<"Right"<<endl;
}
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int c=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(a[i]!=a[j] && a[j]!=a[k] && a[i]+a[j]>a[k]){
                c++;
                }
            }
        }
    }
   cout<<c;
}


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(2e3) + 17;

int n, k;
ll ans;
const ll MOD = 924844033;
ll dp[MAXN][MAXN][3];
ll g[MAXN];
ll f[2][MAXN];

bool read() {
    if (!(cin >> n >> k))
        return false;

    return true;
}

ll add(ll a, ll b) { return ((a += b) >= MOD) ? a - MOD : a; }

ll getfac(int i) {
    ll fac = 1;

    if (i != n)
        fac = (n - i) * getfac(i + 1) % MOD;

    ll res = fac * f[min(n, 2 * k) & 1][i] % MOD;

    if (i & 1)
        res = add(MOD, -res);

    ans = add(ans, res);
    return fac;
}

void solve() {
    f[0][0] = 1;

    for (int a = 1; a <= min(n, 2 * k); ++a) {
        int nn = (n - a) / (2 * k);
        dp[0][0][0] = dp[0][1][2] = 1;

        if (a > k)
            dp[0][1][1] = 1;

        for (int i = 1; i <= nn; ++i) {
            dp[i][0][1] = dp[i][0][2] = 0;
            dp[i][0][0] = dp[i - 1][0][0];

            for (int k = 1; k <= nn + 1; ++k) {
                dp[i][k][0] = add(dp[i - 1][k][0], add(dp[i - 1][k][1], dp[i - 1][k][2]));
                dp[i][k][1] = add(dp[i - 1][k - 1][0], dp[i - 1][k - 1][1]);
                dp[i][k][2] = add(dp[i - 1][k - 1][0], add(dp[i - 1][k - 1][1], dp[i - 1][k - 1][2]));
            }
        }

        for (int s = 0; s <= nn + 1; ++s) {
            g[s] = add(dp[nn][s][0], dp[nn][s][1]);

            if (a + k * (2 * nn + 1) <= n)
                g[s] = add(g[s], dp[nn][s][2]);
        }

        for (int s = 0; s <= n; ++s) {
            f[a & 1][s] = 0;

            for (int j = 0; j <= nn + 1 && j <= s; ++j)
                f[a & 1][s] = add(f[a & 1][s], g[j] * f[a & 1 ^ 1][s - j] % MOD);
        }
    }

    getfac(0);
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
#ifdef SEREZHKA
    freopen("file.in", "r", stdin);
#endif
    
    while (read())
        solve();
    
    return 0;
}



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

int main(){
    int N; cin >> N;
    vector<string> S(N); for(int i = 0; i < N; ++i) cin >> S[i];

    int cnt = 1;
    int rep_cnt = 0;
    int max_n = 0;
    vector<pair<string, int>> a(N);

    sort(S.begin(), S.end());

    for(int i = 1; i < N; ++i) {
        if(i == N - 1) {
            if(S.at(i - 1) == S.at(i)) {
                cnt++;
                a[rep_cnt] = make_pair(S.at(i - 1), cnt);
                rep_cnt++;
            } else {
                a[rep_cnt] = make_pair(S.at(i - 1), cnt);
                rep_cnt++;
                a[rep_cnt] = make_pair(S.at(i), 1);
                rep_cnt++;
            }
            if(max_n < cnt) {
                max_n = cnt;
            }
        } else {
            if(S.at(i - 1) == S.at(i)) {
                cnt++;
            } else {
                a[rep_cnt] = make_pair(S.at(i - 1), cnt);
                rep_cnt++;
                if(max_n < cnt) {
                    max_n = cnt;
                }
                cnt = 1;
            }
        }
    }

    for(int i = 0; i < rep_cnt; ++i) {
        if(a[i].second == max_n) {
            cout << a[i].first << endl;
        }
    }
}

Measured memory_bytes: 17408
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 7+1e18
#define lld long double
#define eps 0.000001
#define endl '\n'
using namespace std ;
 
int gcd(int a, int b)
{
    if (a == 0)   return b;
    if(b==0)      return a;
    if (a == b)   return a;
    if (a > b)    return gcd(a%b, b);
    return gcd(a, b%a);
}
 
/*seive
 int d[302]={0};
 int l=300;
  for(int i=2;i<l;i++)
		if(d[i]==0)
			for(int j=i;j<=l;j+=i)
				d[j]=d[j/i]+1;
 
 
  loop(i,1,301) cout<<i<<" "<<d[i]<<endl;
*/
bool vis[2005]={false};
int conn=0;
vector<int> v[2005];
void dfs(int q) 
{
	vis[q] = 1;
	
	for(int i=0;i<v[q].size() ;i++)
		if (!vis[v[q][i]])
			dfs(v[q][i]);
    
} 
 
/*lli power(lli x, lli y, lli p)
{
    lli res = 1;  
 
    x = x % p;  
    
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
 
        y = y>>1; 
		x = (x*x) % p;  
    }
    return res;
}*/
int main()
{
	////////////////////
	fastio;
	///////////////////
	
	lli a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[1]-a[0] + a[2]-a[1]<<endl;
	
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n, t, u;
	int[][] a, b;
	int ans;

	void run(){
		t=10;
		u=5;
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			a=new int[u][n];
			for(int j=0; j<u; j++){
				String s=sc.next();
				for(int i=0; i<n; i++){
					a[j][i]=s.charAt(i)=='.'?0:1;
				}
			}
			solve();
		}
	}

	void rec(int k, int p){
		if(p>=ans){
			return;
		}
		if(k==t+1){
			ans=min(ans, p+n-1);
			return;
		}
		for(int q=p; q<p+n; q++){
			boolean f=true;
			for(int j=0; j<u; j++){
				for(int i=0; i<n; i++){
					f&=a[j][i]==0||b[j][q+i]==0;
				}
			}
			if(f){
				for(int j=0; j<u; j++){
					for(int i=0; i<n; i++){
						if(a[j][i]==1){
							b[j][q+i]=k;
						}
					}
				}
				rec(k+1, q+1);
				for(int j=0; j<u; j++){
					for(int i=0; i<n; i++){
						if(a[j][i]==1){
							b[j][q+i]=0;
						}
					}
				}
			}
		}
	}

	void solve(){
		ans=INF;
		b=new int[u][(n+1)*(t+1)];
		rec(1, 0);
		println(""+ans);
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
  int n,m,a[10000];
  int s=0;
  scanf("%d %d",&n,&m);
  long int i;
  for(i=0;i<n;i++)
  {
    scanf("%d ",&a[i]);
    s=s+a[i];
  }
  
  
  int p,s1=0;
  p=ceil(1.0*s/(4*m));
  for(i=0;i<n;i++)
  {
    if(a[i]>=p)
    {
      s1=s1+1;
    }
  }
  
  if(s1>=m)
  {
    printf("Yes");
  }
    
  if(s1<m)
    printf("No");
  
}

Measured memory_bytes: 128
N,K=map(int, input().split())
sushi=sorted([tuple(map(int, input().split())) for _ in range(N)], key=lambda x: x[1], reverse=True)

typ = set()
ans = 0
cur = 0
rem = []

for t,d in sushi:
	if t in typ:
		if K > 0:
			K -= 1
			cur += d
			rem.append(d)
	else:
		typ.add(t)
		cur += d
		if K > 0:
			K -= 1
		elif len(rem):
			cur -= rem.pop()
		else:
			break

	ans = max(ans, cur + len(typ)**2)

print(ans)


Measured memory_bytes: 66520
<?php
  $s = trim(fgets(STDIN));
  $k = trim(fgets(STDIN));
  $f = $s[0];
  $i = 0;
  while($f == 1){
      $i++;
      $f = $s[$i];
  }
  if($i >= $k) echo 1;
  else echo $f;
  

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




    int main(){
        int n;
        double ans = 0.0, a;
        std::cin >> n;
        for (int i = 1; i <= n; ++i)
        {
            std::cin >> a;
            ans += 1.0 / a;
        }
        ans = 1.0 / ans;
        std::cout << setprecision(16) << ans << "\n";
    }


Measured memory_bytes: 256
def mapt(fn, *args):
    return tuple(map(fn, *args))

def main():
    n = int(input())
    x = mapt(int, input().split(" "))
    ans = float("inf")
    for p in range(1, 101):
        r = 0
        for xj in x:
            r += (xj-(p))**2
        ans = min(ans, r)
    print(ans)

main()

Measured memory_bytes: 9160
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 100000
#define M_INF 1000000000
int n,m,v,i,k;

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

void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;
  std::vector<ll> v(n);
  int l ;
  rep(i,n) cin>>v[i];
  rep(i,n){
    l = gcd(l,v[i]);
  }
  rep(i,n){
    if(k%l==v[i]%l &&  v[i] >= k){
      cout<<"POSSIBLE"<<endl;
      return;
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
}

int main(){
  solve();
  return 0;
}


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

int main(int argc, char const *argv[])
{

    long n, k;
    cin >> n >> k;
    vector<long> vec(n);
    vector<long> houmon(n, -1);
    long temp;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        vec.at(i) = temp - 1;
    }
    long a = 0;
    long c = 0;
    long index1;
    long index2;
    bool flag = false;
    for (long i = 0; i < k; i++)
    {
        // cout << (a + 1) << endl;
        if (houmon.at(a) != -1)
        {
            index1 = i;
            index2 = houmon.at(a);
            flag = true;
            break;
        }
        else
        {
            houmon.at(a) = i;
        }
        a = vec.at(a);
    }
    if (flag)
    {
        long sa = index1 - index2;
        k -= index1;
        k %= sa;
        for (long i = 0; i < k; i++)
        {
            a = vec.at(a);
        }
    }
    cout << (a + 1) << endl;
    return 0;
}


Measured memory_bytes: 6432
#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 ff              first
#define ss              second
#define ll              int64_t
#define ld              long double
#define nl              cout<<"\n"
#define all(v)          v.begin(),v.end()
#define mset(a,v)       memset((a),(v),sizeof(a))
#define forn(i,a,b)     for(int64_t i=int64_t(a);i<int64_t(b);++i)
#define forb(i,a,b)     for(int64_t i=int64_t(a);i>=int64_t(b);--i)
#define fastio()        ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> 

#define mod         1000000007
#define mod2        998244353 
#define inf         1000000000000007
#define pi          3.14159265358979323846

template<class L,class R> ostream& operator<<(ostream& out,pair<L,R> &p)        {return out<<"("<<p.ff<<", "<<p.ss<<")";}
template<class T> ostream& operator<<(ostream& out,vector<T> &v)                {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,deque<T> &v)                 {out<<"[";for(auto it=v.begin();it!=v.end();++it){if(it!=v.begin())out<<", ";out<<*it;}return out<<"]";}
template<class T> ostream& operator<<(ostream& out,set<T> &s)                   {out<<"{";for(auto it=s.begin();it!=s.end();++it){if(it!=s.begin())out<<", ";out<<*it;}return out<<"}";}
template<class L,class R> ostream& operator<<(ostream& out,map<L,R> &m)         {out<<"{";for(auto it=m.begin();it!=m.end();++it){if(it!=m.begin())out<<", ";out<<*it;}return out<<"}";}

void dbg_out() {cerr<<"]\n";}
template<typename Head,typename... Tail> 
void dbg_out(Head H,Tail... T) {cerr<<H;if(sizeof...(Tail))cerr<<", ";dbg_out(T...);}
#ifdef LOCAL
	#define dbg(...) cerr<<"["<<#__VA_ARGS__<<"] = [",dbg_out(__VA_ARGS__)
#else
	#define dbg(...)
#endif

ll count_digits(ll n)   {ll dig=floor(log10(n)+1);return dig;}
ll mpow(ll x,ll y,ll p) {ll r=1;x=x%p;while(y>0){if(y&1)r=(r*x)%p;y=y>>1;x=(x*x)%p;}return r;} 
ll mod_inv(ll a,ll m)   {ll m0=m,y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;} 
/* const ll MAXN=1000007;ll spf[MAXN+5];vector<ll> prime; */
/* void sieve(ll n)        {forn(i,2,MAXN+1)spf[i]=i;for(ll i=2;i*i<=n;i++)if(spf[i]==i)for(ll j=i*i;j<=n;j+=i)if(spf[j]==j)spf[j]=i;forn(i,2,MAXN+1)if(spf[i]==i)prime.push_back(i);} */

//-------------------------------L_I_Erq34-------------------------------

int main()
{
	fastio();
	ll z,n,m,t,k,i,j,l,d,h,r;
	string s;
	cin>>s;
	ll res=0;
	for(char ch:s)
		res=(res+(ch-'0'))%9;
	if(res)
		cout<<"No\n";
	else
		cout<<"Yes\n";
	cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms\n";
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> d(N);
    REP(i, N) cin >> d[i];
    sort(d.begin(), d.end());
    cout << max(d[N/2]-d[N/2-1], 0ll) << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N,D=LI()

print(N//(2*D+1)+(1 if N%(2*D+1) else 0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, a, b) for (int i = (a); i < (int)(b); i++)
typedef vector<int> VI;
typedef vector<VI> VVI;

int Main(string s)
{
    int S = s.size();
    int counter = 0;
    int mid = S/2;
    if(S%2) { // S is odd
        for(int i = 1; i <= mid; i++) {
            if(s[mid+i] != s[mid-i]) counter++;
        }
    }
    else { // S is even
        for(int i = 0; i < mid; i++) {
            if(s[mid+i] != s[mid-i-1]) counter++;
        }
    }
    return counter;
}

int main(void){
    string s;
    cin >> s;
    cout << Main(s) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

  cout << (b + c) - max(c - 1 - a - b, 0LL) << endl;

  return 0;
} 


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

using namespace std;

int main()
{
    int n, i, a[100000], b[100000], z=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&b[i]);
    }
    for(i=0;i<n;i++)
    {
        if(a[i]>b[i])
            z=z+a[i]-b[i];
    }
    printf("%d\n",z);
    return 0;
}


Measured memory_bytes: 256
#C
import itertools
N,M,Q=map(int,input().split())
X=[[int(x) for x in input().split()] for i in range(Q)]
IN=[int(i) for i in range(1,M+1)]
Max=0
for com in itertools.combinations_with_replacement(IN, N):
    Sum=0
    for i in range(Q):
        a=int(X[i][0])-1
        b=int(X[i][1])-1
        c=int(X[i][2])
        d=int(X[i][3])
        if com[b]-com[a]==c:
            Sum+=d
    Max=max(Max,Sum)
print(Max)

Measured memory_bytes: 68172
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	long long sum=1,mod=1000000007,sum1=1,sum2=1;
	cin>>n>>m;
	if(abs(n-m)>=2)
	{
		cout<<0<<endl;
	    return 0;
	}	
	for(int i=1;i<=min(n,m);i++)
	sum=sum*i%mod;
	for(int i=1;i<=max(n,m);i++)
	sum1=sum1*i%mod;	
	sum2=sum1%mod*sum%mod;
	if(abs(n-m)==1)
	cout<<sum2%mod<<endl;
	if(n==m)
	cout<<sum2*2%mod<<endl;
	return 0;
}

Measured memory_bytes: 256
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad
import Data.Foldable
import Data.Char
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    n <- readLn :: IO Int
    as <- r'
    let av = U.fromList as
    let ocMap = IM.fromListWith (+) (map (\x->(x,1)) as)
    let norm = IM.foldr' (\a b -> f a + b) 0 ocMap
    forM_ [0..n-1] (\m ->
            print $ solve (ocMap IM.!(av U.! m)) norm
        )


solve idx norm = norm - f idx + f (max 0 (idx-1))

f :: Int -> Int
f n = div (n*(n-1)) 2



Measured memory_bytes: 48252
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <string.h>

#define testin freopen("1.txt","r",stdin);
#define testout freopen("out.txt","w",stdout);
#define ll long long

#define yes "Yes\n"
#define no "No\n"

using namespace std;

const int maxn=(int)1e5+10;

int a[maxn];

int main(){
    int n;
    cin>>n>>a[0];
    a[0]--;
    for(int i=1;i<n;i++){
        scanf("%d",a+i);
        if(a[i]<a[i-1]){
            cout<<no;
            return 0;
        }else if(a[i]>a[i-1]){
            a[i]--;
        }
    }
    cout<<yes;
    return 0;
}


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

const int MAX_K = 500001;
int n;
pair<int, int> o[MAX_K], e[MAX_K];

int main(){
  cin >> n;
  rep(i, MAX_K){
    o[i].first = e[i].first = n / 2;
    o[i].second = e[i].second = i;
  }
  rep(i, n){
    int tmp; cin >> tmp;
    if(i % 2 == 0){
      e[tmp].first--;
    }else{
      o[tmp].first--;
    }
  }
  sort(e, e + MAX_K); //reverse(e, e + 50001);
  sort(o, o + MAX_K); //reverse(o, o + 50001);
  //rep(i, n / 2)cerr << e[i].first << "-" << e[i].second <<" " <<o[i].first <<"-" <<o[i].second<<endl;
  
  int res;
  if(o[0].second == e[0].second){
    res = min(o[0].first + e[1].first, o[1].first + e[0].first);
  }else{
    res = o[0].first + e[0].first;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 8192
#include <iostream>
using namespace std;
#define loop(i,n) for(int i=1;i<=n;i++)

int a[102];
int b[102][102];
int s[102];

int main(){
  int n,m;
  cin>>n>>m;
  loop(i,m)cin>>a[i];
  loop(i,m)loop(j,n)cin>>b[i][j];
  loop(i,n)s[i]=0;

  loop(i,m){
    int tar=a[i];
    int x=0;
    loop(j,n){
      if(b[i][j]==tar){
        s[j]++;
      }else{
        x++;
      }
    }
    s[tar]+=x;
  }

  loop(i,n)cout<<s[i]<<endl;
  return 0;
}

Measured memory_bytes: 3136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();

			int a = vs[0];
			int b = vs[1];

			if (b % a == 0) {
				Console.WriteLine(a + b);
			} else {
				Console.WriteLine(b - a);
			}

		}
	}
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  int s=1<<n;
  vector<int> ss(s);
  for(int i=0;i<s;i++) cin>>ss[i],ss[i]*=-1;

  multiset<int> ms(ss.begin(),ss.end());

  int x=*ms.begin();
  ms.erase(ms.begin());

  multiset<int> cs;
  cs.emplace(x);
  for(int i=0;i<n;i++){
    multiset<int> nx;
    for(int c:cs){
      auto it=ms.upper_bound(c);
      if(it==ms.end()) drop("No");
      nx.emplace(*it);
      ms.erase(it);
    }
    for(int v:nx)
      cs.emplace(v);
  }

  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
 
using namespace std;

/**************************************************************************/
int main()
{
	fastIO;
	ll n,m,q,i,j,k,p,dp[501][501];
	vector < ll > v[501];
	cin>>n>>m>>q;
	fo(i,m)
	{
		cin>>j>>k;
		v[j].pb(k-j+1);
	}
	Fo(i,1,n+1)sort(v[i].begin(),v[i].end());
	Fo(i,1,n+1)
	{
		Fo(j,i,n+1)
		{
			ll temp = 0;
			Fo(k,i,j+1)
			{
				ll len = j - k + 1;
				ll st = 0, ed = v[k].size() - 1, mn = -1; 
				while(st<=ed)
				{
					ll md = st + ( ed - st ) / 2;
					if(v[k][md]<=len)
					{
						mn = md;
						st = md + 1;
					}
					else ed = md - 1;
				}
				//cout<<i<<" "<<j<<" "<<k<<" "<<mn<<endl;
				if(mn==-1)continue;
				else temp += mn + 1;
			}
			dp[i][j] = temp;
		}
	}
	while(q--)
	{
		cin>>i>>j;
		cout<<dp[i][j]<<endl;
	}

}/*************************************************************************/ 

Measured memory_bytes: 5376
#include <iostream>
#include <math.h>
#include <limits.h>
#include<cstdio>
using namespace std;

int n;
int a[101];

int main(void)
{
    cin >> n;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int count = 0;

    // selection sort
    for(int i=0;i<n;i++){
        int minj = i;
        for(int j=i;j<n;j++){
            if(a[j] < a[minj]){
                minj = j;
            }
        }
        if(minj != i){
            swap(a[i], a[minj]);
            count++;
        }
    }

    for(int i=0;i<n;i++){
        cout << a[i];
        if(i != n-1) cout << " ";
    }
    cout << endl << count << endl;
    
    return 0;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint ungigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking 
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1<<29)
using namespace std;
const int mo=1000000007;
const int N=605;
int n,k,ans;
int a[N],b[N];
int f[N],ban[N];
int val[N][N];
int g[N][N];
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=k;i++){
		scanf("%d%d",&a[i],&b[i]);
		ban[a[i]]=b[i]; ban[b[i]]=a[i];
	}
	f[0]=1;
	for (int i=2;i<=2*n;i+=2) f[i]=1ll*f[i-2]*(i-1)%mo;
	ans=f[2*(n-k)];
	for (int i=1;i<=2*n;i++)
		for (int j=i+1;j<=2*n;j++){
			bool fl=0;
			for (int p=1;p<=k;p++)
				if ((i<a[p]&&a[p]<=j)^(i<b[p]&&b[p]<=j)){
					fl=1; break;
				}
			if (fl) continue;
			int cnt0=0;
			for (int p=i+1;p<=j;p++) cnt0+=(!ban[p]);
			if (cnt0&1) continue;
			g[i][j]=val[i][j]=f[cnt0];
		}
	for (int i=2*n;i>=1;i--)
		for (int j=i+1;j<=2*n;j++)
			for (int k=j+1;k<=2*n;k++)
				g[i][k]=(g[i][k]+mo-1ll*val[i][j]*g[j][k]%mo)%mo;
	for (int i=1;i<=2*n;i++)
		for (int j=i+1;j<=2*n;j++){
			int sum=0;
			for (int k=j%(2*n)+1;;k=k%(2*n)+1){
				sum+=!ban[k];
				if (k==i) break;
			}
			ans=(ans+1ll*f[sum]*g[i][j])%mo; 
		}
	printf("%d",ans);
}


Measured memory_bytes: 3072
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  [a,b] <- readInts
  print . showAnswer $ solve (a,b)

type Input  = (Int, Int)
type Output = Bool

solve :: Input -> Output
solve (a,b) = a <=8 && b <= 8

showAnswer :: Output -> Answer
showAnswer = String . bool ":(" "Yay!"

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int H, W;
    cin >> H >> W;
    cout << string(W + 2, '#') << endl;
    FOR(i, 0, H) {
        string s;
        cin >> s;
        cout << "#" << s << "#" << endl;
    }
    cout << string(W + 2, '#') << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int D, T, S;

    scanf("%d %d %d", &D, &T, &S);

    float time = (float)D/S;

    if(time <= T) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 1664
import java.util.Stack

fun main(args: Array<String>) {
    val (n, q) = readLine()!!.split(" ").map(String::toInt)
    val g = run {
        val g = Array<MutableList<Int>>(n + 1) { mutableListOf() }
        repeat(n - 1) {
            val (a, b) = readLine()!!.split(" ").map(String::toInt)
            g[a].add(b)
            g[b].add(a)
        }
        g
    }

    val result = Array<Int>(n + 1) { 0 }

    repeat(q) {
        val (p, x) = readLine()!!.split(" ").map(String::toInt)
        result[p] += x
    }

    val stack = Stack<Int>()
    val isDone = Array<Boolean>(n + 1) { false }
    stack.add(1)

    while (stack.isNotEmpty()) {
        val node = stack.pop()
        isDone[node] = true

        for (child in g[node]) {
            if (!isDone[child]) {
                result[child] += result[node]
                stack.push(child)
            }
        }
    }

    for (i in 1 until g.size) {
        print("${result[i]} ")
    }
}

Measured memory_bytes: 153232
#include <stdio.h>
#include <math.h>

#define INF (int)2e9
int count2;
void merge(int *A, int left, int mid, int right)
{
    int n1,n2;
    int L[250010],R[250010];
    int i,j,k;

    n1 = mid - left;
    n2 = right - mid;
    for (i = 0; i < n1; ++i) {
        L[i] = A[left + i];
    }
    for (i = 0; i < n2; ++i) {
        R[i] = A[mid + i];
    }
    L[n1] = INF;
    R[n2] = INF;
    i = 0;
    j = 0;

    for (k = left; k < right; k++) {
        if (L[i] <= R[j]) {
            A[k] = L[i];
            ++i;
        }
        else {
            A[k] = R[j];
            ++j;
        }
        count2++;
    }
}

void mergeSort(int *A, int left, int right)
{
    int mid;

    if (left + 1  < right) {
        mid = (left + right)/2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {

    int n;
    int S[500010];
    int i;


    scanf("%d", &n);
    for (i = 0; i < n; ++i){
        scanf("%d", &S[i]);
    }

    mergeSort(S, 0, n);
    for (i = 0; i < n-1; ++i) {
        printf("%d ", S[i]);
    }
    printf("%d\n", S[n-1]);
    printf("%d\n",count2);

    return 0;
}


Measured memory_bytes: 5696
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int[] days = new int[4];
        for(int i = 0; i < 4; i++){
            days[i] = sc.nextInt();
        }
        System.out.println(days[0] != days[2] ? 1 : 0);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);++i)
#define fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  int n;
  cin>>n;
  vector<int>l(n);
  rep(i,n){
    cin>>l[i];
  }
  l.push_back(INF);
  sort(l.begin(),l.end());

  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      int idx=lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin();
      ans+=idx-j-1;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main(){
	cin>>a>>b>>c;
	for(register int i=1;i<=b;i++){
		int y=b*i+c;
		if(y%a==0){
			cout<<"YES"<<endl;
			return 0;
		}
	}
	cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> Pi;
const ll inf = 1e18 + 1;
const ll limit = 1e9;

int main() {
    int n; cin >> n;
    map<string,int> mp;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        mp[s]++;
    }
    cout << mp.size() << "\n";
}   
 

Measured memory_bytes: 19188
import sys
import time
import math
st = time.perf_counter()
def inpl():
    return list(map(int, input().split()))
# ------------------------------

N = int(input())
A = inpl()

A.sort()
A.reverse()

ans = 0
N -= 1
for i in range(len(A)):
	if i == 0: t = 1
	else : t = 2
	for _ in range(t):
		ans += A[i]
		N -= 1
		if N == 0:
			break
	if N == 0:
		break

print(ans)


# ------------------------------
ed = time.perf_counter()
print('time:', ed-st, file=sys.stderr)


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

int main() {
  int n;
  cin>>n;
  int a[n+1];
  for (int i=1; i<=n; i++) cin>>a[i];
  int b[n+1];
  vector<int> b_vec;
  for (int i=0; i<=n; i++) b[i] = 0;
  for (int i=n; i>0; i--) {
    int b_sum = 0;
    for (int j=i; j<=n; j+=i) {
      b_sum += b[j];
    }
    if (a[i] == 1 && b_sum % 2 == 1) {
      continue;
    } else if (a[i] == 0 && b_sum % 2 == 0) {
      continue;
    }
    b[i] = 1;
    b_vec.push_back(i);
  }
  reverse(b_vec.begin(), b_vec.end());
  cout<<b_vec.size()<<endl;
  if (b_vec.size() == 0) {
    return 0;
  }
  for (int i=0; i<b_vec.size(); i++) {
    if (i == 0) {
      printf("%d", b_vec[i]);
    } else {
      printf(" %d", b_vec[i]);
    }
  }
  cout<<endl;

}

Measured memory_bytes: 3064
import numpy as np

n, d = (int(i) for i in input().split())
X = [[int(ii) for ii in input().split()] for i in range(n)]
X = np.array(X)

count = 0
for i in range(X.shape[0]):
    for ii in range(X.shape[0]):
        if i == ii:
            continue
        if float.is_integer(np.linalg.norm(X[i] - X[ii])):
            count += 1

print(count // 2)


Measured memory_bytes: 12432
#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>;

const int INF = 1001001001;
vector<int> to[100005];

int main() {
  int s, w;
  cin >> s >> w;
  
  if(w >= s) cout << "unsafe" << endl;
  else cout << "safe" << endl;
  
  return 0;
}

Measured memory_bytes: 5932
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char c;
int now,f[67109000];
int main() {
	c=getchar();
	for (int i=1;i<67109000;i++)
	f[i]=1000000;
	f[0]=0; now=0;
	while (c>='a'&&c<='z') {
		int w=c-'a';
		now=now^(1<<w);
		//f[now]++;
		for (int i=0;i<26;i++)
		f[now]=min(f[now],f[now^(1<<i)]+1);
		//printf("%d %d\n",now,f[now]);
		c=getchar();
	}
	printf("%d\n",max(f[now],1));
	return 0;
}

Measured memory_bytes: 262400
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列

    s=input()
    ans=0
    cnt=0
    for i in range(3):
        si=s[i]
        if si=="S":
            cnt=0
        else:
            cnt+=1
            ans=max(ans,cnt)
    print(ans)





if __name__ == "__main__":
    main()

Measured memory_bytes: 72736
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    int a,b,c,d;

    cin >> a >> b >> c >> d;

    if(a * b > c * d){
        cout << a * b << endl;
    }
    else {
        cout << c * d << endl;
    }
    
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
#include <unordered_set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1000000 + 10;
const int mod = 1000000007;
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    IOS
    LL a, b;
    cin >> a >> b;
    if(a%b==0){
        cout << -1 << endl;
    }else{
        for(LL i = a;;i+=a){
            if(i%b!=0){
                cout << i << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

long long cnt,ans2;
int n,x,y,hd[110],d[110],dma[110],de,ans1;
struct node{int to,next;}e[210];

void addedge(int x,int y)
{
	e[++cnt]=(node){y,hd[x]},hd[x]=cnt;
	e[++cnt]=(node){x,hd[y]},hd[y]=cnt;
}

void dfs(int x,int fa,int dep)
{
	de=max(de,dep),dma[dep]=max(dma[dep],d[x]-(fa!=0));
	for (int i=hd[x]; i; i=e[i].next)
		if (e[i].to!=fa) dfs(e[i].to,x,dep+1);
}

int main()
{
	scanf("%d",&n),ans1=n+1,cnt=1;
	for (int i=1; i<n; i++) scanf("%d%d",&x,&y),addedge(x,y),d[x]++,d[y]++;
	for (int i=1; i<=n; i++) 
	{
		de=0,memset(dma,0,sizeof(dma)),dfs(i,0,1);
		if (de<=ans1)
		{
			cnt=1;
			for (int j=1; j<de; j++) cnt*=dma[j];
			if (de<ans1||cnt<ans2) ans1=de,ans2=cnt;
		}
	}
	for (int i=2; i<2*n; i+=2)
	{
		de=0,memset(dma,0,sizeof(dma));
		dfs(e[i].to,e[i^1].to,1),dfs(e[i^1].to,e[i].to,1);
		if (de<=ans1)
		{
			cnt=2;
			for (int j=1; j<de; j++) cnt*=dma[j];
			if (de<ans1||cnt<ans2) ans1=de,ans2=cnt;
		}
	}
	printf("%d %lld\n",ans1,ans2);
	return 0;
}

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

signed main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N)cin>>A[i];
  int H=A[0];
  int co=0;
  rep(i,N){
    if(H<=A[i]){
      co++;
      H=A[i];
    }
  }
  cout<<co<<endl;
}

Measured memory_bytes: 256
#-swank
(unless (member :child-sbcl *features*)
  (quit
	:unix-status
	(process-exit-code
	  (run-program *runtime-pathname*
				   `("--control-stack-size" "128MB"
					 "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
					 "--eval" "(push :child-sbcl *features*)"
					 "--script" ,(namestring *load-pathname*))
				   :output t :error t :input t))))

(let ((n (read)))
  (princ (loop repeat n sum (- 1 (- (read) (read))))))


Measured memory_bytes: 18356
#include <iostream>
using namespace std;
int main() {
  int n, S[100000], q, T, C, i, j, m;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> S[i];
  }
  cin >> q;
  C = 0;
  while (q--) {
    cin >> T;
    i = 0;
    j = n;
    while (i < j) {
      m = (i + j) / 2;
      if (S[m] == T) {
        C++;
        break;
      } else if (S[m] > T) {
        j = m;
      } else {
        i = m + 1;
      }
    }
  }
  cout << C << endl;
  return 0;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
int n,t,ans[200005];
int main() {
    scanf("%d",&n);
    for(int i=2;i<=n;i++) {
        scanf("%d",&t);
        ans[t]++;
    }
    for(int i=1;i<=n;i++) printf("%d ",ans[i]);
    return 0;
}

Measured memory_bytes: 4616