akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> s(n), t(m);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> t[i];
    }
    // n == 1 || m == 1
    // otherwise
    constexpr ll mod = 1000000007LL;
    vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(m, vector<ll>(4)));
    dp[0][0][0] = 1;
    dp[0][0][3] = s.front() == t.front();

    for (int i = 1; i < n; ++i) {
        dp[i][0][0] = 1;
        dp[i][0][2] = dp[i - 1][0][2] + dp[i - 1][0][3];
        dp[i][0][3] = s[i] == t.front();
    }

    for (int i = 1; i < m; ++i) {
        dp[0][i][0] = 1;
        dp[0][i][1] = dp[0][i - 1][1] + dp[0][i - 1][3];
        dp[0][i][3] = s.front() == t[i];
    }

    for (int i = 1; i < n; ++i) {
        for (int j = 1; j < m; ++j) {
            for (int k = 0; k < 4; ++k) {
                dp[i][j][0] += dp[i - 1][j - 1][k];
                dp[i][j][0] %= mod;
            }

            dp[i][j][1] = dp[i][j - 1][1] + dp[i][j - 1][3];
            dp[i][j][2] = dp[i - 1][j][2] + dp[i - 1][j][3];

            if (s[i] == t[j])
                dp[i][j][3] = dp[i][j][0];

            dp[i][j][1] %= mod;
            dp[i][j][2] %= mod;
            dp[i][j][3] %= mod;
        }
    }

    ll ans = 0;
    for (int k = 0; k < 4; ++k) {
        ans += dp.back().back()[k];
        ans %= mod;
    }

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

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

int main() {
  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;

  string ans;
  for (int i = 0; i < N; i++) {
    ans.push_back(S.at(i));
    ans.push_back(T.at(i));
  }

  printf("%s", ans.c_str());
  return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
#define _LIBCPP_DEBUG 0
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (n); ++i)	
using namespace std;

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

int main() {
	string divide[4] = { "dream","dreamer","erase","eraser" };
	string s;
	cin >> s;
	

	reverse(s.begin(), s.end());

	rep(i, 4) {
		reverse(divide[i].begin(), divide[i].end());
	}
	bool can = true;
	for (int i = 0; i < s.size(); ) {
		bool can2 = false;
		rep(j, 4) {
			string d = divide[j];
			if (s.substr(i, d.size()) == d) {
				i += d.size();
				can2 = true;
			}
		}
		if (!can2) {
			can = false;
			break;
		}

	}
	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 888
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here

        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt(), m = in.nextInt();
        int total = 0;
        int[] votes = new int[n];
        for (int i = 0; i < n; i++) {
            votes[i] = in.nextInt();
            total += votes[i];
        }

        double criteria = Math.ceil((double)total / (4 * m));
        int count = 0;
        for (int vote: votes) {
            if (vote >= criteria)count++;
        }
        
        out.println(count >= m ? "Yes": "No");
        out.close();

    }
}


Measured memory_bytes: 21972
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let n = read::<u32>();

    let p = read_vec::<u32>();
    let t = read_vec::<u32>();

    let mut ans = 100000;
    for i in 0..n + 1 {
        for j in 0..n + 1 {
            for k in 0..n + 1 {
                for l in 0..n + 1 {
                    if t[0] * i + t[1] * j + t[2] * k + t[3] * l >= n {
                        let ps = p[0] * i + p[1] * j + p[2] * k + p[3] * l;
                        ans = std::cmp::min(ans, ps);
                    }
                }
            }
        }
    }
    println!("{}", ans);
}



Measured memory_bytes: 5032
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	char ch; cin>>ch;
	if (ch=='A') cout<<"T";
	else if (ch=='T') cout<<"A";
	else if (ch=='C') cout<<"G";
	else if (ch=='G') cout<<"C";
	else cout<<endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	cin >> n;

	if (n == 0) {
		cout << 0 << endl;
		return 0;
	}
	string ans = "";
	while (n != 0) {
		if (n % 2 != 0) {
			ans = "1" + ans;
			n--;
		} else {
			ans = "0" + ans;
		}

		n /= -2;
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n,0);
        inv = vector<int>(n,0);
        fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
int poorpow(int b, int a) {
    int tmp = 1;
    REP (i,a) {
        tmp *= b;
    }
    return tmp;
}


