akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def tsum(l, r):
    return (r + l) * (r - l + 1) // 2

def exp(num):
    return tsum(1, num) / num

def solve():
    n, k = MI()
    P = LI()

    E = [0] * n
    pre = 0
    for i in range(n):
        E[i] = pre + exp(P[i])
        pre = E[i]
    # print(E)

    p = E[0]
    mx = E[k-1]
    for j in range(k, n):
        diff = E[j] - E[j-k]
        # print(diff)
        if mx < diff:
            mx = diff
    print(mx)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 25412
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 100000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

LL a[N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);

    LL ans1=0,sum1=0;
    LL ans2=0,sum2=0;
    if(a[1]==0){
        sum1=1;
        ans1=1;
        sum2=-1;
        ans2=1;
    }
    else if(a[1]>0){
        sum1=a[1];
        sum2=-1;
        ans2=a[1]+1;
    }
    else{
        sum1=1;
        sum2=a[1];
        ans1=llabs(a[1])+1;
    }

    for(int i=2;i<=n;i++){
		if(sum1>0){
			if(a[i]+sum1<0)
                sum1+=a[i];
			else{
				ans1+=a[i]+sum1+1;
				sum1=-1;
			}
		}
		else{
			if(a[i]+sum1>0)
                sum1+=a[i];
			else{
				ans1+=llabs(sum1+a[i])+1;
				sum1=1;
			}
		}
	}
	if(sum1==0)
		ans1++;

    for(int i=2;i<=n;i++){
        if(sum2>0){
            if(a[i]+sum2<0)
                sum2+=a[i];
			else{
				ans2+=a[i]+sum2+1;
				sum2=-1;
			}
        }
        else {
            if(a[i]+sum2>0)
                sum2+=a[i];
            else{
				ans2+=llabs(sum2+a[i])+1;
				sum2=1;
			}
        }
    }
    if(sum2==0)
        ans2++;

    LL res=min(ans1,ans2);
    printf("%lld\n",res);
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll N, K;
vector<ll> A;
vector<ll> D;
vector<ll> KK;
vector<vector<ll>> DP;

int main() {
	cin >> N >> K;
	A.resize(N);
	for (ll n = 0; n < N; n++)cin >> A[n];
	D.resize(41,0);
	for(ll n = 0;n < N;n++){
		for (ll d = 0; d <= 40; d++) {
			if (A[n] & ((ll)1 << (40 - d)))D[d]++;
		}
	}
	KK.resize(41, 0);
	for (ll d = 0; d <= 40; d++) {
		if (K & ((ll)1 << (40 - d)))KK[d]++;
	}
	DP.resize(41, vector<ll>(2, 0));
	DP[0][0] = 0;
	DP[0][1] = 0;
	for (ll d = 1; d <= 40; d++) {
		//DP[d][1]
		ll from1 = 0;
		if(DP[d-1][1] != 0)from1 = 2 * DP[d - 1][1] + max(D[d], N - D[d]);
		ll from2 = 0;
		if (KK[d] == 1)from2 = 2 * DP[d - 1][0] + D[d];
		DP[d][1] = max(from1, from2);
		//DP[d][0]
		if (KK[d] == 0) {
			DP[d][0] = 2 * DP[d - 1][0] + D[d];
		}
		else {
			DP[d][0] = 2 * DP[d - 1][0] + N - D[d];
		}
	}
	cout << max(DP[40][0], DP[40][1]) << endl;
	return 0;
}

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

// After reading the editorial

// int main(void)
// {
//     int x1, y1, x2, y2;
//     cin >> x1 >> y1 >> x2 >> y2;

//     int x = x2 - x1, y = y2 - y1;

//     int x3, y3, x4, y4;
//     x3 = x2 - y;
//     y3 = y2 + x;
//     x4 = x1 - y;
//     y4 = y1 + x;
//     printf("%d %d %d %d\n", x3, y3, x4, y4);
//     return (0);
// }

int main(void)
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int diff_x = x2 - x1;
    int diff_y = y2 - y1;

    int x3, y3, x4, y4;
    x3 = x2 - diff_y;
    y3 = y2 + diff_x;
    x4 = x1 - diff_y;
    y4 = y1 + diff_x;

    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return (0);
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[[int(i) for i in input().split()]for i in range(m)]
b=[None]*n
for i in a:
    if i[1]==n:
        if b[i[0]-1]!=None:
            print('POSSIBLE')
            exit()
        else:
            b[i[0]-1]=True
    if i[0]==1:
        if b[i[1]-1]!=None:
            print('POSSIBLE')
            exit()
        else:
            b[i[1]-1]=True
print('IMPOSSIBLE')

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

typedef long long ll;

using namespace std;

int main() {
  ll K, A, B;
  cin >> K >> A >> B;
  ll res = 0;
  if (A >= B - 2 || A + 1 > K) {
    res = K + 1;
  } else {
    K -= A + 1;
    ll t = K / 2;
    res = (t + 1) * B - t * A + K % 2;
  }
  printf("%lld\n", res);
}

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

