akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;



int main()
{  int n,k;
   cin>>n>>k;
   vector<int> value;
   for(int i=0;i<n;i++){
     int a1;
     cin>>a1;
     value.push_back(a1);
   }
   sort(value.begin(),value.begin()+n);
   int sum=0;
   for(int i=0;i<k;i++){
    sum=sum+value[i];
   }
   cout<<sum<<endl;
   return 0;
}


Measured memory_bytes: 3136
"""
n,m<=10
"""

n,m = map(int, input().split( ))
s = []

for i in range(m):
    sij = list(map(int, input().split( )))
    s.append(sij[1:])

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

ans = 0

for i in range(2**n):
    flag = True
    for k in range(m):
        tst = 0
        for sm in s[k]:
            tst ^= i>>(sm-1)&1
        if tst^p[k]:###
            flag = False
            break
    if flag:
        ans += 1

print(ans)

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

using namespace std;
using namespace placeholders;

template <class T> void mini(T &l, T r) {l = min(l, r);}
template <class T> void maxi(T &l, T r) {l = max(l, r);}

template <class TH> void _dbg(const char *sdbg, TH h) {
  cerr << sdbg << "=" << h << "\n";
}
template <class TH, class ...TA> void _dbg(const char *sdbg, TH h, TA ...a) {
  while (*sdbg != ',') cerr << *sdbg++; cerr << "=" << h << ","; _dbg(sdbg + 1, a...);
}
template <class T> ostream &operator<<(ostream &os, vector <T> v) {
  os << "[";
  for (auto vv : v) os << vv << ",";
  return os << "]";
}
template <class L, class R> ostream &operator<<(ostream &os, pair <L, R> p) {
  return os << "(" << p.first << "," << p.second << ")";
}

#define eput(...) //_dbg(#__VA_ARGS__, __VA_ARGS__)

using llint = long long;

const int N = 1e5 + 10;

int n, m;
int a[N], b[N];
vector <int> e[N];
bool ok = 1;
int col[N];

void dfs(int u, int c) {
  col[u] = c;
  for (auto v : e[u]) {
    if (col[v] == -1)
      dfs(v, 1 - c);
    else if (col[v] != 1 - c) {
      ok = 0;
    }
  }
}

void run() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d%d", a + i, b + i);
    e[a[i]].push_back(b[i]);
    e[b[i]].push_back(a[i]);
  }
  fill_n(col, n + 1, -1);
  dfs(1, 0);
  eput(ok);
  llint ans = 0;
  if (ok) {
    vector <int> cnt(2);
    for (int i = 1; i <= n; ++i) cnt[col[i]]++; 
    ans = 1ll * cnt[0] * cnt[1];
  } else {
    ans = 1ll * n * (n - 1) / 2;
  }
  printf("%lld\n", ans - m);
}

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


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

const int INF = 1e9;
const int MOD = 1e9 + 7;

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

    int h, w;
    cin >> h >> w;
    vector<vector<int>> dp(h, vector<int>(w, 0));
    vector<vector<char>> grid(h, vector<char>(w));
    dp[0][0] = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> grid[i][j];
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (grid[i][j] == '.') {
                if (i - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i - 1][j]) % MOD;
                if (j - 1 >= 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	ll n,m,x;
	cin>>n>>m;
	ll w[n+1],p[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>w[i]>>p[i];
	}
	ll dp[n+1][m+1];
	for(int i=0;i<=n;i++)
	dp[i][0]=0;
	for(int i=0;i<=m;i++)
	dp[0][i]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(w[i]>j)
			dp[i][j]=dp[i-1][j];
			else
			{
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+p[i]);
			}
		}
	}
	x=0;
	for(int i=0;i<=m;i++)
	{
		x=max(x,dp[n][i]);
	}
	cout<<x<<endl;
}

Measured memory_bytes: 79104
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
	double x = 0, y = 0;
	int hosuu, kakudo;
	char tmp;
	int theta = 90;

	while ( 1 )
	{
 		cin >> hosuu >> tmp >> kakudo;
		if ( hosuu == 0 && kakudo == 0 )
		{
			break;
		}

		y = y + hosuu * sin( theta * M_PI / 180 );
		x = x + hosuu * cos( theta * M_PI / 180 );

		theta = theta - kakudo;
	}

	cout << ( int )x << endl;
	cout << ( int )y << endl;

	return 0;
}

Measured memory_bytes: 3408
#include <iostream>
#include <string>

