akhauriyash/Code-Regression huggingface dataset:
import std.stdio;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.functional;
import std.bigint;
import std.numeric;
import std.array;
import std.math;
import std.range;
import std.container;
import std.ascii;
import std.concurrency;
void times(alias fun)(int n) {
    foreach(i; 0..n) fun();
}
auto rep(alias fun, T = typeof(fun()))(int n) {
    T[] res = new T[n];
    foreach(ref e; res) e = fun();
    return res;
}
void main() {
    int a, b, c, d;
    readf("%d %d %d %d\n", &a, &b, &c, &d);
    writeln(max(a*b, c*d));
}

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

// fold was added in D 2.071.0
static if (__VERSION__ < 2071) {
    template fold(fun...) if (fun.length >= 1) {
        auto fold(R, S...)(R r, S seed) {
            static if (S.length < 2) {
                return reduce!fun(seed, r);
            } else {
                return reduce!fun(tuple(seed), r);
            }
        }
    }
}

// minElement/maxElement was added in D 2.072.0
static if (__VERSION__ < 2072) {
    auto minElement(alias map, Range)(Range r)
    if (isInputRange!Range && !isInfinite!Range)
    {
        alias mapFun = unaryFun!map;
        auto element = r.front;
        auto minimum = mapFun(element);
        r.popFront;
        foreach(a; r) {
            auto b = mapFun(a);
            if (b < minimum) {
                element = a;
                minimum = b;
            }
        }
        return element;
    }
    auto maxElement(alias map, Range)(Range r)
    if (isInputRange!Range && !isInfinite!Range)
    {
        alias mapFun = unaryFun!map;
        auto element = r.front;
        auto maximum = mapFun(element);
        r.popFront;
        foreach(a; r) {
            auto b = mapFun(a);
            if (b > maximum) {
                element = a;
                maximum = b;
            }
        }
        return element;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int a,b,c;
    cin >> a >> b >> c;
    for(int i=a;i<=a*b;i+=a){
        if(i%b==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl; 
    return 0;
}

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

using namespace std;

char s[110];
int n;

int main()
{
	scanf("%s", s + 1);
	n = strlen(s + 1);
	int ans = 0;
	for (int i = 1; i + i <= n; i++)
		ans += (s[i] != s[n - i + 1]);
	printf("%d\n", ans);

	return 0;
}

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

const int N = 2e5+9;
const long long inf = 1e15;

int n,a[N];
long long dp[N][3],ans=-inf;

int main(){
    scanf("%d",&n);
    for(int i = 1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i = 0;i<N;i++){
        for(int j = 0;j<3;j++) dp[i][j]=-inf;
    }
    dp[0][0] = dp[0][1] = dp[0][2] = 0;
    for(int i = 1; i<=n/2;i++){
        dp[i][0] = dp[i-1][0] + a[(2*i)-1];
        dp[i][1] = max(dp[i-1][1],dp[i-1][0]) + a[2*i];
        dp[i][2] = max(max(dp[i-1][2],dp[i-1][1]),dp[i-1][0]) + a[(2*i)+1];
    }
    if(n%2==0) ans=max(dp[n/2][0],dp[n/2][1]);
    else{
        for(int i = 0;i<3;i++){
            ans=max(ans,dp[n/2][i]);
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 7144
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main() {
  int i, j;
  int n;
  long long int na;
  int data[100001];
  int dif[100001];
  //  long int times[100001];
  long long int sum = 0;
  int times;
  int tme[100001];
  long long int one;
  int sum2 = 0;
  int flag = 0;
 
  scanf("%d", &n);
  na = (long long int)n;
 
  for (i = 0; i < n; i++) {
    scanf("%d", & data[i]);
    sum += data[i];
  }
 
  one = na * (na + 1) / 2;
  if (sum % one != 0) {
    flag = 1;
  } else {
    times = sum / one;
    for (i = 0; i < n-1; i++) {
      dif[i] = data[i+1] - data[i];
    }
    dif[n-1] = data[0] - data[n - 1];
 
    for (i = 0; i < n; i++) {
      if ((times - dif[i]) % n != 0) {
        flag = 1;
        break;
      } else {
        tme[i] = (times - dif[i]) / n;
        if(tme[i]<0){
          flag = 1;
          break;
        }
      }
    }
    if (flag == 0) {
      for (i = 0; i < n; i++) {
        sum2 += tme[i];
      }
    }
   }
  if (flag == 0) {
    printf("YES");
/*
    if (sum2 == times) {
      printf("YES");
 
    } else {
      printf("NO");
    }
*/
  } else {
    printf("NO");
  }
 
  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define SIZE_OF_ARRAY(a) (sizeof(a)/sizeof(a[0]))

unsigned GetDigit(unsigned num){
    return std::to_string(num).length();
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    string ans2;
    int N,D,X;
    cin >> N;
    cin >> D >> X;
    int a[N];
    for(int i = 0;i < N;i++){
        cin >> a[i];
    }
    int temp;
    for(int i = 0;i < N;i++){
        for(int j = 0;j <= 10000000;j++){
            temp = a[i] * j + 1;
            if(temp <= D)
                ans++;
            else
                break;
        }
    }
    ans += X;
    cout << ans << endl;
}

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

int main(void)
{
    using namespace std;
    int K;
    cin >> K;

    vector<long long int> a;
    for (int i = 1; i <= 9; i++) {
        a.push_back(i);
    }

    while (true) {
        /*
        for (long long int x : a) {
            printf("%lld ", x);
        }
        printf("\n");
        */
        if (K <= a.size()) {
            printf("%lld\n", a.at(K - 1));
            return 0;
        }
        K = K - a.size();
        vector<long long int> old;
        swap(a, old);
        for (long long int x : old) {
            for (int i = -1; i <= 1; i++) {
                int d = x % 10 + i;
                if (0 <= d && d < 10) {
                    long long int  nx = x * 10 + d;
                    a.push_back(nx);
                }
            }
        }    
    }
}

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

int main() {
    int n; cin >> n;
    vector<int> vec(n);
    for (int i=0; i<vec.size(); i++) {
        cin >> vec[i];
    }

    int maximum = *max_element(vec.begin(), vec.end());
    int sum = accumulate(vec.begin(), vec.end(), 0);

    if (sum - maximum > maximum) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B;
    cin >>A>>B;
    
    ll ans=0;
    rep(i,10){
        rep(j,10){
            rep(k,10){
                rep(m,10){
                    rep(n,10){
                        ll num=i*10000+j*1000+k*100+m*10+n;
                        //cout<<num<<endl;
                        if(num<=B && num>=A){
                            if(i==n && j==m){
                                ans++;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3604
import numpy as np
from collections import Counter

N = int(input())
A = list(map(int, input().split(" ")))

MIN = min(A)
MAX = max(A)

print(2 * N - 1)

if abs(MAX) > abs(MIN):
    index = np.argsort(A)[-1] + 1
    for i in range(1, N + 1):
        if i != index:
            print(index, i)
    print(index, index)
    for i in range(1, N):
        print(i, i + 1)
else:
    index = np.argsort(A)[0] + 1
    for i in range(1, N + 1):
        if i != index:
            print(index, i)
    print(index, index)
    for i in range(1, N)[::-1]:
        print(i + 1, i)

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

signed main() {
  int h,w,a,b;
    cin>>h>>w>>a>>b;
  for(int i=0;i<h;i++){
    string s;
    for(int j=0;j<w;j++){
      if(i<b&&j<a) s+='0';
      else if(i>=b&&j>=a) s+='0';
      else s+='1';
    }
    cout<<s<<endl;
  }
}


Measured memory_bytes: 1280
#解説
S = input()
T = input()

start = [-1]*26
goal = [-1]*26

for i in range(len(S)):
  a = ord(S[i]) - ord("a")
  b = ord(T[i]) - ord("a")
  
  if start[a] != -1 or goal[b] != -1:
    if start[a] != b or goal[b] != a:
      print("No")
      break
  else:
    start[a] = b
    goal[b] = a
else:
  print("Yes")

Measured memory_bytes: 3760
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pii pair<ll, ll>
#define pll pair<ll, ll>
#define pli pair<ll, ll> 
#define pdd pair<ld, ld> 
#define pb push_back
#define reset(x,v) memset(x,v,sizeof(x))
#define mod 1000000007
using namespace std;
map<int, bool> mp;
int main(){
	FASTIO
	int k;
	cin >> k;
	int c = 1, m = 7 % k;
	while(m != 0){
		if(mp[m]){
			c = -1;
			break;
		}
		mp[m] = true;
		m = (m * 10 + 7) % k;
		c++;
	}
	cout << c;
    return 0;
}

Measured memory_bytes: 50524
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int a,b,c,d;
int main()
{
	cin >>a>>b>>c>>d;
	while (a>0 && c>0)
	{
		//cout <<a<<" "<<c<<" ##\n";
		c-=b;
		if (c<=0)
		{
			cout <<"Yes";
			break;
		}
		a-=d;
		if (a<=0)
		{
			cout <<"No";
			break;
		}
	}
	return 0;
} 

Measured memory_bytes: 3596
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, S, T;
vector <int> Graph[int(1e5 + 5)];
int Dist[int(1e5 + 5)];
bool visited[int(1e5 + 5)][3];

int Solve(){
  priority_queue <Pii, vector<Pii>, greater<Pii> > que;
  que.push({0, S});

  while (!que.empty()){
    Pii Q = que.top(); que.pop();
    if (visited[Q.se][Q.fi % 3]) continue;
    visited[Q.se][Q.fi % 3] = true;

    if (Q.fi % 3 == 0) Dist[Q.se] = Q.fi / 3;

    for (int i = 0; i < Graph[Q.se].size(); i++){
      int next = Graph[Q.se][i];
      que.push({Q.fi + 1, next});
    }
  }
  printf("%d\n", Dist[T]);
  return 0;
}


int main(){
  scanf("%d%d", &N, &M);
  fill(Dist, Dist + N + 1, -1);
  for (int i = 0; i < M; i++){
    int U, V; scanf("%d%d", &U, &V);
    Graph[U].push_back(V);
  }
  scanf("%d%d", &S, &T);
  Solve();

  return 0;
}


Measured memory_bytes: 9848
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int r, d, x;
    cin >> r >> d >> x;
    int ans = 0;

    for (int i = 0; i < 10; i++)
    {

        ll now = r * x - d;
        Cout(now);
        x = now;

    }

    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n, d; cin >> n >> d;
	cout << (n / (2 * d + 1)) + (n % (2 * d + 1) != 0);

	return 0;
}

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

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

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

using namespace std;

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

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

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

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

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

string s;

signed main(){
    io();

    in(s);
    rep(i,s.size()){
        printf("%c",s[i]=='1'?'9':'1');
    }puts("");

    return 0;
}


Measured memory_bytes: 632
import java.util.*;
 
public class Main {
  public static void main (String[] arg) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int p[] = new int[N];
    int check = 0;

    for (int i = 0; i < N; i++){
      p[i] = scan.nextInt();
      if(p[i] != i+1){
        check++;
      }
    }
    
    if(check == 0 || check == 2){
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }

  }
}

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

using namespace std;
#define endl "\n"
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> pii;
ll x, k, d, temp;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> x >> k >> d;
    x = abs(x);
    ll move_num = x / d;
    if (move_num > k) move_num = k;
    if (abs(k - move_num) % 2 == 0)
        temp = x - move_num * d;
    else temp = x - (move_num + 1) * d;
    cout << abs(temp);
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>

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

using namespace std;

typedef long long ll;

#define MOD (1000000007)

ll a, b, t;

int main() {
    cin >> a >> b >> t;
    
    cout << (t / a) * b << endl;
    
}



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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	char c;
	cin>>c;
	int var = (int)(c);
	if(var>=65 && var<=90) cout<<"A";
	else cout<<"a";
	return 0;
} 

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt" , "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif

	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == 'p')
				ans -= 1;
		}
		else
		{
			if (s[i] == 'g')
				ans += 1;
		}
	}
	cout << ans << endl;



}


Measured memory_bytes: 512
h,w = map(int,input().split())
field = []
xx = [-1, 0, 0, 1]
yy = [0, -1, 1, 0]

for i in range(h):
    field.append(input())

for i in range(h):
    for j in range(w):
        if field[i][j] == '#':
            flag = False
            for x,y in zip(xx,yy):
                if i+x < 0 or i+x > h-1:
                    continue
                elif j+y < 0 or j+y > w-1:
                    continue
                elif field[i+x][j+y] == '#':
                    flag = True     
                    break
            if flag == False:
                print('No')
                exit()

print('Yes')

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

double dp[3000][3000];
int n;

vector<double> a;
double rec(int node, int heads){
    int tails = node - heads;
    if(node == n){
        return heads > tails;
    }
    if(dp[node][heads] != -1){
        return dp[node][heads];
    }

    return dp[node][heads] = (1.0-a[node])*rec(node+1, heads) + a[node]*rec(node+1, heads+1);
}


int main(){

    for(int i = 0; i < 3000; i++){
        for(int j = 0; j < 3000; j++){
            dp[i][j] = -1.0;
        }
    }

    cin >> n;
    a.resize(n);
    for(auto &x : a) cin >> x;
    

    cout << setprecision(10) << fixed << rec(0, 0) << endl;



    return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
int sw[12][12];
int n, m;
int p[12];
int ans = 0;

void search(int num, int st[12]){
    if(num == n){
        for(int i = 0; i < m; i++){
            int ad = 0;
            for(int j = 0; j < sw[i][0]; j++)if(st[sw[i][j+1]-1] > 0)ad++;
            if(ad%2 != p[i]){
                return;
            }
            if(i == m-1){
                ans++;
                return;
            }
        }
    }
    st[num] = -1;
    search(num+1, st);
    st[num] = 1;
    search(num+1, st);
}

int main(){
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> sw[i][0];
        for(int j = 0; j < sw[i][0]; j++)cin >> sw[i][j+1];
    }
    for(int i = 0; i < m; i++)cin >> p[i];
    int a[12] = {0};
    search(0, a);
    cout << ans << endl;
    return 0;
}

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

#define I inline
#define fi first
#define se second
#define R register
#define LL long long
#define mp make_pair
#define reg register int
#define pii pair<int,int>
#define cr const reg&
using namespace std;
const int inf = 2147483647;
const int N = 1e5 + 1;

I int _max(cr x, cr y) {return x > y ? x : y;}
I int _min(cr x, cr y) {return x < y ? x : y;}
I int read() {
	reg x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return x * f;
}
I void ptt(cr x) {if(x >= 10) ptt(x / 10); putchar(x % 10 + '0');}
I void put(cr x) {x < 0 ? putchar('-'), ptt(-x) : ptt(x);}
I void pr1(cr x) {put(x), putchar(' ');}
I void pr2(cr x) {put(x), puts("");}

int n, a[N];

int gcd(int a, int b) {return !b ? a : gcd(b, a % b);}

bool dfs(cr x) {
	bool bk = 0; int s = 0;
	for(reg i = 1; i <= n; i++) {
		if(a[i] == 1) bk = 1;
		if(a[i] & 1) s++;
	} if((n - s) & 1) return x;
	if(bk || s > 1) return !x;
	for(reg i = 1; i <= n; i++) {
		if(a[i] & 1) {a[i]--; break;}
	} int qq = a[1];
	for(reg i = 2; i <= n; i++) qq = gcd(qq, a[i]);
	for(reg i = 1; i <= n; i++) a[i] /= qq;
	return dfs(!x);
}

int main() {
	n = read();
	for(reg i = 1; i <= n; i++) a[i] = read();
	if(dfs(1)) puts("First");
	else puts("Second");
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const string YES = "Yes";
const string NO = "No";
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;


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

    string s,t;
    int q;
    cin >> s >> q;
    while(q--){
        int type; cin >> type;
        if (type==1) swap(s,t);
        else{
            int f; char c;
            cin >> f >> c;
            if (f==1) t.push_back(c);
            else s.push_back(c);

        }
    }
    reverse(ALL(t));
    cout << t + s << endl;

}



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

int main()
{
    ll t,n,i,j,k;
    string s;
    cin>>n;
    cin>>s;
    ll c=0;
    for(i=1;i<n;i++)
    {
        if(s[i-1]!=s[i])
        {
            c++;
        }
    }
    cout<<c+1<<endl;
    return 0;
}


Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 10000000000000
using namespace std;
using ll = long long;
int main() {
	int n;
	string a, b, c;
	ll ans = 0;
	cin >>n>> a >> b >> c;
	for (int i = 0; i < n; i++) {
		if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
			ans += 2;
		}
		else if (a[i] != b[i]||b[i]!=c[i]||c[i]!=a[i]) {
			ans += 1;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <list>
#include <numeric>
#include <math.h>
#include <cstdlib>
#include <queue>
#include <iterator>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>
#include <bitset>
#include <mutex>
#include <condition_variable>
#include <atomic>
#include <stack>
#include <memory>
#include <deque>
#include <string_view>
#include <random>
#include <chrono>
#include <cstring>

using namespace std;

static int my_speed_up = []() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); return 0; }();
using ll = long long; using ull = unsigned long long;
template<class T> using v = vector<T>;
template<class T> using vv = vector<vector<T>>;
template<class T> using vvv = vector<vector<vector<T>>>;
template<class T> using vvvv = vector<vector<vector<vector<T>>>>;
#define for_b(i, b) for (int i = 0; i < (b); ++i)
#define for_ab(i, a, b) for (int i = a; i < (b); ++i)
#define what_is(x) cout << #x << " = " << x << endl;
#define what_are(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl;
#define pad(x) for_b(i, x) cout << "  ";
#define show_1d(___x) cout << #___x << " = "; for (auto& ___num : ___x) cout << ___num << ", "; cout << endl;
#define show_2d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto ___num : ___row) cout << ___num << ", "; cout << endl; }
#define show_3d(___x) cout << #___x << endl; for (auto& ___row : ___x) { for (auto& ___row2 : ___row) { for (auto ___num : ___row2) cout << ___num << ", "; cout << endl; }cout << endl; }

vv<int> d4 = {{1,0},{-1,0},{0,1},{0,-1}};
vv<int> d8 = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
bool is_valid_pos(const vv<int>& tb, int x, int y) {
    return x >= 0 && x < tb.size() && y >= 0 && y < tb[0].size();
}


int main()
{
    string S, T;
    cin >> S >> T;
    
    int res = S.size();
    for_b(i,S.size() - T.size() + 1)
    {
        int cur = 0;
        for_b(j, T.size())
        {
            if (S[i+j] != T[j])
                ++cur;
        }
        res = min(res, cur);
    }
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 3656
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class BGoToJail {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        in >> n;
        vector<vector<int>> d(n,vector<int>(2,0));

        int cnt = 0;
        rep(i,n){
            in >> d[i][0] >> d[i][1];
        }
        rep(i,n){
            if(d[i][0]==d[i][1]){
                cnt++;
            }else{
                cnt=0;
            }
            if(cnt==3){
                out << "Yes" << endl;
                return ;
            }
        }
        out << "No" << endl;
	}
};


int main() {
	BGoToJail solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

using namespace std;

typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int x,y,sum=0;
    int a[4]={0,300000,200000,100000};
    cin>>x>>y;
    if(x<=3)
        sum+=a[x];
    if(y<=3)
        sum+=a[y];
    if(x==1&&y==1)
        sum+=400000;
    cout<<sum<<endl;
    return 0;
}


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

char a;
long long n,m;
long long b[100][100];

void o(int x,int y){
	if(b[x-1][y]!=-1)
		b[x-1][y]+=1;
	if(b[x+1][y]!=-1)
		b[x+1][y]+=1;
	if(b[x][y-1]!=-1)
		b[x][y-1]+=1;
	if(b[x][y+1]!=-1)
		b[x][y+1]+=1;
	if(b[x-1][y-1]!=-1)
		b[x-1][y-1]+=1;
	if(b[x-1][y+1]!=-1)
		b[x-1][y+1]+=1;
	if(b[x+1][y-1]!=-1)
		b[x+1][y-1]+=1;
	if(b[x+1][y+1]!=-1)
		b[x+1][y+1]+=1;
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			cin>>a;
			if(a=='#') { b[i][j]=-1; o(i,j); }
		}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			if(b[i][j]==-1)
				cout<<"#";
			else
				cout<<b[i][j];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
/**
 *      ABC 75 A
 *      author  : kyomukyomupurin
 *      created : 2018-09-04 16:46:38
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int A, B, C; cin >> A >> B >> C;
    if (A == B){
        cout << C << endl;
    }
    else if (B == C){
        cout << A << endl;
    }
    else {
        cout << B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

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


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdbool.h>
#define e 1000000007

typedef  long long ll;

int int_cmp(const void *a, const void *b){ 
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib; 
} 


ll int_cmp1(const void *a, const void *b){ 
    const int *ia = (const int *)a;
    const int *ib = (const int *)b;
    return *ia  - *ib; 
} 


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

int min(int a,int b){
	if(a>b)
		a=b;
	return a;	
}

int absolu(int n){
	if(n<0)
		n*=-1;
	
	return n;	
}


void solve(){

	ll a[200000];
	int n,i;
	
	
	scanf("%d",&n);
	for(i=0 ; i<n ; i++){
		scanf("%lld",&a[i]);
	}
	ll ans=0;
	for(i=0 ; i<n-1 ; i++){
		if(a[i]>a[i+1]){
			ll val=a[i]-a[i+1];
			a[i+1]+=val;
			ans+=val;
		}
	} 
	
	printf("%lld\n",ans); 
}

 





int main(){
 /* int t;
	scanf("%d",&t);
	
	while(t--)*/
		solve();
	
	
	
	return 0;
}	
	

Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define ld long double
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MAXN = 1002;
char a[MAXN][MAXN];
ll visit[MAXN][MAXN];

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

void solve(){

    ll n,m; cin>>n>>m;
    FOR(i,1,n) FOR(j,1,m) cin>>a[i][j];

    queue<pair<ll,ll>> q;

    FOR(i,1,n) FOR(j,1,m){
        if(a[i][j] == '#'){
            q.push({i,j});
            clog<<i<<" "<<j<<endl;
            visit[i][j] = 1;
        }
    }
    ll ans = 0;

    while(q.size() != 0){
        ll x = q.size();

        while(x--){
            ll x = q.front().first,y = q.front().second;
            q.pop();

            for(ll i=0;i<4;i++){
                ll n_x = x + dx[i];
                ll n_y = y + dy[i];
                if(n_x < 1 || n_x > n || n_y < 1 || n_y > m || visit[n_x][n_y] == 1) continue;
                q.push({n_x,n_y});
                visit[n_x][n_y] = 1; 
            }
        }

        if(q.size() > 0) ans++;
        clog<<q.size()<<endl;
    }
    cout<<ans<<endl;
}

signed main(){

   FastRead;    


    ll t,w;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}



Measured memory_bytes: 25396
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  string S;
  while (cin >> N >> S) {
    int pass = 0, fail = N;
    while (fail - pass > 1) {
      int len = (pass + fail) / 2;
      unordered_map<string, int> mp;
      bool res = false;
      for (int i = 0; i + len <= N; i++) {
        string sub = S.substr(i, len);
        if (mp.count(sub)) {
          if (mp[sub] + len <= i) {
            res = true;
            break;
          }
        } else {
          mp[sub] = i;
        }
      }
      if (res) {
        pass = len;
      } else {
        fail = len;
      }
    }
    cout << pass << endl;
  }
  return 0;
}


Measured memory_bytes: 6668
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main {
	public static void main(String[] args)throws Exception{
		PrintWriter out = new PrintWriter(System.out);
		int K=nextInt();
		if(K%2==1&&K%5!=0){
			long sum=7;
			for(int i=1;i<=K;i++){
				if(sum%K==0){
					System.out.println(i);
					System.exit(0);
				}
				sum*=10;sum%=K;
				sum+=7;sum%=K;
			}
		}
		else
			System.out.println(-1);
	}
	static boolean isOK(int index,int key,int[]a){
		if (a[index]>=key) return true;
	    else return false;
	}
	static int binary_search(int key,int[] a) {
	    int ng = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	    int ok = (int)a.length; // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	    while (Math.abs(ok - ng) > 1) {
	        int mid = (ok + ng) / 2;
	        if (isOK(mid,key,a)) ok = mid;
	        else ng = mid;
	    }
	    return ok;
	}
	//FastScanner
	static InputStream in = System.in;
	static  byte[] buffer = new byte[1024];
	static int length = 0, p = 0;
	public static boolean hasNextByte () {
		if (p < length) return true;
		else {
			p = 0;
			try {length = in.read(buffer);}
			catch (Exception e) {e.printStackTrace();}
			if (length == 0) return false;
		}
		return true;
	}
	public static int readByte () {
		if (hasNextByte() == true) return buffer[p++];
		return -1;
	}
	public static boolean isPrintable (int n) {return 33<=n&&n<=126;}
	public static void skip () {
		while (hasNextByte() && !isPrintable(buffer[p])) p++;
	}
	public static boolean hasNext () {skip(); return hasNextByte();}
	public static String next () {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int temp = readByte();
		while (isPrintable(temp)) {
			sb.appendCodePoint(temp);
			temp = readByte();
		}
		return sb.toString();
	}
	public static int nextInt () {return Math.toIntExact(nextLong());}
	public static int[] nextInts (int n) {
		int[] ar = new int[n];
		for (int i=0; i<n; i++) ar[i] = nextInt();
		return ar;
	}
	public static long nextLong () {
		if (!hasNext()) throw new NoSuchElementException();
		boolean minus = false;
		int temp = readByte();
		if (temp == '-') {
			minus = true;
			temp = readByte();
		}
		if (temp<'0' || '9'<temp) throw new NumberFormatException();
		long n = 0;
		while (isPrintable(temp)) {
			if ('0'<=temp && temp<='9') {
				n *= 10;
				n += temp - '0';
			}
			temp = readByte();
		}
		return minus? -n : n;
	}
}



Measured memory_bytes: 32748
a,b,c,d = map(int,input().split())
c_=0
d_=0
n=0
if a%c!=0 and b>c:
    c_= a+c-a%c #12
    n+=1
elif b<c:
    c_= b
else:
    c_ = a
    n+=1
if a%d!=0 and b>d:
    d_= a+d-a%d #16
    n+=1
elif b<d:
    d_= b
else:
    d_ = a
    n+=1
r = max(c,d)%min(c,d)
b_=min(c,d)
while r!=0:
    a_= b_
    b_=r
    r=a_%b_
e = int(c*d/b_)
if a%e!=0 and b>e:
    e_= a+e-a%e #48
    n-=1
elif b<e:
    e_= b
else:
    e_ = a
    n-=1
n += (b-c_)//c+(b-d_)//d-(b-e_)//e
print(1+b-a-n)

Measured memory_bytes: 3064
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int ans = 0;
        for (int i = 1; i <= n; ++i) {
            if (String.valueOf(i).length() % 2 == 1) {
                ++ans;
            }
        }
        writer.println(ans);
        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 28116
/* 
    Author - linpaws07 
*/
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define inf (int)1e9
#define f first
#define s second
#define eps 1e-9
#define PI 3.1415926535897932384626433832795
#define scd(t) scanf("%d",&t)
#define sclld(t) scanf("%lld",&t)
#define scc(t) scanf("%c",&t)
#define scs(t) scanf("%s",t)
#define scf(t) scanf("%f",&t)
#define sclf(t) scanf("%lf",&t)
#define memst(a, b) memset(a, (b), sizeof(a))
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int,int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rp(i,n) for(int i=0;i<(n);i++)
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define fre(i,a,b) for(int i=(a);i<=(b);i++)
#define frd(i,a,b) for(int i=(a);i>=(b);i--)
inline bool eq(double a, double b) { return fabs(a-b) < 1e-9; }
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
auto start = high_resolution_clock::now();
inline void measure();

char a[1002][1002];
int64 dp[1002][1002];
int main(){
    FAST
    //Do awesome things here
    int h, w;
    cin >> h >> w;
    rp(i, h){
        rp(j, w){
            cin >> a[i][j];
        }
    }
    dp[0][0] = 1;
    fr(i, 1, w){
        dp[0][i] = (a[0][i] == '#' ? 0 : dp[0][i - 1]);
    }
    fr(i, 1, h){
        dp[i][0] = (a[i][0] == '#' ? 0 : dp[i - 1][0]);
    }
    fr(i, 1, h){
        fr(j, 1, w){
            if(a[i][j] == '#')  dp[i][j] = 0;
            else dp[i][j] =  (dp[i - 1][j] + dp[i][j - 1]) % mod;
        }  
    }
    cout << dp[h - 1][w - 1] << endl;
    return 0;
}


inline void measure(){
    auto stop = high_resolution_clock::now(); 
    auto duration = duration_cast<milliseconds>(stop - start);
    cout << duration.count() << endl;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
const int N = 510;
int a[N][N],mat[N][N],b[N][N],n,m;
char s[N];
int main() {
  scanf("%d%d",&n,&m);
  for (int i = 1 ; i <= n ; ++ i) {
    scanf("%s",s+1);
    for (int j = 1 ; j <= m ; ++ j)
      mat[i][j] = (s[j] == '#');
  }
  for (int i = 1 ; i <= m ; ++ i)
    a[1][i] = 1, b[n][i] = 1;
  for (int i = 1 ; i <= m ; i += 2)
    for (int j = 2 ; j < n ; ++ j)
      a[j][i] = 1;
  for (int i = 2 ; i <= m ; i += 2)
    for (int j = 2 ; j < n ; ++ j)
      b[j][i] = 1;
  for (int i = 1 ; i <= n ; ++ i)
    for (int j = 1 ; j <= m ; ++ j)
      if (mat[i][j]) a[i][j] = b[i][j] = 1;
  for (int i = 1 ; i <= n ; ++ i) {
    for (int j = 1 ; j <= m ; ++ j) {
      if (a[i][j]) putchar('#');
      else putchar('.');
    }
    puts("");
  }
  puts("");
  for (int i = 1 ; i <= n ; ++ i) {
    for (int j = 1 ; j <= m ; ++ j) {
      if (b[i][j]) putchar('#');
      else putchar('.');
    }
    puts("");
  }
  return 0;
}


Measured memory_bytes: 3712
n = int(input())
l = list(map(int, input().split()))
cnt = 0
for i in range(n):
    if l[i] % 2 == 0:
        if l[i] % 3 == 0:
            cnt += 1
        elif l[i] % 5 == 0:
            cnt += 1
        else:
            print("DENIED")
            quit()
print("APPROVED")


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int prime(int d){
for (int i=2;i<=d/2;i++){
   if (d%i==0) return 0;
}
return 1;
}

int main (void) {
int X;
scanf("%d",&X);
int i=0;
int res=0;
if (X==2) {res=X;}
else {
if (prime(X)) res=X;
else {for (int i=0;i<X*2;i++){
        if (prime(X+i)==1) {res=X+i;
                            break;}
     }
}
}
printf("%d",res);



return EXIT_SUCCESS;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
const long long mod = 1000000007LL;

int main() {
  ll n;
  cin >> n;
  vector<bool> v(n);
  rep(i,n) {
    ll a, b;
    cin >> a >> b;
    if(a==b) v[i] = true;
    else v[i] = false;
  }
  bool ok = false;
  rep(i,n-2) {
    if(v[i]&&v[i+1]&&v[i+2]) ok = true;
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repd(a,b,c) for(int a=c;a>=b;a--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define pb push_back
#define pbb pop_back
const int N = 5e5+100;
signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
   // cin>>T;
    for(int t=1;t<=T;t++)
  {
      //  cout<<"Case #"<<t<<": ";
      int n,m;
      cin>>n>>m;
      int a[n];
      int sum=0;
      for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
      }
      double val = 1.0*sum/(4*m);
      int val2=0;
      for(int i=0;i<n;i++)
      {
        if(a[i]>=val)val2++;
      }
      if(val2>=m)cout<<"Yes\n";
      else cout<<"No\n";


       
       

  }
    
    
}

Measured memory_bytes: 256
n = int(input())
tc = 0
xc, yc = 0, 0
for i in range(n):
    t, x, y = map(int, input().split())
    d = abs(x-xc)+abs(y-yc)
    if d > t-tc:
        print('No')
        exit()
    else:
        if (t-tc-d)%2 != 0:
            print('No')
            exit()
    xc, yc, tc = x, y, t
else:
    print('Yes')


Measured memory_bytes: 74080