int find_cost(int h,vector<vector<int> >v,int n)
{
  if(h<=0)
    return 0;
  int val=INT_MAX;
  for(int i=0;i<n;i++)
  {
     int u=v[i][1]+find_cost(h-v[i][0],v,n);
     val=min(u,val);
  }
  return val;
}
int main()
{
  int h,n,x,y;
  cin>>h>>n;
  
  vector<vector<int> >v(n,vector<int>(2));
  for(int i=0;i<n;i++)
  { cin>>x>>y;
  	v[i][0]=x;v[i][1]=y;
  }
  vector<int>dp(h+1,INT_MAX);
  dp[0]=0;
  for(int i=1;i<=h;i++)
  {
  	for(int j=0;j<n;j++)
  	{
  		dp[i]=min(dp[i],i-v[j][0]>=0?dp[i-v[j][0]]+v[j][1]:v[j][1]);
	}
  }
  /*
  for(int i=0;i<=h;i++){cout<<i<<" ";}
  for(int i=0;i<=h;i++){cout<<dp[i]<<" ";}*/
  cout<<dp[h]<<endl;
return 0;    
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <cstring>
#include <cassert>
#include <list>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <limits>
using namespace std;
typedef long long          ll;
typedef unsigned long long ull;
typedef long double        ld;
typedef pair<int,int>      pii;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;
typedef vector<long long>  vll;
#define left(x)		   (x << 1)
#define right(x) 	   (x << 1) + 1
#define mid(l, r) 	   ((l + r) >> 1)
#define mp                 make_pair
#define pb                 push_back
#define all(a)             a.begin(),a.end()
#define debug(x)	   {cerr <<#x<<" = " <<x<<"\n"; }
#define debug2(x, y)       {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<"\n";}
#define debug3(x, y, z)    {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<"\n";}
#define debug4(x, y, z, w) {cerr <<#x<<" = " <<x<<", "<<#y <<" = " <<y <<", "<<#z<<" = "<<z<<", "<<#w << " = " <<w <<"\n";}
#define ss                 second
#define ff                 first
#define m0(x) 		   memset(x,0,sizeof(x))

template<typename T >T min_ ( T a , T b ) { return a > b ? b : a ; }
template < typename T ,  typename... Ts > T min_( T first , Ts... last ){ return  min_(first, min_(last...)); }
template<typename T >T max_ ( T a , T b ) { return a > b ? a : b ; }
template < typename T ,  typename... Ts > T max_( T first , Ts... last ){ return  max_(first, min_(last...)); }

template<class T, class S> std::ostream& operator<<(std::ostream &os, const std::pair<T, S> &t) {
	os<<"("<<t.first<<", "<<t.second<<")";
	return os;
}
template<typename T> ostream& operator<< (ostream& out, const vector<T>& v) {
    out << "["; size_t last = v.size() - 1; for(size_t i = 0; i < v.size(); ++i) {
    out << v[i]; if (i != last) out << ", "; } out << "]"; return out;
}
const int mod = 1e9+7;

ll pwr(ll base, ll p){
ll ans = 1; while(p) { if(p&1) ans=(ans*base)%mod; base=(base*base)%mod; p/=2; } return ans;
}
ll gcd(ll a, ll b) {  return b == 0 ? a : gcd(b,a%b); }
ll lcm(ll a, ll b) {  return a*(b/gcd(a,b)); }

const long double PI = (long double)(3.1415926535897932384626433832795);
const ll  mx_ll   = numeric_limits<ll> :: max();
const int mx_int  = numeric_limits<int> :: max();

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

    int n,k; cin >> n >> k;

    vi arr(k);
    int sum = 0;
    for(int i = 0; i < k; ++i) {
        cin >> arr[i];
        sum += arr[i];
    }
    int fans = (sum <= n) ? (n-sum) : -1;
    cout << fans << endl;
    

    return 0;
}


Measured memory_bytes: 3640
#include<cstdio>
#include<algorithm>
using namespace std;

int main(void){
  long long s=0,t=0,ans=10000000000;
  int a[200001],n,i;

  scanf("%d",&n);

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

  for(i=0;i<n-1;i++){
    t+=a[i];
    ans=min(ans,abs(s-2*t));
  }

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

  return 0;
}



