akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll ans = 0LL;

    if (a + b <= k) {
        ans = a;
        k -= a + b;
        ans -= min(k, c);
    }
    else {
        ans = min(a, k);
    }

    Cout(ans);

    return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
	char w[4];
	for (int i=0;i<4;i++)
		w[i]=getchar();
	int a[4];
	for (int i=0;i<4;i++)
		a[i]=w[i]-'0';
	int f1=0,f2=0;
	int fir=a[0]*10+a[1],las=a[2]*10+a[3];
	if (fir<13&&fir>0)
		f1=1;
	if (las<13&&las>0)
		f2=1;
	if (f1&&f2)
		cout<<"AMBIGUOUS";
	else if (f1)
		cout<<"MMYY";
	else if (f2)
		cout<<"YYMM";
	else
		cout<<"NA";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ms(a,b) memset(a,0,sizeof(a))
#define debug(x) cerr<<#x<<"="<<x<<endl;
typedef long long ll;
const int maxn=1e5+100;

int main()
{
	ll n,m;
	cin>>n>>m;
	ll t=pow(2,m);
	ll x=(1900*m+100*(n-m));
	cout<<x*t;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;

map<ll, ll> bitcnt(ll num){
    map<ll, ll> ret;
    ll base = 1;
    while(base <= num) base *= 2;
    base /= 2;
    
    while(base){
        ret[base] = num/(base*2)*base;
        if(num%(base*2) >= base) ret[base] += num%(base*2) - base + 1;
        base /= 2;
    }

    return ret;
}

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

    ll a, b;
    cin >> a >> b;
    
    map<ll, ll> cnt_a, cnt_b;
    cnt_a = bitcnt(a-1);
    cnt_b = bitcnt(b);

    ll res = 0;
    for(ll i = 0; i < 60; ++i){
        ll base = 1ll << i;
        if((cnt_b[base] - cnt_a[base])%2 == 1) res += base;
    }

    cout << res << endl;

}

Measured memory_bytes: 3664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
        	int n = in.nextInt();
        	int a[] = new int [n];
        	for (int i = 0; i < a.length; i++) {
        		a[i] = in.nextInt();
        	}
        	
        	int num = 0;
        	for (int i = 0; i < a.length; i++) {
        		int k = i;
        		for (int j = i; j < a.length; j++) {
        			if (a[j] < a[k]) {
        				k = j;
        			}
        		}
        		if (a[i] > a[k]) {
        			int t = a[i];
        			a[i] = a[k];
        			a[k] = t;
        			num += 1;
        		}
        	}
        	
        	String s = new String();
        	for (int i = 0; i < a.length; i++) {
        		s = s.concat(Integer.toString(a[i]));
        		if (i + 1 != a.length) s = s.concat(" ");
        	}
        	
        	out.println(s);
        	out.println(num);
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
    }
}

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

const int max_data = 4;
int x;
int n=0;
int ans;

void solve(int n, int x)
{
	if(x > max_data*9){
		return;
	}

	if(n == max_data && x==0){
		ans++;
		return;
	}else if(n == max_data){
		return;
	}

	for(int i=0;i<=9;i++){
		if(x-i >= 0){
			solve(n+1,x-i);
		}
	}
	return;
}

int main()
{
	while(cin >> x){
		ans = 0;
		solve(n,x);
		cout << ans << endl;
	}
	return 0;
}

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

int main() {
    ll n,k;
    cin>>n>>k;
    int mod=1e9+7;
    ll ans=0;
    for (ll i=k;i<=n+1;i++)
        ans=(ans+(n+n-i+1)*i/2-(i-1)*i/2+1)%mod;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V) for (auto v : (V)) cout << v << " "
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
template < class T > using vec = std::vector< T >;
template < class T > void print(T &x) { cout << x << "\n"; }
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI = acos(-1.0);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int D,N;
  cin >> D>>N;
  if (N<=99)cout <<(int)(pow(100,D)*N)<<"\n";
  else cout <<(int)(pow(100,D)*101)<<"\n";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a,b,ans,i,t;
	
	while((scanf("%d",&a))!=EOF){
		scanf("%d",&b);
		t=a+b;
		for(ans=1;;){
			t=(t-t%10)/10;
			if(t>0)
			ans++;
			else{
				printf("%d\n",ans);
				break;
			}
		}
	}
		
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ldb;
typedef unsigned int ui;
typedef unsigned long ul;
 
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
 
typedef priority_queue<pi> pq;
typedef priority_queue<int,vector<int>,greater<int>> pqg;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound


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

int temp;
cin>>temp;
if(temp<30) cout<<"No";
else cout<<"Yes";

return 0; 
}


Measured memory_bytes: 3668
use std::io;
use std::str::FromStr;


fn get_num() -> i32 {
	let mut input = String::new();

	io::stdin().read_line(&mut input)
		.expect("");

	i32::from_str(input.trim()).unwrap()
}

