akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
    public static void main(String[] args) throws NumberFormatException {
        Scanner sc = new Scanner(System.in);

        String S = sc.nextLine().trim();
        int[] digits = new int[4];

        boolean nonDigit = false;
        for (int i = 0; i < 4; i++) {
            char c = S.charAt(i);
            if (Character.isDigit(c)) {
                digits[i] = Character.digit(S.charAt(i), 10);
            } else {
                nonDigit = true;
                break;
            }
        }

        if (nonDigit) {
            System.out.println("NA");
        } else {
            boolean canYYMM = isYY(digits[0], digits[1]) && isMM(digits[2], digits[3]);
            boolean canMMYY = isMM(digits[0], digits[1]) && isYY(digits[2], digits[3]);

            if (canYYMM && canMMYY) {
                System.out.println("AMBIGUOUS");
                return;
            }
            if (canYYMM) {
                System.out.println("YYMM");
                return;
            }
            if (canMMYY) {
                System.out.println("MMYY");
                return;
            }
            System.out.println("NA");
        }
    }

    private static boolean isYY(int d1, int d2) {
        return 0 <= d1 && d1 <= 9 && 0 <= d2 && d2 <= 9;
    }
    private static boolean isMM(int d1, int d2) {
        if (d1 == 0) {
            return 1 <= d2 && d2 <= 9;
        } else if (d1 == 1) {
            return 0 <= d2 && d2 <= 2;
        } else {
            return false;
        }
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#define mod 1000000007
#define pie 3.141592653589793238
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;
  
  if(a>b)cout << "safe" << endl;
  else cout << "unsafe" << endl;
  
  return 0;
}

Measured memory_bytes: 3652
N, A, B = map(int, input().split())
count = 0

def cal(n):
    item = str(n)
    count = 0
    for i in range(len(item)):
        count += int(item[i])
    return count

for i in range(1, N+1):
    sum = cal(i)
    if A <= sum <= B:
        count += i

print(count)

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

int n,m,s[100],c[100];
int D[100];