Measured memory_bytes: 896
#include <stdio.h>
#include <math.h>
#include <string.h>
typedef long long ll;
int main(int argc,int *argv[])
{
	int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k;
	scanf("%d",&k);
	printf("%d",a[k-1]) ;
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

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

  if ( (a - (2 * b)) >= 0 ) {
    cout << (a - (2 * b)) << endl;
  }
  else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[], int N){
	int i;
	for(i=0; i<N; i++){
		if(i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N){
	int j, i, v;
	for(i=1; i<N; i++){
		v = A[i];
		j = i-1;
		while(j>=0 && A[j]>v){
			A[j+1] = A[j];
			j--;
		}
		A[j+1] = v;
		trace(A, N);
	}
}

int main(){
	int N,i,j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	
	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    int ans;
    if (a>9 || b>9) ans = -1;
    else ans = a*b;
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int INF = 1e9;
	

ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b%2 == 1) tmp = mulMod(tmp,a);
	return tmp;
}

ll GCD(ll a, ll b){
	if(a > b) return GCD(b,a);
	if(a == 0) return b;
	return GCD(b%a,a);
}

//////////////////////////////////////////////

string str;
vector < char > ans;

int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int sz = 0;
	cin >> str;
	FOR(i,str.length()){
		if(str[i] == 'B'){
			if(sz != 0){
				sz--;
				ans.POB();
			}
		}
		else{
			sz++;
			ans.PB(str[i]);
		}
	}
	FOR(i,sz) cout << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long ll;
const int MAXN = 100005;


int n;
string ans;
string s;

bool solve(char c)
{
	for (int i = 1; i < n; i++)
	{
		if (ans[i] == 'W')
		{
			if (s[i] == 'x') ans[(i+1)%n] = ans[(i-1)%n];
			else
			{
				if (ans[(i-1)%n] == 'W') ans[(i+1)%n] = 'S';
				else ans[(i+1)%n] = 'W';
			}
		}
		else
		{
			if (s[i] == 'o') ans[(i+1)%n] = ans[(i-1)%n];
			else
			{
				if (ans[(i-1)%n] == 'W') ans[(i+1)%n] = 'S';
				else ans[(i+1)%n] = 'W';
			}
		}
	}

	if (ans[0] != c) return false;


	if (c == 'S')
	{
		if (s[0] == 'o')
		{
			if (ans[1] != ans[n-1]) return false;
		}
		else if (ans[1] == ans[n-1]) return false;
	}
	else
	{
		if (s[0] == 'x')
		{
			if (ans[1] != ans[n-1]) return false;
		}
		else if (ans[1] == ans[n-1]) return false;
	}

	return true;
}


int main()
{
	//freopen("input.in", "r", stdin);
	cin >> n;
	cin >> s;
	ans = s;

	ans[0] = 'S';
	ans[1] = 'S';
	if (solve('S'))
	{
		cout << ans << endl;
		return 0;
	}

	ans[0] = 'S';
	ans[1] = 'W';
	if (solve('S'))
	{
		cout << ans << endl;
		return 0;
	}

	ans[0] = 'W';
	ans[1] = 'S';
	if (solve('W'))
	{
		cout << ans << endl;
		return 0;
	}

	ans[0] = 'W';
	ans[1] = 'W';
	if (solve('W'))
	{
		cout << ans << endl;
		return 0;
	}

	cout << -1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
int bubblesort(int A[],int N) {
    int temp = 0;
    int x = 0;
    int flag = 1;
    while(flag == 1){
    flag = 0;    
        for (int j = N - 1; j >= 1; j--) {
            if (A[j] < A[j - 1]) {
                temp = A[j];
                A[j] = A[j - 1];
                A[j - 1] = temp;
                flag = 1;
                x++;
             }
        }
    }
    return x;
}
int main() {
    int n,c,i;
    int a[100];
    c = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    c = bubblesort(a, n);
    for(i=0; i<n-1; i++)
        printf("%d ",a[i]);
    printf("%d\n",a[n-1]);
    printf("%d\n",c);
    
    return 0;
}


Measured memory_bytes: 1992
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int N;
    cin >> N;
    if (N % 2==0){
        cout << N / 2 << endl;
    }
    else {
        cout << (N / 2) + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    
    vector<ll> A(N);
    vector<ll> sum_l2r(N), sum_r2l(N);

    vector<int> left_ix(N-1), right_ix(N-1);

    sum_l2r[0] = 0, sum_r2l[0] = 0;
    for (int i = 0; i<N; i++) {
        cin >> A[i];
        if (i > 0) {
            sum_l2r[i] += (sum_l2r[i-1] + A[i]);
        }
        else sum_l2r[i] = A[i];
    }
    for (int i = 0; i<N; i++) {
        if (i > 0) {
            sum_r2l[i] += (sum_r2l[i-1] + A[N-i-1]);
        }
        else sum_r2l[0] = A[N-1];
    }
    
    for (int mid_ix = 1; mid_ix < N-2; mid_ix++) {
        if (mid_ix > 1) {
            left_ix[mid_ix] = left_ix[mid_ix-1];

            ll left_diff = abs(sum_l2r[mid_ix] - 2*sum_l2r[left_ix[mid_ix-1]]);
            for (int ix = left_ix[mid_ix-1]+1; ix < mid_ix; ix++) {
                if (left_diff > abs(sum_l2r[mid_ix] - 2*sum_l2r[ix])) {
                    left_ix[mid_ix] = ix;
                    left_diff = abs(sum_l2r[mid_ix] - 2*sum_l2r[ix]);
                }
                else break;
            }

            right_ix[mid_ix] = right_ix[mid_ix-1];
            
            ll right_diff = abs(sum_r2l[mid_ix] - 2*sum_r2l[right_ix[mid_ix - 1]]);
            for (int ix = right_ix[mid_ix-1]+1; ix < mid_ix; ix++) {
                if (right_diff > abs(sum_r2l[mid_ix] - 2*sum_r2l[ix])) {
                    right_ix[mid_ix] = ix;
                    right_diff = abs(sum_r2l[mid_ix] - 2*sum_r2l[ix]);
                }
                else break;
            }
        }
        else {
            left_ix[1] = 0;
            right_ix[1] = 0;
        }
    }

    ll ans = 1e9 + 7;
    for (int mid_ix = 1; mid_ix < N-2; mid_ix++) {
        ll left_min = min(sum_l2r[mid_ix] - sum_l2r[left_ix[mid_ix]], sum_l2r[left_ix[mid_ix]]);
        ll left_max = max(sum_l2r[mid_ix] - sum_l2r[left_ix[mid_ix]], sum_l2r[left_ix[mid_ix]]);
        ll right_min = min(sum_r2l[N-2-mid_ix] - sum_r2l[right_ix[N-2-mid_ix]], sum_r2l[right_ix[N-2-mid_ix]]);
        ll right_max = max(sum_r2l[N-2-mid_ix] - sum_r2l[right_ix[N-2-mid_ix]], sum_r2l[right_ix[N-2-mid_ix]]);
        
        ans = min(max(left_max, right_max) - min(left_min, right_min), ans);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 6528
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define endl '\n'
#define MOD 1000000007
 
int main()
{ 
	ll a,b;
	cin>>a>>b;
	cout<<a*b<<endl;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        int M = Integer.parseInt(scanner.next());
        int[][] gate = new int[M][2];
        for (int i = 0; i < M; i++) {
            gate[i][0] = Integer.parseInt(scanner.next());
            gate[i][1] = Integer.parseInt(scanner.next());
        }
        scanner.close();


        // 最小レンジを求める
        int min = Integer.MIN_VALUE;
        int max = Integer.MAX_VALUE;
        for (int i = 0; i < M; i++) {
            if (min < gate[i][0]) min = gate[i][0];
            if (max > gate[i][1]) max = gate[i][1];

            if (min > max) {
                System.out.println(0);
                return;
            }
        }
        System.out.println(max - min + 1);
    }
}


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

using namespace std;

int p1, p2, N, a[100009], pos[100009], fac[200100], inv[200100];
const int mod = 1e9 + 7;

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int subtract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}

int power (int a, int b)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = mul (p, a);
        a = mul (a, a);
    }
    return p;
}