fn get_nums() -> Vec<i32> {
	let mut input = String::new();

	io::stdin().read_line(&mut input)
		.expect("");

	input.trim()
		.split_whitespace()
		.map(|d| i32::from_str(d).unwrap())
		.collect::<Vec<_>>()
}

fn min(x: i32, y: i32) -> i32 {
	if x < y {
		x
	} else {
		y
	}
}


fn main() {
	let _ = get_num();
	let k = get_num();

	let mut d = 0;
	let xs = get_nums();

	for x in xs {
		d += 2*min(x, (k-x).abs())
	}

	println!("{}", d);
}									





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

typedef long long ll;
int n;
ll a[100001],d[3002][3002],INIT=-1e18;

ll p(int l, int r){
    if(d[l][r]!=INIT)return d[l][r];
    if(l==r-1)return d[l][r]=(1-((n*3-r-l)%2)*2)*a[l];
    if((n*3-l-r)%2==0){
        return d[l][r]=max(p(l+1, r)+a[l], p(l, r-1)+a[r-1]);
    }else{
        return d[l][r]=min(p(l+1, r)-a[l], p(l, r-1)-a[r-1]);
    }
}

int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            d[i][j]=INIT;
        }
    }
    ll ans=p(0, n);
    cout<<ans<<endl;
}


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

int main(){
    int x=0,hund=0;
    cin >> x;
    hund = x/100;
    x -= hund*100;
    if(hund*0<=x&&x<=hund*5)cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

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

int main(){
  int x,n;
  cin >> x >> n;
  int p[n];
  rep(i,n){cin >> p[i];}
  
  int ans = 100;
  int ansIndex = 0;
  for(int i= 0; i <= 101; i++){
    bool flag = true;
    rep(j,n){
      if(p[j] == i) flag = false;
    }
    if(flag){
      if(ans>=abs(x-i)){
        if(ans==abs(x-i)){
          ans = abs(x-i);
        }else{
          ans = abs(x-i);
          ansIndex = i;
        }
      }
    }
  }
  
  cout << ansIndex << endl;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main {                       
 
  public static void main(String[] args) {                     
      Scanner sc = new Scanner(System.in);
      
      ArrayList<Integer> ans = new ArrayList<Integer>();
      
      while(true){
           int N = sc.nextInt();
           
           if(N == 0){
               break;
           }
           
           int score[] = new int[N];
           
           for(int i = 0;i < N;i++){
               score[i] = sc.nextInt();
           }
           
           Arrays.sort(score);

           int sum = 0;
           for(int i = 1 ;i <= N - 2;i++){
               sum += score[i];               
           }                      
           
           int average = sum/(N-2);
           
           ans.add(average);
      }
      
      for(int i = 0;i < ans.size();i++){
          System.out.println(ans.get(i));
      }
    
  }  
      
}

Measured memory_bytes: 28804
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var r = Integer.parseInt(br.readLine());

      System.out.println(r * 2 * Math.PI);
    }
  }
}


Measured memory_bytes: 33228
#include<vector>
#include<iostream>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

void solve(int q,vector<string> &a,vector<int> &b,vector<int> &c){
  rep(i,a.size()){
    int f = c[i]-b[i]+1;
    if (f <= q && q <= c[i]){
      cout <<a[i] <<" " << q-f+1 << endl;
      return;
    }
  }
  cout <<"Unknown" << endl;
}

main(){
  int n,q;
  while(cin>>n>>q && n){
    vector<string> a(n);
    vector<int> b(n),c(n);
    rep(i,n)cin>>a[i]>>b[i]>>c[i];
    rep(i,q){
      int p;cin>>p;solve(p,a,b,c);
    }
  }
}

Measured memory_bytes: 0
# coding: utf-8
# Your code here!
INF = 2000000000

def getTheNumberOfCoin():
    for i in range(n + 1):
        T.append(INF)
    T[0] = 0
    
    for i in range(m):
        for j in range(C[i], n + 1):
            T[j] = min(T[j], T[j-C[i]] + 1)
    
    return T




T = []
C = []
nums=list(map(int,input().split()))
n = nums[0]
m = nums[1]
nums=list(map(int,input().split()))
for i in range(m):
    C.append(nums[i])

getTheNumberOfCoin()
print(T[n])







Measured memory_bytes: 7636
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        String n = inp.next();
        String ans = isp(n) ? "Yes" : "No";
        System.out.println(ans);
    }
    public static boolean isp(String s) {
        char ss[] = s.toCharArray();
        char pp[] = new char[ss.length];
        for (int i = 0; i < ss.length; i++) {
            pp[ss.length - i - 1] = ss[i];
        }
        return Arrays.equals(ss, pp);
    }
}

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

using namespace std;