int main(){
	
	scanf("%d%d",&n,&m);
	for ( int i = 0; i < m; i++ ){
		scanf("%d%d",&s[i],&c[i]);
	}
	
	memset(D,-1,sizeof(D));
	for ( int i = 0; i < m; i++ ){
		if ( D[s[i]] != -1 ){
			if ( D[s[i]] != c[i] ){
				printf("-1\n");
				return 0;
			} 
		} else {
			D[s[i]] = c[i];
		}
	}
	for ( int i = 2; i <= n; i++ ){
		if ( D[i] == -1 ) D[i] = 0;
	}

	if ( n > 1 && D[1] == -1 ) {
		D[1] = 1;
	}
	else if ( n > 1 && D[1] == 0 ){
		printf("-1\n");
		return 0;
	}
	if ( n == 1 && D[1] == -1 ) D[1] = 0;
	for ( int i = 1; i <= n; i++ ) printf("%d",D[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  string s;
  cin >> N >> s;
  int red = 0;
  int blue = 0;
  for (int i = 0; i < N; i++) {
  	if (s.at(i) == 'R') {
    	red++;
    }else {
    	blue++;
    }
  } 
  if (red > blue) {
  	cout << "Yes\n";
  }else {
  	cout << "No\n";
  }
}

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

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N){
        cin >> P.at(i);
    }
    int count = 0;
    int mi = P.at(0);
    rep(i, N){
        if (mi >= P.at(i)){
        mi = P.at(i);
        count++;
        }
    }
    cout << count << endl;
    return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
long long  ans=0;
int main()
{
    int n,i;
    long long f[10];
    char a[15];
    memset(f,0,sizeof(f));
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s",a);
        if(a[0]=='A')
            f[1]+=1;
        else if(a[0]=='M')
            f[2]+=1;
        else if(a[0]=='R')
            f[3]+=1;
        else if(a[0]=='H')
            f[4]+=1;
        else if(a[0]=='C')
            f[5]+=1;
    }
    /*for(i=1;i<=5;i++)
    {
        if(f[i]>0)
            g+=1;
        else
            f[i]=1;
    }*/
    ans+=f[1]*f[2]*f[3];
    ans+=f[1]*f[2]*f[4];
    ans+=f[1]*f[2]*f[5];
    ans+=f[2]*f[3]*f[4];
    ans+=f[2]*f[3]*f[5];
    ans+=f[1]*f[3]*f[4];
    ans+=f[1]*f[3]*f[5];
    ans+=f[1]*f[4]*f[5];
    ans+=f[2]*f[4]*f[5];
    ans+=f[3]*f[4]*f[5];
 
    printf("%lld",ans);
    return 0;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  int A, B, C; cin >> A >> B >> C;
  if(C >= A && C <= B) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3636
import math,sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili=lambda:list(map(int,sys.stdin.readlines()))
li = lambda:list(map(int,input().split()))
#for deque append(),pop(),appendleft(),popleft(),count()
I=lambda:int(input())
S=lambda:input().strip()
mod = 1000000007

n,k,s=li()
c=0
f=0
while(k>0 and n>0):
    print(s,end=" ")
    k-=1
    n-=1
while(n):
    if(s==0):
        print(1,end=" ")
    elif(s==(10**9)):
        print(s-1,end=" ")
    else:
        print(s+1,end=" ")
    n-=1


print("")


Measured memory_bytes: 4576
#include <iostream>

using namespace std;

int main() {
    int x;

    cin >> x;

    int ths = 0;
    int fvs = 0;
    if (x >= 500) {
        ths += (x / 500);
        x -= (ths * 500);
    }

    if (x >= 5) {
        fvs += (x / 5);
    }

    cout << ((ths * 1000) + (fvs * 5)) << endl;
}

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

int main() {

	string S;
	cin >> S;

	string firstTwo = S.substr(0,2);
	int firstTwoNum = stoi(firstTwo);

	string lastTwo = S.substr(2);
	int lastTwoNum = stoi(lastTwo);

	if (firstTwoNum >= 1 && firstTwoNum <= 12) {
		if (lastTwoNum >= 1 && lastTwoNum <= 12) {
			cout << "AMBIGUOUS" << endl;
		}else {
			cout << "MMYY" << endl;
		}
	}else {
		if (lastTwoNum >= 1 && lastTwoNum <= 12) {
			cout << "YYMM" << endl;
		}else {
			cout << "NA" << endl;
		}
	}

	

	return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int W = sc.nextInt();
    int[] w = new int[N];
    int[] v = new int[N];
    for (int i = 0; i < N; i++) {
      w[i] = sc.nextInt();
      v[i] = sc.nextInt();
    }
    
    long[][] dp = new long[N][W+1];
    dp[0][w[0]] = v[0];
    for (int i = 0; i < N-1; i++) {
      for (int j = 0; j <= W; j++) {
        // not use
        dp[i+1][j] = Math.max(dp[i+1][j], dp[i][j]);
        // use
        if (j+w[i+1] > W) continue;
        dp[i+1][j+w[i+1]] = Math.max(dp[i+1][j+w[i+1]], dp[i][j]+v[i+1]);
      }
    }
    
    long ans = 0;
    for (int j = 0; j <= W; j++) {
      ans = Math.max(ans, dp[N-1][j]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 126036
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>

#define x first
#define y second

#define INF 0x3f3f3f3f

using namespace std;

typedef long long LL;
typedef pair<int,int>PII;

const int maxn = 1e5 + 10;

int vis[maxn],cnt[maxn];
int fa[maxn],sz[maxn],deg[maxn];

int ans = 0;

int get(int x) {
    return x == fa[x] ? x : fa[x] = get(fa[x]);
}

void Union(int x,int y) {
    int xx = get(x);
    int yy = get(y);
    if(xx == yy) return ;
    fa[yy] = xx;
    sz[xx] += sz[yy];
    return ;
}

int main(void) {
    int n,m,k;
    int u,v;
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i ++) {
        fa[i] = i;
        // 刚开始每个都是独立的,都是一个 
        sz[i] = 1;

    }
    for(int i = 1; i <= m; i ++) {
        cin >> u >> v;
        // 记录每个点的出度 
        deg[u] ++;
        deg[v] ++;
        Union(u,v);
    }
    for(int i = 1; i <= k; i ++) {
        cin >> u >> v;
        if(get(u) == get(v)) {
            // 不是朋友,但在同一个连通块内,所以都需要减少 
            cnt[u] --;
            cnt[v] --;
        }
    }
    for(int i = 1; i <= n; i ++) {
        cout << sz[get(i)] - deg[i] + cnt[i] - 1<< " ";
    }
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <tuple>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 P = 1000000000 + 7;
const int maxn = 300000;
i64 fact[maxn], tcaf[maxn];

i64 deg(i64 x, i64 d) {
    d %= P - 1;
    if (d < 0) d += P - 1;
    i64 y = 1;
    while (d) {
        if (d & 1) y *= x, y %= P;
        x *= x, x %= P;
        d /= 2;
    }
    return y;
}

i64 cnk(int n, int k) {
    return fact[n] * tcaf[k] % P * tcaf[n - k] % P;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    fact[0] = tcaf[0] = 1;
    for1(i, maxn - 1) fact[i] = fact[i - 1] * i % P, tcaf[i] = deg(fact[i], -1);
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    i64 ans = cnk(n + m - 2, n - 1);
    forn(i, b) {
        ans -= cnk(n - a - 1 + i, i) * cnk(a - 1 + m - i - 1, a - 1);
        ans %= P;
    }
    if (ans < 0) ans += P;
    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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


/*
int main(){
    int n,m; cin >> n >> m;
    vector<int> s(m),c(m);
    for (int i = 0; i < m; i++)
    {
        cin >> s.at(i) >> c.at(i);
    }
    vector<int> ans(n,-1);
    for (int i = 0; i < m; i++)
    {
        int digit = s.at(i) - 1;
        int num = c.at(i);
        if (digit == 0 && num == 0 && n != 1)
        {
            cout << -1 << endl;
            return 0;
        }
        if (ans.at(digit) == -1 || ans.at(digit) == num)
        {
            ans.at(digit) = num;
        }
        else
        {
            cout << -1 << endl;
            return 0;
        }

        
    }

    for (int i = 0; i < n; i++)
    {
        if (ans.at(i) == -1) ans.at(i) = 0;
    }
    
    if (n != 1 && ans.at(0) == 0)ans.at(0) = 1;


    for (auto &&i : ans)
    {
        cout << i;
    }
    
    cout << endl;
    
    
}
*/

int main(){
    int n,m; cin >> n >> m;
    vector<int> s(m),c(m);
    for (int i = 0; i < m; i++)
    {
        cin >> s.at(i) >> c.at(i);
    }
    int start;
    if (n == 1) start = 0;
    else start = pow(10,n-1);
    for (int i = start; i < pow(10,n); i++)
    {
        bool flag = true;
        string t = to_string(i);
        //cout << t << endl;
        for (int i = 0; i < m; i++)
        {
            int digit = s.at(i) - 1;
            int num = c.at(i);
            //cout << digit << " " << (char)(num + '0') << endl;

            if (t.at(digit) != (char)(num + '0'))flag = false;
            //else cout << "true" << endl;
        }
        if (flag)
        {
            cout << i << endl;
            return 0;
        }
        
    }
    cout << -1 << endl;
    return 0;

}


Measured memory_bytes: 512
import java.util.*;

public class Main{
public static void main(String[] args)
{ 
  Scanner sc=new Scanner(System.in);
  int x=sc.nextInt();
  int n=sc.nextInt();
  Set<Integer> set =new HashSet<>();
  for(int i=0;i<n;i++)
    set.add(sc.nextInt());
  int ans=x;
  for(int i=x,j=x;;i++,j--)
  {  if(!set.contains(i))
    { ans=i;
     break;}
   
   else if(!set.contains(j-1))
    {ans=j-1;
      break;}
    
    else if(!set.contains(i+1))
    { ans=i+1;
     break;}
    
  }

  System.out.println(ans);
}
 
}


Measured memory_bytes: 35920
ARG_N = gets.to_i
ARG_A = gets.split.map(&:to_i)
MOD = 10**9+7

def modpow(a,n)
  res = 1
  while(n>0) do
    res = res * a % MOD if n & 1
    a = a * a % MOD
    n /= 2
  end
  res
end

def modinv(a)
  return modpow(a, MOD - 2)
end

lcm = 1
result = 0
ARG_A.each do |a|
  prev_lcm = lcm
  lcm = a.lcm(lcm)
  result = ((result * (lcm / prev_lcm)) + (lcm / a)) % MOD
end

puts result

Measured memory_bytes: 51684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;
#define md 200005
ll fac[md + 2];
ll PowerMod(ll a, ll b)
{
    ll tmp = a, ret = 1;
    while (b)
    {
        if (b & 1)
            ret = (ret * tmp) % mod;
        tmp = (tmp * tmp) % mod;
        b >>= 1;
    }
    return ret;
}
ll modInverse(ll n)
{
    return PowerMod(n, mod - 2);
}
int main()
{
    fac[0] = 1;
    for (ll i = 1; i < md; i++) fac[i] = (fac[i - 1] * i) % mod;
    ll n, a, b, base = 2 * 1LL;
    cin >> n >> a >> b;
    //if (n == a || n == b) return cout << 0, 0;
    //a = min(a, n - a);
    //b = min(b, n - b);
    ll ans = PowerMod(base, n);
    ans = (ans + mod - 1) % mod;
    //cout << ans << " ";
    ll tmpa = a, tmpn = n;
    ll fup = 1;
    while (tmpa--)
    {
        fup = fup * tmpn;
        fup %= mod;
        tmpn--;
    }
    fup = (fup * modInverse(fac[a])) % mod;
    // cout << fup << " ";
    ans = (ans + mod - fup) % mod;
    if (a != b) {
        ll tmpb = b;
        tmpn = n;
        fup = 1;
        while (tmpb--)
        {
            fup = fup * tmpn;
            fup %= mod;
            tmpn--;
        }
        fup = (fup * modInverse(fac[b])) % mod;
        // cout << fup << endl;
        ans = (ans + mod - fup) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MN 210001
#define int long long
using namespace std;

int read_p,read_ca;
inline int read(){
	read_p=0;read_ca=getchar();
	while(read_ca<'0'||read_ca>'9') read_ca=getchar();
	while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
	return read_p;
}
const int MOD=1e9+7,M=1e15;
int n,a[MN],ro=0,mmh=0,k,ls[MN*30],rs[MN*30],s[MN*30],NUM=0;
void add(int &p,int l,int r,int k){
	if (!p) p=++NUM,ls[p]=rs[p]=s[p]=0;
	s[p]++;
	if (l==r) return; 
	int mid=l+r>>1;
	if (k<=mid) add(ls[p],l,mid,k);else add(rs[p],mid+1,r,k);
}
int ask(int p,int l,int r,int k){
	if (!p) return 0;
	if (r<=k) return s[p];
	
	int mid=l+r>>1;
	if (k<=mid) return ask(ls[p],l,mid,k);else return ask(rs[p],mid+1,r,k)+ask(ls[p],l,mid,k);
}
signed main(){
	int i,j,k;
	n=read();k=read();
	add(ro,-M,M,0);
	for (i=1;i<=n;i++){
		a[i]=read()-k;a[i]+=a[i-1];
		mmh+=ask(ro,-M,M,a[i]);
		add(ro,-M,M,a[i]);
	}
	printf("%lld\n",mmh);
}

Measured memory_bytes: 142976
n = int(input())
li = list()
for i in range(n):
    a, b = [int(x) for x in input().split()]
    li.append([a,b])

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

if count >= 3: print('Yes')
else: print('No')

Measured memory_bytes: 9184
//https://atcoder.jp/contests/abc143/tasks/abc143_c
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    string S; cin>>S;    
    string ans;
    char prev=0;
    for(auto& c:S){
        if(prev!=c) ans.push_back(c);
        prev=c;
    }
    cout<<ans.length()<<endl;
    return 0;
}

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

int main(){
	int n, k;
	cin >> n >> k;
	if(n % k == 0) cout << 0 << endl;
	else cout << 1 << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

int h,w;
char c;
bool v[2001][2001];

int lft[2001][2001];
int rr[2001][2001];
int up[2001][2001];
int down[2001][2001];

int res;

bool valid(int x,int y){
    if(x<0 || x>=h || y<0 || y>=w)return false;
    if(v[x][y])return true;
    return false;
}
void solve()
{
    //lft
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
            if(!valid(i,j))continue;
            if(valid(i,j-1))lft[i][j] = lft[i][j-1]+1;
        }
    }

    for(int j = 0;j<w;j++){
        for(int i = 0;i<h;i++){
            if(!valid(i,j))continue;
            if(valid(i-1,j))up[i][j] = up[i-1][j]+1;
        }
    }
    for(int i = 0;i<h;i++){
        for(int j = w-1;j>=0;j--){
            if(!valid(i,j))continue;
            if(valid(i,j+1))rr[i][j] = rr[i][j+1]+1;
        }
    }
    for(int j = 0;j<w;j++){
        for(int i = h-1;i>=0;i--){
            if(!valid(i,j))continue;
            if(valid(i+1,j))down[i][j] = down[i+1][j]+1;
        }
    }
    for(int i = 0;i<h;i++){
        for(int j = 0;j<w;j++){
//            cout<<i<<" "<<j<<" "<<lft[i][j]<<" "<<rr[i][j]<<" "<<up[i][j]<<" "<<down[i][j]<<" ";
 //           cout<<lft[i][j]+rr[i][j]+up[i][j]+down[i][j]<<endl;
            res = max(res,lft[i][j]+rr[i][j]+up[i][j]+down[i][j]+1);
        }
    }
    cout<<res<<endl;
}

int main()
{
    cin>>h>>w;
    for(int i=0;i<h;i++)
        for(int j = 0;j<w;j++){
            cin>>c;
            if(c=='.')v[i][j]=true;
        }
    solve();
    return 0;
}


Measured memory_bytes: 66816
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    int n = sc.nextInt();

    for(int i = 0; i < n ; i++){
        list.add(sc.nextInt());
    }

    Collections.sort(list);

    int num = list.get(n/2) - list.get(n/2 - 1);

    //System.out.println(list);

    System.out.println(num);









    
    






    

    



    
  

    


    


    

    
    
    



    





}
}

Measured memory_bytes: 61848
#include <bits/stdc++.h>
 
#define loop(n, i) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()

using namespace std;

int main(int argc, char const* argv[])
{
    while (1) {
        int N; cin >> N;
        if (!N) break;
        int ans = 0;
        for (int i = 1; i <= 1000; i++) for (int j = i+1; j < 1000; j++) {
            if ((i + j) * (j - i + 1) == N * 2) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  int n,m,ans;ans=0;
  cin >>n >>m;
  vector<int>k(m);//
  vector<vector<int>>data(n+1,vector<int>(m+1));
  for(int i=0;i<m;i++){
  	cin >>k[i];
  	for(int j=0;j<k[i];j++){
  	int sp; cin >>sp;
      data.at(sp-1).at(i)=1;      
  	}    
  }
  vector<int>p(m);
  for(int i=0;i<m;i++){
  cin >>p[i];
  }
  vector<int>count_light(m); 
  for(int tmp=0;tmp<(1<<n);tmp++){
  	bitset<11>s(tmp);
  	for(int i=0;i<n;i++){
    	if(s.test(i)){
        	for(int j=0;j<m;j++){
            	if(data.at(i).at(j)==1){
                count_light.at(j)+=1;
                }
            }
        }  
    }
    int flag=0;
   	for(int k=0;k<m;k++){
   		if(count_light.at(k)%2!=p[k]){flag=1;}
    }
    if(flag==0){ans++;}
    for(int j=0;j<m;j++){
    count_light.at(j)=0;
    }    
  }
  cout <<ans;
}
 

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

string s;
ll a, c, ret, ans;
void dfs(string t, int d) {
	//cout << t << " " << d << endl;
	if(t.size() == s.size()) {
		VI v;
		REP(i, t.size()) v.PB(t[i]-'0');
		do {
			ll b = 0;
			REP(i, t.size()) b *= 10, b += v[i];
			//cout << b << " " << abs(a-b) << " " << c-abs(a-b) << endl;
			if((ans < min(abs(a-b), c-abs(a-b))) || (ans == min(abs(a-b), c-abs(a-b)) && b < ret)) {
				ans = min(abs(a-b), c-abs(a-b));
				ret = b;
			}
		} while(next_permutation(ALL(v)));
		return;
	}
	FOR(i, d+1, 10) {
		char c = '0' + i;
		dfs(t + c, i);
	}
}

signed main(void)
{
	cin >> s;
	const int n = s.size();
	a = stol(s);
	c = 1, ans = -LLINF;
	REP(i, n) c *= 10;

	dfs("", -1);
	cout << setfill('0') << setw(n) << ret << endl;

	return 0;
}

Measured memory_bytes: 3192
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
// typedef pair<ll, ll> P;
typedef pair<int, int> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int n;
vector<P> G[100000];
vector<int> ans(100000);

void dfs(int n, int p, int c) {
  ans[n] = c;
  REP(i, G[n].size()) {
    if (G[n][i].first == p) continue;
    if (G[n][i].second == 0)
      dfs(G[n][i].first, n, c);
    else
      dfs(G[n][i].first, n, c ^ 1);
  }
}

int main() {
  cin >> n;
  REP(i, n - 1) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    w = w % 2;
    G[u].push_back(P(v, w));
    G[v].push_back(P(u, w));
  }
  dfs(0, -1, 0);
  REP(i, n) cout << ans[i] << endl;
  return 0;
}

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

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

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

int main() {
    int N, M; cin >> N >> M;
    vector<pair<int,int>> condition;
    repp(i, 0, M) {
        int s, c; cin >> s >> c;
        condition.emplace_back(s, c);
    }

    repp(i,0,1000) {
        string i_str = to_string(i);
        if (i_str.size() != N) continue;
        bool ok = true;
        repp(j,0,M) ok &= i_str[condition[j].first - 1] - '0' == condition[j].second;
        if (ok) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] x = new int[N+1];
		int left=0;
		int right=0;
		for (int i=1;i<=N;i++) {
			x[i] = sc.nextInt();
			if (x[i]<=0) {
				x[i] *= -1; // 絶対値にする
				left++;
			} else {
				right++;
			}
		}

		int minDist = Integer.MAX_VALUE;
		int dist;

		for (int i=0;i<=left;i++) {
			int j =  K - i;
			if (j<=right) {
				//左にi本、右にj本の時の最小距離を求める
				if (i==K) { // 左だけ
					dist = x[left-i+1];
					if (dist < minDist) {
						minDist = dist;
					}
				}
				else if (j==K) { // 右だけ
					dist = x[left+j];
					if (dist < minDist) {
						minDist = dist;
					}
				}
				else {
					//左行ってから右
					dist = x[left-i+1]*2 + x[left+j];
					if (dist < minDist) {
						minDist = dist;
					}
					//右行ってから左
					dist = x[left-i+1] + x[left+j]*2;
					if (dist < minDist) {
						minDist = dist;
					}
				}
			}
		}

		System.out.println(minDist);

	}
}



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

void out1(int n,int N){
    cout << '?';
    for (int i=0;i<N;++i) cout << ' ' << n+i;
    cout << endl;
}

void out2(int n,vector<int> v){
    cout << "? " << n;
    for (int i=0;i<v.size();++i) cout << ' ' << v[i];
    cout << endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    string left,S;
    vector<char> ans(2*N+1);
    out1(1,N); cin >> left;
    int lb=1,ub=N+1;
    while(ub-lb>1){
        int mid=(ub+lb)>>1;
        out1(mid,N); cin >> S;
        (S==left?lb:ub)=mid;
    }
    ans[lb]=left[0],ans[lb+N]=(left[0]=='R'?'B':'R');
    vector<int> half,rest;
    for (int i=1;i<N;++i) half.emplace_back(lb+i);
    for (int i=1;i<lb;++i){
        out2(i,half); cin >> S;
        ans[i]=S[0]; rest.emplace_back(i);
    }
    for (int i=lb+N+1;i<=2*N;++i){
        out2(i,half); cin >> S;
        ans[i]=S[0]; rest.emplace_back(i);
    }
    for (int i=ub;i<lb+N;++i){
        out2(i,rest); cin >> S;
        ans[i]=S[0];
    }
    cout << "! ";
    for (int i=1;i<=2*N;++i) cout << ans[i];
    cout << endl;
}

Measured memory_bytes: 724
import java.util.*
import java.math.*
import kotlin.math.*

fun readLn()=readLine()!!
fun readInt()=readLn().toInt()
fun readInts()=readLn().split(" ").map{it.toInt()}
fun readLong()=readLn().toLong()
fun readLongs()=readLn().split(" ").map{it.toLong()}

val out=mutableListOf<String>()
fun printLine(s:String){out.add(s)}
fun output(){println(out.joinToString("\n"))}

fun main(){
    var (n,k)=readInts()
    var has=Array(n+1){false}
    for(i in 1..k){
        var d=readInt()
        var a=readInts()
        for(j in a)has[j]=true
    }
    var ans=0
    for(i in 1..n)if(!has[i])ans++
    printLine("$ans")
    output()
}

Measured memory_bytes: 39100
#include<stdio.h>
int main() {
	int h, w, n;
	int i, j, k;
	int c = 0;
	int a[200000] = {};

	scanf("%d %d %d", &h, &w, &n);

	for (k = 0; k < n; k++) {
		scanf("%d %d", &i, &j);
		if (i < j)continue;
		if (a[i] == 0 || a[i] > j)a[i] = j;
	}

	for (i = 1; i <= h; i++) {
		if (a[i] == 0) continue;

		if (a[i] == i - c) {
			c++;
			continue;
		}

		if (a[i] < i - c) {
			break;
		}
	}

	printf("%ld\n", i - 1);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    int t; cin>>a>>b;
    if(a%3==0 || b%3==0 || (a+b)%3==0){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
}

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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;


int main() {
  ll K; cin >> K;
  ll X, Y; cin >> X >> Y;
  int mx = X<0 ? -1 : 1; X = abs(X);
  int my = Y<0 ? -1 : 1; Y = abs(Y);
  if (K%2==0&&(X+Y)%2==1) { cout << -1 << endl; return 0; } 
  if (K>X+Y) {
    if (K%2==1&&(X+Y)%2==1) {
      cout << 3 << endl;
      cout << mx*(K-Y) << " " << my*Y << endl;
      cout << mx*(X+(K-Y))/2 << " " << my*(Y+(X+Y+K)/2) << endl;
      cout << mx*X << " " << my*Y << endl;
    }
    else {
      ll d = K-(X+Y)/2;
      cout << 2 << endl;
      if (X>Y) cout << mx*(K-(d+Y)) << " " << my*(d+Y) << endl;
      else cout << mx*(d+X) << " " << my*(K-(d+X)) << endl;
      cout << mx*X << " " << my*Y << endl;
    }
  }
  else {
    ll left = (K-(X+Y)%K)%K;
    ll h1 = (left%2==0) ? left/2+Y : (left+K)/2+Y;
    ll h2 = h1 - Y;
    if (h1%K==0||h1%K+X>=K) {
      // ll h1 = (left%2==0) ? left/2+Y : (left+K)/2+Y;
      // ll h2 = h1 - Y;
      ll w = X;
      ll count = (h1+h2+w)/K;
      cout << count << endl;
      rep(i,count) {
        ll d = (i+1)*K;
        if (d<=h1) cout << 0 << " " << my*d << endl;
        else if (d<=h1+w) cout << mx*(d-h1) << " " << my*h1 << endl;
        else cout << mx*w << " " << my*(h1-(d-(h1+w))) << endl;
      }
    } 
    else {
      ll w1 = (left%2==0) ? left/2+X : (left+K)/2+X;
      ll w2 = w1 - X;
      ll h = Y;
      ll count = (w1+w2+h)/K;
      cout << count << endl;
      rep(i,count) {
        ll d = (i+1)*K;
        if (d<=w1) cout << mx*d << " " << 0 << endl;
        else if (d<=w1+h) cout << mx*w1 << " " << my*(d-w1) << endl;
        else cout << mx*(w1-(d-(w1+h))) << " " << my*h << endl;      
      }
    }
  }
  return 0;
}

Measured memory_bytes: 2304
import sys

class Node:
    def __init__(self,data):
        self.data  = data
        self.left  = None
        self.right = None
    

def insert(node,x):
    if node is None:
        node = Node(x)
    elif node.data == x:
        return node
    elif node.data > x:
        node.left = insert(node.left,x)
    else:
        node.right = insert(node.right,x)
    return node

def search(node,x):
    if node is None:
        return 'no'
    elif node.data == x:
        return 'yes'
    elif node.data > x:
        return search(node.left,x)
    else:
        return search(node.right,x)

class BST:
    def __init__(self):
        self.root = None

    def insert(self,x):
        if self.root is None:
            self.root = Node(x)
        else:
            self.root = insert(self.root,x)
    
    def search(self,x):
        return search(self.root,x)

def mid_walk(node):
    if node is None:
        return 
    yield from mid_walk(node.left)
    yield node.data
    yield from mid_walk(node.right)

def pre_walk(node):
    if node is None:
        return 
    yield node.data
    yield from pre_walk(node.left)
    yield from pre_walk(node.right)


n = int(input())
bt = BST()
for line in sys.stdin:
    if line[0] == 'i':
        bt.insert(int(line[7:]))
    elif line[0] == 'f':
        print(bt.search(int(line[5:])))
    else:
        print(' '+' '.join(map(str,mid_walk(bt.root))))
        print(' '+' '.join(map(str,pre_walk(bt.root))))



Measured memory_bytes: 115380
A, B, M = map(int, input().split())

a = list(map(int, input().split()))
b = list(map(int, input().split()))

xyc = []
for i in range(M):
  xyc.append(list(map(int, input().split())))

saisho1 = min(a) + min(b)

kouho = [0 for i in range(M)]

for i in range(M):
  kouho[i] = a[xyc[i][0]-1] + b[xyc[i][1]-1] - xyc[i][2]

saisho2 = min(kouho)

print(min(saisho1, saisho2))

Measured memory_bytes: 42532
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    vector<vector<char>>a(H+2,vector<char>(W+2));
    for(int i=0;i<H+2;i++){
        for(int j=0;j<W+2;j++){
         a.at(i).at(j)='#';
        }
    }
    for(int i=1;i<H+1;i++){
        for(int j=1;j<W+1;j++){
          cin>>a.at(i).at(j);
        }}
    for(int i=0;i<H+2;i++){
        for(int j=0;j<W+2;j++){
            cout<<a.at(i).at(j);}cout<<endl;}
    return 0; 
}

Measured memory_bytes: 256
s = gets.chomp

if s == "SUN"
    puts 7
elsif s == "MON"
    puts 6
elsif s == "TUE"
    puts 5
elsif s == "WED"
    puts 4
elsif s == "THU"
    puts 3
elsif s == "FRI"
    puts 2
else
    puts 1
end

Measured memory_bytes: 1788
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;

int main(){
    int n;
    cin >> n;
    int p[n];
    for(int i=0; i<n; i++){
        cin >> p[i];
    }

    int count = 0;
    for(int j=1; j<n-1; j++){
        if((p[j]-p[j-1])*(p[j]-p[j+1])<0){
            count ++;
        }
    }cout << count;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

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 V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v){ t = v; }

template<typename T,typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

vector<int> nex;
void dfs(int cur, vector<bool> &used, vector<vector<int>> &tree)
{
    nex.pb(cur);
    for(auto x : tree[cur])
    {
        if(!used[x])
        {
            used[x] = true;
            dfs(x, used, tree);
        }
    }
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n-1), b(n-1);
    REP(i, n-1) cin >> a[i] >> b[i];
    vector<vector<int>> tree(n);
    REP(i, n-1)
    {
        tree[a[i]-1].pb(b[i]-1);
        tree[b[i]-1].pb(a[i]-1);
    }

    vector<int> c(n);
    REP(i, n) cin >> c[i];
    sort(all(c), greater<int>());

    map<int, int> mp;
    REP(i, n-1)
    {
        mp[a[i]-1]++;
        mp[b[i]-1]++;
    }
    vector<P> p;
    for(auto x : mp)
    {
        p.pb(make_pair(x.second, x.first));
    }
    sort(all(p), greater<P>());
    
    vector<int> ans(n);
    vector<bool> used(n);

    used[p[0].second] = true;
    dfs(p[0].second, used, tree);

    REP(i, n) ans[nex[i]] = c[i];
    /*
    for(int i=0, j=0; i < n; i++)
    {
        if(!used[p[i].second]) ans[p[i].second] = c[j], j++, used[p[i].second] = true;
        for(auto x : tree[p[i].second])
        {
            if(!used[x])
            {
                ans[x] = c[j];
                used[x] = true;
                j++;
            }
        }
    }
    */

    LL sum = 0;
    REP(i, n-1) sum += min(ans[a[i]-1], ans[b[i]-1]);
    cout << sum << endl; 
    REP(i, n) cout << ans[i] << " \n"[i == n-1];

}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;


void solve(){
	int n;
	cin >> n;
	int a[n];
	forn(i,0,n)
	cin >> a[i];
	multiset<int> bs;
	bs.insert(a[0]);
	for(int i =1;i<n;i++){
		auto it = bs.lower_bound(a[i]);
		if(it!=bs.begin()){
			it--;
			bs.erase(it);
		}
		bs.insert(a[i]);
	}

	cout << bs.size() << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


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

int main(void) {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  cout << a[0] << " " << a[1] << " " << a[2] << endl;
}


Measured memory_bytes: 3136
S = list(input())
a = len(S)
b = 0
c = 0
for i in range(a):
  if i%2==0:
    if(S[i] == "h"):
      b+=1
  else:
    if(S[i]=="i"):
      c+=1
if(b+c==a and b==c):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 8988
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
	int n,m;
	cin >> n >> m;

	priority_queue<int,vector<int>,greater<int>> s;
	priority_queue<int,vector<int>,greater<int>> g;
	for(int i = 0;i < m;i++){
		int l,r;
		cin >> l >> r;
		l--,r--;
		s.push(l);
		g.push(r);
	}

	vector<int> v(n);
	int cnt = 0;
	for(int i = 0;i < n;i++){
		while(s.size() && i == s.top()){
			s.pop();
			cnt++;
		}
		v[i] = cnt;
		while(g.size() && i == g.top()){
			g.pop();
			cnt--;
		}
	}

	int ans = 0;
	for(int a:v){
		if(a == m)ans++;
	}

	cout << ans << endl;
}


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

int main(){
  double W, H;
  cin >> W >> H;
  int x, y;
  cin >> x >> y;
  
  double S = W * H;
  double harf = S / 2;

  cout << fixed << setprecision(15);
  cout << harf << " ";
  if(x * 2 == W && y * 2 == H){
    cout << 1 << endl;
  }
  else{
    cout << 0 << endl;
  }
}

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

int main(){
    int S,h,m,s;
    cin>>S;
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-h*3600-m*60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    
    return 0;
}

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main (void){
   char S[11],T[11],U[11];
   int A,B;

   scanf("%s%s",S,T);

   scanf("%d%d",&A,&B);

   scanf("%s",U);

   if(strcmp(U,S) == 0) A--;
   else if(strcmp(U,T) == 0) B--;

   printf("%d %d\n",A,B);
   return 0;
   }


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;

int main() {
	//ios_base::sync_with_stdio(false);
	//cout<<setprecision(20);
	string s;
	int n;
	cin>>s>>n;
	int j=0;
	char ans[1000000];
	while(j*n<s.size()){
	    ans[j]=s[j*n];
	    j++;
	}
	for(int i=0;i<j;i++) cout<<ans[i];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {
     ll d,s,t;
     cin>>d>>t>>s;
     if((d/s)+(d%s?1:0)<=t)
       cout<<"Yes\n";
     else
       cout<<"No\n";
   }
}


Measured memory_bytes: 3648
List = input()
List = List.split()
N = int(List[0])
K = int(List[1])
H = []
for i in range(N):
    height = int(input())
    H.append(height)
H.sort()
distance = 0
minDis = H[K-1] - H[0]
for i in range(N-K+1):
    distance = H[i+K-1] - H[i]
    if distance < minDis:
        minDis = distance
print(minDis)

Measured memory_bytes: 7388
<?php

fscanf(STDIN, "%d %d", $n, $l);

$taste = [];
$min = 10000;
for($i=0;$i<$n; $i++){
    $taste[] = $l + $i;
    if(abs($min) > abs($taste[$i])){
        $min =  $taste[$i];
    }

}

echo array_sum($taste) - $min;

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

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)

int main(){
bitset<65536> bs;
unsigned long long s;
unsigned long long a,b,r,l,c,d;
cin>>a>>b;
r=(a-1)%4;
if(r==3){c=0;}
else if(r==1){c=1;}
else if(r==2){c=a;}
else {c=a-1;}
l=b%4;
if(l==3){d=0;}
else if(l==1){d=1;}
else if(l==2){d=b+1;}
else {d=b;}
bs=bitset<65536>(c^d);
s=bs.to_ullong();
cout<<s<<endl;
return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <atcoder/segtree>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;
using namespace atcoder;

int dp[300001];

int op(int a, int b) {
    return max(a, b);
}
int e() {
    return 0;
}

int main()
{
	int n,k;cin>>n>>k;
	segtree<int , op, e> seg(300001);
  
	vector<int> vec;
	
	for(int i = 0;i<n;i++)
	{
		int x;s(x);
		vec.push_back(x);	
	}
	
  int maxii = 0;
  
	for(int i = n-1;i>=0;i--)
	{
		int low = max(0 , vec[i]-k);
		int high = min(300000 , vec[i] + k);
		
		int maxi = seg.prod(low,high+1);
		
		dp[i] = 1 + maxi;
		maxii = max(maxii , dp[i]);
      
      	seg.set(vec[i],dp[i]);
	}
	
	
	cout<<maxii<<endl;
	
	
	return 0;
}

Measured memory_bytes: 11768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= n/4; i++) {
    if ((n-4*i)%7==0) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
  return 0;
}

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

string sub(int n) {
  if (n == 0) return "0";
  string s;
  int c = 0;
  while (n != 0) {
    if (n % 2 == 0) {
      s = "0" + s;
    } else {
      s = "1" + s; --n;
    }
    n /= -2;
    ++c;
  }
  return s;
}

int main() {
  int n;
  cin >> n;
  cout << sub(n) << endl;
}

Measured memory_bytes: 256
n = int(input())
A = [0]+[int(i) for i in input().split()]+[0]
S = [0]*(n+2)
current = 0
s = 0

for i in range(len(A)):
    s += abs(A[i]-current)
    S[i] = s
    current = A[i]




for i in range(1,n+1):
    print(S[i-1]+S[-1]-S[i+1]+abs(A[i+1]-A[i-1]))  

Measured memory_bytes: 14048
#include <iostream>
#include <queue>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;

int main(){
    int n,k;
    long double prob=0;
    cin >> n >> k;

    for(int i=1;i<=n;i++){
        if(i>=k){
            prob += 1.0;
            continue;
        }
        prob += pow(0.50, ceil(log2((long double)k/i)));
        // if(pow(0.5, ceil(log2((float)k/i)))>1) cout << i << endl;
    }
    prob /= n;
    cout << std::fixed;
    cout << std::setprecision(10) << prob << endl;
    return 0;
}




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

bool isPalindrome(string s)
{
  int len = s.size();
  int edge = len / 2;
  
  for (int i = 0; i < edge; i ++)
    if (s.at(i) != s.at(len - 1 - i)) return false;
  
  return true;
}

int main()
{
  string s;
  cin >> s;
  
  int len = s.size();
  
  if (!isPalindrome(s))
  {
    cout << "No" << endl;
    return 0;
  }
  if (!isPalindrome(s.substr(0, len / 2) ) )
  {
    cout << "No" << endl;
    return 0;
  }
  if (!isPalindrome(s.substr(len / 2 + 1, len / 2) ) )
  {
    cout << "No" << endl;
    return 0;
  }

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

Measured memory_bytes: 256
from sys import stdin


def main():
    A, B = [int(x) for x in stdin.readline().split()]
    sum = 0
    for i in range(2):
        if A >= B:
            sum += A
            A -= 1
        else:
            sum += B
            B -= 1
    print(sum)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include <math.h>
using namespace std;
int main() {
  double N;
  cin >> N;
  double X = ceil(N / 1.08);
  if (floor(X * 1.08) == N) {
    cout << X << endl;
  } else if (floor((X + 1) * 1.08) == N) {
    cout << X << endl;
  } else if (floor((X - 1) * 1.08) == N) {
    cout << X << endl;
  } else {
    cout << ":(" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long 
#define ull unsigned long long
#define db double
#define vi vector<ll>
#define vvi vector<vector<int> >
#define vvii vector<vector<pii> >
#define rep(i,a,b) for(int i=a;i<b;i++)
#define endl "\n"
#define pii pair<ll,ll>
#define piii pair<ll,pair<ll,ll> >
#define mem(a,b) memset(a , b , sizeof a ) ; 
#define pb push_back
#define pf push_front
#define F first 
#define S second 
#define mp make_pair
#define all(v) v.begin(),v.end()

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}



#define deb1(a) cout<<#a<<"=*"<<a<<endl;
#define deb2(a) cout<<#a<<"=@"<<a<<endl;
#define deb3(a) cout<<#a<<"=#"<<a<<endl;
#define deb4(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;
#define deb5(a,b) cout<<#a<<"="<<a<<" and "<<#b<<"="<<b<<endl;


typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


ll mod=1000000007;
ll vis[212345]={0};
vvi v(212345);
ll d[212345]={0};


ll pow(ll a, ll b, ll m)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%m;
		b/=2;
		a=(a*a)%m;
	}
	return ans;
}





int main()
{
speed
ll n;
cin>>n;
ll a[n+1];
ll c=0;
rep(i,1,n+1) {
	cin>>a[i];
	if(a[i]%2&&i%2) c++;
}
cout<<c<<endl;

}


Measured memory_bytes: 8084