akhauriyash/Code-Regression huggingface dataset:
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

const MOD: usize = 1000000007;
fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let n: usize = parse!(it);
    // a: 0, c: 1, g: 2, t: 3
    let mut dp = vec![vec![vec![0; 4]; 4]; 4];
    for i in 0..4 {
        for j in 0..4 {
            for k in 0..4 {
                match (i, j, k) {
                    (0, 2, 1) | (2, 0, 1) | (0, 1, 2) => (),
                    (i, j, k) => dp[i][j][k] = 1,
                }
            }
        }
    }

    for i in 3..n {
        let mut buf = vec![vec![vec![0; 4]; 4]; 4];
        for j in 0..4 {
            for k in 0..4 {
                for l in 0..4 {
                    for m in 0..4 {
                        match (j, k, l, m) {
                            (_, 0, 2, 1) | (_, 0, 1, 2) | (_, 2, 0, 1) => buf[k][l][m] = 0,
                            (0, _, 2, 1) | (0, 2, _, 1) => (),
                            (i, j, k, l) => {
                                buf[j][k][l] += dp[i][j][k];
                                buf[j][k][l] %= MOD
                            }
                        }
                    }
                }
            }
        }
        dp = buf;
    }
    let mut ret = 0;
    for i in 0..4 {
        for j in 0..4 {
            for k in 0..4 {
                ret += dp[i][j][k];
                ret %= MOD;
            }
        }
    }
    println!("{}", ret);
}

fn test() {
    let mut f = fs::File::open("foo.txt").unwrap();
    let mut s = String::new();
    f.read_to_string(&mut s).unwrap();
    solve(&s);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    // #[test]
    // fn test_main() {
    //     test();
    // }
    #[test]
    fn test_input() {
        let s = "
100
        ";
        solve(s);
    }
}


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int x;
    cin >> x;
    cout << (1-x) << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+50;