void Prec (int lim){fac[0] = inv[0] = 1;for (int i=1; i<=lim; i++)fac[i] = mul (fac[i - 1], i);
inv[lim] = power (fac[lim], mod - 2);for (int i=lim - 1; i>=1; i--)inv[i] = mul (inv[i + 1], i + 1);}
int comb (int N, int K){if (K < 0 || K > N || N < 0) return 0;int ans = mul (fac[N], inv[N - K]);ans = mul (ans, inv[K]);return ans;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N), Prec (2 * N + 10);
for (int i=1; i<=N + 1; i++)
{
    scanf ("%d", &a[i]);
    if (pos[a[i]]) p1 = pos[a[i]], p2 = i;
    else pos[a[i]] = i;
}
///cate se repeta
///comb (N - (p2 - p1 + 1), L - 1)
for (int L=1; L<=N + 1; L ++)
{
    int ans = subtract (comb (N + 1, L), comb (N + 1 - (p2 - p1 + 1), L - 1));
    printf ("%d\n", ans);
}
return 0;
}


Measured memory_bytes: 3584
S = input()
cand = [0 for _ in range(2 **(len(S) - 1))]
for i in range(2 ** (len(S) - 1)):
    now = 0
    tmp = []
    for k in range(len(S) - 1):
        if i & (1 << k):
            tmp.append(S[now:k + 1])
            now = k + 1
    tmp.append(S[now:])
    for x in tmp:
        if x == '':
            continue
        else:
            cand[i] += int(x)
print(sum(cand))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(){

  vector<int> a, alice, bob;
  int n;
  int sum_alice = 0;
  int sum_bob = 0;
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    int tmp;
    scanf("%d", &tmp);
    a.push_back(tmp);
  }

  sort(a.begin(), a.end(), greater<int>());

  for(int i = 0; i < n; i++){
    if(i%2 == 0){
      alice.push_back(a[i]);
    }
    else{
      bob.push_back(a[i]);
    }
  }

  for(int i = 0; i != alice.size(); i++)
    sum_alice += alice[i];

  for(int i = 0; i != bob.size(); i++)
    sum_bob += bob[i];

  printf("%d", sum_alice - sum_bob);



  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define int long long
using namespace std;
const int INF = 10000000000000;//5000000000000000