int main() {

	long long n,m;
	long long result;

	cin >> n >> m;

	if (abs(n - m) > 1) {
		cout << 0 << endl;
		return 0;
	}

	result = 1;
	for (long i = 1; i <= n; i++) {
		result *= i;
		if (result >= 1000000007) {
			result = result % 1000000007;
		}
	}

	for (long i = 1; i <= m; i++) {
		result *= i;
		if (result >= 1000000007) {
			result = result % 1000000007;
		}
	}
	if (n == m) {
		result *= 2;
		if (result >= 1000000007) {
			result = result % 1000000007;
		}
	}
	cout << result << endl;
	return 0;
}

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s; cin >> s;
    ll ans = 0LL; rep(i, s.size()) ans += (s[i] - '0');
    if(ans % 9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3736
#include <stdio.h>

int main(){

	int N;

	scanf("%d",&N);

	if(N==1||N==2){
	printf("2\n");
	}
	else{
		if(N%2==0){
		printf("%d\n",N);
		}
		else{
		printf("%d\n",2*N);
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
    char num[1001];
    int ans = 0;
    int i;
    
    while(1) {
        scanf("%s", num);
        
        if(num[0] == '0'){
            break;
        }
        
        for(i = 0; num[i] != '\0'; i++){
            ans += (num[i] - '0');
        }
        
        printf("%d\n", ans);
        
        ans = 0;
        
    }
    
    return 0;
}



Measured memory_bytes: 2120
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>

#define INF (int)1e09

using std::cin;
using std::cout;
using std::endl;
using std::setprecision;
using std::fixed;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::string;
using std::vector;
using std::list;
using std::map;
using std::set; // insert erase find count
using std::queue;
using std::priority_queue;
using std::stack;

template <typename T> using Vec = vector<T>; // c++11
typedef pair<int, int> PII;
typedef pair<int, pair<int, int> > PIII;

int dijk(int n, Vec<Vec<int> >& table) {
    Vec<int> answer((1 << n), INF);
    priority_queue<PII, Vec<PII>, std::greater<PII> > pq;

    for (int i = 0; i < n; i++) {
        pq.push(make_pair(table[i][0], 1 << i));
        answer[1 << i] = table[i][0];
    }

    while (!pq.empty()) {
        int now_cost = pq.top().first;
        int now_have = pq.top().second;
        pq.pop();


        for (int i = 0; i < n; i++) {
            if ((now_have & (1 << i)) == 0) {
                int min_cost = table[i][0];
                for (int j = 0; j < n; j++) {
                    if ((now_have & (1 << j)) != 0) {
                        min_cost = min(min_cost, table[i][j + 1]);
                    }
                }
                int update_cost = now_cost + min_cost;
                int update_have = (now_have | (1 << i));
                if (update_cost < answer[update_have]) {
                    answer[update_have] = update_cost;
                    pq.push(make_pair(update_cost, update_have));
                }
                /*
                cout << "HERE = " << now_have << " " << i + 1 << endl;
                cout << "MIN_COST = " << min_cost << endl;
                cout << update_cost << " " << update_have << endl;
                */
            }
        }
    }
    return answer[(1 << n) - 1];
}

int main(void) {
    while (1) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        Vec<Vec<int> > table(n, Vec<int>(n + 1));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n + 1; j++) {
                cin >> table[i][j];
            }
        }
        int ans = dijk(n, table);
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        int n = Integer.parseInt(str[0]);
        int k = Integer.parseInt(str[1]);
        boolean[] treated = new boolean[n];
        Arrays.fill(treated, false);
        int cnt = n;
        int d = 0;
        for (int i = 0; i < k; i++) {
            d = Integer.parseInt(br.readLine());
            str = br.readLine().split(" ");
            for (int j = 0; j < d; j++) {
                if (treated[Integer.parseInt(str[j]) - 1] == false) {
                    treated[Integer.parseInt(str[j]) - 1] = true;
                    cnt--;
                }
            }
        }
        System.out.println(cnt);

    }
}


Measured memory_bytes: 33564
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
int main(){
	ll n; cin>>n;
	priority_queue<double,vector<double>,greater<double>> pq;
	ll a[n]; for(ll i=0;i<n;i++) cin>>a[i],pq.push((double)a[i]);
	ll ans=0;
	while(pq.size()>1){
		auto x=pq.top(); pq.pop();
		auto y=pq.top(); pq.pop();
		pq.push((x+y)/2.0);
	}
	cout<<fixed<<setprecision(12)<<pq.top();
}


