akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793
 
int dx[8] = {1,1,1,0,0,-1,-1,-1};
int dy[8] = {-1,0,1,-1,1,-1,0,1};
   
int main(){
  int h,w;
  cin >> h >> w;
  vector<vector<char>> s(h+2,vector<char>(w+2));
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
        cin >> s.at(i).at(j);
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
      if(s.at(i).at(j)=='.'){
        int cnt=0;
       rep(k,8){
         int H=i+dy[k];
         int W=j+dx[k];
          if(s.at(H).at(W)=='#')cnt++;
       }
       char nw=char('0'+cnt);
       s.at(i).at(j)=nw;
      }
    }
  }
  for(int i=1;i<=h;i++){
    for(int j=1;j<=w;j++){
        cout << s.at(i).at(j);
    }
    cout << endl;
  }


} 
    

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
vector<ll> node[200005];
ll ans[200005]={0};
bool used[200005]={0};
void dfs(ll pos,ll num){
  ans[pos]=num;
  num++;
  num%=2;
  for(int i=0;i<node[pos].size();i++){
    ll to=node[pos][i];
    if(!used[to]){
      used[to]=true;
      dfs(to,num);
    }
  }
}
int main(){
  ll n;
  cin>>n;
  for(int i=1;i<n;i++){
    ll s,t;
    cin>>s>>t;
    node[s].push_back(t);
    node[t].push_back(s);
  }
  for(int i=1;i<=n;i++) used[i]=false;
  used[1]=true;
  dfs(1,0);

  ll n1=0,n2=0;
  for(int i=1;i<=n;i++){
    if(ans[i]==0) n1++;
    else n2++;
  }
  if(n1<n2){
    for(int i=1;i<=n;i++) ans[i]^=1;
    swap(n1,n2);
  }
  if(n2*3+1<n){
    ll a=3;
    for(int i=1;i<=n;i++){
      if(ans[i]==1) {
        ans[i]=a;
        a+=3;
      }
    }
    ll mb=a;
    a=1;
    for(int i=1;i<=n;i++){
      if(ans[i]==0||ans[i]==1){
        ans[i]=a;
        a++;
        if(a%3==0&&a<mb) a++;
      }
    }
  }
  else{
    ll a=1,b=2,c=3;
    for(int i=1;i<=n;i++){
      if(ans[i]==0){
        if(a<=n){
          ans[i]=a;
          a+=3;
        }
        else{
          ans[i]=c;
          c+=3;
        }
      }
      else{
        if(b<=n){
          ans[i]=b;
          b+=3;
        }
        else{
          ans[i]=c;
          c+=3;
        }
      }
    }
  }
  for(int i=1;i<=n;i++) cout<<ans[i]<<" ";
  cout<<endl;
}