bool solve() {
    int n; cin >> n;
    cout << LCM(2,n) << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
int cnt[1005][1005],N,D,a;
int s2[1005][1005],s3[1005][1005];
int sum2(int x1,int y1,int x2,int y2) {
    if(x1 > x2 || y1 > y2) return 0;
    ++x1,++y1,++x2,++y2;
    return s2[x2][y2] - s2[x2][y1 - 1] - s2[x1 - 1][y2] + s2[x1 - 1][y1 - 1];
}
int sum3(int x1,int y1,int x2,int y2) {
    if(x1 > x2 || y1 > y2) return 0;
    ++x1,++y1,++x2,++y2;
    
    return s3[x2][y2] - s3[x2][y1 - 1] - s3[x1 - 1][y2] + s3[x1 - 1][y1 - 1];
}
bool check2(int x,int y,int b) {
    int d1 = sum2(max(0,b + x - D + 1),max(0,b + y - D + 1),x - 1,y - 1);
    int d2 = sum2(x + b + 1,y + b + 1,D - 1,D - 1);
    int d3 = sum2(max(0,b + x - D + 1),y + b + 1,x - 1,D - 1);
    int d4 = sum2(x + b + 1,max(0,b + y - D + 1),D - 1,y - 1);
    return !d1 && !d2 && !d3 && !d4;
}
bool check3(int x,int y,int b) {
    int d1 = sum3(x + b + 1,0,D - 1,D - 1);
    int d2 = sum3(0,y + b + 1,D - 1,D - 1);
    int d3 = sum3(max(0,b + x - D + 1),0,x - 1,D - 1);
    int d4 = sum3(0,max(0,b + y - D + 1),D - 1,y - 1);
    return !d1 && !d2 && !d3 && !d4;
}
void Solve() {
    read(N);read(D);
    int x,y;
    for(int i = 1 ; i <= N ; ++i) {
	read(x);read(y);
	cnt[x % D][y % D]++;
    }
    int t = 0;
    for(int i = 0 ; i < D ; ++i) {
	for(int j = 0 ; j < D ; ++j) {
	    if(cnt[i][j]) {
		t = sqrt(cnt[i][j]);
		if(t * t < cnt[i][j]) ++t;
		a = max(t - 1,a);
	    }
	}
    }
    for(int i = 0 ; i < D ; ++i) {
	for(int j = 0 ; j < D ; ++j) {
	    if(cnt[i][j] > a * a && cnt[i][j] <= a * (a + 1)) s2[i + 1][j + 1]++;
	    else if(cnt[i][j] > a * (a + 1)) s3[i + 1][j + 1]++;
	}
    }
    for(int i = 1 ; i <= D ; ++i) {
	for(int j = 1 ; j <= D ; ++j) {
	    s2[i][j] = s2[i][j] + s2[i - 1][j] + s2[i][j - 1] - s2[i - 1][j - 1];
	    s3[i][j] = s3[i][j] + s3[i - 1][j] + s3[i][j - 1] - s3[i - 1][j - 1];
	}
    }
    int b;
    for(b = 0 ; b < D ; ++b) {
	if(check2(0,0,b) && check3(0,0,b)) break; 
    }
    for(int i = 0 ; i < D ; ++i) {
	for(int j = 0 ; j < D ; ++j) {
	    if(!(i + j)) continue;
	    while(b) {
		if(check2(i,j,b - 1) && check3(i,j,b - 1)) --b;
		else break;
	    }
	}
    }
    out(a * D + b);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 12032
#include<cstdio>
#include<iostream>
using namespace std;
int a[10][10];
int main()
{
    int a1;
    cin>>a[1][1]>>a[1][2]>>a[2][2];
    a1=a[2][2]*3;
    a[1][3]=a1-a[1][1]-a[1][2];
    a[3][1]=a1-a[1][3]-a[2][2];
    a[3][3]=a1-a[1][1]-a[2][2];
    a[2][1]=a1-a[1][1]-a[3][1];
    a[2][3]=a1-a[2][1]-a[2][2];
    a[3][2]=a1-a[1][2]-a[2][2];
    for(int i=1;i<=3;i++)
    {
        for(int j=1;j<=3;j++)
        {
        	cout<<a[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
typedef struct LIST{
	int to;
	struct LIST *next;
}Edge;
void add_edge(Edge **edge,int s,int t){
	Edge *tmp=(Edge*)malloc(sizeof(Edge));
	tmp->to=t;
	tmp->next=edge[s];
	edge[s]=tmp;
	return;
}
void delete_edge(Edge **edge,int v){
	int i;
	Edge *e,*tmp;
	FOR(i,0,v){
		e=edge[i];
		while(e!=NULL){
			tmp=e->next;
			free(e);
			e=tmp;
		}
	}
	return;
}
Edge *edge[100000];
int size[100000];
int a[100000];
int dfs(int v,int prev){
	int cnt=0,s,max=0,t;
	Edge *e;
	if(size[v]==1) return a[v];
	for(e=edge[v];e!=NULL;e=e->next){
		if(e->to==prev) continue;
		s=dfs(e->to,v);
		cnt+=s;
		max=MAX(max,s);
	}
	t=a[v]*2-cnt;
	if(a[v]>cnt||a[v]<max||2*a[v]<cnt){
		puts("NO");
		exit(0);
	}
	return t;
}
int main(void)
{
	int n,x,y,i;
	scanf("%d",&n);
	FOR(i,0,n) scanf("%d",&a[i]);
	if(n==2){
		printf("%s\n",a[0]==a[1]?"YES":"NO");
		return 0;
	}
	FOR(i,0,n-1){
		scanf("%d%d",&x,&y);
		add_edge(edge,--x,--y);
		add_edge(edge,y,x);
		size[x]++,size[y]++;
	}
	for(i=0;size[i]==1;i++);
	printf("%s\n",dfs(i,-1)==0?"YES":"NO");
	return 0;
}


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

#define ll long long

using namespace std;

const int N = (int)1e5 + 7;

int to[N][2];
int sz;

void add(string &t) {
  int v = 0;
  for (char c : t) {
    if (!to[v][c - '0']) {
      to[v][c - '0'] = ++sz;
    }
    v = to[v][c - '0'];
  }
}

int n;
ll l, sum;

ll get(ll x) {
  return x & -x;
}

void dfs(int v, int h = 0) {
  int cnt = (to[v][0] > 0) + (to[v][1] > 0);
  if (cnt == 1) {
    sum ^= get(l - h);
  }
  if (to[v][0])
    dfs(to[v][0], h + 1);
  if (to[v][1])
    dfs(to[v][1], h + 1);
}

main() {
  scanf("%d %lld", &n, &l);
  string s;
  for (int i = 1; i <= n; i++) {
    cin >> s;
    add(s);
  }
  dfs(0);
  if (sum == 0) {
    cout << "Bob";
  } else {
    cout << "Alice";
  }
}


Measured memory_bytes: 3584
H,W,A,B=map(int,input().split())
#print(H,W,A,B)

h=[A*H+i*(W-2*A) for i in range(H)]
w=[B*W+i*(H-2*B) for i in range(W)]
#print(h)
#print(w)


for i,hh in enumerate(h):
  if hh in w:
    #print(i,w.index(hh))

    aa=[]
    for a in range(H-i):
      aa.append(W-A)
    for a in range(i):
      aa.append(A)
    #print("aa",aa)    

    bb=[]
    for b in range(W-w.index(hh)):
      bb.append(H-B)
    for b in range(w.index(hh)):
      bb.append(B)
    #print("bb",bb)    
    
    for a in range(H):
      pp=""
      for b in range(W):
        #print(a,b)
        if aa[a]>0 and bb[b]>0:
          pp+="1"
          aa[a]-=1
          bb[b]-=1
        else:
          pp+="0"
      print(pp)
    exit()

print("No")

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

using namespace std;

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

int main(){
    int a, b;

    cin >> a >> b;

    if (a > 8 || b > 8) {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }

    return 0;
}



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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n, s;
    cin >> n >> s;

    if(n < s) {
        cout << -1 << en;
        return;
    }

    auto f = [&](auto &&self, ll b, ll x) -> ll {
        if(b == 1)
            return -1;
        if(b > x)
            return x;
        return self(self, b, x / b) + x % b;
    };

    ll n2 = sqrt(n);

    rep(i, 2, n2 + 1) {
        if(f(f, i, n) == s) {
            cout << i << en;
            return;
        }
    }
    rep2(i, 1, n2) {
        ll b = (n - s) / i + 1;
        if(f(f, b, n) == s) {
            cout << b << en;
            return;
        }
    }

    if(s == 1)
        cout << max(2LL, n) << en;
    else if(s == n) {
        cout << max(2LL, n + 1) << en;
    } else {
        cout << -1 << en;
    }
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define forE(i,x) for(int i=head[x];i!=-1;i=ne[i])
using namespace std;
typedef long long i64;
typedef unsigned long long u64;
typedef unsigned u32;
typedef pair<int,int> pin;
#define mk(a,b) make_pair(a,b)
#define lowbit(x) ((x)&(-(x)))
#define sqr(a) ((a)*(a))
#define clr(a) (memset((a),0,sizeof(a)))
#define ls ((x)<<1)
#define rs (((x)<<1)|1)
#define mid (((l)+(r))>>1)
#define pb push_back
#define w1 first
#define w2 second
inline void read(int &x){
	x=0;int f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	x*=f;
}
inline void judge(){
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
}
/*******************************head*******************************/
const int maxn=505;
int a[maxn][maxn];
int n,m,h,w;
int main(){
	// judge();
	read(n);read(m);read(h);read(w);
	rep(i,1,n)rep(j,1,m)a[i][j]=1000;
	int S=(h*w-1)*1000;
	for(int i=h;i<=n;i+=h)for(int j=w;j<=m;j+=w)
		a[i][j]=-S-1;
	int res=0;
	rep(i,1,n)rep(j,1,m)res+=a[i][j];
	if(res<=0){
		puts("No");
	}else{
		puts("Yes");
		rep(i,1,n){
			rep(j,1,m)printf("%d ",a[i][j]);
			puts("");
		}
	}
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>

int main()
{
    int h = 0;
    int w = 0;
    std::cin >> h >> w;

    int array[w+1][h+1] = {};

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            std::cin >> array[j][i];
        }
    }

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
             array[w][i] += array[j][i];
             array[j][h] += array[j][i];

        }
    }
    for (int i = 0; i < h; i++) {
        array[w][h] += array[w][i];
    }

    for (int i = 0; i < h + 1; i++) {
        for (int j = 0; j < w + 1; j++) {
            std::cout << array[j][i];
            if (j < w) {
                std::cout << " ";
            }
            if (j == w) {
                std::cout  << std::endl;
            }
        }
    }

    return 0;

}

Measured memory_bytes: 3096
N = int(input())
S = [list(input()) for _ in range(N)]

ans = 0
for k in range(N):
  D = [[0] * N for i in range(N)]
  for i in range(N):
    for j in range(N):
      D[i][j] = S[i][(j + k) % N]
  for i in range(N):
    for j in range(N):
      if D[i][j] != D[j][i]:
        break
    else:
      continue
    break
  else:
    ans += 1

print(ans * N)

Measured memory_bytes: 184752
dat = []
isok = []
for _ in range(3):
    l = list(map(int, input().split()))
    dat.append(l)
    isok.append([False] * 3)
n = int(input())
for _ in range(n):
    c = int(input())
    for i in range(3):
        for j in range(3):
            if dat[j][i] == c:
                isok[i][j] = True
if isok[0][0] and isok[0][1] and isok[0][2]:
    print("Yes")
elif isok[1][0] and isok[1][1] and isok[1][2]:
    print("Yes")
elif isok[2][0] and isok[2][1] and isok[2][2]:
    print("Yes")
elif isok[0][0] and isok[1][0] and isok[2][0]:
    print("Yes")
elif isok[0][1] and isok[1][1] and isok[2][1]:
    print("Yes")
elif isok[0][2] and isok[1][2] and isok[2][2]:
    print("Yes")
elif isok[0][0] and isok[1][1] and isok[2][2]:
    print("Yes")
elif isok[2][0] and isok[1][1] and isok[0][2]:
    print("Yes")
else:
    print("No")


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

int main() {
  int H1,M1,H2,M2,K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  int time1 = H1*60 + M1;
  int time2 = H2*60 + M2;
  
  int time3 = time2 - time1 - K;
  
  cout << time3 << endl;
  
}

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

int main() {
  double pi, S, C, r;
  pi = 3.141592653589;
  cin >> r;

  S = pi * r * r;
  C = 2 * pi * r;
  cout << fixed << setprecision(6);
  cout << S << " " << C << endl;
}


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

#define endl '\n'

void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(15);
}
const int MAX = 1e5 + 5 ;
vector<int> g[MAX] ; 
pair<int,int> dis[MAX] ;
int col[MAX] ;
// int que[MAX] ;
// int dist[MAX] ;
const int INF = 1e9 ;
struct qry{
	int d,v,c ;
	int qno ;
};
vector< qry > Q ;
int dp[MAX][12] ;
int c; 
void solve(int u,int d){
	// cout << u << " , " << d << " , c = " << c << endl ;
	int &ret = dp[u][d] ;
	if(ret != -1) return  ;
	if(d == 0){
		ret = c ;
		return  ;
	}
	ret = c ;
	for(auto v:g[u]){
		solve(v,d-1) ;
	}
	solve(u,d-1) ;
}
int main(int argc,char* argv[]) { 
    io() ;
    #ifndef ONLINE_JUDGE
       // freopen("inp.txt", "r", stdin) ;
        // freopen("out.txt", "w", stdout);
    #endif
    int n,m,qr ;
    cin >> n >> m  ;
    int u,v ;
    for(int i = 0 ; i < m ; i++){
    	cin >> u >> v ;
    	g[u].push_back(v) ;
    	g[v].push_back(u) ;
    }
	for(int i = 0 ; i < MAX ; i++){
		dis[i].first = INF ;
		dis[i].second = 0 ;
	}
    cin >> qr ;
    for(int i = 1 ; i <= qr ; i++){
    	int d,v,c ;
    	cin >> v >> d >> c ;
    	qry qq ;
    	qq.v = v ;
    	qq.d = d ;
    	qq.c = c ;
    	Q.push_back(qq) ;
    }
    reverse(Q.begin(), Q.end()) ;
    memset(dp, -1, sizeof(dp)) ;
    for(auto qq:Q){
    	int d = qq.d ;
    	int u = qq.v ;
    	c = qq.c ;
    	solve(u,d);
    }
    for(int i = 1 ; i <= n ; i++){
    	if(dp[i][0] == -1) cout << 0 << endl ;
    	else cout << dp[i][0] << endl ;
    }
    return 0 ; 
}

Measured memory_bytes: 14064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

int main(void){
    ll n, w;
    cin >> n >> w;

    vector<ll> w1;
    vector<ll> w2;
    vector<ll> w3;
    vector<ll> w4;
    ll w0;
    ll tmp;
    cin >> w0 >> tmp;
    w1.push_back(tmp);

    rep(i, 0, n-1){
        ll t1, t2;
        cin >> t1 >> t2;

        if(t1 == w0){
            w1.push_back(t2);
        }else if(t1 == w0 + 1){
            w2.push_back(t2);
        }else if(t1 == w0 + 2){
            w3.push_back(t2);
        }else if(t1 == w0 + 3){
            w4.push_back(t2);
        }
    }

    sort(w1.begin(), w1.end(), greater<ll>());
    sort(w2.begin(), w2.end(), greater<ll>());
    sort(w3.begin(), w3.end(), greater<ll>());
    sort(w4.begin(), w4.end(), greater<ll>());

    if(w1.size())
    rep(i, 0, w1.size() - 1){
        w1[i + 1] = w1[i] + w1[i + 1];
    }
    if(w2.size())
    rep(i, 0, w2.size() - 1){
        w2[i + 1] = w2[i] + w2[i + 1];
    }
    if(w3.size())
    rep(i, 0, w3.size() - 1){
        w3[i + 1] = w3[i] + w3[i + 1];
    }
    if(w4.size())
    rep(i, 0, w4.size() - 1){
        w4[i + 1] = w4[i] + w4[i + 1];
    }

    ll ans = 0;
    rep(i, 0, w1.size() + 1){
        rep(j, 0, w2.size() + 1){
            rep(k, 0, w3.size() + 1){
                rep(l, 0, w4.size() + 1){
                    ll v = 0;
                    if(i * w0 + j * (w0 + 1) + k * (w0 + 2) + l * (w0 + 3) > w)continue;
                    if(i != 0)
                        v += w1[i - 1];
                    if(j != 0)
                        v += w2[j - 1];
                    if(k != 0)
                        v += w3[k - 1];
                    if(l != 0)
                        v += w4[l - 1];
                    ans = max(v, ans);
                }
            }
        }
    }

    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
//
//  main.cpp
//  dp
//
//  Created by 贾皓翔 on 2019/11/26.
//  Copyright © 2019 贾皓翔. All rights reserved.
//
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <cstring>
#include <unordered_set>
#define ll long long
using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    if (N==M) {
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}





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

int main() {

    int H, N;
    cin >> H >> N;

int sum = 0;
    rep(i, N) {
        int a;
        cin >> a;
        sum += a;
        if (sum >= H) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (sum >= H) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3636
use proconio::input;
use std::collections::BTreeSet;

fn main() {
    input! {
        x: i32,
        n: usize,
        v: [i32; n]
    }
    let mut set = BTreeSet::new();
    for &p in v.iter() {
        set.insert(p);
    }

    let mut ans = 0;
    for i in 0..100 {
        if !set.contains(&(x-i)) {
            ans = x-i;
            break;
        }
        if !set.contains(&(x+i)) {
            ans = x+i;
            break;
        }
    }
    println!("{}",ans)
}


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

int Sum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;
    int sum = Sum(N);
    if(N % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1LL<<60;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------
int N;
vector<int> S = {3,5,7};
int f(int d,int x){
  if(d > N) return 0;
  int ans = 0;
  for(int i=0; i<3; i++){
    int nx = d*S[i] + x;
    if(nx > N) continue;
    int temp = nx;
    bool a3=false,a5=false,a7=false;
    while(temp){
      if(temp%10==3){
        a3 = true;
      }else if(temp%10==5){
        a5 = true;
      }else if(temp%10==7){
        a7 = true;
      }
      temp /= 10;
    }
    if(a3 && a5 && a7){
      ans++;
    }
    ans += f(d*10,nx);
  }
  return ans;
}
int main(){
  cin >> N;
  cout << f(1,0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	a=(a+12)%14;
	b=(b+12)%14;
//	cout<<a<<"#"<<b<<endl;
	if(a<b){
		cout<<"Bob";
	}else if(b<a){
		cout<<"Alice";
	}else{
		cout<<"Draw";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;
using namespace atcoder;

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

int e(){
  return -1;
}

int ta;
bool comp(int x){
  return x < ta;
}

int main(){
  int n, q;
  cin >> n >> q;
  segtree<int, op, e> seg(n);
  rep(i, n){
    int in;
    cin >> in;
    seg.set(i, in);
  }
rep(_q, q){
  int t, a, b;
  cin >> t >> a >> b;
  if(t == 1) seg.set(a-1, b);
  else if(t == 2) cout << seg.prod(a-1, b) << endl;
  else{
    ta = b;
    a--;
    cout << seg.max_right<comp>(a) + 1 << endl;
  }
}
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

class dice{
    int label2num[7];
    map<int,int> num2label;
    public:
    dice(int a[6]){
        for(int i=0;i<6;i++) label2num[i+1]=a[i];
        for(int i=0;i<6;i++) num2label[a[i]]=num2label[a[i]]*10+(i+1);
    }
    int getNum(int label){
        return label2num[label];
    }
    vector<int> getLabels(int num){
        vector<int> r(0);
        for(int l=num2label[num];l>0;l/=10){
            r.push_back(l%10);
        }

        return r;
    }
    vector<int> getSideNums(int topLabel){
        vector<int> r(4);
        int *s;
        switch(topLabel){
            case 1:
                s=new int[4]{2,3,5,4};
                break;
            case 2:
                s=new int[4]{1,4,6,3};
                break;
            case 3:
                s=new int[4]{1,2,6,5};
                break;
            case 4:
                s=new int[4]{1,5,6,2};
                break;
            case 5:
                s=new int[4]{1,3,6,4};
                break;
            case 6:
                s=new int[4]{2,4,5,3};
                break;
        }
        for(int i=0;i<4;i++) r[i]=label2num[s[i]];

        delete[] s;
        return r;
    }
};

int main(){
    int a[6], b[6];
    for(int i=0;i<6;i++) cin >> a[i];
    for(int i=0;i<6;i++) cin >> b[i];
    
    dice A(a), B(b);

    int atop=1;
    vector<int> btops=B.getLabels(A.getNum(1));

    for(int btop : btops){
        if(A.getNum(7-atop) != B.getNum(7-btop)) continue;

        vector<int> asides=A.getSideNums(atop), bsides=B.getSideNums(btop);
        for(int i=0;i<4;i++){
            bool flg=true;
            for(int j=0;j<4;j++) flg=flg && (asides[j]==bsides[(j+i)%4]);
            if(flg){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()

int const N = 200001;

int main(){
    ll x, y, z;
    scanf("%lld%lld%lld", &x, &y, &z);
    ll can = min(x, z);
    x -= can; 
    z -= can;
    ll rem = min(z, y);
    y -= rem;
    z -= rem; 
    printf("%lld %lld\n", x, y);
} 

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	io, flush := NewIO()
	defer flush()
	n := io.ScanInt()
	strs := io.ScanStrings(n)
	var maxStrs []string
	var max int
	countMap := map[string]int{}
	sort.Strings(strs)
	for _, s := range strs {
		countMap[s]++
		count := countMap[s]
		if count > max {
			max = count
			maxStrs = []string{s}
			continue
		}
		if count == max {
			maxStrs = append(maxStrs, s)
		}
	}
	sort.Strings(maxStrs)
	for _, s := range maxStrs {
		io.Println(s)
	}
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 43392
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) FOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int A, B;
    cin >> A >> B;
    cout << max({A + B, A - B, A * B}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result[10010]={0};
  ll tmp;
  cin >> n;
  m = ceil(sqrt(n));
  for(i=1;i<=m;i++){
    for(j=1;j<=m;j++){
      for(k=1;k<=m;k++){
        tmp = i*i+j*j+k*k+i*j+j*k+k*i;
        if(tmp<=10000) result[tmp]++;
      }
    }
  }
  for(i=1;i<=n;i++) cout << result[i] << endl;
  return 0;
}

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

using namespace std;

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

	string s;
	getline(cin, s);

	char c = *(s.end() - 1);
	if (c == '3') {
		cout << "bon\n";
	} else if (c == '0' || c == '1' || c == '6' || c == '8') {
		cout << "pon\n";
	} else {
		cout << "hon\n";
	}

	return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main() {
	int a, b, ans;
	scanf("%d%d", &a, &b);
	if(a <= 0 && 0 <= b) { printf("Zero\n"); return 0; }
	if(0 < a || (b - a + 1) % 2 == 0) { printf("Positive\n"); return 0; }
	else { printf("Negative\n"); return 0; }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int n,t,c,b=0,d=0,ans=10000;
    cin>>n>>t;
    int a[n][2];
    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            cin>>a[i][j];
        }
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(a[i][0]>a[j][0]){
                c=a[i][0];
                a[i][0]=a[j][0];
                a[j][0]=c;
                c=a[i][1];
                a[i][1]=a[j][1];
                a[j][1]=c;
                
            }
        }
    }
    while(b==0){
        if(a[d][1]<=t){
           ans=a[d][0];
           b++;
        }
        d++;
        if(d==n){
            break;
        }
    }
    if(ans==10000){
        cout<<"TLE"<<endl;
    }
    else{
        cout<<ans<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
void dfs(int x,int y,char z);
char a[100][100];
int h,w;
int ans = 0;
int main(){

    while(cin>>h>>w,h){
        ans = 0;

        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                cin>>a[i][j];
            }
        }
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if(a[i][j]!='.')dfs(i,j,a[i][j]),ans++;
            }
        }
        cout<<ans<<endl;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                a[i][j] = '.';
            }
        }

    }


    return 0;
}
void dfs(int x,int y,char z){
    a[x][y] = '.';
    if(z==a[x][y+1]&&y+1<w)dfs(x,y+1,z);
    if(z==a[x+1][y]&&x+1<h)dfs(x+1,y,z);
    if(z==a[x][y-1]&&y-1>=0)dfs(x,y-1,z);
    if(z==a[x-1][y]&&x-1>=0)dfs(x-1,y,z);

    return;
}

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

//計算量O(k)
// nPk
long long permutation(int n, int k){
    long long perm = 1;
    for(int i = 0; i < k; i++){
        perm *= (n - i);
    }

    return perm;
}

//計算量O(min(k,n-k))
// nCk
long long combination(int n, int k){
    long long cns = min(k,n-k);
    long long com = permutation(n,cns);
    for(int i = 0; i < cns; i++){
        com /= (cns - i);
    }

    return com;
} 


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

    int num0 = 0;
    int num1 = 0;

    rep(i,n){
        int a;
        cin >> a;
        if(a % 2 == 0) num0 ++;
        else num1 ++;
    }

    long long ans = 0;

    if(p == 0){
        for(int i = 0; i<=num1; i+=2){
            ans += combination(num1,i) * pow(2,num0);
        }
        cout << ans << endl;
        return 0;
    }

    if(p == 1){
        for(int i=1; i<=num1; i+=2){
            ans += combination(num1,i) * pow(2,num0);
        }
        cout << ans << endl;
        return 0;
    }

}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i = 0; i < N; i++){
    cin >> x[i];
  }
  int ans = 999999999;
  for(int i = 0; i < N - K + 1; i++){
    int l = abs(x[i]);
    int r = abs(x[i+K-1]);
    if(x[i] <= 0 && x[i+K-1] <= 0){
      if(ans > l){
        ans = l;
      }
    } else if(x[i] <= 0 && x[i+K-1] >= 0){
      if(ans > min(l*2+r, l+r*2)){
        ans = min(l*2+r, l+r*2);
      }
    } else if(x[i] >= 0 && x[i+K-1] >= 0){
      if(ans > r){
        ans = r;
      }
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 3708
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ld A,B,C,D,E,F,G,H,W,R,L,K,P,Q,X,Y,Z,N,M;
string S,T;
ll V[1000007];

int main(){
  cin >> A ;
  for(ld i=0;i<=50000;i+=1){
    if((int)(i*1.08)==A){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string.h>
#include<stack>
using namespace std;

int n;
int m[100][100], d[100], f[100];
int t = 0;
char c[100];
stack<int> s;

int next(int u){
  for(int i = 0; i < n; i++){
    if(m[u][i] == 1 && c[i] == 'w') return i;
  }
  return 0;
}

void dfs(int u){
  s.push(u);
  c[u] = 'g';
  d[u] = ++t;

  while(s.empty() == 0){
    u = s.top();
    int v = next(u);
    if(c[v] == 'w'){
      c[v] = 'g';
      d[v] = ++t;
      s.push(v);
    }
    else{
      s.pop();
      c[u] = 'b';
      f[u] = ++t;
    }
  }
}


int main(){

  cin >> n;

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      m[i][j] = 0;
      c[i] = 'w';
    }
  }

  for(int i = 0; i < n; i++){
    int id, k, x;
    cin >> id >> k;
    for(int j = 0; j < k; j++){
      cin >> x;
      m[i][x - 1] = 1;
    }
  }

  for(int i = 0; i < n; i++){
    if(c[i] != 'b') dfs(i);
  }

  for(int i = 0; i < n; i++){
    cout << i + 1 << " " << d[i] << " " << f[i] << endl;
  }

  return 0;
}



Measured memory_bytes: 3132
# -*- coding: utf-8 -*-

def main():
    n, a, b = map(int, input().split())

    comp = n // (a + b)
    uncomp = n - comp * (a + b)

    ans = comp * a + min(a, uncomp)
    # print('comp:{}, uncomp:{}'.format(comp, uncomp))
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m;cin>>n>>m;
    ll sum=0;
    rep(i,m){
        ll a;cin>>a;
        sum+=a;
    }
    cout<<(sum<=n?n-sum:-1)<<endl;
}


Measured memory_bytes: 3656
// Author : Harshdeep Sharma , IIT Indore
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
// #define MOD  998244353
#define ll long long
const double PI = atan(1.0) * 4;
// const ll INF = (int)1e9 ;
const int di[4] = { -1, 0, 1, 0} ;
const int dj[4] = {0, -1, 0, 1} ;
const ll INF = (ll)2e18 + 50;
const int maximum  = numeric_limits<int>::min();
const int minimum  = numeric_limits<int>::max();
const int MOD = 1e9 + 7 ;
const int N = 1e7 + 50  ;
ll c[N] ;


// function to calculate any numbered power of some number without modulo
ll power(ll a , ll e) {
	ll res = 1LL ;
	while (e > 0) {
		if (e % 2 == 1) res = res * a;
		a =  a * a  ;
		e /= 2 ;
	}
	return res ;
}
// function to check whether a bracketed sequence is balanced or not
bool isBalanced(const string &exp) {
	// Initialising Variables
	bool flag = true;
	int count = 0;

	// Traversing the Expression
	for (int i = 0; i < exp.length(); i++) {

		if (exp[i] == '(') {
			count++;
		}
		else {
			count--;
		}
		if (count < 0) {
			flag = false;
			break;
		}
	}
	if (count != 0) {
		flag = false;
	}

	return flag;
}
// function to sort by second in a set of pairs
bool sortbysec(const pair<pair<int, int>, int> &a,
               const pair<pair<int, int>, int> &b) {
	return (a.second < b.second);
}

void uniformly_distribute_k_numbers_in_a_square_grid(int n , int k ) {
	int p = 0 , q = 0 ;
	vector<vector<int>> a(n, vector<int>(n)) ;
	for (int i = 1 ; i <= k ; ++i ) {
		a[p][q] = 1 ;
		p = p + 1 ;
		q = (q + 1) % n ;
		if (p == n) {
			p = 0  ;
			q = (q + 1) % n ;

		}
	}
}

// function to calculate gcd
ll gcd(int a, int b) {
	// Everything divides 0
	if (a == 0)
		return b;
	if (b == 0)
		return a;

	// base case
	if (a == b)
		return a;

	// a is greater
	if (a > b)
		return gcd(a - b, b);
	return gcd(a, b - a);
}

int mex(const vector<int> &a) {
	int res ;
	int n = a.size() ;
	vector<int> cnt(n + 1) ;
	for (int i = 0 ; i < n ; i++) {
		++cnt[a[i]] ;
	}
	for (int i = 0 ; i < n ; i++) {
		if (cnt[i] == 0) {
			res = i ;
			break ;
		}
	}
	return res ;
}
// void C_i_j(int n) {

// 	for (int i = 0; i < n; i++) {
// 		for (int j = 0; j <= i; j++) {
// 			if (i == j || j == 0)
// 				c[i][j] = 1;
// 			else
// 				c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
// 		}
// 	}
// }

ll summation(int n ) {
	return n * (n + 1) / 2 ;
}

void f(int n) {

	for (int i = 1 ; i < n ; i++) {
		c[i] = 1 ;
	}
	for (int i = 2 ; i < n ; i++) {
		// if (c[i] == 0) {
		for (int j = i ; j < n ; j += i) {
			c[j]++ ;
		}
		// }
	}
}


// main funtion
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	f(N) ;
	// int t ;
	// cin >> t ;
	// while (t--) {
	int n ;
	cin >> n ;
	ll ans = 0 ;

	for (int i = 1 ; i <= n ; i++) {
		ans += i * c[i] ;
	}

	cout << ans << "\n";




















	// }







	return 0 ;
}


Measured memory_bytes: 81756