using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  for (int c = 1; c <= 3; c++) {
  	if ((a * b * c) % 2 == 1) {
      cout << "Yes" << endl;
      return 0;
    } 
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
const int m = 1000000007;

long double dp[3001][3001];
long double p[3001];

int main() {
	dp[0][0] = 1;
	int n;
	scanf("%d", &n );
	for( int i=1; i<=n; ++i )
		scanf("%Lf", p+i);
	for( int i=1; i<=n; ++i ) {
		dp[i][0] = dp[i-1][0]*p[i];
		for( int t=1; t<=i; ++t )
			dp[i][t] = p[i]*dp[i-1][t] + (1-p[i])*dp[i-1][t-1];
	}
	long double ans = 0;
	for( int i=0; i+i<=n; ++i )
		ans += dp[n][i];
	printf("%.10Lf\n", ans);
}


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

int main() {
    ll N;
    cin >> N;
    ll ans = 1;
    ll div;
    div = pow(10,9) + 7;
    for(int i = 1; i <= N; i++){
        ans *= i;
        ans = ans % div;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = (1..n).map { sc.nextLong() }


  val map = mutableMapOf<Long, Int>()
  for (ai in a) {
    val tmp = map.getOrElse(ai) { 0 }
    map.put(ai, tmp+1)
  }

  val mm = map.filter { it.value >= 2 }.keys.sorted().reversed()
  if (mm.size == 0) {
    println(0)
    return
  }

  val mk = mm[0]
  val mv = map.getOrElse(mk) { 0 }
  if (mv >= 4) {
    println(mk * mk)
    return
  }

  if (mm.size == 1) {
    println(0)
    return
  }

  val mkk = mm[1]
  println(mk * mkk)

}

Measured memory_bytes: 69900
#include <bits/stdc++.h>
using namespace std;
int n , k , a[200];
bool dp[100010];
int main()
{
    cin >> n >> k;
    for(int i = 0 ; i < n ; i++)    cin >> a[i];

    dp[0] = 0;
    for(int i = 1,j,cnt ; i <= k ;dp[i] = !dp[i], i++)
        for(j = 0 ,dp[i] = 1; j < n ; j++)
            if(i - a[j] >= 0)dp[i] &= dp[i-a[j]];

    cout << (dp[k] ? "First\n" : "Second\n");
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
using namespace std;

int main()
{
    int n, k;
    int i;
    
    cin >> n >> k;
    
    int ans = k;
    
    for(i = 1; i < n; i++) {
        ans = ans * (k - 1);
    }
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 256
/* ****revpro**** */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl       '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii        map<ll,ll>
using namespace std;

#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n,k;
        cin>>n>>k;
        ll dp[k+1]={0};
        ll a[n];
        rep(i,0,n)
            cin>>a[i];
        rep(i,0,k+1)
        {
            if(!dp[i])
            {
                rep(j,0,n)
                {
                    if(i-a[j]<0)
                        break;
                    if(!dp[i-a[j]])
                        {dp[i]=1;break;}
                }
                if(!dp[i])
                {
                    rep(j,0,n)
                    {
                        if(i+a[j]>k)
                            break;
                        dp[i+a[j]]=1;
                    }
                }
            }
        }   
        if(dp[k])
            cout<<"First";
        else cout<<"Second";
    }
    return 0;
}

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

const bool DEBUG = false;

string S;

void input() { cin >> S; }

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

  if ((S[2] == S[3]) && (S[4] == S[5]))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;

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

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    vector<int> v, vv;
    SORT(A);
    REP(i, N) {
        int cnt = upper_bound(ALL(A), A[i]) - lower_bound(ALL(A), A[i]);
        if (binary_search(ALL(v), A[i]) == false) {
            v.push_back(A[i]);
            vv.push_back(cnt);
        }
    }

    int ans = 0, i = 0, size = vv.size();
    SORT(vv);
    while (size > K) {
        ans += vv[i];
        size--;
        i++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2804
#include<bits/stdc++.h> 
using namespace std; 
void solve(); 
int main() 
{ 
ios_base::sync_with_stdio(false);cin.tie(NULL); 



int t=1; 
/*is Single Test case?*/ 
while(t--) 
{ 
	solve(); 
	cout<<"\n"; 
} 

cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
return 0; 
} 
void solve() 
{ 
	string a , b;
	cin>>a;
	cin>>b;
    int sa=a.size();
    int sb=b.size();
	int mins=INT_MAX;
	for(int i=0;i<sa-sb+1;i++){
		int count=0;
		for(int j=i;j<i+sb;j++){
			if(a[j]!=b[j-i])
				count++;
		}
		mins=min(count,mins);
	}
	cout<<mins;
} 



Measured memory_bytes: 3832
use std::io::*;

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

fn main() {
 let (a, b, c) = (read(), read(), read());
  println!("{}",
    if a + b + c >= 22 { "bust" }
    else { "win" }
  );
}

Measured memory_bytes: 4352
/**
 * Created by kaki on 2017/04/17.
 */

import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        Scanner scan = new Scanner(System.in);
        int x = Integer.parseInt(scan.next());
        int y = Integer.parseInt(scan.next());
        int area = x * y;
        int distance = (x + y) * 2;
        System.out.println(area +" "+ distance);
    }
}

Measured memory_bytes: 25944
#include	<stdio.h>
#include	<string.h>

int main(void)
{
	int n = 0;			//???????????°
	int i;				//??°??????????????°
	int j;				//??°??????????????°
	int cntt = 0;		//??????????????°
	int cnth = 0;		//??±???????????°
	char cardt[100];	//??????????????????
	char cardh[100];	//??±???????????????

	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < 100; j++)
		{
			cardt[j] = 0;
			cardh[j] = 0;
		}

		scanf("%s %s", cardt, cardh);
		if (strcmp(cardt, cardh) == 0)
		{
			//printf("????????????\n");
			cntt += 1;
			cnth += 1;
		}
		else if (strcmp(cardt, cardh) > 0)
		{
			//printf("????????????\n");
			cntt += 3;
		}
		else if (strcmp(cardt, cardh) < 0)
		{
			//printf("??±?????????\n");
			cnth += 3;
		}
	}

	printf("%d %d\n", cntt, cnth);

	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint h, w;
    cin >> h >> w;
    vector<string> s(h);
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }
    vector<vector<int>> u(h, vector<int>(w));
    vector<vector<int>> d(h, vector<int>(w));
    vector<vector<int>> l(h, vector<int>(w));
    vector<vector<int>> r(h, vector<int>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '.') {
                if (i == 0)
                    u[i][j] = 1;
                else
                    u[i][j] = u[i - 1][j] + 1;
                if (j == 0)
                    l[i][j] = 1;
                else
                    l[i][j] = l[i][j - 1] + 1;
            }
        }
    }
    for (int i = h - 1; i >= 0; --i) {
        for (int j = w - 1; j >= 0; --j) {
            if (s[i][j] == '.') {
                if (i == h - 1)
                    d[i][j] = 1;
                else
                    d[i][j] = d[i + 1][j] + 1;
                if (j == w - 1)
                    r[i][j] = 1;
                else
                    r[i][j] = r[i][j + 1] + 1;
            }
        }
    }
    int ret = 0;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            chmax(ret, u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3);
        }
    }
    cout << ret << "\n";
    return 0;
}

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