Measured memory_bytes: 19200
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<class T>
vector<T> divisor(T n){
    vector<T> ret;
    for(T i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.push_back(i);
            if(i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return(ret);
}

template<typename T>
T extgcd(T a, T b, T &x ,T &y){
    for (T u = y = 1, v = x = 0; a; ) {
        ll q = b/a;
        swap(x -= q*u, u);
        swap(y -= q*v, v);
        swap(b -= q*a, a);
    }
    return b;
}


int main() {
    ll n;
    cin >> n;
    auto v = divisor(2*n);
    ll ans = INF<ll>;
    for (auto &&a : v) {
        ll b = 2*n/a; ll x, y;
        ll g = extgcd(a, -b, x, y);
        if(g < 0) x = -x, y = -y;
        if(abs(g) != 1) continue;
        ll w = (-y)/a-3;
        while(w*a <= -y) w++;
        ans = min(ans, b*(a*w+y));
    }
    cout << ans << "\n";
    return 0;
}

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

int main(){
    int N, A[210]; cin >> N;
    for (int i=0; i < N ; i++) cin >> A[i];

    int countera=0;

    for ( ; ; ) {
        int counterb=0;
        for ( int j=0; j < N ; j++){
            if ( A[j] % 2 == 0) counterb++;
        }
        if ( counterb == N ) {
            for ( int j=0 ; j < N ; j++){
                A[j]/=2;
            }
            countera++;
        }else break;
    } 

    cout << countera << endl;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    int a[n] = {0};
    for(int i=0; i<m*2; i++) {
        int x; cin>>x;
        a[x-1]++;
    }
    for(int i=0; i<n; i++) {
        cout<<a[i]<<"\n";
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(n, m, A):
    count = [0] * (m + 1)
    for a in A:
        for i in range(1, len(a)):
            count[a[i]] += 1
    ret = 0
    for c in count:
        if c == n:
            ret += 1
    print(ret)
    return

def main():
    n, m = map(int, input().split())
    a = []
    for i in range(n):
        a.append(list(map(int, input().split())))
    solve(n, m, a)

if __name__ == '__main__':
    main()


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

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    vector<ll> v;
    for(ll i = 1;i*i<N;i++){
        if(N%i != 0) continue;
        v.push_back(i);
        v.push_back(N/i);
        //ans += i-1;
        if(N/i - 1 > i){
            ans += N/i -1;
        }
    }

    cout << ans << endl;
    
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef long long ll;
typedef long long ll;
//typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX / 100;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

//typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
const double PI = 3.14159265358979323846;

typedef pair<char, char> P;


int main() {
    string s;
    cin >> s;
    int n = s.size();

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

}



Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

#define ll          long long
#define pb          push_back
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int


int solve( ){
 
int d;
cin>>d;
d=25-d;
cout<<"Christmas"<<" ";
string a="Eve ";
rep(i,0,d)cout<<a;


return 0;
}
int main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
  
 
  clock_t time_req;

    // Without using pow function
    time_req = clock();
    
//cin>>t;
   while(t--)
     {solve();
     }

         time_req = clock() - time_req;
   // cout << "Processor time taken is "
      // << (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
}


Measured memory_bytes: 256
x, y = list(map(int, input().split()))
total = 0
if x == 1:
    total += 300000
elif x == 2:
    total += 200000
elif x == 3:
    total += 100000
else:
    total += 0

if y == 1:
    total += 300000
elif y == 2:
    total += 200000
elif y == 3:
    total += 100000
else:
    total += 0

if x == 1 and y == 1:
    total += 400000
else:
    total += 0

print(total)

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll n, x;
set<ll> st;
bool ok;

int main () {
    fastIO;
    cin >> n;
    for(li i = 0; i < n; i ++) {
        cin >> x;
        if(st.count(x)) ok = true;
        st.insert(x);
    }

    if(ok) cout << "NO";
    else cout << "YES";
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
int main (){
int n,m,k;
cin>>n>>m;
int a[m],i,b;
for(i=0;i<m;i++)
a[i]=0;
for(i=0;i<n;i++){
cin>>k;
for(;k>0;k--){
cin>>b;
a[b-1]++;
}
}
int c=0;
for(i=0;i<m;i++){
if(a[i]==n)
c++;
}
cout<<c;
return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [i for i in map(int, input().split(" "))]
if 0 in a:
    print(0)
else:
    c = 10**18
    b = a[0]
    for i in a[1:]:
        b *= i
        if b > c:
            b = -1
            break
    print(b)


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

int main(void) {
  int d;
  cin >> d;
  switch (d) {
    case 25:
      cout << "Christmas " << endl;
      break;
    case 24:
      cout << "Christmas Eve" << endl;
      break;
    case 23:
      cout << "Christmas Eve Eve" << endl;
      break;
    case 22:
      cout << "Christmas Eve Eve Eve" << endl;
      break;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int on[30][100000];

int main()
{
    int N,C;
    cin >> N >> C;
    for(int i=0; i<N; i++){
        int s, t, c;
        cin >> s >> t >> c;
        s--;
        t--;
        c--;
        for(int j=s; j<=t; j++){
            on[c][j]=1;
        }
    }
    int ans=0;
    for(int t=0; t<100000; t++){
        int cnt=0;
        for(int c=0; c<C; c++){
            if(on[c][t]==1) cnt++;
        }
        ans=max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 12032
/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		BigInteger b = new BigInteger(s);
		int shift = b.toString(2).length();
		BigInteger ans = new BigInteger("1");
		ans = ans.shiftLeft(shift);
		ans = ans.subtract(new BigInteger("1"));
		System.out.println(ans);
		// your code goes here
	}
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a,b,x;
	int i,j;
	
	cin>>a>>b>>x;
	
	int mn=10000007;
	for(i=0;i<=x/1000+1;i++){
		for(j=0;j<=x/500+1;j++){
			if(1000*i+500*j>=x && mn>a*i+b*j){
				mn=a*i+b*j;
			}
		}
	}

	cout<<mn<<endl;
	return 0;
	
}	


Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <map>
#include <set>
#include <utility>
#include <queue>
#include <bitset>
#include <math.h>
#include <numeric>

using namespace std;
 
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define endl '\n'
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    ll n = s.size();
    ll res=0,num=0;
    for(ll i=0;i<n;i++){
        //各'W'に対して左側に'B'が何個あるのかを足していく
        if(s[i]=='W'){
            res += num;//Bの数(累積和的な感じ)
        }else{
            num++;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#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()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    ll ret = 0;
    if(x == 1) ret += 300000;
    else if(x == 2) ret += 200000;
    else if(x == 3) ret += 100000;
    if(y == 1) ret += 300000;
    else if(y == 2) ret += 200000;
    else if(y == 3) ret += 100000;
    if(x == 1 && y == 1) ret += 400000;

    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>  // sort, 二分探索, etc
#include <iomanip>  // setprecision (浮動小数点の出力の誤差)
#include <map>
#include <queue>
#include <set>
#include <stack>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=a,i##_len=(b);i<i##_len;++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define cauto const auto&
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

using namespace std;
using ui = unsigned int;
using ll = long long;
using ull = unsigned long long;

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

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

ll comb(int n, int r) {
    vector<vector<ll> > v(n+1, vector<ll>(r+1, 0));
    for(int i=0;i<n+1;i++) {v[i][0]=1; if(i < r+1)v[i][i]=1; }
    for(int i=1;i<n+1;i++) {for(int j=1;j<min(i,r+1);j++) {v[i][j]=v[i-1][j-1]+v[i-1][j];}}
    return v[n][r];
}

// CHAR_MAX  = 127
// INT_MAX   = 2.1e+09 (2147483647)
// LONG_MAX  = 9.2e+18 (9223372036854775807)
// LLONG_MAX = 9.2e+18 (9223372036854775807)


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

    int c500 = x / 500;
    int c5 = (x % 500) / 5;

    cout << (c500 * 1000 + c5 * 5) << '\n';

    return 0;
}


Measured memory_bytes: 888
#include <iostream>

using namespace std;
int dat[100][100];

int main(){
	int n, f, v, g;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>f>>v;
		for(int j=1;j<=v;j++){
			cin>>g;
			dat[f][g]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++){
			cout<<dat[i][j]<<" ";
		}
		cout<<dat[i][n]<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1200
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) //[l, r)
#define rep(i,n) REP(i,0,n)           //[0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl
#define showslr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i];}cerr<<endl //[l, r))

#define yes puts("Yes")
#define no puts("No")
#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

inline void io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}

void _DEBUG(){cerr<<endl;}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<",";_DEBUG(b...);}

template<typename T> inline void in(T &e){cin>>e;}
template<typename H,typename... T>void in(H &a, T&... b){in(a);in(b...);}
template<typename T> inline void out(T e){cout<<e<<endl;}
template<typename H,typename... T> void out(H a, T... b){out(a);out(b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int a,b;
int ans=0;

signed main(){
    io();
    in(a,b);
    REP(i,a,b+1){
        string s=to_string(i);
        //show(s);
        bool f=true;
        rep(j,s.size()/2){
            //show(s[j], s[s.size()-j-1]);
            if(s[j]!=s[s.size()-j-1]){
                f=false;
                break;
            }
        }
        if(f) ans++;
    }

    out(ans);

    return 0;
}


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

using namespace std;
using  ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

int main(){
  int s,w;
  std::cin >> s>>w;
  std::cout << (w>=s?"unsafe":"safe") << '\n';
  return 0;
}


Measured memory_bytes: 3580
console.log((args=>{
  const S = args.trim();
  const N = S.length;
  let c = 0;
  for ( let i = 0; i < N; i++ ) {
    if ( S[i] === '0' ) c++;
    else c--;
  }
  return N-Math.abs(c);
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 32300
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}

		public static void main(String[] args) {
			String str=scan.next();
			for(int i=0;i<str.length()-1;i++) {
				String sstr=str.substring(i,i+2);
				if(sstr.equals("AC")) {
					System.out.println("Yes");
					return;
				}
			}
			System.out.println("No");
		}
}


Measured memory_bytes: 21972
def f(n):
    if n%2==0:
        if (n//2)%2==0:
            return n
        else:
            return n^1
    else:
        if (n+1)//2%2==0:
            return 0
        else:
            return 1
A, B = map(int, input().split())
print(f(A-1)^f(B))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;

int main(){
    int h,w,n=0;
    std::vector<int> vec_h,vec_w;
    while(1){
        cin >> h >> w;
        vec_h.push_back(h);
        vec_w.push_back(w);
        if(h==0&&w==0)break;
        n++;
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<vec_h[i];j++){
            for(int k=0;k<vec_w[i];k++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A;
	int m = INF;
	int ans = 0;
	rep(i, 0, 5)
	{
		cin >> A;
		if (A % 10 != 0)
		{
			chmin(m, A % 10);
		}
		ans += (A + 9) / 10 * 10;
	}

	if (m != INF)
	{
		ans -= 10 - m;
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int long long i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int main(){

    ll n;
    cin>>n;
    vector<pair<ll,ll>> ku;
    vector<ll> s;
    for(int i=0;i<n-1;i++){
        ll a,b,c;
        cin>>a>>b>>c;
        ku.push_back(make_pair(b,a));
        s.push_back(c);
    }
  /*  rep(i,n-1){
        cout<<ku[i].first<<ku[i].second<<endl;
    }*/
    for(int i=0;i<n-1;i++){
        ll time=0;
        for(int j=i;j<n-1;j++){
            if(time<ku[j].first){
                time+=ku[j].first-time;
                time+=ku[j].second;
               //cout<<time<<"a"<<endl;
            }else{
                if(time%s[j]!=0){
                    time+=s[j]-(time%s[j]);
                }
                 time+=ku[j].second;
               // cout<<"a"<<time<<endl;
            }
           
        }
        
        cout<<time<<endl;
    }
    cout<<0<<endl;
    
    return 0;
}


Measured memory_bytes: 256
def solve():
    N = int(input())
    P = list(map(int, input().split()))
    cnt = 0
    for i, p in enumerate(P):
        i = i+1
        if p == i:
            cnt += 1
            if i == N:
                P[i-2],P[i-1] = P[i-1], P[i-2]
            else:
                P[i-1],P[i] = P[i], P[i-1]
            
    print(cnt)
    
solve()

Measured memory_bytes: 13880
w,h = map(int,input().split())
a = [10**18]+[int(input()) for i in range(w)]
b = [10**18]+[int(input()) for i in range(h)]
a.sort(reverse=True)
b.sort(reverse=True)
ans = 0
while len(a)>1 or len(b)>1:
  if a[-1]<b[-1]:
    ans += a[-1]*len(b)
    a.pop()
  else:
    ans += b[-1]*len(a)
    b.pop()
print(ans)

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

using namespace std;
using ll = long long;

const ll INF = 1LL << 60;

ll cost(int i, int s, const vector<ll> &A) {
  if (s == 0)
    return A[i];
  else if (s == 4)
    return A[i];
  else if (s == 1 || s == 3) {
    if (A[i] % 2 == 0 && A[i] > 0)
      return 0;
    else if (A[i] > 0)
      return 1;
    else
      return 2;
  } else {
    if (A[i] % 2 == 0)
      return 1;
    else
      return 0;
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int L;
  cin >> L;
  vector<vector<ll>> dp(510000, vector<ll>(5, INF));
  vector<ll> A(L);
  for (int i = 0; i < L; i++)
    cin >> A[i];
  dp[0][0] = 0;
  for (int i = 0; i < L; i++) {
    for (int j = 0; j < 5; j++) {
      for (int k = j; k < 5; k++) {
        dp[i + 1][k] = min(dp[i + 1][k], dp[i][j] + cost(i, k, A));
      }
    }
  }
  ll res = INF;
  for (int i = 0; i < 5; i++)
    res = min(res, dp[L][i]);
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 39680
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int x[n];
    int t = a[1] - a[0];
    for (int i = 2; i < n - 1; i++) {
        t = a[i] - t;
    }
    x[n - 1] = (t + a[n - 1]) / 2;
    for (int i = n - 2; i >= 0; i--) {
        x[i] = a[i] - x[i + 1];
    }
    for (int i = 0; i < n; i++) {
        cout << 2 * x[i] << " ";
    }
    cout << "\n";
}

Measured memory_bytes: 2944
function Main(input) {
  const num = input.split("\n");
  const amari = parseInt(num[0] % 500, 10);
        itchien = parseInt(num[1], 10);
  if(amari > itchien){
    console.log("No");
  } else {
    console.log("Yes");
  }
}

function debug(){
	var input = document.getElementById("input").value;
	Main(input);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
    int n;
    cin >> n;
    if(n < 10) cout << n << endl;
    else if(n < 100) cout << 9 << endl;
    else if(n < 1000) cout << n - 90 << endl;
    else if(n < 10000) cout << 909 << endl;
    else if(n < 100000) cout << n - 9090 << endl;
    else cout << 90909 << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> V (N);
  for(auto &l: V) cin >> l;

  double sum = 0.0;
  for(auto &l: V) sum+= 1.0 * (1.0/l*1.0);
  cout << fixed << setprecision(9) << 1/sum << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
template<class T> 
inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> 
inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 
 
 
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;

    ll n;
    cin>>n;
    ll w[200];
    ll ans=LLINF;
    rep(i,n) cin>>w[i];
    rep(t,n){
        ll s=0,u=0;
        rep(i,n){
            if(i<=t) s+=w[i];
            else u+=w[i];
        }
        // cout<<s<<" "<<u<<" ";
        chmin(ans,abs(s-u));
        // cout<<ans<<endl;
    }
    cout<<ans<<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();
        long d = sc.nextInt();
        long a = sc.nextInt();
        E[] e = new E[n];
        for(int i=0 ;i<n; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            e[i] = new E(x, (y+a-1)/a);
        }
        Arrays.sort(e);
        long res = 0;
        long pow = 0;
        Queue<E> q = new LinkedList<>();
        for(int i=0; i<n; i++) {
            while (!q.isEmpty()) {
                E entry = q.peek();
                if (e[i].x - entry.x > d * 2) {
                    pow -= entry.h;
                    q.poll();
                } else {
                    break;
                }
            } if (e[i].h > pow) {
                res += e[i].h - pow;
                q.add(new E(e[i].x, e[i].h - pow));
                pow += e[i].h - pow;
            }
        }


        System.out.println(res);


    }

    static class E implements Comparable {
        long x;
        long h;
        public E (long x, long h) {
            this.x = x;
            this.h = h;
        }

        @Override public int compareTo(Object o) {
            return Long.compare(x, ((E)o).x);
        }
    }

}


Measured memory_bytes: 123872
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin)-1;i>=(end);i--)
#define IREP(i, n) IFOR(i,n,0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=("; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;


template<typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) { REP(i, a.size()) {cin >> a[i]; a[i]--;} }

ll mod = 1000000007;

int main()
{
    ll D;
    cin>>D;

    string ans;
    
    if(D==25) ans="Christmas";
    else if(D==24) ans="Christmas Eve";
    else if(D==23) ans="Christmas Eve Eve";
    else ans="Christmas Eve Eve Eve";

    cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

bool p[101];

vector<ll> prime;
ll pn[25];

void init(){
  p[0] = true;
  p[1] = true;

  rep(i, 101)rep(j, 101){
    if(i<=1) continue;
    if(j<=1) continue;
    if(i*j >100) break;
    
    p[i*j] = true;
  }
  rep(i, 101){
    if(!p[i]) prime.pb(i);
  }
}

ll func(ll a, ll p){
  ll ans = 0 ;
  while(a != 0){
    if(a % p != 0) break;
    a/=p;
    ans++;
  }

  return ans;
}


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

  init();
  
  ll N;
  cin >> N;

  rep(i,N+1){
    if(i <= 1) continue;
    rep(j, prime.size()){
      pn[j] += func(i, prime[j]);
    }
  }

  vector<ll> ans;
  rep(i, prime.size()){
    ans.pb(pn[i]);
  }
  
  ll ret = 0;

  //4 4 2
  rep(i,ans.size()){
    rep(j,ans.size()){
      if(i == j) continue;
      rep(k,ans.size()){
	if(k == i || k == j) continue;

	if(ans[i] >= 4 && ans[j] >= 4 && ans[k] >= 2) ret ++;
      }
    }
  }
  ret /= 2;
  
  // 74
  rep(i, ans.size()){
    if(ans[i] >= 74) ret ++;
  }

  // 2 24
  rep(i, ans.size()){
    rep(j, ans.size()){
      if(i==j) continue;

      if(ans[i] >= 24 && ans[j] >= 2) ret ++;
    }
  }

  // 4 14
  rep(i, ans.size()){
    rep(j, ans.size()){
      if(i==j) continue;

      if(ans[i] >= 14 && ans[j] >= 4) ret ++;
    }
  }

  

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N, D;

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

  int range = 2 * D + 1;
  int ans = N / range;

  if (N % range == 0) {
    cout << ans << endl;
  } else {
    cout << ans + 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{int N,X,Y,n,i,k,j,l,flag,m,di,tim;
scanf("%d",&N);
n=N+1;
flag=0;
int x[100001];
int t[100001];
int y[100001];
int dis[100001];
int time[100001];
x[0]=0;y[0]=0;t[0]=0;
for(i=1;i<=n-1;i++){
	scanf("%d%d%d",&t[i],&x[i],&y[i]);}
	for(k=0;k<=n-2;k++){
		if(x[k+1]>=x[k]){
			X=x[k+1]-x[k];}
			else{
				X=x[k]-x[k+1];}
				if(y[k+1]>=y[k]){
			Y=y[k+1]-y[k];}
			else{
				Y=y[k]-y[k+1];}
		dis[k]=X+Y;
		time[k]=t[k+1]-t[k];
		di=dis[k]%2;
		tim=time[k]%2;
		if(di!=tim || dis[k]>time[k]){
			printf("No");
			flag=1;
			break;}}
	if(flag==0){
		printf("Yes");}
			

	
	return 0;
}


Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main()
{
    long long n,m,s=0,k;
    cin>>n;
    if(n%2!=0)
    {
        cout<<0<<endl;
    }
    else
    {
        k=10;
        while(k<=n)
        {
            s+=(n/k);
            k*=5;
        }
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

int N = 200010;
long long M = 1000000007;
typedef long long ll;

vector<ll> fact, invfact;
vector<vector<int>> g;
int n;
vector<int> s, dp, sol;

// Fijar M el modulo
inline int add(int a, int b) {
	a += b;	if (a >= M) a -= M;
	return a;
}
inline int sub(int a, int b) {
	a -= b;	if (a < 0) a += M;
	return a;
}
inline int mul(int a, int b) {
	return (int)((long long)a * b % M);
}
inline int inv(int a) {
	a %= M;
	if (a < 0) a += M;
	int b = M, u = 0, v = 1;
	while (a) {
		int t = b / a;
		b -= t * a; swap(a, b);
		u -= t * v; swap(u, v);
	}
	//assert(b == 1);
	if (u < 0) u += M;
	return u;
}

// Complejidad: O(log_p n)
ll choose(ll n, ll m) {
	int p = M;
	ll c = 1;
	while (n || m) {
		ll a = n % p, b = m % p;
		if (a < b) return 0;
		c = c * fact[a] % p * invfact[b] % p * invfact[a - b] % p;
		n /= p; m /= p;
	}
	return c;
}

void precompute() { // O(N)
	fact = invfact = vector<ll>(N);
	fact[0] = invfact[0] = 1;
	for (int i = 1; i < N; ++i) {
		fact[i] = (i * fact[i - 1]) % M;
		invfact[i] = inv(fact[i]); // Inverso modular
	}
	// Ahora ya se puede llamar a choose
}

void dfs(int i, int p=-1) {
	int inisi = s[i], inidpi = dp[i];
	for (int j : g[i]) {
		if (j == p) continue;
		s[i] = n - s[j];
		ll ant = dp[j], ant2 = s[j];
		dp[j] = mul(choose(n-1, s[i]), mul(inv(choose(n-1, s[j])), dp[i]));
		sol[j] = dp[j];
		dp[i] = mul(dp[i], inv(mul(choose(n - 1, s[j]), ant)));
		s[j] = n - 1;
		dfs(j, i);
		s[i] = inisi; 
		dp[i] = inidpi;
		dp[j] = ant;
		s[j] = ant2;
	}
}

ll dfs1(int u, int p = -1) {
	map<int, ll> res;
	for (int v : g[u]) {
		if (v == p) continue;
		res[v] = dfs1(v, u);
		s[u] += s[v];
	}
	int ress = 1LL, cnt = s[u];
	for (pair<int, ll> x : res) {
		ress = mul(ress, mul(choose(cnt, s[x.first]), x.second));
		cnt -= s[x.first];
	}
	s[u]++;
	return dp[u] = ress;
}

int main() {
	precompute();
	cin.sync_with_stdio(false); cin.tie(nullptr);
	cin >> n;
	g = vector<vector<int>>(n);
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v; u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dp = s = sol = vector<int>(n, 0);
	sol[0] = dfs1(0);
	dfs(0);
	for (int x : sol) cout << x << "\n";
	return 0;
}

Measured memory_bytes: 31988
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n,m = LI()
    aa = sorted([LI() for _ in range(n)]) + [[inf,0]]
    r = 0
    q = []
    ai = 0
    for i in range(m+1):
        while aa[ai][0] <= i:
            heapq.heappush(q,-aa[ai][1])
            ai += 1
        if len(q) > 0:
            t = heapq.heappop(q)
            r -= t

    return r


print(main())





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

int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);
  int CNT[100000];
  memset(CNT, 0, sizeof(int)*100000);

  char S, P;
  int END = 0;
  for(int i = 0; i < N; i++) {
    scanf(" %c", &S);
    if(i != 0 && S != P) END++;
    P = S;
    if(S == '0') {
      CNT[END]--;
    }  else {
      CNT[END]++;
    }
  }
  END++;

  int MAX = 0;
  int CUR = 0;
  int CHG = 0;
  int LP  = -1;
  for(int i = 0; i < END; i++) {
    if(CNT[i] < 0) {
      if(CHG < K) {
	if(CHG == 0)
	  LP = i;
	CHG++;
      } else {
	if(LP != -1) {
	  CUR += CNT[LP];
	  if(LP != 0) {
	    CUR -= CNT[LP-1];
	  }
	}
	LP += 2;
      }
      CUR -= CNT[i];
    } else {
      CUR += CNT[i];
    }

    if(MAX < CUR) MAX = CUR;
    //printf("%d(%d): MAX=%d, CUR=%d, CHG=%d/%d LP=%d\n", i, CNT[i], MAX, CUR, CHG, K, LP);
  }
  printf("%d\n", MAX);
  return 0;
}


Measured memory_bytes: 512
N, M = map(int,input().split())
S = []
K = []
for i in range(M):
    tmp = list(map(int,input().split()))
    k= tmp[0]
    S.append([tmp[i] for i in range(1, k+1)])
P = list(map(int,input().split()))
ans = 0
for i in range(2**N):
    s = [0]*N # スイッチが立っているか
    for j in range(N):
        if (i >> j) % 2 == 1:
            s[j] = 1
    LIGHT = [False]*M
    for k in range(M): # 電球ｋが光っているか
        count = 0
        for c in S[k]:
            c -= 1
            if s[c] == 1:
                count += 1
        if count % 2 == P[k]:
            LIGHT[k] = True
    if all(LIGHT):
        ans += 1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>
#include<tuple>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N; cin >> N;
	
	ll cnt = 0;
	for (ll A = 1; A <= N - 1; A++) {
		cnt += N / A;
		if (N % A == 0)cnt--;
	}

	cout << cnt << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
using namespace std;
int n, c, v[500000], mem[500000];
void solve(int l, int r) {
	if(r - l == 1) return; c += r - l;
	solve(l, (l + r) / 2);
	solve((l + r) / 2, r);
	merge(v + l, v + (l + r) / 2, v + (l + r) / 2, v + r, mem);
	for(int i = l; i < r; i++) v[i] = mem[i - l];
}
int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", &v[i]);
	solve(0, n);
	for(int i = 0; i < n; i++) {
		if(i) printf(" ");
		printf("%d", v[i]);
	}
	printf("\n%d\n", c);
}

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64

signed main() {
  int n,m;cin>>n>>m;
  vector<int> a(n);
  priority_queue<int> q;
  for(int i=0;i<n;++i) {
    cin>>a[i];
    q.push(a[i]);
  }

  for(int i=0;i<m;++i){
    int p = q.top(); q.pop();
    p >>= 1;
    q.push(p);
  }

  int ans = 0;
  for(int i=0;i<n;++i){
    int p = q.top(); q.pop();
    ans += p;
  }

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


Measured memory_bytes: 2168
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    arr = list(map(int, input().split()))
    
    target = x
    count = 1
    while True:
        if target not in arr:
            print(target)
            break
        if count % 2 != 0:
            target -= count
        else:
            target += count
        count += 1

Measured memory_bytes: 9180
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int N, K; cin >> N >> K;
    vi V; rep1(i, N)V.push_back(i);
    rep(i, K) {
        int d; cin >> d;
        rep(i, d) {
            int A;
            cin >> A;
            rep(j, V.size()) {
                if (V[j] == A) {
                    V.erase(V.begin() + j);
                }
            }
        }
    }
    cout << V.size() << endl;
}






Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main(){
    ll n,k;
    cin >> n >> k;
    ll sum = min(n,k);
    ll v[n+10];
    ll kotae;
    ll ans = -1;
    for(int i = 0; i < n; i++){
        ll temp;
        cin >> temp;
        v[i] = temp;
    }
    for(int i = 0; i <= sum; i++){
        for(int j = 0; j <= sum - i; j++){
            kotae = 0;
            vector<ll> minus;
            for(int k = 0; k < i; k++){
                kotae += v[k];
                if(v[k] < 0){
                    minus.push_back(v[k]);
                }
            }
            for(int k = n-1; k >= n-j;k--){
                kotae += v[k];
                if(v[k] < 0){
                    minus.push_back(v[k]);
                }
            }
            sort(minus.begin(),minus.end());
            ll hoge = minus.size();
            ll dokomade = min(k - i - j,hoge);
            for(int k = 0; k < dokomade; k++){
                kotae -= minus[k];
            }
            ans = max(ans,kotae);

        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main (void)  {
    int x=0,j=0,i=0,hoge;
    char t[1010],w[15];

    scanf("%s", w);
    for(hoge=0;w[hoge]!=0;hoge++){
        w[hoge]=toupper(w[hoge]);
    }
    
    // printf("%s\n", w);
    while(1){
        scanf("%s", t);
        if(strcmp("END_OF_TEXT", t)==0){
            break;
        }
        
        for(hoge=0;t[hoge]!=0;hoge++){
            t[hoge]=toupper(t[hoge]);
        }
        // printf("%s\n", t);

        if(strcmp(w,t)==0){
            j++;
        }
    }

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

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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];
    int ans = INF;
    REP(i, N)
    {
        int count = 0;
        while(A[i] % 2 == 0)
        {
            A[i] /= 2; 
            count++;
        }
        ans = min(ans, count);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
import math
Q = int(input())
for _ in range(Q):
	A,B = map(int,input().split())
	res = 0
	if A == B or A + 1 == B:
		res = 2 * A - 2
	else:
		C = int(math.sqrt(A * B))
		if C * C == A * B:
			C -= 1
		if C * (C + 1) >= A * B:
			res = 2 * C - 2
		else:
			res = 2 * C - 1
	print(res)

Measured memory_bytes: 3060