int n,k;
ll dp(ll s){
  return s*(s-1)*(s-2)+3*s*(s-1)+s;
}
int main(){
  cin>>n>>k;
  if (k&1)
    cout<<dp(n/k);
  else
    cout<<dp(n/k)+dp(n/(k/2)-n/k);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
typedef pair<ll,ll>pll;
const  ll MAX=100000000;
int main()
{

    ll a,b,c;

    cin>>a>>b>>c;


    ll ans=a/b;

    if(a%b)ans++;

    if(ans<=c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}








Measured memory_bytes: 3616
fun main(args: Array<String>) {
    val N = nextInt()
    val A = next().map { it - '0' - 1 }
    if (A.all { it == A[0] }) return println(0)
    fun solve(a: List<Int>): Int {
        var two = 0
        var res = 0
        val n = a.size - 1
        a.forEachIndexed { i, v ->
            if (two == 0) res = res xor v
            two += Integer.numberOfTrailingZeros(n - i) - Integer.numberOfTrailingZeros(i + 1)
        }
        return res
    }
    val ans = if (A.contains(1)) solve(A.map { it % 2 }) else solve(A.map { it / 2 }) * 2
    println(ans)
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())


Measured memory_bytes: 43880
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template <typename T>
void tk_input(vector<T> &arr){
    for(T &i: arr)
        cin>>i;
}

//1.Check for overflows and don't panic
//
//2.If you cannot think of a solution, try 
//  to think from backwards
void solve()
{
    int n;
    cin>>n;
    n = (n + 1) % 2;
    cout<<n<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
       //freopen("Debug.txt", "w", stderr);
    #else
    #endif
        solve();
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    int N, L;
    scanf("%d %d", &N, &L);
    vector<string> S(N);
    REP(i, N){
        cin >> S[i];
    }
    sort(S.begin(), S.end());
    REP(i, N){
        cout << S[i];
    }
    cout << endl;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int r;cin >> r;
  cout << 3*r*r << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int num(){
    char s[11];
    int i, n;
    for(i=0; i<sizeof(s); i++){
        s[i] = getchar();
        if(s[i] == ' ' || s[i] == '\n'){
            s[i] = '\0';
            break;
        }
    }
    sscanf(s, "%d", &n);
    return n;
}
int main(void){
    int a, b;
    int i, n, cou=0, c, d, e, f;
    a = num();
    b = num();
    
    n = b-a+1;
    
    for(i=0; i<n; i++){
        c = a/10000;
        d = a/1000%10;
        e = a%100/10;
        f = a%10;
        if(c == f && d == e){
            cou++;
        }
        a++;
        c=0, d=0, e=0, f=0;
    }
    printf("%d\n", cou);
    
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
    int temp;
    if(a<b){
        temp=b;
        b=a;
        a=temp;
    }
    while(1){
        temp=a%b;
        if(temp==0){
            printf("%d\n",b);
            return 0;
        }
        a=b;
        b=temp;
    }
    return 0;
}



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

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

	if(x > y)	cout << "a > b" << endl;
	else if(x < y)	cout << "a < b" << endl;
	else			cout << "a == b" << endl;
	 
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
class UnionFind {
	vector<int>par, sz;
public:
	UnionFind(int n) {
		par = sz = vector<int>(n);
		for (int i = 0; i < n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (sz[x] > sz[y]) {
			par[y] = x;
			sz[x] += sz[y];
		}
		else {
			par[x] = y;
			sz[y] += sz[x];
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
	int size(int x) {
		return sz[find(x)];
	}
};
string a[5000];
int x[5000];
int Min[5000],cnt[5000];
int main(){
	int n;scanf("%d",&n);
	map<string,int>mp;
	rep(i,n){
		cin>>a[i]>>x[i];
		int b=mp.size();
		mp[a[i]]=b;
	}
	int m;scanf("%d",&m);
	UnionFind uf(n);
	rep(i,m){
		string s,t;cin>>s>>t;
		uf.unite(mp[s],mp[t]);
	}
	memset(Min,0x3f,sizeof(Min));
	rep(i,n){
		Min[uf.find(i)]=min(Min[uf.find(i)],x[i]);
		cnt[uf.find(i)]++;
	}
	int ans=0;
	rep(i,n)ans+=Min[i]*cnt[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 4012
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++){
    cout << 'x';
  }
  cout << '\n';
  
  return 0;
}

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

int main() {
  int X, Y;
  cin >> X >> Y;
  rep(i, X+1){
    if(i*2+(X-i)*4==Y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define F           first
#define S           second
#define mp(x,y)     make_pair(x,y) 
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)


const ll N   =  500005;
const ll mod = 1e9 + 7;

using namespace std;


void solve()
{
ll a,b,k,c=0;
cin>>a>>b>>k;
for (int i = 100; i >=1 ; --i)
{
  if(a%i==0 and b%i==0)
    c++;
  if(c==k)
  {
    c(i);
    return;
  }
}
}

signed main(){

      ios_base::sync_with_stdio(false);   
      cin.tie(NULL);
      ll T=1;
      //cin>>T;
      while(T--)
      {
      solve();
      }
      return 0;
    }


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

struct edge {
	int to, nn;
	edge(int x=0, int y=0):to(x), nn(y) {}
};



//head

int n;
vector<edge> G[50];
int m;
bitset<49> uv[20];
ll meb[1<<20];

bool dfs(int i, int j, int nn, int v) {
	if(i == v) {
		return true;
	}
	for(edge &e:G[i]) {
		if(e.to == v) {
			uv[nn].set(e.nn);
			return true;
		}
		if(e.to == j) continue;
		if(dfs(e.to, i, nn, v)) {
			uv[nn].set(e.nn);
			return true;
		}
	}
	return false;
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	rep(i, n-1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].emplace_back(b, i);
		G[b].emplace_back(a, i);
	}
	cin >> m;
	rep(i, m) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		dfs(u, -1, i, v);
	}

	rep(i, 1<<m) {
		bitset<49> now(0);
		rep(j, m) if(i>>j&1) {
			now |= uv[j];
		}
		int cnt = 0;
		rep(i, n-1) if(!now.test(i)) cnt++;
		meb[i] = 1LL<<cnt;
	}
	meb[0] = 0;
	rep(i, m) rep(j, 1<<m) {
		if(j>>i&1) meb[j] -= meb[j^(1<<i)];
	}

	const int X = (1<<m)-1;

	cout << (1LL<<(n-1)) - abs(meb[X]) << endl;
}

Measured memory_bytes: 11808
//----AUTHOR:kkdrummer----/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef    long long   ll;
typedef    long double   ld;
//typedef    unordered_set<ll>   usll;
//typedef    unordered_multiset<ll>   umsll;
typedef    multiset<ll>   msll;
typedef    set<ll>   sll;
typedef    vector<ll>   vll;
typedef    pair<ll,ll>   pll;
typedef    vector<pll>   vpll;
typedef    priority_queue<ll>   pqll;
typedef    vector<int>   vi;
typedef    set<int>   si;
typedef    multiset<int>   msi;
//typedef    unordered_multiset<int>   umsi;
//typedef    unordered_set<int>   usi;
typedef     pair<int,int>   pi;
typedef    vector<pi>   vpi;
typedef    set<pi>   spi;
typedef    priority_queue<int>   pqi;
typedef    tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>   ind_set;
typedef    tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>   ind_setll;
#define    in   insert
#define    fi   first
#define    se   second
#define    pb   push_back
#define    mp   make_pair
#define    be   begin
#define    en   end
#define    itr   iterator
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define    mo   1000000007
#define    inf  9223372036854775807
#define    ninf   -inf
#define    ima   2147483647
#define    imi   -ima
#define    oncnt    __builtin_popcount
#define    zerobegin   __builtin_clz
#define    zeroend   __builtin_ctz
#define    parity   __builtin_parity
#define    all(x)   x.be(),x.en()
#define    eps   1e-9
#define    coutd   cout<<setprecision(10)<<fixed
#define    mems(dp,x)   memset(dp,x,sizeof(dp))
const    ld   PI=3.1415926535897932384626433832792884197169399375105820974944;
inline ll modpow(ll x,ll n){if(n==0)return 1;if(n==1)return(x%mo);ll u=(modpow(x,n/2));u=(u*u)%mo;if(n%2!=0)u=(u*x%mo)%mo;return u;}
inline ll modinv(ll x){return modpow(x,mo-2);}
inline ll mmul(ll a,ll b){    if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll madd(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;if(a+b>=mo)return(a+b)%mo;return(a+b);}
inline ll msub(ll a, ll b){if(a>=mo)a=a%mo;if(b>=mo)b=b%mo;return(((a-b)%mo+mo)%mo);}
inline ll mdiv(ll a,ll bb){if(a>=mo)a=a%mo;ll b=modinv(bb);if(b>=mo)b=b%mo;if(a*b>=mo)return(a*b)%mo;return(a*b);}
inline ll gcd(ll a,ll b){return __gcd(a,b);}

int main()
{
io
int testcases=1;//cin>>testcases;
while(testcases--)
{










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

si s;
for(int i=0;i<k;i++)
{
	int h;
	cin>>h;
	for(int j=0;j<h;j++)
	{
		int x;
		cin>>x;
		s.insert(x);
	}
}

cout<<n-s.size();



}return 0;}


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

int main(void) {
	// your code goes here
	int n,k,a[100001],i,v;
	cin >> n >> k;
	for(i=1;i<=n;i++) cin >> a[i];
	if((n-1)%(k-1)==0) v=(n-1)/(k-1);
	else v=(n-1)/(k-1)+1;
	cout << v << endl;
	return 0;
}


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

int main (){
  int N;
  cin >> N;
  
  int n1, n10, n100, n1000;
  n1 = N % 10;
  n10 = (N % 100) /10;
  n100 = (N % 1000) /100;
  n1000 = N / 1000;
  
  if (n1 == n10 && n10 == n100) {
    cout << "Yes" << endl;
  }
  else if (n10 == n100 && n100 == n1000) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


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

int main(){
	int n,ix;
	cin>>n;
	int a[n];
	for (int i=0;i<n;i++)
		cin>>a[i];
	long long int dp[n][n][2];
	for (int i=0;i<n;i++){
		dp[i][i][0] = a[i];
		dp[i][i][1] = -a[i];
	}
	for (int i=1;i<n;i++){
		for (int j=i;j<n;j++){
			ix = j-i;
			dp[ix][j][0] = max(dp[ix+1][j][1]+a[ix], dp[ix][j-1][1]+a[j]);
			dp[ix][j][1] = min(dp[ix+1][j][0]-a[ix], dp[ix][j-1][0]-a[j]);
		}
	}
	cout<<dp[0][n-1][0];
}

Measured memory_bytes: 140800
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<double> p;

    for (int i = 0; i < n; i++) {
        double temp;
        cin >> temp;
        p.push_back(temp);
    }

    vector<double> q;

    for (int i = 0; i < n; i++) {
        double temp = (p[i] + 1) / 2;
        q.push_back(temp);
    }

    double max = 0;
    double memo = 0;

    for (int i = 0; i < k; i++) {
        memo += q[i];
    }

    max = memo;

    for (int i = 1; i < n - k + 1; i++) {
        memo = memo - q[i - 1] + q[i + k - 1];
        if (memo > max) {
            max = memo;
        }
    }
    cout << fixed << setprecision(13) << max << endl;
    return 0;
}


Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    string s;cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C'){
            for(;i<s.size();i++){
                if(s[i]=='F'){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
}


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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 1e5 + 5;

int n;
vi conn[N];

int dfs(int v) {
    if (!sz(conn[v])) {
        // cout << v << ' ' << 0 << endl;
        return 0;
    }
    int mn = 0;
    vi depths;
    for (auto& u : conn[v]) {
        depths.push_back(dfs(u));
    }
    sort(all(depths), greater<int>());
    rep(i, 0, sz(depths)) {
        mn = max(mn, i + 1 + depths[i]);
    }

    return mn;
}

int main() {
	cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    rep(i, 0, n - 1) {
        int a;
        cin >> a;
        conn[a].push_back(i + 2);
    }

    cout << dfs(1);
}


Measured memory_bytes: 16848
from itertools import product

import numpy as np


H, W, K = map(int, input().split())
field = np.array([[int(c == "#") for c in input()] for _ in range(H)])

ans = 0
for hs in product([0, 1], repeat=H):
    for ws in product([0, 1], repeat=W):
        test_field = field.copy()
        for i, h in enumerate(hs):
            if h == 1:
                test_field[i] = 0
        for j, w in enumerate(ws):
            if w == 1:
                test_field[:, j] = 0
        if test_field.sum() == K:
            ans += 1
print(ans)



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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    string S;
    cin >> S;
    int n = S.length() - 2;
    cout << S[0] << n << S[S.length() - 1] << endl;
    return 0;
}

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

int main() {
    int k;
    cin >> k;
    set<int> st; 
    st.insert(7);
    int curr = 7;
    int count = 0; 
    while(true) {
      count++;
      if(curr % k == 0) {
        cout << count;
        return 0;
      }
      curr = (10*curr + 7)%k;
      if(st.find(curr) != st.end()) {
        cout << -1; 
        return 0;
      }
      st.insert(curr);
    }
	return 0;
}

Measured memory_bytes: 50476
//be naame khodaa

#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <sstream>
#define fi first
#define se second
#define rep(i, x, n) for (int i = x; i < n; i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> VI;

const int maxn = 2005;

int a[maxn], X[maxn], Y[maxn], xMin[maxn], yMax[maxn];

int main()
{
	ios::sync_with_stdio(false);
	int n, z, w;
	cin >> n >> z >> w;
	for (int i = 0; i < n; i++)
		cin >> a[i+1];
	a[0] = w;
	yMax[0] = 0, xMin[0] = 1e9;
	for (int i = 1; i <= n; i++){
		X[i] = max (abs(a[n] - a[n-i]), yMax[i-1]);
		Y[i] = min (abs(a[n] - a[n-i]), xMin[i-1]);
		yMax[i] = max (yMax[i-1], Y[i]);
		xMin[i] = min (xMin[i-1], X[i]);
	}
	cout << X[n] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	char buf[101],result[500],type;
	int p,i;

	while(true){
		scanf("%s %c",buf,&type);
		if(type == 'X')break;

		p = 0;
		switch(type){
		case 'U':
			for(i = 0;buf[i] != '\0';){
				if(i == 0){
					if(buf[i] >= 97 && buf[i] <= 122){
						result[p++] = buf[i] - 32;
					}else{
						result[p++] = buf[i];
					}
					i++;
				}else if(buf[i] == '_'){
					i++;
					if(buf[i] >= 97 && buf[i] <= 122){
						result[p++] = buf[i] - 32;
					}else{
						result[p++] = buf[i];
					}
					i++;
				}else{
					if(buf[i] >= 65 && buf[i] <= 90){
						result[p++] = buf[i];
					}else{
						result[p++] = buf[i];
					}
					i++;
				}
			}
			result[p] = '\0';

			printf("%s\n",result);
			break;
		case 'L':
			for(i = 0;buf[i] != '\0';){
				if(i == 0){
					if(buf[i] >= 65 && buf[i] <= 90){
						result[p++] = buf[i] + 32;
					}else{
						result[p++] = buf[i];
					}
					i++;
				}else if(buf[i] == '_'){
					i++;
					if(buf[i] >= 97 && buf[i] <= 122){
						result[p++] = buf[i] - 32;
					}else{
						result[p++] = buf[i];
					}
					i++;
				}else{
					if(buf[i] >= 65 && buf[i] <= 90){
						result[p++] = buf[i];
					}else{
						result[p++] = buf[i];
					}
					i++;
				}
			}
			result[p] = '\0';

			printf("%s\n",result);
			break;
		case 'D':
			for(i = 0;buf[i] != '\0';){
				if(i == 0){
					if(buf[i] >= 65 && buf[i] <= 90){
						result[p++] = buf[i] + 32;
					}else{
						result[p++] = buf[i];
					}
					i++;
				}else if(buf[i] == '_'){
					result[p++] = buf[i];
					i++;
				}else{
					if(buf[i] >= 65 && buf[i] <= 90){
						result[p++] = '_';
						result[p++] = buf[i] + 32;
					}else{
						result[p++] = buf[i];
					}
					i++;
				}
			}
			result[p] = '\0';


			printf("%s\n",result);
			break;
		}
	}
    return 0;
}

Measured memory_bytes: 2544
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define N 10
#define L 1000

int main(){
  char str_in[N];
  char str_doc[L][L];
  char str_vir[L][L];
  int i,j;
  int n=0,m=0;
  int count=0;
  int number=0;
  
  scanf("%s",str_in);
  
  for(i=0;str_in[i]!='\0';i++){
    str_in[i]=tolower(str_in[i]);
  }
  str_in[i]='\0';
  
  for(i=0;i<L;i++){
    scanf("%s",str_doc[i]);
    if(strcmp(str_doc[i],"END_OF_TEXT")==0)break;
    count++;
  }
  
  for(i=0;i<count;i++){
    for(j=0;str_doc[i][j]!='\0';j++){
      str_doc[i][j]=tolower(str_doc[i][j]);
    }
    str_doc[i][j]='\0';
    }

  
  for(i=0;i<count;i++){
    for(j=0;str_doc[i][j]!='\0';j++){
      if(str_doc[i][j]=='"'){
	str_doc[i][j]=' ';
      }
    }
  }
  
  for(i=0;i<count;i++){
    for(j=0;str_doc[i][j]!='\0';j++){
      if(str_doc[i][j]==' '){
	str_vir[n][m]='\0';
	n++;
      }else{
	str_vir[n][m]=str_doc[i][j];
	m++;
      }
    }
    str_vir[n][m]='\0';
    n++;
    m=0;
  }
  
  for(i=0;i<n;i++){
    if(strcmp(str_in,str_vir[i])==0){
	number++;  
    }
  }
  
  
  printf("%d\n",number);
  return 0;
}

Measured memory_bytes: 908
#include<iostream>

using namespace std;

int main()
{
    int a, b, c, d;
    int cnt1, cnt2;
    while(cin >> a >> b >> c >> d) {
        if(a%d)
            cnt1 = a/d+1;
        else
            cnt1 = a/d;
        if(c%b)
            cnt2 = c/b+1;
        else
            cnt2 = c/b;
        if(cnt1 >= cnt2)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
  string s,t;
  cin >> s >> t;
  int cnt = 0;
  for (int i = 0; i < 3; i++){
    if (s[i] == t[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <utility>
#include <numeric>
#include <map>
#include <iomanip>
#include <queue>
using namespace std;

const long long INF = 1LL << 40;

int main(){
	long long N, K; cin >> N >> K;

	vector<vector<long long>> vv(N);
	for(int i = 0; i < N; i++){
		long long t, d; cin >> t >> d; t--;
		vv[t].push_back(d);
	}

	for(int i = 0; i < N; i++){
		sort(vv[i].begin(), vv[i].end(), greater<long long>());
		if(vv[i].empty()) vv[i].push_back(-INF);
	}
  
  	sort(vv.begin(), vv.end(), [&](vector<long long> a, vector<long long> b) {return a[0] > b[0];});

	long long cur = 0;
	priority_queue<long long> que;

	for(int i = 0; i < K; i++){
		cur += vv[i][0];
		for(int j = 1; j < vv[i].size(); j++){
			que.push(vv[i][j]);
		}
	}
	for(int i = K; i < N; i++){
		for(int j = 0; j < vv[i].size(); j++){
			que.push(vv[i][j]);
		}
	}

	long long res = cur + K*K;
	for(long long x = K - 1; x >= 1; x--){
		long long v = vv[x][0];
		long long w = que.top();
		if(v < w){
			que.pop(); cur += w;
			que.push(v); cur -= v;
		}
		res = max(res, cur + x*x);
	}

	cout << res << endl;
    
}

Measured memory_bytes: 8696
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
int main()
{
    int a,b,c,k,ans=0;
    in a>>b>>c>>k;
    for(int i=0;i<k;i++)
    {
        if(a>0)
        {
            ans+=1;
            a--;
        }
        else if(b>0)
        {
            ans+=0;
            b--;
        }
        else
        {
            ans+=-1;
            c--;
        }
    }

    cout<<ans<<endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> box(n);
  for(int i=0; i<n; ++i){
    cin >> box.at(i);
  }
  int ansnum = 0;
  vector<bool> ans(n, false);
  stack<int> st;
  for(int i=n-1; i>=0; --i){
    int x = (i+1) *2;
    int eo = 0;
    while(x<=n){
      if(ans[x-1]) ++eo;
      x += i+1;
    }
    eo %= 2;
    if(box[i] != eo){
      ans[i] = true;
      ++ansnum;
      st.push(i+1);
    }
  }
  cout << ansnum << endl;
  while(!st.empty()){
    cout << st.top() << " ";
    st.pop();
  }
  cout << endl;
}

Measured memory_bytes: 2304
#include<stdio.h>
int main(){
int a[101],b,c=0,i,j,d;
scanf("%d\n",&b);
for(i=0;i<b;i++){
scanf("%d",&a[i]);
}
for(i=0;i<b;i++){
for(j=b-1;j>i;j--){
if(a[j-1]>a[j]){
c++;
d=a[j];
a[j]=a[j-1];
a[j-1]=d;
}
}
}
for(i=0;i<b;i++){
if(i==b-1){
printf("%d",a[i]);
}
else{
printf("%d ",a[i]);
}
}
printf("\n");
printf("%d\n",c);
return 0;
}


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

int main() {
    ll N, K;
    cin >> N >> K;
    ll sum = 0;
    for (ll i = K; i <= N + 1; i++) {
        sum += (N - i + 1) * i + 1;
        sum %= 1000000007LL;
    }
    cout << sum << endl;
    return 0;
}


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

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<int> a(3*n, 0);
  rep(i, 3*n){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll ans = 0;
  for(int i=n; i < n*3; i+=2){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using vc=vector<char>;
using vvc=vector<vc>;
using pii = pair<int,int>;
using pil = pair<int,ll>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpil = vector<pil>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  ll ans=-N+1;
  rep2(k,1,N) ans+=ceil((double)N/k);
  
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int A, B, C, X, Y, result;

int main()
{
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
    if(A + B <= 2 * C)
    {
        result = A * X + B * Y;
    }
    else
    {
        result = max(X, Y) * 2 * C;
        if(X > Y)
        {
            result = min(result, Y * 2 * C + (X - Y) * A);
        }
        else
        {
            result = min(result, X * 2 * C + (Y - X) * B);
        }
    }
    printf("%d", result);
}

Measured memory_bytes: 256
#! -*- coding:utf-8 -*-
import sys
# import time
for line in sys.stdin:
  n=int(line)
  # n=input()
  # start = time.time()
  #plist = [1 for i in xrange(n+1)]
  #??¨??¨1???????????????
  #1?????¨???????????????????´???°??¨??????
  plist = [1]*(n+1)
  #0??¨1????´???°?????????????????§0???????????????
  plist[0]=plist[1]=0
  i=2
  #??¶??°????????????????????????
  while True:
      pos0 = 2*i
      if pos0 < len(plist):
          plist[pos0] = 0
      else:
          break
      i+=1
  #???????????¨????????????????????????
  for x in xrange(3,int(n**0.5)+1):
    if plist[x]:
      for pos0 in xrange(x**2,n+1,x):
        plist[pos0] = 0
  # elapsed_time = time.time()-start
  # print elapsed_time
  print plist.count(1)

Measured memory_bytes: 22868
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1000000010
#define EPS 1e-9
#define F first
#define S second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"

typedef pair<int,int> PII;
typedef pair<int,string> PIS;
typedef pair<string,int> PSI;


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans=-1000000000000000010;
  ans=max(ans,a*c);
   ans=max(ans,a*d);
    ans=max(ans,b*c);
     ans=max(ans,b*d);
     cout<<ans<<endl;


  return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;
void insert(int);

void inorder (Node);
void preorder (Node);


int main(){

  int n,num,i;
  char command[10];

  scanf("%d",&n);

  root = NULL;
  for(i = 0 ; i < n ; i++){

    scanf("%s",command);

    if(command[0] == 'i'){//insert
      scanf("%d",&num);
      insert(num);
    }

    else if(command[0] == 'p'){//print
      inorder(root);
      printf("\n");

      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


void insert( int z){

  Node y = NULL;
  Node x = root;
  Node k;

  k = malloc(sizeof(struct node));

  k -> key = z;
  k -> left = NULL;
  k -> right = NULL;


  while(x != NULL){
    y = x;
    if(k -> key < x->key){
      x = x->left;
    }
    else {
      x = x->right;
    }
  }
    k->parent = y;
    if(y == NULL)root = k;
    else if(k->key < y->key)y->left = k;
    else y->right = k;
}


void inorder (Node o){
  if(o->left != NULL)inorder(o->left);
  printf(" %d",o->key);

  if(o->right != NULL)inorder(o->right);
}




void preorder(Node o){
  printf(" %d",o->key);

  if(o->left != NULL)preorder(o->left);
  if(o->right != NULL)preorder(o->right);
}

Measured memory_bytes: 24040
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int mypow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x;
		}
		x = x * x;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
int mystoi(string x) {
	int res = 0;
	rep(i, x.size()) {
		res = res * 10 + x[i] - '0';
	}
	return res;
}
/*--------Library Zone!--------*/

int x, y, z, k;
int a[1005], b[1005], c[1005];
signed main() {
	cin >> x >> y >> z >> k;
	rep(i, x)cin >> a[i];
	rep(i, y)cin >> b[i];
	vector<int>vec;
	rep(i, x) {
		rep(j, y) {
			vec.push_back(a[i] + b[j]);
		}
	}
	sort(all(vec)); reverse(all(vec));
	vector<int>ans;
	rep(i, z) {
		cin >> c[i];
		rep(j, min((int)vec.size(), k)) {
			ans.push_back(vec[j] + c[i]);
		}
	}
	sort(all(ans)); reverse(all(ans));
	rep(i, k) {
		cout << ans[i] << endl;
	}
}

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

int main(){
	bool x[1000000];
	int cou, num;
	
	while(cin >>num){
		cou = 0;
		for(int i = 2; i <= num; i++){
			x[i] = true;
		}
		for(int i = 2; i <= sqrt(num); i++){
			if(x[i]){
				for(int j = (i * 2); j <= num; j += i){
					x[j] = false;
				}
			}
		}
		
		for(int i = 0; i <= num; i++){
			if(x[i]){
				cou++;
			}
		}
		
		cout <<cou<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N = I()
a = LI()
ans = 0
num_count = [0]*(10**5+2)
for x in a:
    num_count[x-1] += 1
    num_count[x] += 1
    num_count[x+1] += 1
print(max(num_count))


Measured memory_bytes: 14300
package main

import (
	"fmt"
)


func main() {
	var s string
	fmt.Scanf("%s", &s)

	if s == "RRR" {fmt.Println(3)}
	if s == "SRR" {fmt.Println(2)}
	if s == "RSR" {fmt.Println(1)}
	if s == "RRS" {fmt.Println(2)}
	if s == "SSR" {fmt.Println(1)}
	if s == "RSS" {fmt.Println(1)}
	if s == "SRS" {fmt.Println(1)}
	if s == "SSS" {fmt.Println(0)}

}


Measured memory_bytes: 1832
import sys
import collections

sys.setrecursionlimit(10**6)
input = sys.stdin.readline
#read = sys.stdin.buffer.read

N = 2100000
MAX_NUM = N + 1
MOD = pow(10, 9) + 7

fac  = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv  = [0 for _ in range(MAX_NUM)]

fac[0]  = fac[1] = 1
finv[0] = finv[1] = 1
inv[1] = 1

for i in range(2,MAX_NUM):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def combinations(n,k):
    global fac, finv
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

def main():
    K = int(input())
    S = input()[:-1]
    lenS = len(S)
    ans = 0
    for i in range(lenS, lenS+K+1):
        k = min(i-lenS, lenS-1)
        ans += (((combinations(i-1, k)*pow(25, i-lenS, MOD))%MOD)*pow(26, lenS+K-i, MOD))%MOD
        ans %= MOD

    print(ans)


if __name__ == "__main__":
    main()


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9 + 7);

ll mod_pow(ll a, ll b, ll p) {
  ll res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b >>= 1;
  }
  return res;
}


const int SZ = 312345;
ll inv[SZ];
ll fact[SZ];
ll fact_inv[SZ];
ll choose(int n, int r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

ll f(int win, int lose, int A, int B) {
  ll pA = A * inv[A+B] % MOD;
  ll pB = B * inv[A+B] % MOD;
  ll ans = choose(win + lose - 1, lose);
  (ans *= mod_pow(pA, win, MOD)) %= MOD;
  (ans *= mod_pow(pB, lose, MOD)) %= MOD;
  (ans *= (win + lose)) %= MOD;
  return ans;
}

int main2() {
  int N = nextInt();
  int A = nextInt();
  int B = nextInt();
  int C = nextInt();

  ll ans = 0;

  for (int i = 0; i < N; i++) {
    ans += f(N, i, A, B);
    ans += f(N, i, B, A);
  }
  ans %= MOD;

  ll m = (A+B+C) * inv[A+B] % MOD;
  ans = (ans * m) % MOD;
  cout << ans << endl;
  return 0;
}

int main() {

  inv[1] = 1;
  for (int i = 2; i < SZ; i++) inv[i] = inv[(int) (MOD % i)] * (MOD - MOD / i) % MOD;
  fact[0] = 1;
  for (int i = 1; i < SZ; i++) fact[i] = fact[i-1] * i % MOD;
  fact_inv[0] = 1;
  for (int i = 1; i < SZ; i++) fact_inv[i] = fact_inv[i-1] * inv[i] % MOD;


#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main(){
  int r,D,x2000;
  cin >> r >> D >> x2000;
  vector<int> value(11);
  value.at(0) = x2000;
  for(int i = 0;i<10;i++){
    value.at(i+1) = r * value.at(i) - D;
  }
  for(int i = 0;i<10;i++){
    cout << value.at(i+1) << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (n); i++)
int main()
{
  vector<int> vec(5);
  int sum = 0;
  rep(i, 5)
  {
    int num;
    cin >> num;
    sum += num;
  }
  cout << 15 - sum << endl;
  return 0;
}

Measured memory_bytes: 3540
#include<bits/stdc++.h>
using namespace std;
priority_queue < int >q;
const int maxn = 1e5 + 10;
int a[maxn];
int main()
{
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		int x;
		scanf("%d", &x);
		q.push(x);
	}
	while(m--){
		int x = q.top();
		q.pop();
		q.push(x / 2);
	}
	long long ans = 0;
	while(q.size()){
		ans += q.top();
		q.pop();
	}
	cout << ans<<endl;
	return 0;
}

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

const int maxn = 2e5+5;
int n, a[maxn];
ll sum[maxn], xo[maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        sum[i] = a[i];
        xo[i] = a[i];
    }
    for (int i = 1; i <= n; i++) {
        sum[i] += sum[i-1];
        xo[i] ^= xo[i-1];
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int lo = i, hi = n+1;
        while (lo + 1 < hi) {
            int mid = (lo+hi)>>1;
            if ((sum[mid]-sum[i-1]) == (xo[mid]^xo[i-1])) {
                lo = mid;
            }
            else hi = mid;
        }
        ans += (lo-i+1);
    }
    cout << ans << '\n';
}



Measured memory_bytes: 4224
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
using namespace std;

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

long long int DP[1001][1001] = {};

int n;
int s[200], t[200];
bool visited[200] = {};

int dfs(int u, int d){
	if(visited[u]){
		return d - 1;
	}
	visited[u] = true;
	s[u] = d;
	for(int i = 0; i < n; i++){
		if(DP[u][i]){
			d = dfs(i, d + 1);
		}
	}
	t[u] = d + 1;
	return d + 1;
}

int main(){
	
	cin >> n;
	
	for(int loop = 0; loop < n; loop++){
		
		int id, k;
		cin >> id >> k;
		id--;
		
		for(int i = 0; i < k; i++){
			int num;
			cin >> num;
			num--;
			DP[id][num] = 1;
		}
		
	}
	
	int ret = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 0){
			ret = dfs(i, ret + 1);
		}
	}
	
	for(int i = 0; i < n; i++){
		cout << i + 1 << " " << s[i] << " " << t[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3484
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cassert>
using namespace std;

int dp[202020];
int dp2[1 << 26];

int main() {
    string s;
    cin >> s;
    int n = int(s.size());
    
    int x = 0;
    for (int i = 1; i < (1 << 26); i++) dp2[i] = 1e9;
    for (int i = 0; i < n; i++) {
        x ^= 1 << (s[i] - 'a');
        int m = 1e9;
        m = min(m, dp2[x]);
        
        for (int j = 0; j < 26; j++) {
            int xx = x ^ (1 << j);
            m = min(m, dp2[xx]);
        }
        
        dp2[x] = min(dp2[x], m + 1);
        dp[i] = m + 1;
    }
    
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 263556
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int H,W;
		String work[] = new String[2];

		while(true){

			try {
				work = br.readLine().split("[\\s]+");

				if(work[0].equals("0") && work[1].equals("0"))break;

				H = Integer.parseInt(work[0]);
				W = Integer.parseInt(work[1]);

				for(int row = 0; row < H; row++){
					for(int col = 0; col < W; col++){
						if((row+col)%2 == 0){
							System.out.printf("#");
						}else{
							System.out.printf(".");
						}
					}
					System.out.printf("\n");
				}

				System.out.printf("\n");


			} catch (IOException e) {

				e.printStackTrace();
			}
		}
	}
}




Measured memory_bytes: 61188
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

// Integral Rectangles
// 2013/08/13
public class Main{
	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-12;

	String line;

	void run(){
		for(int T=sc.nextInt(); T>0; T--){
			line=sc.next();
			solve();
		}
	}

	void solve(){
		println(dfs(0, line.length())+"");
	}

	int dfs(int s, int t){
		// debug("s", s, "t", t);
		if(line.charAt(s+1)!='['){
			// debug(line.substring(s+1, t));
			return Integer.parseInt(line.substring(s+1, t))/2+1;
		}
		int stack=0;
		int left=0;
		ArrayList<Integer> list=new ArrayList<Integer>();
		for(int i=s+1; i<=t-1; i++){
			// debug(i);
			if(line.charAt(i)=='['){
				if(stack++==0){
					left=i;
				}
				// stack++;
			}else if(line.charAt(i)==']'){
				stack--;
			}
			if(stack==0){
				int right=i;
				// left,right [, ]
				list.add(dfs(left, right));
			}
		}
		// debug(list);
		sort(list);
		int res=0;
		for(int i=0; i<list.size()/2+1; i++){
			res+=list.get(i);
		}
		// debug("s", s, "t", t,res);
		return res;
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 40148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))


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


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using vec_b = vector<bool>;
using vec_str = vector<string>;
using graph = mat;
using edge = pair<ll,ll>;
using wgraph = vector<vector<edge>>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back


int main()
{
    ll K, A, B;
    cin >> K >> A >> B;

    bool f = false;
    REP(i,A,B+1) {
        if(i % K == 0) f = true;
    }
    if(f) _PR("OK");
    else _PR("NG");


    return 0;
}

/*



*/

Measured memory_bytes: 3596