Measured memory_bytes: 3704
#include <iostream>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n; ll k;
    cin >> n >> k;
    vector <ll> a(n),f(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> f[i];
    sort(a.begin(),a.end());
    sort(f.rbegin(),f.rend());
    ll l=-1,r=1000000000000,mid;
    while(l+1<r){
        mid = (l+r)/2;
        ll sum = 0;
        for(int i=0;i<n;i++){
            if(a[i]*f[i]>mid){
                sum += max(0LL,a[i]-mid/f[i]);
            }
        }
        if(sum <= k) r = mid;
        else l = mid;
    }
    cout << r << endl;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <map>
#include <string>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int pos;
char str[10000];

string GetVariable() {
  string ret = "";
  assert(isalpha(str[pos]));
  while (isalpha(str[pos])) {
    ret += str[pos];
    pos++;
  }
  return ret;
}

int main() {
  while (scanf("%s", str), str[0] != '#') {
    pos = 0;
    while (str[pos] != '\0') {
      if (str[pos] == '|') { pos++; }
      assert(str[pos] == '(');
      pos++;
      map<string, int> use;
      int ok = 1;
      while (str[pos] != ')') {
        int v = 1;
        if (str[pos] == '~') { pos++; v ^= 1; }
        string s = GetVariable();
        if (str[pos] == '&') { pos++; }
        if (use.count(s)) {
          if (use[s] != v) {
            use[s] = -1;
            ok = 0;
          }
        } else {
          use[s] = v;
        }
      }
      pos++;
      if (ok) {
        puts("yes");
        goto next;
      }
    }
    puts("no");
next:;
  }
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        Map<Integer, Integer> haveProblems = new HashMap<>();
        Map<Integer, Integer> needProblems= new HashMap<>();

        int have = scanner.nextInt();
        for (int i = 0; i < have; i++) {
            int tmp = scanner.nextInt();
            if (haveProblems.containsKey(tmp))
                haveProblems.put(tmp, haveProblems.get(tmp) + 1);
            else
                haveProblems.put(tmp, 1);
        }

        int need = scanner.nextInt();

        for (int j = 0; j < need; j++) {
            int tmpp = scanner.nextInt();
            if (haveProblems.containsKey(tmpp) && haveProblems.get(tmpp) > 0) {
                haveProblems.put(tmpp, haveProblems.get(tmpp) - 1);
            } else {
                System.out.println("NO");
                return;
            }
        }
        System.out.println("YES");

    }

}

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