signed main() {
	int X;
	cin >> X;
	int big = 0;
	int small = 0;
	big = X / 500;
	small = (X % 500) / 5;
	cout << big * 1000 + small * 5 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define all(obj) (obj).begin(),(obj).end()
const int mod = 1e9+7;
ll cnt[100005];

ll pp(ll i,ll j){
    ll res=1;
    while(j>0){
        if(j&1)res=res*i%mod;
        i=i*i%mod;
        j>>=1;
    }
    return res;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    rep(i,k)cnt[i]=0;
    for(int i=k;i>0;i--){
        ll t=k/i;
        cnt[i]=pp(t,n);
        int ii=i*2;
        while(ii<=k){
            cnt[i]-=cnt[ii];
            ii+=i;
        }
    }
    ll ans=0;
    for(int i=1;i<=k;i++){
        ans+=i*cnt[i];
        ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

const int MAX_N = 100;

int par[MAX_N];
int Rank[MAX_N];
int size;

void init(int n) {
    for (int i = 0; i < n; i++) {
        par[i] = i;
        Rank[i] = 0;
    }
    size = n;
}

int find(int x) {
    if (par[x] == x) {
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;

    size--;
    if (Rank[x] < Rank[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (Rank[x] == Rank[y]) {
            Rank[x]++;
        }
    }
}

bool same(int x, int y) {
    return find(x) == find(y);
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    int a[M], b[M];
    rep(i, M) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    int ans = 0;
    rep(i, M) {
        init(N);
        rep(j ,M) {
            if (i == j) continue;
            unite(a[j], b[j]);
        }
        //dump(size);
        if (size != 1) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <array>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;
const int  INF=10e7;

typedef  pair<int,int> P;


int main(){
     int n;
     cin>>n;
     int a;
     int ma=-INF;
     int ans=0;
     for(int i=0;i<n;++i){
          cin>>a;
          ans+=a;
          if(ma<a)ma=a;
     }
    

     if(ma<ans-ma)cout<<"Yes"<<endl;
     else cout<<"No"<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pii pair<int,int>

const int inf = 1e16;

const int N = 51;
vector<pair<int,pii> > g[N];
int n,m,s;
int c[N];
int d[N];
int dp[N][(N*N)];

void solve()
{
   cin >> n >> m >> s;
    
   int u,v,w,x;
    
   f(i,m)
   {
       cin >> u >> v >> w >> x;
       u--; v--;
       
       g[u].pb({v,{w,x}});
       g[v].pb({u,{w,x}});
   }
    
   f(i,n) cin >> c[i] >> d[i];
   
   if(s >= 2500) s = 2500;
    
   f(i,n) f(j,2501) dp[i][j] = inf; 
   dp[0][s] = 0;
    
  f(go,n+1)  
   for(int i=0;i<n;i++)
   {
       for(auto x : g[i])
           for(int j=0;j<=2500;j++)
       {
         if(j - x.S.F >= 0)  
           dp[i][j - x.S.F] = min(dp[i][j - x.S.F], dp[x.F][j] + x.S.S);
       }
      
       for(int j=0;j<=2500;j++)
       {
           if(j - c[i] >= 0)
           {
                dp[i][j] = min(dp[i][j],dp[i][j-c[i]] + d[i]);
           }
       }
       
   }
    
   for(int i=1;i<n;i++)
   {
       int res = inf;
       
       for(int j=0;j<=2500;j++) res = min(res,dp[i][j]);
       
       cout << res << '\n';
   }
}

signed main()
{
    fast;
    solve();
}

Measured memory_bytes: 4624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=2e5+5;
const ll mod=1e9+7;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;cin>>n>>m;
    ll a[n];for(ll i=0;i<n;i++)cin>>a[i],a[i]/=2;
    ll lcm=a[0];
    for(ll i=1;i<n;i++){
        ll v1 = lcm/ __gcd(a[i],lcm);
        ll v2 = a[i]/ __gcd(a[i],lcm);
        lcm = v1*v2*__gcd(a[i],lcm);
        if(lcm>m)return cout<<0 , 0;
    }
    ll rem=(lcm/a[0])%2;
    for(ll i=0;i<n;i++)if( (lcm/a[i])%2!=rem)return cout<<"0" , 0;
    cout<<(m/lcm + 1)/2;
}


Measured memory_bytes: 1024
/*
    なせば大抵なんとかなる！ 
*/
 
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
 
#define amt(a) int a;scanf("%d",&a)
#define dlld(a,b) long long int a,b;scanf("%I64d %I64d",&a,&b)
#define scd(a) int a;scanf("%d",&a)
#define sclld(a) long long int a;scanf("%I64d",&a)
#define scs(a) char a[2000000];scanf("%s",a)
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define arr(a,b) int *a=(int *)malloc(n*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(n*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int main()
{
 char a[5200],b[5200],c[5200];
scanf("%s %s %s" ,a,b,c);
int lena=strlen(a),lenb=strlen(b),lenc=strlen(c);
if(a[lena-1]==b[0] &&b[lenb-1]==c[0])
printf("YES\n");
else
printf("NO\n");
	return 0;}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 2000001
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pi 3.14159265358979323846
#define Q ll _; cin >> _; while(_--)
#define endl "\n"
#define flush fflush(stdout);

int main(){

    fast;

    string a,b;
    cin >> a >> b;
    ll cnt = 0;
    for(ll i=0;i<a.size();i++){
        if(a[i]!=b[i]){
            cnt++;
        }
    }

    cout << cnt << endl;

}

//    cout << fixed << setprecision(12);


Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  string s;
  cin >> s;
  ll ans = 0;
  for(ll bit = 0; bit < (1 << s.size() - 1); bit++) {
    bitset<9> bs = bitset<9>(bit);
    //cout << bs << endl;
    int pos = 0;
    vector<ll> a(s.size());
    REP(i, s.size()) {
      if (bs[i] || i == s.size() - 1) {
        ll num = stoll(s.substr(s.size() - i - 1, i - pos + 1));
        //cout << i << " " << num << endl;
        a.push_back(num);
        pos = i + 1;
      }
    }
    REP(i, a.size()) ans += a[i];
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	static int N_bookCount, M_bookCount, K_sumTime;

	static long ansCount = 0;

	static long[] A;
	static long[] B;

	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		N_bookCount = scan.nextInt();
		M_bookCount = scan.nextInt();
		K_sumTime = scan.nextInt();

		A = new long[N_bookCount + 1];
		B = new long[M_bookCount + 1];

		for (int i = 1; i <= N_bookCount; i++) {
			A[i] = scan.nextInt();
		}

		for (int i = 1; i <= M_bookCount; i++) {
			B[i] = scan.nextInt();
		}

		//累積和を求めておく。
		Map<Integer, Long> aDeskSum = new HashMap<Integer, Long>();
		aDeskSum.put(0, (long) 0);
		aDeskSum.put(1, (long) A[1]);
		for (int i = 2; i <= N_bookCount; i++) {
			aDeskSum.put(i, aDeskSum.get(i - 1) + A[i]);
		}
		Map<Integer, Long> bDeskSum = new HashMap<Integer, Long>();
		bDeskSum.put(0, (long) 0);
		bDeskSum.put(1, (long) B[1]);
		for (int i = 2; i <= M_bookCount; i++) {
			bDeskSum.put(i, bDeskSum.get(i - 1) + B[i]);
		}

		//AをしたからBを上から見ていく
		int j = M_bookCount;
		for (int i = 0; i <= N_bookCount; i++) {

			//Aだけで合計時間を超える場合は抜ける
			if (aDeskSum.get(i) > K_sumTime) {
				break;
			}

			while (K_sumTime < aDeskSum.get(i) + bDeskSum.get(j)) {
				if (j == 0)
					break;

				j--;
			}

			ansCount = Math.max(ansCount, i + j);

		}

		System.out.println(ansCount);

	}

	//***********************以下共通関数************************************************
	/**
	 * 文字列を反転して返す
	 * @param pStr 文字列
	 * @return 反転した文字列
	 */
	public static String myReverse(String pStr) {
		if (pStr.length() < 1) {
			return "";
		}

		StringBuffer sb = new StringBuffer(pStr);
		return sb.reverse().toString();
	}

	/**
	 * 余りを求める。
	 * @param a
	 * @param b
	 * @return 余り。余りがマイナスの時はプラスで返す。
	 */
	public static long myMod(long a, long b) {
		long ret = 0;

		ret = a % b;

		if (ret < 0) {
			ret += b;
		}

		return ret;
	}

	/**
	 * 乗数を求める ※mod対応
	 * @param kisu 基数
	 * @param josu 乗数
	 * @param primeNumMod_0 法 mod値 使わない場合は「0」
	 * @return
	 */
	public static long myPowWithMod(long kisu, long josu, long primeNumMod_0) {

		long ans = 1;

		//乗数が0の場合→1
		if (josu == 0)
			return 1;

		if (primeNumMod_0 == 0) {
			//modを使わないとき

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= kisu;
					josu = josu / 2;
				} else {
					//累乗が奇数の時
					ans *= kisu;
					josu--;
				}
			}

			return ans;

		} else {
			//modを使うとき

			//初めに桁を落とす
			kisu = myMod(kisu, primeNumMod_0);

			while (josu > 0) {

				if (josu % 2 == 0) {
					//累乗が偶数の時

					kisu *= myMod(kisu, primeNumMod_0);
					josu = josu / 2;

				} else {
					//累乗が奇数の時
					ans *= myMod(kisu, primeNumMod_0);
					josu--;

				}
			}

			return myMod(ans, primeNumMod_0);

		}

	}

}


Measured memory_bytes: 86908
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,l;
    cin>>n>>l;
    vector<ll> v;
    for(int i=0;i<n;i++){
    	v.pb(l+i);
    }
    ll num=1e9,sum=0;
    for(int i=0;i<n;i++)
    {
    	sum+=v[i];
    	if(abs(num)>=abs(v[i]))num=v[i];
    }
    cout << sum-num<<endl;
    return 0;
}


Measured memory_bytes: 256
import numpy as np

n,d = map(int,input().split())
point = []
for i in range(n):
  array = list(map(int, input().strip().split()))
  point.append(array)

tmp = 0
ans = 0
  
for i,a in enumerate(point):
  for j in range(i+1,n):
    for k in range(d):
      tmp += (a[k]-point[j][k])**2
    if np.sqrt(tmp).is_integer():
      ans += 1
    tmp = 0
    
print(ans)

Measured memory_bytes: 12504
#include <iostream>
#include <algorithm>

using namespace std;

int main(void) {
	int a, b, c, k, sum;
	int n;

	cin >> a >> b >> c >> k;

	n = max({a, b,c});
	sum = n;

	for (int i=0; i < k; i++) {
		sum = sum * 2;
	}

	cout << a + b + c + sum - n << endl;

	return 0;
}

Measured memory_bytes: 3632
<?php
list($N,$M)=sscanf(trim(fgets(STDIN)),"%d %d");
$A = 0;
$W = array();
$cnt=1;
$cntt=0;
$ch = array();
$sumW = 0;
for($i=0;$i<$M;$i++){

    list($p,$S)=sscanf(trim(fgets(STDIN)),"%d %s");
    if(!isset($ch[$p])) $ch[$p] = 0;
    if(!isset($W[$p])) $W[$p] = 0;
    if ($ch[$p] == 0){
        if($S == 'AC'){
            $A++;
            $ch[$p] = 1;
            $sumW += $W[$p];
        }else{
            $W[$p]++;
        }
    }
}
printf("%d %d",$A,$sumW);

Measured memory_bytes: 32628
#include <bits/stdc++.h>
#include <math.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++)

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

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

typedef long long ll;

#define MAX_N 10000

struct Edge {
    int to;
    int weight;
    Edge(int t, int w)
        : to(t)
        , weight(w)
    {
    }
};
using Graph = vector<vector<int>>;
using Graph_e = vector<vector<Edge>>;

vector<int> dx = { 1, 0, -1, 0 };
vector<int> dy = { 0, 1, 0, -1 };
typedef pair<int, int> P;

template <typename T>
T GCD(T x, T y)
{
    return (y ? GCD<T>(y, x % y) : x);
}

struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank;

    UnionFind(int n = 1)
    {
        init(n);
    }

    void init(int n = 1)
    {
        par.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x)
    {
        if (par[x] == x) {
            return x;
        } else {
            int r = root(par[x]);
            return par[x] = r; // 辺の縮約（一度根をたどったら辺を直接根に向かって貼り直す）
        }
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (rank[x] < rank[y])
            swap(x, y);
        if (rank[x] == rank[y])
            ++rank[x];
        par[y] = x; // xよりyのほうが高さが小さい木
        return true;
    }
};

// railwayとroadそれぞれについてunion-find treeを用意し，どちらでもis-sameなcityの数を求める
int main()
{
    int N, K, L;
    cin >> N >> K >> L;
    UnionFind road(N);
    UnionFind railway(N);
    rep(i, K)
    {
        int p, q;
        cin >> p >> q;
        p--, q--;
        road.merge(p, q);
    }
    rep(i, L)
    {
        int p, q;
        cin >> p >> q;
        p--, q--;
        railway.merge(p, q);
    }

    // 道路と鉄道のグループが同じ集合の要素をカウント
    map<pair<int, int>, int> dic;
    rep(i, N)
    {
        auto p = make_pair(road.root(i), railway.root(i));
        if (!dic.count(p)) {
            dic[p] = 1;
        } else {
            dic.at(p)++;
        }
    }

    rep(i, N)
    {
        auto p = make_pair(road.root(i), railway.root(i));
        cout << dic.at(p);
        if (i < N - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
}

// N^2で間に合わないときはたいてい前処理でかいけつ

Measured memory_bytes: 15104
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val k = sc.nextInt()
  val aList = mutableListOf<List<Int>>()
  for (i in 1..k) {
    val d = sc.nextInt()
    val a = (1..d).map {
      sc.nextInt()
    }
    aList.add(a)
  }

  println(abc166b(n, k, aList))
}

private fun abc166b(n: Int, k: Int, a: List<List<Int>>): Int {
  val hasTreat = mutableSetOf<Int>()
  for (ai in a) {
    for (aii in ai) {
      hasTreat.add(aii)
    }
  }
  var ans = n - hasTreat.size
  return ans
}


Measured memory_bytes: 48104
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back
#define sz(x) int(x.size())

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;

class UnionFind{
public:
  vi Parent;
  UnionFind(int n){
    Parent = vi(n,-1);
  }

  int root(int a){
    if(Parent[a] < 0) return a;
    else return Parent[a] = root(Parent[a]);
  }

  int size(int a){
    return -Parent[root(a)];
  }

  bool merge(int a, int b){
    a = root(a);
    b = root(b);
    if(a == b) return false;

    if(size(a) < size(b)) swap(a,b);
    Parent[a] += Parent[b];
    Parent[b] = a;

    return true;
  }
};

class Factrial{
public:
  vl Fac;
  Factrial(int MAX){
    Fac = vl(MAX+1);
    rep(i,MAX) {
      if(i == 0) Fac[i+1] = 1;
      else Fac[i+1] = ((i+1)*Fac[i])%MOD;
    }
  }
};

int main(){
  int n; cin >> n;
  vl x(n),l(n);
  rep(i,n) cin >> x[i] >> l[i];
  vector<pair<ll,ll>> lr(n);
  rep(i,n){
    lr[i] = mp(x[i]-l[i],x[i]+l[i]);
  }
  sort(all(lr));
  int ans = n;
  ll left = lr[0].first, right = lr[0].second;
  for(int i = 1; i < n; i++) {
    if(lr[i].first < right){
      chmin(right, lr[i].second);
      ans--;
    }
    else{
      left = lr[i].first;
      right = lr[i].second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3328
from operator import itemgetter

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

city_num = [0 for _ in range(n)]
l = []
for i in range(m):
    p, y = map(int, input().split())
    l.append([i, p, y])

l.sort(key=itemgetter(2))

for i in range(m):
    j, p, y = l[i]
    city_num[p-1] += 1
    idz = str(str(p).zfill(6))
    idk = str(str(city_num[p-1]).zfill(6))
    l[i].append(idz+idk)

l.sort(key=itemgetter(0))
for i in range(m):
    print(l[i][-1])

Measured memory_bytes: 36560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    vector<string> s(3);
    rep(i,3) cin >> s[i];
    rep(i,3) reverse(all(s[i]));
    int i = 0;
    while(true){
        if (s[i].size() == 0) break;
        char c = s[i].back();
        s[i].pop_back();
        if (c == 'a') i = 0;
        else if (c == 'b') i = 1;
        else i = 2;
    }
    cout << (char)('A'+i) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <memory.h>
using namespace std;

char a[11][11], b[11][11];
int s[11], t[11];

int main(void)
{
	int h, w, k, i, j, x, y, ans = 0;

	scanf("%d %d %d", &h, &w, &k);
	for (i = 1; i <= h; i++)
		scanf("%s", a[i] + 1);

	for (i = 0; i < (1 << h); i++)
		for (j = 0; j < (1 << w); j++)
		{
			memcpy(b, a, sizeof(a));

			int p = i, q = j;

			for (x = 1; x <= h; x++)
			{
				s[x] = p & 1;
				p >>= 1;
			}

			for (x = 1; x <= w; x++)
			{
				t[x] = q & 1;
				q >>= 1;
			}

			for (x = 1; x <= h; x++)
				if (s[x])
					for (y = 1; y <= w; y++)
						b[x][y] = '.';

			for (x = 1; x <= w; x++)
				if (t[x])
					for (y = 1; y <= h; y++)
						b[y][x] = '.';

			int cnt = 0;
			for (x = 1; x <= h; x++)
				for (y = 1; y <= w; y++)
					if (b[x][y] == '#')
						cnt++;

			if (cnt == k)
				ans++;
		}

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1736
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

string s;

bool isop(char ch){
    if(ch=='+' || ch=='-' || ch=='*' || ch=='/')return true;
    else return false;
}

void mul(const set<int> &a, const set<int> &b, char op, set<int> &ret){
    for(auto e1:a){
        for(auto e2:b){
            if(op=='+')ret.insert(e1+e2);
            if(op=='-')ret.insert(e1-e2);
            if(op=='*')ret.insert(e1*e2);
            if(op=='/'){
                if(e2==0)continue;
                ret.insert(e1/e2);
            }
        }
    }
}

set<int> dfs(int l, int r){
    vector<int> br(300,-1);
    stack<int> stk;
    for(int i=l;i<r;i++){
        if(s[i]=='(')stk.push(i);
        else if(s[i]==')'){
            assert(stk.size());
            br[stk.top()] = i;
            stk.pop();
        }
    }
    for(int i=l;i<r;i++){
        if( br[i]!=-1 && br[i]==r-1){
            l++,r--;
        }else break;
    }
    
    set<int> ret;
    int c = 0;
    
    bool ops=false;
    for(int i=l;i<r;i++){
        if(s[i]=='(')c++;
        else if(s[i]==')')c--;
        else if( isop(s[i]) && c==0 ){
            ops = true;
            mul( dfs(l,i) , dfs(i+1,r), s[i], ret);
        }
    }
    
    if(!ops)ret = set<int>{stoi(s.substr(l,r-l))};
    
    return ret;
}

int main(){
    while(cin>>s && s!="#"){
        set<int> res = dfs(0,s.size());
        cout<<res.size()<<endl;
    }
}

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

int main()
{
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++)
  {
    if (s.at(i) == '7')
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3592
// single-source shortest path (BFS)

#include <cstdio>
#include <cstdlib>
#include <cstring>

const int N = 100010;
const int M = 500010;
const int inf = 0x3fffffff;

struct Edge {
	int to, len, next;
} es[M];

int SIZE = 0; // number of edges
int h[N]; // pointer to edge list
int dist[N], queue[N], inq[N]; // for calculating shortest path

inline void add(int u, int v, int w) {
	int i = ++SIZE;
	es[i].to = v;
	es[i].len = w;
	es[i].next = h[u];
	h[u] = i; 
}

inline int inc(int x) {
	return (x == N - 1 ? 0 : x + 1);
}

void sssp(int r) {
	int front = 0, back = 0;
	queue[back++] = r;
	while (front != back) {
		int x = queue[front];
		inq[x] = 0;
		front = inc(front);
		for (int i = h[x]; i; i = es[i].next) {
			int y = es[i].to;
			int new_d = dist[x] + es[i].len;
			if (new_d < dist[y]) {
				dist[y] = new_d;
				if (!inq[y]) {
					queue[back] = y;
					inq[y] = 1;
					back = inc(back);
				}
			}
		}
	}
}

void run() {
	int n, m, r, x, y, w;
	scanf("%d%d%d", &n, &m, &r);
	memset(h, 0, sizeof(h));
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d", &x, &y, &w);
		add(x, y, w);
	}
	for (int i = 0; i < n; i++) {
		dist[i] = (i == r ? 0 : inf);
		inq[i] = 0;
	}
	sssp(r);
	for (int i = 0; i < n; i++)
		if (dist[i] == inf)
			printf("INF\n");
		else
			printf("%d\n", dist[i]);
}

int main() {
	run();
}

Measured memory_bytes: 9856
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
int main ()
{
    int n,m;
    cin>>n>>m;
    string a[110];
    for (int i=0;i<n;i++)
    	cin>>a[i];
    map<string, int> str;
    for (int i=0;i<n;i++)
    	str[a[i]]++;
     map<string, int> ::iterator it;
     for (it =str.begin();it!=str.end();it++)
     	for (int i=0;i<it->second;i++)
     		cout<<it->first;
    cout<<endl;
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
l = raw_input().split(" ")
#print(l[0])
#print(l[1])

a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

ans="No"


if (int(l[0]) in a and int(l[1]) in a):
    ans="Yes"

if (int(l[0]) in b and int(l[1]) in b):
    ans="Yes"

if (int(l[0]) in c and int(l[1]) in c):
    ans="Yes"

print(ans)


Measured memory_bytes: 2568
#include <iostream>
#include <complex>

using namespace std;

int main() {
	int a;

	cin >> a;


	int kotae = 0;

	for (int i = 1; i <= a; i = i + 2) {
		int temp = 0;
		for (int j = 1; j <= sqrt(i); j++) {
			if (i % j == 0) {
				++temp;
			}
		}

		temp *= 2;

		if (sqrt(i) == (int)sqrt(i)) {
			--temp;
		}

		if (temp == 8) {
			++kotae;
		}
	}

	cout << kotae << endl;
}

Measured memory_bytes: 256