using namespace std;

int main()
{
    int x, y;
    cin >> x >> y;

    vector<int> a{0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    if (a[x] == a[y])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// nichijou
#define REP(i,a,b) for (int i(a), _B(b); i < _B; ++i)
#define RP(i,n) REP(i,0,n)
#define PER(i,a,b) for(int i((a)-1), _B(b); i >= _B; --i)
#define PR(i,n) PER(i,n,0)
#define REP1(i,a,b) REP(i,a,(b)+1)
#define RP1(i,n) REP1(i,1,n)
#define PER1(i,a,b) PER(i,(a)+1,b)
#define PR1(i,n) PER1(i,n,1)
#define DO(n) REP(__i,0,n)
template<typename T>
void cmax(T & a, T b) {a = max(a, b);}
template<typename T>
void cmin(T & a, T b) {a = min(a, b);}

// data type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second

// STL container
typedef vector<int> vi;
typedef vector<ll> vll;
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define CLR(a) a.clear()
#define BK(a) (a.back())
#define FT(a) (a.front())
#define DB(a) a.pop_back()
#define DF(a) a.pop_front()
#define PB push_back
#define EB emplace_back

/* I gave you my heart and then you turned around. */
void _BG(const char * s) {}
template<typename T, typename ... TT>
void _BG(const char * s,T a, TT...b)
{
	for (int c = 0; *s && (c || *s != ','); ++s) {
		cerr<<*s;
		switch (*s) {
		case '(':
		case '[':
		case '{':
			++c;
			break;
		case ')':
		case ']':
		case '}':
			--c;
			break;
		}
	}
	cerr<<" = "<<a;
	if (*s) {
		cerr<<", ";
		_BG(++s,b...);
	} else
		cerr<<endl;
}
#define BG(...) do { \
	cerr << __PRETTY_FUNCTION__ << ':' << __LINE__ << ": "; \
	_BG(#__VA_ARGS__,__VA_ARGS__); \
} while(0)

/* Reading input is now 20% cooler! */
bool RD(void) {return true;}
bool RD(char & a) {return scanf(" %c", &a) == 1;}
bool RD(char * a) {return scanf("%s", a) == 1;}
bool RD(double & a) {return scanf("%lf", &a) == 1;}
bool RD(int & a) {return scanf("%d", &a) == 1;}
bool RD(ll & a) {return scanf("%lld", &a) == 1;}

template<typename T, typename ... TT>
bool RD(T & a, TT & ...  b) {return RD(a) && RD(b...);}

/* Do princesses dream of magic sheep? */
#define RI(a) int a; RD(a)
#define RII(a,b) RI(a); RI(b)
#define RIII(a,b,c) RI(a); RII(b,c)
#define RIIII(a,b,c,d) RI(a); RIII(b,c,d)

/* For it's time for you to fulfill your output. */
void PT(const char a) {putchar(a);}
void PT(const char * a) {fputs(a, stdout);}
void PT(char * a) {fputs(a, stdout);}
void PT(const double a) {printf("%.16f", a);}
void PT(const int a) {printf("%d", a);}
void PT(const ll a) {printf("%lld", a);}

/* The line will last forever! */
template<char sep = ' ',char end = '\n'>
void PL(void) {if (end) PT(end);}
template<char sep = ' ',char end = '\n',typename T, typename ... TT>
void PL(const T a, const TT ...  b) {PT(a); if (sizeof...(b) && sep) PT(sep); PL<sep,end>(b...);}

/* Good Luck && Have Fun ! */
const int N = 1e5 + 87;
ll d[N * 2];
int main()
{
	RII(n,m);
	ll v = 0;
	int a,b;
	RD(a);
	REP(i,1,n) {
		RD(b);
		if (b < a)
			b += m;
		int k = b - a;
		v += k;
		if (k > 1) {
			++d[a+2];
			--d[b+1];
			--k;
			d[b+1] -= k;
			d[b+2] += k;
		}
		a = b > m ? b - m : b;
	}
	RP1(i,m*2-1) d[i] += d[i-1];
	RP1(i,m*2-1) d[i] += d[i-1];
	RP1(i,m-1) d[i] += d[i+m];
	ll ans = v - d[m];
	RP1(i,m-1) cmin(ans, v - d[i]);
	PL(ans);
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#define N (100 + 19)
#define inf (1000000000)
#define mod (1000000000 + 7)

typedef long long ll;

int bin_pow(int a, int b) {
	if (b == 0)return 1;
	if (b == 1)return a;
	int x = bin_pow(a, b / 2);
	if (b & 1)return (ll)x * x % mod * a % mod;
	else return (ll)x*x%mod;
}

int add(int x, int y) {
	ll res = x;
	res += y;
	res += (ll)mod * mod;
	return res % mod;
}

int sub(int x, int y) {
	ll res = x;
	res -= y;
	res += (ll)mod * mod;
	return res % mod;
}

int c(int n, int k) {
	ll res = 1;
	for (int i = n - k + 1; i <= n; i++) {
		res = (res * i) % mod;
	}
	ll div = 1;
	for (int i = 1; i <= k; i++) {
		div = (div * i) % mod;
	}
	return bin_pow(div, mod - 2) * res % mod;
}

int main() {
	int n;
	scanf("%d", &n);
	int a, b;
	scanf("%d%d", &a, &b);
	int ans = sub(bin_pow(2, n),1);
	//printf("%d\n", c(n, a));
	//printf("%d\n", c(n, b));
	ans = sub(ans, c(n, a));
	ans = sub(ans, c(n, b));
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
void print(int a,int b,int c)
{
	cout<<a<<" "<<b<<" "<<c<<endl;
}
void solve()
{
	for(int i=1;i<=3500;i++)
	{
		for(int j=1;j<=3500;j++)
		{
			int c=n*i*j;
			int m=4*i*j-n*i-n*j;
			if(m>0&&c%m==0)
			{
				print(i,j,c/m);
				return;
			}
		}
	}
}
signed main()
{
	cin>>n;
	if(n%2==0)
	{
		print(n,n,n/2);
		return 0;
	}
	if(n%3==0)
	{
		print(n,n/3*2,n/3*2);
		return 0;
	}
	if((n-3)%4==0)
	{
		print((n+1)/4,(n+1)*(n+1)/4,(n+1)*(n+1)*n/4);
		return 0;
	}
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
int main()
{
    ll arr[10000],n,m,i,j,sum;
    while(cin>>n)
    {
        sum=0;
        for(i=0;i<n;i++)
        {
            cin>>m;
            sum+=m;
            arr[i]=m;
        }
        if (sum%10!=0)
            cout<<sum<<endl;
        else
        {
            ll flag=0;
            sort (arr,arr+n);
            for(i=0;i<n;i++)
            {
               sum=sum-arr[i];
               if (sum%10!=0)
               {
                   flag=1;break;
               }
               else {flag=0;
                sum=sum+arr[i];}
            }
            if (flag==1)
                cout<<sum<<endl;
            else
                cout<<"0"<<endl;
        }
    }
}


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

typedef long long ll;

typedef pair<ll,ll> ii;
typedef pair<ii, ll > iii;

const int kn = 2e5 + 5, N = 1e5+5;
const ll mod = 1e9 + 7, inf = 1e18 ;

#define x first
#define y second

#define ff(i,n) for(int i=1;i<=n;i++)

ll n,m,k,a[kn];

int main() {
	cin >> n;
	ff(i,n) cin >> a[i];
	sort(a+1,a+n+1);
	cout << a[n/2+1] - a[n/2];
	
}
//hahahahahahahahahhahahahahahaahahahahhahahahahahahah


Measured memory_bytes: 1024
using System;
using System.Linq;

namespace C___Traveling_Salesman_around_Lake
{
    class Program
    {
        static void Main(string[] args)
        {
            var K_N = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var An = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int K = K_N[0], N = K_N[1];

            var diff = new int[N + 1];
            for (int i = 1; i < N; i++)
                diff[i] = An[i] - An[i - 1];

            diff[N] = (K - An[N - 1]) + An[0];
            Console.WriteLine(K - diff.Max());
        }
    }
}


Measured memory_bytes: 44640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i > (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define IN(x) cin >> x
#define DE(x) cerr << (x) << " "
#define BR cerr << "\n"
#define OUT(x) cout << (x) << endl
#define FIX cout << fixed << setprecision(10)

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  
  IN(N);
  if (N < 600) {
    ret = 8;
  } else if (N < 800) {
    ret = 7;
  } else if (N < 1000) {
    ret = 6;
  } else if (N < 1200) {
    ret = 5;
  } else if (N < 1400) {
    ret = 4;
  } else if (N < 1600) {
    ret = 3;
  } else if (N < 1800) {
    ret = 2;
  } else if (N < 2000) {
    ret = 1;
  }

  OUT(ret);

}


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

int main(){
  ll k; // <= 1e6
  cin >> k;

  vector<int> a(1e6+1,0);
  a[1] = 7%k;
  rep2(i,2,k+1){
    a[i] = (a[i-1]*10+7) % k;
  }
  rep2(i,1,k+1){
    if (a[i] == 0){
      cout << i << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 7212
#include<bits/stdc++.h>
using namespace std;
 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define eb emplace_back
#define ll long long
#define nl '\n'
#define in() ( { int a ; scanf("%d",&a); a; } )
 
const int N = 3e5 + 9;
const int mod = 1e9 + 7;
//int dx[]={1,0,-1,0,1,-1,-1,1};
//int dy[]={0,1,0,-1,1,1,-1,-1};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    string s, t;
    int i, cnt = 0;
    cin >> s >> t;
    for(i = 0; i < s.size(); i++){
        if(s[i] != t[i]){
            cnt++;
        }
    }
    cout << cnt << nl;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int n , k ;
  cin >> n >> k ;
  int now = k ;
  int ans = 1 ;
  
  while(now <= n ){
    now *= k ;
    ans++ ;
  }
  
  cout << ans ;


}


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

int main() {
  int n;
  cin >> n;
  if (n < 1000) cout << "ABC" << endl;
  else cout << "ABD" << endl;
  return 0;
}

Measured memory_bytes: 3608
import sys

stdin = sys.stdin

ns = lambda : stdin.readline().rstrip()
ni = lambda : int(ns())
na = lambda : list(map(int, stdin.readline().split()))

def main():
  h, w = na()
  a = [ns() for _ in range(h)]
  a = ["".join(hw) for hw in zip(*a) if hw.count("#") > 0]
  a = ["".join(hw) for hw in zip(*a) if hw.count("#") > 0]
  print("\n".join(a))

main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	long x;
	cin >> x;
	int co = 0;

	for (int i = 1; i < x + 1; i++)
	{
		int p = 0;
		for (int j = 1; j < 100; j++)
		{
			for (int k = 2; k < 100; k++)
			{
				if (i == pow(j,k))
				{
					p++;
					if (co < i)
					{
						co = 0;
						co = i;
					}
					break;
				}
			}
			if (p != 0)
			{
				break;
			}
		}
	}

	cout << co << endl;
}


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

int n;
int id[102], score[102], rank[102];

int main(){
  while(cin >> n){
    //ツ催?渉可づ債全ツチツーツδ?づ個スツコツアツつェ0ツづ按づ個づ? 0ツづ?渉可甘コツ可サツつオツづ?つィツつォツづ慊つキ
    memset(score, 0, sizeof(score));

    for(int i = 0; i < n * (n - 1) / 2; i++){
      int a, b, c, d;
      cin >> a >> b >> c >> d;

      //ツイツδ督デツッツクツスツつェ1ツつゥツづァツづ按づ個づ? 0ツづ可債?づュツつケツづ慊つキ
      a--;
      b--;

      //Aツつェツ渉淞づ?
      if(c > d){
        score[a] += 3;
      }
      //Aツづ?ツづ債暗クツつォツ閉ェツつッ
      else if(c == d){
        score[a]++;
        score[b]++;
      }
      //Bツつェツ渉淞づ?
      else{
        score[b] += 3;
      }
    }

    //ツソツーツトツつオツつスツ古」ツづ可づ?づ個チツーツδ?つェツ可スツ氾板姪堋づ個チツーツδ?つセツづ?つスツつゥツづュツつゥツづァツづ按つュツづ按づ?づ?つオツづ慊つ、ツづ個づ?
    //ツスツコツアツづーツソツーツトツつキツづゥツづ?つォツづ? ツチツーツδ?づ個渉?氾板づ?暗ェツ渉渉づ可ソツーツトツつオツづ慊つキ
    for(int i = 0; i < n; i++){
      id[i] = i;
    }

    //ツソツーツトツ渉按猟敖づ?つキ
    for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
        //ツ渉?氾板つェツ逆ツ転ツつオツづ?つ「ツづゥツ湘ェツ債?づ? ツ禿シツづェツ妥鳴つヲ
        if(score[i] < score[j]){
          swap(score[i], score[j]);
          swap(id[i], id[j]);
        }
      }
    }

    //ツ出ツ療債づ個配ツ療アツづ可渉?暗環づーツ渉堕つォツつアツづアツづ?つ「ツつォツづ慊つキ
    for(int i = 0; i < n; i++){
      //ツ暗ェツづつ湘」ツづ個チツーツδ?づ?スツコツアツつェツ督ッツつカツづ按づァ, ツ暗ェツづつ湘」ツづ個チツーツδ?づ?督ッツつカツ渉?暗環づーツ渉堕つォツつアツづ敖づ慊つキ
      if(0 < i && score[i] == score[i - 1]){
        rank[id[i]] = rank[id[i - 1]];
      }
      //ツ督ッツつカツスツコツアツづ?づ按つ「ツづ按づァ, i+1ツつェツ渉?暗環づ可づ按づィツづ慊つキ(iツづ債スツコツアツづ個渉?づ?δ仰ーツプツづーツ嘉アツつオツづ?つ「ツづゥツつスツづ?
      else{
        rank[id[i]] = i + 1;
      }
    }

    //ツ出ツ療債つオツづ慊つオツづ・ツつ、
    for(int i = 0; i < n; i++){
      cout << rank[i] << endl;
    }
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define LETSGO     ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(x)     (x).begin() , (x).end()
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
typedef long long int ll;
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


const ll mod = 1e9+7;
const double eps = 1e-9;



void solve(){
    int r,c,k;
    cin >> r >> c >> k;
    char a[r][c];
    for(int i=0;i<r;++i)
        for(int j=0;j<c;++j)
            cin >> a[i][j];

    int ans=0;
    for(int i=0;i<1<<(r+c);++i) {
        int cnt=0;
        for(int l=0;l<r;++l) {
            for(int j=0;j<c;++j) {
                if(((i&(1<<l)) | (i&(1<<(r+j)))) && a[l][j]=='#')continue;
                cnt+=a[l][j]=='#';
            }
        }
        ans+=(cnt==k);
    }
    cout << ans;
}





int main(){
    LETSGO
    int test=1;
    while(test--)
        solve();
    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll N, A, B;
ll X[MAX_N];

int main()
{
    cin >> N >> A >> B;
    ll ans = 0;
    REP(i, N) {
        cin >> X[i];
    }
    for(int i = 1; i < N; ++i) {
        ll pat_a = (X[i] - X[i-1]) * A;
        if(pat_a > B) { ans += B; }
        else { ans += pat_a; }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
s=0
num = [int(i) for i in input().split()]
mx = num[0]
mn = num[0]
for i in range(n):
        s = s+num[i]
        if(mx < num[i]):
            mx = num[i]
        if(mn > num[i]):
            mn = num[i]
print("{} {} {}".format(mn,mx,s))


Measured memory_bytes: 6604
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,m,n) for(int i = m;i<(int)n;i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;
static const int MAX = 100;
static const long long INFTY = (1LL << 32);

int n = 10;
int d[MAX][MAX];

void floyd() {
	for (int k = 0; k < n; k++)
	{
		for (int i = 0; i < n; i++)
		{
			if (d[i][k] == INFTY) continue;
			for (int j = 0; j < n; j++)
			{
				if (d[k][j] == INFTY) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}

int main()
{
	int H, W;
	cin >> H >> W;
	rep(i, 0, 10)rep(j, 0, 10) { cin >> d[i][j]; };

	int m[200][200];
	rep(i, 0, H)rep(j, 0, W) { cin >> m[i][j]; };

	floyd();

	int sum = 0;
	rep(i, 0, H)
	{
		rep(j, 0, W) {
			if (m[i][j] != -1) {
				sum += d[m[i][j]][1];
			};
		}
	};

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

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;

const int MAX = 101;
int n;
int a[MAX];
int b[MAX];

int ID = 1;
map<int, int> mp;
int toI(int num) {
    if (!mp.count(num)) {
        return mp[num] = ID++;
    }
    return mp[num];
}

int bit[MAX];

void add(int i, int x) {
    while (i < ID) {
        bit[i] += x;
        i += i & (-i);
    }
}

int sum(int i) {
    int s = 0;
    while (i > 0) {
        s += bit[i];
        i -= i & (-i);
    }
    return s;
}

int main() {
    scanf("%d", &n);
    memset(bit, 0, sizeof(bit));
    int ans = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        b[i] = a[i];
    }
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        toI(a[i]);
    }
    for (int i = 0; i < n; i++) {
        ans += sum(ID-1) - sum(toI(b[i]));
        add(toI(b[i]), 1);
    }
    for (int i = 0; i < n; i++) {
        if (i > 0) printf(" ");
        printf("%d", a[i]);
    }
    printf("\n");
    printf("%d\n", ans);
    return 0;
}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define  IOS    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     int h,w;
     cin >> h >> w;
     int n;
     cin >> n;
     vector<int> v(n);
     for(int i=0;i<n;i++)cin >> v[i];
     vector<vector<int>> grid(h,vector<int> (w));
     int a = 0;
     int k = v[a];
     for(int i=0;i<h;i++){
       for(int j=0;j<w;j++){
          if(k>0)grid[i][j]=a+1,k--;
          else{
            a++;
            grid[i][j]=a+1;
            k = v[a]-1;
          }
          // cout << grid[i][j] << ' ';
       }
       // cout << '\n';
     }
     for(int i=0;i<h-1;i++){
        if(grid[i][w-1]==grid[i+1][0])reverse(all(grid[i+1]));
     }
     for(auto row:grid){
       for(int x:row)
       cout << x << ' ';
       cout << '\n';
     }

  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 384
"""
解説AC。むずい

反転操作で変わるもの
⇨両端の関係性だけ

違う文字で囲まれていて、
連続区間で囲まれているやつらをひっくり返すと
連続個数が+2される
LRLLLRRLR ...3

LRRRRRRLR ...5
コレでもOK(違う文字で囲まれているので)
だけど、素直に連続してもじが並んでいるものの個数を数えると良いかも
LLRRRLLLR ...5

端っこだけ注意。けど、端っこ含めてひっくり返すときは+1なので、
操作の一番最後に行う
LLLLLLLLR ...7
LLLLLLLLL ...8
"""
N,K = map(int, input().split())
S = input()

prev = S[0]
from collections import defaultdict
LRs = defaultdict(list)
cnt_seq = 0
for i in range(1,N):
    if prev == S[i]:
        cnt_seq += 1
    prev = S[i]

# print(cnt_seq)
ans = min(cnt_seq+2*K,N-1)
print(ans)

Measured memory_bytes: 3444
// ~/BAU/ACM-ICPC/Teams/Rampage/Abukhadijah
// ~/sudo apt-get verdict Accpeted
// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
const double PI = acos(-1.0);
const double  EPS = 1e-11;
typedef long long ll;
typedef unsigned long long ull;
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
void fast()
{
	std::ios_base::sync_with_stdio(0);
}
int main()
{
	int n;
	cin >> n;
	if (n == 1||n==2||n==3) {
		cout << 1;
		return 0;
	}
	int ans = 0;
	for (int i = 2; i < n; i++)
	{
		int t = (i*i);
		while (t <= n)
		{
			t *= i;
			ans = max(ans, t / i);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

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



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int x, n;
  cin >> x >> n;
  vector<bool> p(102, false);
  rep(i, n){
    int in;
    cin >> in;
    p.at(in) = true;
  }
  int ans = 1001001;
  rep(i, 102){
    if(p.at(i) == true) continue;
    if(abs(x-i) < abs(x - ans)) ans = i;
  }
  cout << ans << endl;
  return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

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

  int64 N, K, S, T, L;
  cin >> N >> K >> S >> T;
  vector<int64> A, c(N+1, 0);
  auto comb = make_v<int64>(51, 51);
  fill_v<int64>(comb, 0);
  comb[0][0] = 1;
  REP(i, 50) {
    REP(j, i+1) {
      comb[i+1][j] += comb[i][j];
      comb[i+1][j+1] += comb[i][j];
    }
  }
  REP(i, N+1) {
    FOR(j, 0, min(K, N) + 1) {
      c[i] += comb[i][j];
    }
  }

  REP(i, N) {
    int64 a;
    cin >> a;
    int b = 0, cnt = 0;
    REP(i, 18) {
      if (((S >> i & 1) && !(a >> i & 1)) || (!(T >> i & 1) && (a >> i & 1))) {
        b = -1;
        break;
      }
      if ((S >> i & 1) || !(T >> i & 1)) continue;
      b |= (a >> i & 1) << (cnt++);
    }
    if (b != -1) {
      A.push_back(b);
      L = cnt;
    }
  }

  int64 res = 0;

  vector<int> cnt(1 << L, 0);
  REP(M, 1 << L) {
    REP(i, A.size()) {
      cnt[A[i] & M]++;
    }
    REP(i, A.size()) {
      res += (__builtin_popcount(M) % 2 ? -1 : 1) * c[cnt[A[i] & M]];
      cnt[A[i] & M] = 0;
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 4232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    ll n;
    cin >> n;
    vector<ll>a(n);
    for(ll i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    vector<ll>cnt;
    ll x=0,ok=1;
    for(ll i=1;i<n;i++){
        if(a[i]==a[i-1]){
            if(ok==1) cnt.push_back(0);
            ok=0;
            cnt[x]++;
        }else{
            if(ok==0) x++;
            ok=1;
        }
    }
    ll ans=n;
    for(ll i=0;i<cnt.size();i++){
        while(cnt[i]>0){
            if(cnt[i]>=2){
                cnt[i]-=2;
                ans-=2;
                continue;
            }
            cnt[i]--;
            if(i!=cnt.size()) cnt[i+1]--;
            ans-=2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4216
import math
n, k = map(int, input().split())
ans = 0
for i  in range(1, n+1):
  c = math.ceil(math.log(k/i,2))
  if c < 0:
    c = 0
  ans += 1 / n * (0.5) ** c
print('{:.12f}'.format(ans))

Measured memory_bytes: 39152
N, X = map(int, input().split())
Ls = [int(i) for i in input().split()]

Ds = [0]
for i, l in enumerate(Ls):
    Ds.append(Ds[i] + l)

ans = 0
for d in Ds:
    if d <= X:
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    int t[4] = {0};
    for(int i=0; i<3; i++) std::cin >> t[i];
    std::sort(t, t+3);
    std::cout << t[0] + t[1] << std::endl;
    return 0;
}

Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
  return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

from decimal import Decimal

a,b,x = II()

p = x*(math.ceil(Decimal(a)/Decimal(x)))
q = x*(math.floor(Decimal(b)/Decimal(x)))

if p>b or q<a or p>q:
  print(0)
else:
  print((q-p)//x+1)

Measured memory_bytes: 61676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2000005;
const int mod=1000000007;
int nx[10],ny[10];
ll fac[maxn],inv_fac[maxn];
struct node { int x,y,z; node(int x_=0,int y_=0,int z_=0):x(x_),y(y_),z(z_) { } } p[10];
inline ll C(int n,int m) { if(n<m) return 0; return fac[n]*inv_fac[m]%mod*inv_fac[n-m]%mod; }
inline ll P(int x,int y,int u,int v) { int a=abs(x-u),b=abs(y-v); return C(a+b,a); }
inline ll solve(int x,int y,int u,int v)
{
	ll ans=0;
	for(int z=nx[3];z<=nx[4];z++)
		(ans+=P(x,y,z,ny[4])*P(z,ny[4]+1,u,v)%mod*(z+ny[4]))%=mod,
		(ans-=P(x,y,z,ny[3]-1)*P(z,ny[3],u,v)%mod*(z+ny[3]-1))%=mod;
	for(int z=ny[3];z<=ny[4];z++)
		(ans+=P(x,y,nx[4],z)*P(nx[4]+1,z,u,v)%mod*(nx[4]+z))%=mod,
		(ans-=P(x,y,nx[3]-1,z)*P(nx[3],z,u,v)%mod*(nx[3]-1+z))%=mod;
	return ans;
}
int main()
{
	fac[0]=fac[1]=inv_fac[0]=inv_fac[1]=1;
	for(int i=2;i<maxn;i++) fac[i]=fac[i-1]*i%mod;
	for(int i=2;i<maxn;i++) inv_fac[i]=(mod-mod/i)*inv_fac[mod%i]%mod;
	for(int i=2;i<maxn;i++) inv_fac[i]=inv_fac[i]*inv_fac[i-1]%mod;
	for(int i=1;i<=6;i++) scanf("%d",&nx[i]);
	for(int i=1;i<=6;i++) scanf("%d",&ny[i]);
	p[1]=node(nx[1]-1,ny[1]-1,1);
	p[2]=node(nx[1]-1,ny[2],-1);
	p[3]=node(nx[2],ny[1]-1,-1);
	p[4]=node(nx[2],ny[2],1);
	p[5]=node(nx[6]+1,ny[6]+1,1);
	p[6]=node(nx[6]+1,ny[5],-1);
	p[7]=node(nx[5],ny[6]+1,-1);
	p[8]=node(nx[5],ny[5],1);
	ll ans=0;
	for(int i=1;i<=4;i++)
		for(int j=5;j<=8;j++)
			(ans+=solve(p[i].x,p[i].y,p[j].x,p[j].y)*p[i].z*p[j].z)%=mod;
	printf("%lld\n",(ans+mod)%mod);
	return 0;
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
#define mp make_pair
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using vll = vector<ll>; using vvll = vector<vll>; using P = pair<ll, ll>;
using ld = long double;  using vld = vector<ld>; 

int main(void) {
	
	ll n; cin >>n;

	cout <<n/3 <<endl;
	
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

accepted = set()
penalty = 0
wa_cnt = [0] * (n+1)

for i in range(m):
    p, s = input().split()
    p = int(p)
    if p in accepted:
        continue
    if s == "AC":
        penalty += wa_cnt[p]
        accepted.add(p)
    else:
        wa_cnt[p] += 1


print(len(accepted), penalty)

Measured memory_bytes: 12652
#include <iostream>

using namespace std;

int main()
{
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		for (int q = 0; q < h; q++) {
			for (int e = 0; e < w; e++) {
				if (q == 0 || e == 0 || q == (h - 1) || e == (w - 1)) cout << '#';
				else cout << '.';
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3108
#include <stdio.h>

#define N 1000

int moji_num(char c) {
	return c - 48;
}

int main(void)
{
	char str[N];
	int x[1001] = { 0 };
	int i = 0,cnt = 0;

	while (1) {
		scanf("%c", &str[i]);
		
		if (str[i] == '\n') {
			cnt++;
			i = 0;
		}
		else {
			x[cnt] += moji_num(str[i]);
			if (x[cnt] == 0) {
				break;
			}
		}
		i++;

	}

	for (i = 0; i < cnt; i++) {
		printf("%d\n", x[i]);
	}
	
	return 0;
}


Measured memory_bytes: 2124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + 7;

int a[N];


int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	for (int i=0; i<3*n; i++)
		cin >> a[i];
	sort(a, a+3*n);
	ll ans = 0;
	for (int i=0; i<n; i++)
		ans += a[3*n - 2 - 2 * i];
	cout << ans << "\n";

	return 0;
}

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

namespace Contest
{
    class Program
    {
        static int Main(string[] args)
        {
            new Program().Process();

            return 0;
        }

        private CommonInput cin;

        private void Process()
        {
            this.cin = new CommonInput();

            int x, y, j, a;
            int tSum, hSum;
            List<int> taro = new List<int>(), hanako = new List<int>();

            while (true)
            {
                x = this.cin.GetNextToInt();
                y = this.cin.GetNextToInt();

                if (x == 0 && y == 0)
                    break;

                taro.Clear();
                hanako.Clear();

                for (int i = 0; i < x; i++)
                    taro.Add(cin.GetNextToInt());

                for (int i = 0; i < y; i++)
                    hanako.Add(cin.GetNextToInt());

                tSum = taro.Sum();
                hSum = hanako.Sum();

                if ((tSum - hSum) % 2 == 0)
                {
                    taro = taro.OrderBy(z => z).ToList();

                    j = 0;
                    do
                    {
                        a = hanako.FindIndex(z => z == taro[j] - (tSum - hSum) / 2);
                    } while (++j < taro.Count && a == -1);

                    if (a != -1)
                        Console.WriteLine("{0} {1}", taro[j - 1], hanako[a]);
                    else
                        Console.WriteLine("-1");
                }
                else
                {
                    Console.WriteLine("-1");
                }
            }
        }
    }

    public class CommonInput
    {
        public CommonInput()
        {
            this._s = new string[0];
            this._i = 0;
        }

        public string Line { get; set; }
        private string[] _s;
        private int _i;
        private char[] _sep = { ' ' };

        public void GetLine()
        {
            this._i = 0;
            do
            {
                this.Line = Console.ReadLine();
            } while (this.Line == "");

            if (this.Line != null)
                this._s = this.Line.Split(this._sep, StringSplitOptions.RemoveEmptyEntries);
        }

        public string GetNext()
        {
            if (this._i < this._s.Length)
                return this._s[this._i++];

            this.GetLine();

            return this._s[this._i++];
        }

        public int GetNextToInt()
        {
            return int.Parse(this.GetNext());
        }

        public long GetNextToLong()
        {
            return long.Parse(this.GetNext());
        }

        public double GetNextToDouble()
        {
            return double.Parse(this.GetNext());
        }
    }
}

Measured memory_bytes: 6492
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int

using namespace std;


int main() {
	speed;
	int n, m;
	int l, r;
	vector<int>L;
	vector<int>R;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> l;
		cin >> r;
		L.push_back(l);
		R.push_back(r);
	}
	sort(L.begin(), L.end());
	sort(R.begin(), R.end());

	int ans=R.front()- L.back();
	if (ans < 0)ans = -1;
	cout << ans+1;
	ed;
	return 0;
}


Measured memory_bytes: 1276