int main() {
	int n, m; cin >> n >> m;
	int k[12], s[12][12], p[12];
	for(int i=0;i<m;i++){
		cin >> k[i];
		for(int j=0;j<k[i];j++){
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	for(int i=0;i<m;i++){
		cin >> p[i];
	}
	int ans = 0;
	for(int bit=0;bit<(1<<n);bit++){
		int on = 0;
		 for(int i=0;i<m;i++){
		 	int cnt = 0;
		 	for(int j=0;j<k[i];j++){
		 		if(bit>>s[i][j]&1) cnt++;
		 	}
		 	if(cnt%2==p[i]) on++;
		 }
		 if(on==m) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp12
{
    class Program
    {
        static void Main(string[] args)
        {
            long H = long.Parse(Console.ReadLine());

            for (int i = 0; i < 50; i++)
            {
                long pow = (long)Math.Pow(2, i);
                if (H < pow)
                {
                    Console.WriteLine(pow - 1);
                    break;
                }
            }
            
        }
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 1e18 * 4;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
  int n, i, j;
  cin >> n;
  vl a(n);
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vl sum(n + 1);
  ll ans = 0;
  for (i = 0; i < n; i++) {
    sum[i + 1] = sum[i] + a[i];
    if (sum[i] * 2 < a[i]) {
      ans = i;
    }
  }
  cout << n - ans << endl;
}
  


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

int main() {
  int N, A, ans = 30;
  cin >> N;
 
  for (int i = 0; i < N  ; i++) {
    int count = 0;
    cin >> A;
    for (int j = 2; j < 1000000000; j*=2) {
      if (A%j != 0) {break;}
      else count++;
  }
  if (ans > count) { ans = count; }
    
  }
  
   cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
c = [0] * 8
free = 0
for i in a:
    if i < 400:
        c[0] += 1
    elif i < 800:
        c[1] += 1
    elif i < 1200:
        c[2] += 1
    elif i < 1600:
        c[3] += 1
    elif i < 2000:
        c[4] += 1
    elif i < 2400:
        c[5] += 1
    elif i < 2800:
        c[6] += 1
    elif i < 3200:
        c[7] += 1
    else:
        free += 1
min_ans = len([i for i in c if i > 0])
max_ans = min_ans + free
if min_ans == 0:
    min_ans = 1
print(min_ans, max_ans)

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

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

using lli = long long int;

std::vector<lli> A;

// k (1, 1, ..., -n, 1)

int main(void){
    int n; scanf("%d", &n);
    A.resize(n); REP(i, n) scanf("%lld", &A[i]);

    lli res = 0;
    while(true){
        lli cnt = 0;
        REP(i, n) cnt += (A[i] >= 0 ? A[i] / n : 0);
        if(cnt == 0) break;
        // x回の操作のうち, y回選ばれる => (x-y) - yn
        REP(i, n){
            lli proc = A[i] / n;
            lli diff = (cnt - proc) - proc * n;
            A[i] += diff;
        }
        res += cnt;
    }

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

    return 0;
}


Measured memory_bytes: 888
s=input()
i=0
a=""
while i<len(s):
  if s[i]=="L":
    a="No"
    break
  else:
    i+=2
if a=="No":
  pass
else:
  i=1
  while i<len(s):
    if s[i]=="R":
      a="No"
      break
    else:
      i+=2
if a=="":
  a="Yes"
print(a)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod=1000000007;

int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  string s,t;
  cin>>s>>t;
  int m=s.size();
  int n=t.size();
  int dp[m+1][n+1];
  for(int i=0; i<=m; i++){
    for(int j=0; j<=n; j++){
        if(i==0||j==0){dp[i][j]=0;}
        else{
            if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
               dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
  }
  int in=dp[m][n];
 // cout<<dp[m][n];
  int i=m,j=n;
  char ans[in+1];
  ans[in]='\0';
  while(i>0&&j>0){
    if(s[i-1]==t[j-1]){
        ans[in-1]=s[i-1];
        i--; j--; in--;
    }
    else if(dp[i-1][j]>dp[i][j-1]){i--;}
    else{j--;}
  }
  cout<<ans;

  return 0;
}

Measured memory_bytes: 38772
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
	stdout     *bufio.Writer
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 2048), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

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

func gcd64(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd64(b, a%b)
}

// readString() string
// readInt() int
// readInt64() int64
// readFloat64() float64

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()
	H := readInt()
	W := readInt()
	S := make([][]byte, H)
	for i := range S {
		S[i] = []byte(readString())
	}
	hp := make([][]int, H)
	for i := range hp {
		hp[i] = make([]int, W)
		for j := 0; j < W; {
			for j < W && S[i][j] == '#' {
				j++
			}
			k := j
			for k < W && S[i][k] == '.' {
				k++
			}
			v := k - j
			for ; j < k; j++ {
				hp[i][j] = v
			}
		}
	}

	wp := make([][]int, H)
	for i := range wp {
		wp[i] = make([]int, W)
	}

	for i := 0; i < W; i++ {
		for j := 0; j < H; {
			for j < H && S[j][i] == '#' {
				j++
			}
			k := j
			for k < H && S[k][i] == '.' {
				k++
			}
			v := k - j
			for ; j < k; j++ {
				wp[j][i] = v
			}
		}
	}

	var ans int
	for i := range S {
		for j := range S[i] {
			ans = max(ans, hp[i][j]+wp[i][j]-1)
		}
	}
	println(ans)
}

// -----------------------------------------------------------------------------


Measured memory_bytes: 72576
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<deque>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
    int H, W;
    int Ch, Cw;
    int Dh, Dw;
    vector<string> S;
    vector<vector<int>> d;
    deque<pair<int,pair<int,int>>> q;
    
    cin>>H>>W;
	
    d.resize(H, vector<int>(W, INF));
    
    cin>>Ch>>Cw;
    
    Ch--, Cw--;
    
    d[Ch][Cw] = 0;
    
    q.push_back({0, {Ch, Cw}});
    
    cin>>Dh>>Dw;
    
    Dh--, Dw--;
    
    S.resize(H);
    
    for(int i = 0; i < H; i++){
        cin>>S[i];
    }
    
    int dx[4] = {0, 0, 1, -1};
    int dy[4] = {1, -1, 0, 0};
    
    while(!q.empty()){
        pair<int,pair<int,int>> p = q.front(); q.pop_front();
        int dis = p.first, y = p.second.first, x = p.second.second;
        
        if(dis < d[y][x]) continue;
        
        if(y == Dh && x == Dw) {
            cout<<dis<<endl;
            return 0;
        }
        
        for(int i = 0; i < 4; i++){
            int ny = y + dy[i], nx = x + dx[i];
            
            if(ny < 0 || ny >= H || nx >= W || nx < 0) continue;
            
            if(S[ny][nx] == '#') continue;
            
            if(d[ny][nx] <= dis) continue;
            
            d[ny][nx] = dis;
            
            q.push_front({dis, {ny, nx}});
        }
        
        for(int i = -2; i <= 2; i++){
            for(int j = -2; j <= 2; j++){
                 int ny = y + i, nx = x + j;
                
                if(ny < 0 || ny >= H || nx >= W || nx < 0) continue;
                
                if(S[ny][nx] == '#') continue;
                
                if(d[ny][nx] <= dis + 1) continue;
                
                d[ny][nx] = dis + 1;
                
                q.push_back({dis + 1, {ny, nx}});
            }
        }
    }
    
    cout<<-1<<endl;
    
	
	return 0;
}

Measured memory_bytes: 12796
#include <stdio.h>
#include <stdlib.h>

#define INF 1000000000
#define min(x, y) (((x) < (y)) ? (x) : (y))

int solv(int n, int *h) {
  int i, d[100000], t;

  for (i = 0; i < 100000; i++) {
    d[i] = INF;
  }
  d[0] = 0;

  for (i = 0; i < n - 1; i++) {
    t = d[i] + abs(h[i] - h[i + 1]);
    d[i + 1] = min(d[i + 1], t);
    if (i + 2 < n) {
      t = d[i] + abs(h[i] - h[i + 2]);
      d[i + 2] = min(d[i + 2], t);
    }
  }

  return d[n - 1];
}

int main(int argc, char **argv) {
  int n, i, h[100000];

  while (scanf("%d", &n) != EOF) {
    for (i = 0; i < n; i++) {
      scanf("%d", h + i);
    }

    printf("%d\n", solv(n, h));
  }

  return 0;
}


Measured memory_bytes: 896
import std.stdio, std.string, std.array, std.conv, std.algorithm, std.typecons, std.range, std.container, std.math, std.algorithm.searching, std.functional,std.mathspecial;

void main(){
    auto na=readln.chomp.split.map!(to!int).array;
    auto xs=readln.chomp.split.map!(to!int);
    auto diffs=xs.map!(x=>x-na[1]);
    auto zeroes=diffs.filter!"a==0".count;
    auto noneZeroes=diffs.filter!"a!=0".array;
    
    long[int] counts;
    counts[0]=1;

    foreach(n;noneZeroes){
        foreach(k,ns;counts.dup){
            counts[k+n]+=ns;
        }
    }

    writeln(counts[0]*(2L^^(zeroes))-1);
}

Measured memory_bytes: 2940
import fractions

N,M = map(int, input().split())
A = [int(a) for a in input().split()]

for i in range(N):
    A[i] //= 2
    
num = 1
f = 0
for i in range(N):
    num = num*A[i]//fractions.gcd(num, A[i])
    if num > M:
        f = 1
        break
    
for i in range(N):
    if (num//A[i])%2 == 0:
        f = 1
        break
        
if f == 0 and M >= num:
    ans = 1
    M -= num
    ans += M//(2*num)
    print(ans)
else:
    print(0)

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000


typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

struct edge{
	int from;
	int to;
	int nxt_edge;
};

const int N = 1e5+5;

int n, e;
struct edge edges[N];
int heads[N];
int dp[N];

int solve(int cur_edge_idx){
	if(cur_edge_idx == -1)
		return 0;
// 	cout << cur_edge_idx << endl;
	int & cur = dp[cur_edge_idx];
	if(~cur)
		return cur;
	cur  = solve(edges[cur_edge_idx].nxt_edge);
	if(edges[cur_edge_idx].to > 0)
	    cur = max(cur, 1 + solve(heads[edges[cur_edge_idx].to]));
	return cur;
}

int main()
{
    cin >> n >> e;
	clr(edges, 0);
	clr(heads, -1);
	clr(dp, -1);
    lp(i, e){
    	cin >> edges[i].from >> edges[i].to;
    	edges[i].nxt_edge = heads[edges[i].from];
    	heads[edges[i].from] = i;
    }
    int res = 0;
    lpi(i, 1, n+1)
    	res = max(res, solve(heads[i]));
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main(){
    int c1=0;
    int c2=0;
    string S;
    cin>>S;
    
    int n=(int)S.size();
    string ans1,ans2;
    for(int i=0;i<n;i++){
        if(i%2==0){
            if(S[i]=='0'){
                c1++;
            }
            else{
                c2++;
            } 
        }
        else{
            if(S[i]=='1'){
                c1++;
            }
            else{
                c2++;
            } 
        }
    }
    cout<<min(c1,c2);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <iomanip>
using namespace std;
const int M = 100000;
const double pi = 3.141592653589;

int main()
{
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int main(){
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    int multiCheck=0;
    if(x==w/2 && y==h/2){
        multiCheck=1;
    }
    cout << (double)(w*h)/2 << " "<< multiCheck;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;	//using vi = vector<int>;

#define rep(i, N) for (int i = 0; i < N; i++)

int main()
{
	int n,ans,temp;
	ans = 0;
	cin >> n;

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

	for (int i = 1; i <= n - 2; i++) {

		if (p[i - 1] == p[i] && p[i] == p[i + 1])break;
		
		if (p[i - 1] <= p[i]) {
			if (p[i] < p[i + 1]) ans++;
		}
		else if (p[i - 1] > p[i]) {
			if (p[i] >= p[i + 1]) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//define int int64_t
#define ll long long
map<int,int>M;
int pref[2*100*1000+4][22]={0};
int last_time[2*100*1000+3][22]={0};
signed main(){
    int n;cin>>n;
    ll ans=0;
    memset(pref,0,sizeof(pref));
    memset(last_time,0,sizeof(last_time));

    //for(int j=0;j<=20;++j)first_time[j]=n+1;
    for(int i=1;i<=n;++i){
        int va;cin>>va;
        int cnt=0;
        for(int j=0;j<20;++j){
            pref[i][j]=pref[i-1][j];
            if(((va>>j)&1)==1)pref[i][j]+=1;            
            if(last_time[pref[i][j]][j]==0)
              last_time[pref[i][j]][j]=i;
        }
        int first_valid_indx=1;
        for(int j=0;j<20;++j){
            //cout<<pref[i][]
            if(pref[i][j]<=1)continue;
            else{
  //              cout<<i<<" "<<j<<" "<<pref[i][j]<<endl;
    //            cout<<last_time[pref[i][j]-1][j]<<" ls"<<endl;
                first_valid_indx=max(first_valid_indx,1+last_time[pref[i][j]-1][j]);
            }
        }
//        cout<<i<<" "<<first_valid_indx<<" i,first_valid_indx\n";
        ans+=1LL*(i-(first_valid_indx)+1);
    }
    cout<<ans<<"\n";
    return 0;
}


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

using namespace std;
#define int long long
int n,a[100][100],f[24][2097200],base=1e9+7,pow_[30];
int F(int i,int ok)
{
    if(f[i][ok]!=-1) return f[i][ok];
    else if(i==n+1)
    {
        return 1;
    }
    else
    {
        int res=0;
        for(int j=1;j<=n;j++)
        {
            if(a[i][j]==1)
            {
                if((ok/pow_[j-1])%2==0) res=(res+F(i+1,ok+pow_[j-1]))%base;
            }
        }
        f[i][ok]=res;
        return res;
    }
}
main()
{
    cin>>n;
    pow_[0]=1;
    for(int i=1;i<=n+1;i++) pow_[i]=pow_[i-1]*2;
    memset(f,-1,sizeof(f));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++) cin>>a[i][j];
    }
    cout<<F(1,0);
}


Measured memory_bytes: 393600
#include <bits/stdc++.h> 
using namespace std; 
  
// Driver program to test methods of graph class 
int main() 
{
    string s;
    cin >> s;
    string answer = "Yes";
    for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0){
            //奇数
            if(s.at(i) == 'L'){
                answer = "No";
                break;
            }
        }else{
            if(s.at(i) == 'R'){
                answer =  "No";
                break;
            }
        }
    }
    
    cout << answer << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        n: usize,
        xs: [(u64, u64);n]
    }

    let mut xs_from: Vec<u64> = xs.iter().map(|v| v.0).collect();
    xs_from.sort();

    let mut xs_to: Vec<u64> = xs.iter().map(|v| v.1).collect();
    xs_to.sort();

    let ans = if n % 2 == 1 {
        med(&xs_to) - med(&xs_from) + 1.0
    } else {
        (med(&xs_to) - med(&xs_from)) * 2.0 + 1.0
    };

    println!("{}", ans as u64);
}

fn med(v: &Vec<u64>) -> f64 {
    let n = v.len();
    if n % 2 == 1 {
        v[n / 2] as f64
    } else {
        (v[n / 2] + v[n / 2 - 1]) as f64 / 2.0
    }
}


Measured memory_bytes: 12832
/*#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")*/
//#pragma GCC optimize("fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC optimize("unroll-loops")
//#define _CRT_SECURE_NO_WARNINGS
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef  long long  ll;
typedef unsigned long long  ull;
typedef pair<ll, ll> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(a.begin(), a.end(), x)
#define pb(x) push_back(x)
#define fr(i, n) for(int i = 0; i < n; ++i)
//typedef cc_hash_table<int, int, hash<int>> hst2;
//typedef cc_hash_table<int, hst2, hash<int>> hst;
typedef pii ord_set_t;
//typedef unordered_map<int, int> hst;
#ifdef ABCD
typedef set<ord_set_t> ordered_set;
typedef unordered_map<int, int> hst;
int __builtin_popcount(int x)
{
	int cnt = 0;
	for (; x > 0; x >>= 1) cnt += x & 1;
	return cnt;
}

#else
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
mt19937 rnd(239);
using namespace __gnu_pbds;
typedef tree<
	ord_set_t,
	null_type,
	less<ord_set_t>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
typedef cc_hash_table<int, int, hash<int>> hst;
#endif
typedef unsigned short int ui;
const int N = 300001;
vi g[N];
ll mod = 1000 * 1000 * 1000 + 7;
string str;
ll p = 31;
set<ll> st;
int num[N];
int par[N];
ll steps[N];
int dp[N][2];
bool check(int i, int l1);
int main()
{
	steps[0] = 1;
	fr(i, N - 1) steps[i + 1] = (steps[i] * p) % mod;
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else

#endif
	string s;
	string str =  "#"; cin >> s;
	str += s;
	int n = str.size() - 1;
	
	for (int i = 1; i <= n; ++i)
	{
		dp[i][0] = dp[i - 1][1] + 1;
		if (str[i] != str[i - 1]) 
			dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);

		if (i > 1)
		{
			dp[i][1] = dp[i - 2][0] + 1;
			if (i >= 3 && !(str[i] == str[i - 2] && str[i - 1] == str[i - 3]))
				dp[i][1] = max(dp[i][1], dp[i - 2][1] + 1);
		}
	}
	cout << max(dp[n][0], dp[n][1]);
}

Measured memory_bytes: 14356
import sys

n, m, x, y = map(int, input().split())
x_list = list(map(int, input().split()))
y_list = list(map(int, input().split()))

for z in range(x + 1, y + 1):
    if max(x_list) < z:
        if min(y_list) >= z:
            print("No War")
            sys.exit(0)

print("War")

Measured memory_bytes: 3060
import itertools

H, W, K = map(int, input().split())
mod = 10**9+7
patterns = []
for p in itertools.product([0, 1], repeat=W-1):
    valid = True
    for i in range(W-2):
        if p[i] == p[i+1] == 1:
            valid = False
            break
    if valid:
        patterns += [p]

dp = [[0]*(W+1) for _ in range(H+1)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        for pattern in patterns:
            if j > 0 and pattern[j-1] == 1:
                dp[i+1][j-1] += dp[i][j]
                dp[i+1][j-1] %= mod
            elif j < W-1 and pattern[j] == 1:
                dp[i+1][j+1] += dp[i][j]
                dp[i+1][j+1] %= mod
            else:
                dp[i+1][j] += dp[i][j]
                dp[i+1][j] %= mod
print(dp[H][K-1])

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

#include <atcoder/mincostflow>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using namespace atcoder;

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

    vector mat(n, vector<bool>(m));
    vector<pair<int64_t, int64_t>> idxs;
    for (auto i : irange(0L, n)) {
        string s;
        cin >> s;
        for (auto j : irange(0L, m)) {
            if (s[j] == '#') {
                continue;
            }

            mat[i][j] = true;
            if (s[j] == 'o') {
                idxs.emplace_back(i, j);
            }
        }
    }

    mcf_graph<int64_t, int64_t> g(n * m + 2);
    int64_t src = n * m, dst = n * m + 1;

    auto IDX = [&](int64_t i, int64_t j) { return i * m + j; };

    for (auto [i, j] : idxs) {
        g.add_edge(src, IDX(i, j), 1, i + j);
    }

    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, m)) {
            if (mat[i][j]) {
                g.add_edge(IDX(i, j), dst, 1, n + m - i - j);
            }
        }
    }

    for (auto i : irange(0L, n - 1)) {
        for (auto j : irange(0L, m)) {
            if (mat[i][j] && mat[i + 1][j]) {
                g.add_edge(IDX(i, j), IDX(i + 1, j), idxs.size(), 0);
            }
        }
    }

    for (auto i : irange(0L, n)) {
        for (auto j : irange(0L, m - 1)) {
            if (mat[i][j] && mat[i][j + 1]) {
                g.add_edge(IDX(i, j), IDX(i, j + 1), idxs.size(), 0);
            }
        }
    }

    auto [f, c] = g.flow(src, dst, idxs.size());

    assert(f == idxs.size());

    // for (const auto& edge : g.edges()) {
    //     cerr << edge.from << "=>" << edge.to << ", cap=" << edge.cap
    //          << ", cost=" << edge.cost << ", flow=" << edge.flow << endl;
    // }

    cout << -c + (n + m) * idxs.size() << endl;
}

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

typedef long long ll;

int main() {
    ll n;
    ll m = 0;
    ll total = 0;
    cin >> n;
    vector<ll>a(n+1);
    vector<ll>b(n+1, 0);
    vector<ll>ans;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    for (int i = n; i >= 1; i--) {
        if (a[i] == 1) {
            total = 0;
            for (int j = 1; i*j <= n; j++) {
                total += b[i*j]; 
            }
            if (total % 2 == 0) {
                b[i]++;
                ans.push_back(i);
                m++;
            }
        } else {
            total = 0;
            for (int j = 1; i*j <= n; j++) {
                total += b[i*j]; 
            }
            if (total % 2 == 1) {
                b[i]++;
                ans.push_back(i);
                m++;
            }
        }
    }
    if (ans.size() == 0) {
        cout << 0 << endl;
    } else {
        cout << m << endl;
        for (int i = 0; i < ans.size(); i++) {
            cout << ans[i] << endl;
        }
    }
}


Measured memory_bytes: 4980