akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>

using namespace std;

int main()
{
    // 整数の入力
    long long N,M,i,a,b;
    cin >> N >> M;
    set<long long>* edges = new set<long long>[N+1];
    for (i= 0;i<M;i++){
        cin >> a >> b;
        edges[a].insert(b);
        edges[b].insert(a);
    }

    for(auto itr = edges[1].begin(); itr != edges[1].end(); ++itr) {
        if (*itr == N){
            cout << "POSSIBLE" << endl;
            return 0;
        }

        for(auto second = edges[*itr].begin(); second != edges[*itr].end(); ++second) {
            if (*second == N){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 28416
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

char maze[10][10];

void dfs(int hpos, int wpos) {
	maze[hpos][wpos] = '0';
	if (hpos - 3 >= 0 && maze[hpos - 3][wpos] == '1')dfs(hpos - 3, wpos);
	if (hpos - 2 >= 0 && maze[hpos - 2][wpos] == '1')dfs(hpos - 2, wpos);
	if (hpos - 1 >= 0 && maze[hpos - 1][wpos] == '1')dfs(hpos - 1, wpos);
	if (hpos + 1 < 8 && maze[hpos + 1][wpos] == '1')dfs(hpos + 1, wpos);
	if (hpos + 2 < 8 && maze[hpos + 2][wpos] == '1')dfs(hpos + 2, wpos);
	if (hpos + 3 < 8 && maze[hpos + 3][wpos] == '1')dfs(hpos + 3, wpos);
	if (wpos - 3 >= 0 && maze[hpos][wpos - 3] == '1')dfs(hpos, wpos - 3);
	if (wpos - 2 >= 0 && maze[hpos][wpos - 2] == '1')dfs(hpos, wpos - 2);
	if (wpos - 1 >= 0 && maze[hpos][wpos - 1] == '1')dfs(hpos, wpos - 1);
	if (wpos + 1 < 8 && maze[hpos][wpos + 1] == '1')dfs(hpos, wpos + 1);
	if (wpos + 2 < 8 && maze[hpos][wpos + 2] == '1')dfs(hpos, wpos + 2);
	if (wpos + 3 < 8 && maze[hpos][wpos + 3] == '1')dfs(hpos, wpos + 3);
}

int main() {
	int n;
	cin >> n;
	for (int o = 0; o < n; o++) {
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				cin >> maze[i][j];
			}
		}

		int x, y;
		cin >> y >> x;
		x--, y--;
		dfs(x, y);
		cout << "Data " << o + 1 << ":" << endl;
		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				cout << maze[i][j];
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 2992
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;



//#[proconio::fastout]
fn main() {
    input! {
        n:u64,
        k:u64,
    }

    const MOD:u64 = 1000_000_007;
    let mut ans = 0u64;
    for i in k..=n + 1 {
        let min = i*(i-1)/2; // [0,k) の和 
        let max = n*i-min;
        ans = (ans + (max-min+1))%MOD;
    }
    println!("{}", ans);
}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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 (a>b) { a=b; return 1; } return 0; }

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
        ios_base::sync_with_stdio(false);
        int N, A, B, ans=0;
        int P[200];

        cin >> N >> A >> B;
        rep(i,N) cin >> P[i];

        int cnt[3] = {};
        rep(i,N){
                if( P[i] <= A ) cnt[0]++;
                else if( P[i] <= B ) cnt[1]++;
                else cnt[2]++;
        }

        ans = min({cnt[0], cnt[1], cnt[2]});

        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
	static long A(long a) {
		long lol1 = a/4;
		long lol2 = 0;
		for(long w = 4*lol1; w<=a; w++) {
			lol2 ^= w;
		}
		return lol2;
	}
public static void main(String[]args) throws IOException{
	Scanner sc =new Scanner(System.in);
	long A1 = sc.nextLong();
	long A2 = sc.nextLong();
	System.out.println(A(A2) ^ A(A1-1));
}
}

Measured memory_bytes: 35644
import bisect

N, M, K = map(int, input().split())

As = list(map(int, input().split()))
Bs = list(map(int, input().split()))

sAs = [0]
sBs = [0]
for a in As:
  sAs.append(sAs[-1]+a)
for b in Bs:
  sBs.append(sBs[-1]+b)
  
rlt = 0
for i in range(N+1):
  t = K - sAs[i]
  if t < 0:
    break
  j = bisect.bisect_right(sBs, t)
  rlt = max(rlt, i+j-1)
  
print(rlt)

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

typedef long long int ll;
typedef long double ld;

//****************************************************                
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll> 
#define vpll vector<pll>
#define all(X) X.begin(),X.end()
#define endl "\n" //comment it for interactive questions
#define trace1(a) cerr << #a << ": " << a << endl;
#define trace2(a,b) cerr << #a << ": " << a << " " << #b << ": " << b << endl;
#define trace3(a,b,c) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << endl;
#define trace4(a,b,c,d) cerr << #a << ": " << a << " " << #b << ": " << b << " " << #c << ": " << c << #d << ": " << d << endl;
#define OC freopen("input.txt" , "r", stdin); freopen("output.txt" , "w", stdout) 
#define MOD (ll)1e9+7; //change it for other mods
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
        //*******************************************************
//Some Functions

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

void solve()
{
    ll n;
    cin >> n;
    vll a(n);
    for(ll i=0;i<n;i++) {
    	cin >> a[i];
    }
    vll poss(n);
    vll curr(n);
    vll couns[n];
    for(ll i=0;i<n;i++) {
    	if(a[i] == 0) {
    		poss[i] = 3 - couns[a[i]].size();
    	}
    	else {
    		ll prev = -1;
    		if(couns[a[i]].size() > 0) {
    			poss[i] = poss[couns[a[i]][couns[a[i]].size()-1]] - 1;
    			prev = couns[a[i]][couns[a[i]].size()-1];
    		}
    		for(ll j = 0; j < couns[a[i]-1].size(); j++) {
    			if(couns[a[i]-1][j] > prev) {
    				poss[i]++;
    			}
    		}
    	}
    	couns[a[i]].pb(i);
    	// cout << poss[i] << "\n";
    }
    ll ans = 1;
    ll m = 1000000007;
    for(ll i=0;i<n;i++) {
    	ans = (ans * poss[i]) % m;
    }
    cout << ans << "\n";
}

int main()
{
    FAST_IO;
    #ifndef ONLINE_JUDGE 
      // OC;
    #endif
    ll t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 8064
#include <iostream>
#include <cstdio>
#include <algorithm>
#define inf 10000000000000
using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
const int maxN = 1005;
const int maxM = 2005;
int N, M, root[maxN];
ll X;
struct edge{
	int u, v;ll val;
}G[maxM], tmp[maxM];
bool cmp(const edge& e1, const edge& e2) {
	return e1.val < e2.val;
}
int get_root(int v) {
	if(v != root[v]) {
		int rt = get_root(root[v]);
		root[v] = rt; v = rt;
	}
	return v;
}
ll kruskal(int n, int m, int& tm) {
	tm = 0;
	ll ans = 0; int tot = 1;
	for(int i = 1; i <= m; ++i) {
		int u = G[i].u, v = G[i].v;
		int rt1 = get_root(u), rt2 = get_root(v);
		if(rt1 != rt2) root[rt1] = rt2, tot++, ans += G[i].val;
		else tmp[++tm] = G[i];
	}
	if(tot < n) return inf;
	return ans;
}
void init() {
	for(int i = 1; i <= N; ++i) root[i] = i;
}
ll qpow(ll num, ll k) {
	ll ans = 1;
	while(k) {
		if(k & 1) ans = (ans * num) % mod;
		k = k >> 1; num = (num * num) % mod;
	}
	return ans;
}
int main() {
	//freopen("input.txt", "r", stdin);
	scanf("%d%d%lld", &N, &M, &X);
	for(int i = 1; i <= M; ++i) scanf("%d%d%lld", &G[i].u, &G[i].v, &G[i].val);
	sort(G + 1, G + 1 + M, cmp);
	init();
	int tm; 
	ll minn = kruskal(N, M, tm);
	//cout << minn << endl;
	if(minn > X) {
		printf("0\n"); return 0;
	} else if(minn == X) {
		//cout << "&&&&&" << endl;
		int tot = 0;
		for(int i = 1; i <= M; ++i) {
			init(); root[G[i].u] = G[i].v;
			if(kruskal(N - 1, M, tm) + G[i].val == X) tot++;
		}
		printf("%lld\n", (((qpow(2, tot) - 2) % mod + mod) % mod) * qpow(2, M - tot) % mod);
	} else {
		int tot1 = 0, tot2 = 0;
		for(int i = 1; i <= M; ++i) {
			init(); root[G[i].u] = G[i].v;
			ll tt;
			if((tt = (kruskal(N - 1, M, tm) + G[i].val)) < X) tot1++;
			else if(tt == X) tot2++;
		}
		//cout << tot1 << ' ' << tot2 << endl;
		printf("%lld\n", 2 * ((qpow(2, tot2) + mod - 1) % mod) % mod * qpow(2, M - tot1 - tot2) % mod);
	}
	return 0;	
}

Measured memory_bytes: 384
#include<iostream>
#define ll long long
#define MOD 1000000007

using namespace std;
int main()
{
    int n,w;
    cin>>n>>w;
    ll int *weights=new ll int[n];
    ll int *value=new ll int[n];
    for(int i=0;i<n;i++)
    {
        cin>>weights[i];
       cin>>value[i];
    }
    ll int **dp=new ll int*[n+1];
    for(int i=0;i<=n;i++)
    {
        dp[i]=new ll int[w+1]();
        for(int p=0;p<=w;p++)
            dp[i][p]=0;
    }
        
            for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=w;j++)
            {
            if(weights[i-1]<=j)
                dp[i][j]=max(dp[i-1][j],max(dp[i][j-1],dp[i-1][j-weights[i-1]]+value[i-1]));
            else
                dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
           
        }
          
        }
    cout<<dp[n][w]<<endl;
}


Measured memory_bytes: 82340
def main():
    n,m = map(int,input().split())
    array = [list(map(int, input().split())) for _ in range(m)]
    P = list(map(int, input().split()))

    ans = 0
    for i in range(2**n):
        binary = bin(i)
        binary = binary[2:].zfill(n)
        binary_list = [int(x) for x in binary]
        for j in range(m):
            temp = 0
            for k in range(array[j][0]):
                switch = array[j][k+1]
                temp += binary_list[switch-1]
            if temp%2 != P[j]:
                break
            if j == m-1:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

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

int main()
{
	string a, b;
	cin >> a >> b;
	int i=0,diff,al = a.length(),bl = b.length();
	diff = abs(al - bl);

	if (al > bl) {
		for (int i = 0; i < diff; i++) {
			b = "0" + b;
		}
	}
	else if (al < bl) {
		for (int i = 0; i < diff; i++) {
			a = "0" + a;
		}
	}

	while (a[i] == b[i] && i<al) {
		i++;
	}

	//cout << "i:" << i << endl;

	if(i == al)cout << "EQUAL" << endl;
	else if (stoi(a.substr(i, 1)) > stoi(b.substr(i, 1))) cout << "GREATER" << endl;
	else cout << "LESS" << endl;

	return 0;
}

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

typedef struct{
  int p;
  int d;
  int k;
  int *c;
}Tree;

Tree *T;

void rootedtree(int);
void depth(int);

int main(){
  int n,id,i,j,root;

  scanf("%d",&n);

  T = malloc(sizeof(Tree) * n);
  
  for(i = 0; i < n; i++){
    T[i].p = -1;
    T[i].d = 0;
  }
  
  for(i = 0; i < n; i++){
    scanf("%d",&id);
    rootedtree(id);
  }
  
 for(i = 0; i < n; i++){
    if(T[i].p == -1) root = i;
  }
  
  depth(root);
 
  for(i = 0; i < n; i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,T[i].d);
    if(T[i].d == 0) printf("root, [");
    else if(T[i].k > 0) printf("internal node, [");
    else printf("leaf, [");

    if(T[i].k > 0){
      for(j = 0; j < T[i].k; j++){
	printf("%d",T[i].c[j]);
	if(j != T[i].k - 1) printf(", ");
      }
    }
      printf("]\n");
  }
  for(i = 0; i < n; i++)free(T[i].c);
  free(T);
  
  return 0;
}

void rootedtree(int id){
  int i;
  scanf("%d",&T[id].k);
  
  if(T[id].k > 0){
    T[id].c = malloc(sizeof(int) * T[id].k);
    for(i = 0; i < T[id].k; i++){
      scanf("%d",&T[id].c[i]);
      T[T[id].c[i]].p = id;
    }
  }
}

void depth(int id){
  int i;
  if(T[id].k > 0){
    for(i = 0; i < T[id].k; i++){
      T[T[id].c[i]].d = T[id].d + 1;
      depth(T[id].c[i]);
    }
  }
}

  



Measured memory_bytes: 4088
#include <cstdio>

using namespace std;

const int N=1e5+10;

struct Edge{ int to,next; };

Edge way[N<<1];
int n,num[N],tot;
bool use[N];

void AddEdge(int a,int b) { way[++tot]=(Edge){b,num[a]}; num[a]=tot; }

void Init()
{
	scanf("%d",&n);
	int a,b;
	for (int i=2;i<=n;++i)
	{
		scanf("%d%d",&a,&b);
		AddEdge(a,b);
		AddEdge(b,a);
	}
}

void Dfs(int x,int fa)
{
	for (int i=num[x];i;i=way[i].next)
	{
		int v=way[i].to;
		if (v==fa) continue;
		Dfs(v,x);
	}
	if (!use[x] && fa && !use[fa])
	{
		use[x]=1;
		use[fa]=1;
	}
}

void Solve()
{
	Dfs(1,0);
	
	bool fl=1;
	for (int i=1;i<=n;++i)
		if (!use[i]) fl=0;
	if (fl) printf("Second\n");
	else printf("First\n");
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 2304
//....SARANSH GUPTA....\\  

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fo(p,n) for(int i=p;i<n;i++)
#define FIO ios_base::sync_with_stdio(false);   cin.tie(NULL);   cout.tie(NULL);
#define endl "\n"
#define mp make_pair
#define pb push_back
#define mod 1000000007

int main()
{
    FIO
    ll n;
    cin>>n;
    ll a[n];
    fo(0,n)
    cin>>a[i];
    ll maxm=a[0];
    ll ans=0;
    fo(1,n)
    {
        if(a[i]<maxm)
        {
            ans+=(maxm-a[i]);
        }
        else
        maxm=a[i];
    }
    cout<<ans;
}

Measured memory_bytes: 5212
import std.stdio, std.string, std.range, std.algorithm, std.math, std.typecons, std.conv;

void main() {
  auto a = readln.split;
  ((a[0][$-1] == a[1][0] && a[1][$-1] == a[2][0]) ? "YES" : "NO").writeln;
}


Measured memory_bytes: 256
n,m,x,y = map(int,input().split())
x_list = list(map(int,input().split()))
x_list.append(x)
y_list = list(map(int,input().split()))
y_list.append(y)
if max(x_list) < min(y_list):
    print('No War')
else:
    print('War')


Measured memory_bytes: 2940
fun main(args: Array<String>) {
    val (n, d) = readLine()!!.split(" ").map { it.toInt() }
    val xs = Array(n, { IntArray(d) })
    repeat(n) {
        xs[it] = readLine()!!.split(" ").map { it.toInt() }.toIntArray()
    }

    var ans = 0
    for (i in 0 until n) {
        for (j in i + 1 until n) {
            val d2 = (0 until d).map { xs[i][it] - xs[j][it] }.map { it * it }.sum()
            var r = 0
            while (r * r <= d2) {
                if (r * r == d2) {
                    ans++
                    break
                }
                r++
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 37904
#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--)
using namespace std;

typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long long ll;

template <typename _T>
inline void read(_T &f) {
    f = 0; _T fu = 1; char c = getchar();
    while (c < '0' || c > '9') { if (c == '-') { fu = -1; } c = getchar(); }
    while (c >= '0' && c <= '9') { f = (f << 3) + (f << 1) + (c & 15); c = getchar(); }
    f *= fu;
}

template <typename T>
void print(T x) {
    if (x < 0) putchar('-'), x = -x;
    if (x < 10) putchar(x + 48);
    else print(x / 10), putchar(x % 10 + 48);
}

template <typename T>
void print(T x, char t) {
    print(x); putchar(t);
}

const int N = 2e5 + 5;

ll suml[N][20], sumr[N][20];
int a[N], l[N][20], r[N][20];
int n, k, q;

int main() {
    read(n); read(k);
    for (int i = 1; i <= n; i++) read(a[i]);
    for (int i = 1; i <= n; i++) {
        l[i][0] = upper_bound(a + 1, a + n + 1, a[i] - k) - a - 1;
        r[i][0] = lower_bound(a + 1, a + n + 1, a[i] + k) - a;
        suml[i][0] = i; sumr[i][0] = i - 1;
    }
    r[n + 1][0] = n + 1;
    for (int j = 1; j <= 19; j++) {
        for (int i = 0; i <= n + 1; i++) {
            l[i][j] = l[l[i][j - 1]][j - 1];
            suml[i][j] = suml[i][j - 1] + suml[l[i][j - 1]][j - 1];
            r[i][j] = r[r[i][j - 1]][j - 1];
            sumr[i][j] = sumr[i][j - 1] + sumr[r[i][j - 1]][j - 1];
        }
    }
    read(q);
    while (q--) {
        int L, R; read(L); read(R);
        ll sumL = 0, sumR = 0;
        int nowL = L, nowR = R;
        for (int j = 19; j >= 0; j--) {
            if (r[nowL][j] <= R) {
                sumL += sumr[nowL][j];
                nowL = r[nowL][j];
            }
            if (l[nowR][j] >= L) {
                sumR += suml[nowR][j];
                nowR = l[nowR][j];
            }
        }
        print(sumR - sumL + nowR - nowL + 1, '\n');
    }
    return 0;
}

Measured memory_bytes: 98172
N, K, L = map(int, input().split())

class UnionFind(object):
    def __init__(self, N):
        self.parent = [i for i in range(N)]

    def root(self, A):
        if self.parent[A] == A:
            return A
        self.parent[A] = self.root(self.parent[A]) #経路縮約
        return self.parent[A]

    def connect(self, A, B):
        A = self.root(A)
        B = self.root(B)
        self.parent[A] = B
        
uni1 = UnionFind(N)
for _ in range(K):
    p, q = map(int, input().split())
    if uni1.root(p-1) != uni1.root(q-1):
        uni1.connect(p-1,q-1)

uni2 = UnionFind(N)
for _ in range(L):
    r, s = map(int, input().split())
    if uni2.root(r-1) != uni2.root(s-1):
        uni2.connect(r-1,s-1)

# print (uni1.parent)
# print (uni2.parent)

ans = dict()
key_list = []
for i in range(N):
    root1 = uni1.root(i)
    root2 = uni2.root(i)
    key = str(root1) + '_' + str(root2)
    key_list += [key]
    if key in ans.keys():
        ans[key] += 1
    else:
        ans[key] = 1
    
for i in range(N):
    print (ans[key_list[i]], end = ' ')
print ()






# for i in range(1, N+1):
#     ans = 0
#     for j in range(1, N+1):
#         # print (uni1.root(i), uni1.root(j), uni2.root(i), uni2.root(j))
#         if uni1.root(i) == uni1.root(j) and uni2.root(i) == uni2.root(j):
#             ans += 1
#     print (ans, end = ' ')
print ()

# print (uni1.parent)
# print (uni2.parent)


Measured memory_bytes: 49412
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node
{
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key)
{
	Node *cur = nil->next;
	while( cur != nil && cur->key != key){
		cur = cur->next;
	}
	return cur;
}

void init()
{
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList()
{
	Node *cur = nil->next;
	int isf = 0;
	while(1){
		if( cur == nil ) break;
		if( isf++ > 0 ) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t)
{
	if ( t == nil ) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst()
{
	deleteNode(nil->next);
}

void deleteLast()
{
	deleteNode(nil->prev);
}

void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

void insert(int key)
{
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main()
{
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (i = 0; i < n; i++)
	{
		scanf("%s%d", com, &key);
		if( com[0] == 'i' ) {
			insert(key);
			np++;
			size++;
		}else if(com[0] == 'd'){
			if ( strlen(com) > 6 ) {
				if(com[6] == 'F'){
					deleteFirst();
				}else if(com[6] == 'L'){
					deleteLast();
				}
			} else {
				deleteKey(key);
				nd++;
			}
			size++;
		}
	}

	printList();
	return 0;
}


Measured memory_bytes: 33888
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	char n[3];
	cin >> n;
	for (int i = 0;i < 3;i++){
		if (n[i] == '1'){
			n[i] = '9';
		}
		else if(n[i] == '9'){
			n[i] = '1';
		}
	}
	cout << n <<endl;
	return 0;
}

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

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

vector<vector<int>> G;
bool used[2002];

int dfs(int v, int depth){
    used[v] = true;
    int ret = 0;
    for(int to: G[v]){
        if(!used[to]) ret += dfs(to, depth-1);
    }
    if(depth < 0) ret++;
    return ret;
}

int main(){
    int N, K;
    cin >> N >> K;
    G.assign(N, vector<int>());
    vector<P> edges;
    for(int i=0;i<N-1;i++){
        int A, B;
        cin >> A >> B;
        A--; B--;
        G[A].push_back(B);
        G[B].push_back(A);
        edges.emplace_back(A, B);
    }

    int ans = INF;
    if(K % 2){
        for(P p: edges){
            memset(used, 0, sizeof(used));
            used[p.first] = true;
            used[p.second] = true;
            ans = min(ans, dfs(p.first, K/2) + dfs(p.second, K/2));
        }
    }else{
        for(int i=0;i<N;i++){
            memset(used, 0, sizeof(used));
            ans = min(ans, dfs(i, K/2));
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
import itertools 
k=int(input());ans=0
l=list(itertools.combinations([i for i in range(1,k+1)], 2));
for i in l:
  if (i[0]%2!=0 and i[1]%2==0) or (i[0]%2==0 and i[1]%2!=0):ans+=1
print(ans)

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

#define int long long
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).end()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a,n) sort(a, a+n)
#define sortvec(V) sort(all(V))

typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

template <class T>
T fac(T n)      // template function to find factorial of a number
{ 
    T res = 1, i; 
    for (i = 2; i <= n; i++) 
        res *= i; 
    return res; 
}
template<class T>
T lcm(T a, T b)     //template function to find lcm of two numbers 
{
    return (a * b) / __gcd(a,b);
}
template<class T>
T digitsum(T x)
{
    T sum = 0;
    while(x)
    {
        sum += x%10;
        x /= 10;
    }
    return sum;
}
// ternary search
/*double ternary(double l, double r){
    double eps = 1e-9;
    while(r - l > eps){
        double m1 = l + (r - l)/3;
        double m2 = r - (r - l)/3;
        double f1 = f(m1);
        double f2 = f(m2);
        if(f1 < f2)
            l = m1;
        else r = m2;
    }
    return f(l);
}*/
void nPermute(string str, int n)  //function to find nth  lexi string
{ 
    sort(all(str));
    int i = 1; 
    do {
        if (i == n) 
            break; 
  
        i++; 
    } while (next_permutation(str.begin(), str.end())); 
    cout<<str<<endl;
} 
vector<int> factors(int n) 
{ 
    vector<int> f; 
    for(int x = 2; x * x <= n; x++) { 
        while (n % x == 0) { 
            f.push_back(x); 
            n /= x; 
        } 
    } 
    if (n > 1) f.push_back(n); 
    return f; 
}
bool prime(int n) 
{ 
    if (n < 2)
        return false;
    for(int x = 2; x*x <= n; x++) 
        if (n%x == 0) 
            return false; 
    return true; 
}
// binomial coeficient in O(K) 
int ncr(int n, int k){
    int res = 1;
    if(k > n - k)
        k = n - k;
    for(int i = 0; i < k; i++){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
tuple<int, int, int> Gcd(int a, int b)      //extended Euclids Algorithm
{
    if(b == 0)
        return {1, 0, a};
    else{
        int x, y, g;
        tie(x, y, g) = Gcd(b, a%b);
        return {y, x - (a/b)*y, g};
    }
}
template<class T>       // modular Exponentiation x^n mod m = x^(n mod (m - 1)) mod m : if n  is very large;
T binpow(T a, T b, T m) {
    a %= m;
    T res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
void solve()
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] != t[i])
            ans++;
    }
    cout << ans <<endl;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}

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

int count(vector<int>* v , int* p , int& n , int& m , string ans = ""){
	if(ans.size() == n){
		for(int i = 0 ; i < m ; i++){
			int c = 0 ;
			for(auto j : v[i]) c += (ans[j]-'0') ;
			if(c%2 != p[i]) return 0 ; 
		}
		return 1 ;
	}
	return count(v,p,n,m,ans+"0") + count(v,p,n,m,ans+"1") ;
}

int main() {
	int n, m ;
	cin >> n >> m ;
	vector<int> v[m] ;
	for(int i = 0 ; i < m ; i++){
		int k ; cin >> k;
		while(k--){
			int x ; cin >> x ; v[i].push_back(x-1) ;
		}
	}
	int p[m] ;
	for(int i = 0 ; i < m ; i++) cin >> p[i] ;
	cout << count(v,p,n,m) ;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int b[2000][2000]={};
int bsum[4001][4001]={};
int main(){
	int N,K;
	scan(N);scan(K);
	rep(i,N){
		int x,y;
		char c;
		scan(x);scan(y);scan(c);
		if(c=='B'){
			b[y%(2*K)][x%(2*K)]++;
		}
		else{
			b[y%(2*K)][(x+K)%(2*K)]++;
		}
	}
	rep(i,4*K){
		rep(j,4*K){
			bsum[i+1][j+1]=bsum[i+1][j]+b[i%(2*K)][j%(2*K)];
		}
	}
	rep(j,4*K+1){
		rep(i,4*K){
			bsum[i+1][j]+=bsum[i][j];
		}
	}
	int ans=0;
	rep(i,2*K+1){
		rep(j,2*K+1){
			int mainbbnum=bsum[i][j]+bsum[i+K][j+K]-bsum[i][j+K]-bsum[i+K][j];
			/*int ulbbnum=bsum[i][j]+bsum[0][0]-bsum[i][0]-bsum[0][j];
			int urbbnum=bsum[i][2*K]+bsum[0][j+K]-bsum[i][j+K]-bsum[0][2*K];
			int dlbbnum=bsum[2*K][j]+bsum[i+K][0]-bsum[i+K][j]-bsum[2*K][0];*/
			int drbbnum=bsum[i+2*K][j+2*K]+bsum[i+K][j+K]-bsum[i+K][j+2*K]-bsum[i+2*K][j+K];
			//int bbnum=mainbbnum+ulbbnum+urbbnum+dlbbnum+drbbnum;
			int bbnum=mainbbnum+drbbnum;
			//printf("i:%d j:%d bbnum:%d\n",i,j,bbnum);
			ans=max(ans,bbnum);
		}
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 78336
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;

int main()
{
    int n, t, a;
    std::cin >> n >> t >> a;

    std::vector<int> h(n);
    for (int i = 0; i < n; i++) {
        std::cin >> h[i];
    }

    double ans = DBL_MAX;
    int idx = 0;

    for (int i = 0; i < n; i++) {
        if (ans > std::abs(a - (t - h[i] * 0.006))) {
            ans = std::abs(a - (t - h[i] * 0.006));
            idx = i + 1;
        }
    }
    std::cout << idx << std::endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 110000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

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


Measured memory_bytes: 888
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

using namespace std;

typedef long long ll;

ll gcd(ll x, ll y)
{
	if (y == 0)
	{
		return x;
	}
	return gcd(y, x%y);
}

int main()
{
	ll a, b;
	cin >> a >> b;

	ll c = gcd(a, b);

	ll k = c;
	ll cnt = 1;
	for (int i = 2; i <= sqrt(c); i++) {
		if (k%i == 0) {
			cnt++;
			while (k%i == 0) {
				k = k / i;
			}
		}
	}
	if (k != 1) { cnt++; }
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long lint;
typedef unsigned long long ulint;


//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
//template <typename T> void print(T* v, int N) { if (N == 0) cout << "{ }"; cout << "{" << v[0]; for (int p = 1; p < N; p++) cout << ", " << v[p]; cout << "}"; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
	


int main() {
	string S;
	cin >> S;
	S[5] = ' '; S[13] = ' ';
	cout << S << endl;

	return 0;
}


Measured memory_bytes: 256
use std::io::BufRead;

pub struct StdinReader<R: BufRead> {
    pub buf_reader: R,
    pub buf: String,
}

impl<R: BufRead> StdinReader<R> {
    pub fn new(r: R) -> Self {
        StdinReader {
            buf_reader: r,
            buf: String::with_capacity(10000),
        }
    }
}

#[macro_export]
macro_rules! input {
    ($reader : expr, $t : ty) => { // one variable
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().parse().unwrap();
                reader.buf.clear();
                tmp_var
            },
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty) => { // 2 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone())
            }
        }
    };
    ($reader : expr, $t0 : ty, $t1 : ty, $t2 : ty) => { // 3 tuple
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: Vec<$t0> = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                (tmp_var[0].clone(), tmp_var[1].clone(), tmp_var[2].clone())
            }
        }
    };
    ($reader : expr, $t : ty; $size : expr) => { // Vector
        match &mut $reader {
            reader => {
                use std::io::BufRead;
                reader.buf_reader.read_line(&mut reader.buf).unwrap();
                let tmp_var: $t = reader.buf.trim().split_whitespace().map(|a| a.parse().unwrap()).collect();
                reader.buf.clear();
                tmp_var
            }
        }
    };
}

fn main() {
    solve_d();
}

fn solve_d() {
    let handle = std::io::stdin();
    let mut r = StdinReader::new(handle.lock());
    let (a, b): (usize, usize) = input!(r, usize, usize);
    if a % 2 == 0 && b % 2 == 0 {
        if (b - a) / 2 % 2 == 0 {
            // 0
            println!("{}", b);
        } else {
            // 1
            println!("{}", b ^ 1);
        }
    } else if a % 2 == 0 && b % 2 == 1 {
        if (b + 1 - a) / 2 % 2 == 0 {
            // 0
            println!("{}", 0);
        } else {
            // 1
            println!("{}", 1);
        }
    } else if a % 2 == 1 && b % 2 == 0 {
        if (b - 1 - a) / 2 % 2 == 0 {
            // 0
            println!("{}", a ^ b);
        } else {
            // 1
            println!("{}", a ^ b ^ 1);
        }
    } else {
        if (b + 1 - a) / 2 % 2 == 0 {
            // 0
            println!("{}", a);
        } else {
            // 1
            println!("{}", a ^ 1);
        }
    }
}



Measured memory_bytes: 4352
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

x ,a = LI()
if x>= a:
    print(10)
else:
    print(0)

  


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

using namespace std;

bool isPrime(int num)
{
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
    {
      // 素数ではない
      return false;
    }
  }

  // 素数である
  return true;
}

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

  int n;
  cin >> n;
  vector<pair<int,int>> p(n);
  vector<int> c(100001);
  rep(i, n) {
    cin >> p[i].first >> p[i].second;
  }

  int count = 0;
  for(int i = 1;i<100001;i++) {
    if(isPrime(i) && isPrime((i+1)/2))
      count++;
    c[i] = count;
  }

  rep(i, n) {
    int ans = c[p[i].second] - c[p[i].first-1];
    cout << ans << endl;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
//#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rev(i,b,a) for (ll i = b - 1; i >= a; i--)
#define all(v) v.begin(), v.end()
#define maxe(v) *max_element(v.begin(), v.end())
#define mine(v) *min_element(v.begin(), v.end())
#define pb push_back
#define pf push_front
#define rem 1000000007
#define cont continue
//#define minn 999999999
//#define maxx 0
ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
ll modulo(ll a, ll b)
{
    ll r = a % b;
    return r < 0 ? r + b : r;
}
//ncr
ull ncr(ull n, ull r)
{
    if(r > n - r) r = n - r; // because C(n, r) == C(n, n - r)
    ull ans = 1;
    ull i;

    for(i = 1; i <= r; i++) {
        ans *= n - r + i;
        ans /= i;
    }

    return ans;
}
class abc
{
    public:
    ll val;
    ll ind;
};
bool fun1(abc x,abc y)
{
    return x.val>y.val;
}
///////////////////////////////////////////////////////
class abcd
{
    public:
    ll day;
    ll vas;
};
bool fun1(abcd x,abcd y)
{
    return x.vas<y.vas;
}
///////////////////////////////////////////
ll power(ll x, ll y, ll p)
{
    ll res = 1;      // Initialize result

    x = x % p;  // Update x if it is more than or
                // equal to p

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res*x) % p;

        // y must be even now
        y = y>>1; // y = y/2
        x = (x*x) % p;
    }
    return res;
}

// Returns n^(-1) mod p
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p);
}
ll fact[100000+2];
ll ncrfast(ll n, ll r, ll p)
{
   if (r==0)
      return 1;
    return (fact[n]* modInverse(fact[r], p) % p *
            modInverse(fact[n-r], p) % p) % p;
}
///////////////////////////////////////////////////////
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*ll tc;
    cin>>tc;
    while(tc--)
    {}*/
    ll n;
    cin>>n;
    ld a[n];
    rep(i,0,n)
    cin>>a[i];
    
    ld dp[n+1][n+1]={};
    dp[1][0] = 1-a[0];
    dp[1][1]=a[0];
    rep(i,2,n+1)
    {
        rep(j,0,i+1)
        {
            if( j==0 )
            {
                dp[i][j]= dp[i-1][j]*( 1.0 - a[i-1] );
            }
            else
            {
                dp[i][j] = dp[i-1][j]*( 1.0 - a[i-1] ) + dp[i-1][j-1]*a[i-1];
            }
        }
    }
    ld ans=0;
    rep(i,(n+1)/2 , n+1 )
    ans+=dp[n][i];
    cout<<fixed<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 140928
#include <iostream>

using namespace std;

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

	int max1 = n / 4;
	int max2 = n / 7;
	for (int i = 0; i <= max1; i++) {
		for (int j = 0; j <= max2; j++) {
			if (i * 4 + j * 7 == n) {
				cout << "Yes" << '\n';
				return 0;
			}
		}
	}
	cout << "No" << '\n';
	return 0;
}

Measured memory_bytes: 256
s = int(input())

mod = 10**9+7
N = 10**5
fac = [1]*(N+1)
finv = [1]*(N+1)
for i in range(N):
    fac[i+1] = fac[i] * (i+1) % mod
    finv[-1] = pow(fac[-1], mod-2, mod)
for i in reversed(range(N)):
    finv[i] = finv[i+1] * (i+1) % mod

def cmb1(n, r, mod):
    if r <0 or r > n:
        return 0
    r = min(r, n-r)
    return fac[n] * finv[r] * finv[n-r] % mod

ans = 0
for n in range(1, 1000):
    if s-3*n < 0:
        break
    temp = cmb1(s-3*n+n-1, n-1, mod)
    ans += temp
ans %= mod
print(ans)


Measured memory_bytes: 69308
#include<bits/stdc++.h>
#define int long long int
#define ld long double
#define getFaster ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define rev(i,n,init) for(int i=n;i>=init;i--)
#define MAXN 200005
#define MOD2 998244353
#define MOD1 1e9+7
#define f first
#define s second
#define endl '\n'
#define pii pair<int,int>
#define piii pair<pii,int>
#define precise(i) cout<<fixed<<setprecision(i)
#define codejam cout<<"Case #"<<ii+1<<": ";
#define impossible cout<<"IMPOSSIBLE"<<endl;
#define error(s) throw runtime_error(s)
using namespace std;
const long double PI = atan(1.0)*4;
const int64_t INF=3e18;
const int32_t LOG=21;
const int MOD=MOD2;
int dp[3005][3005];
int cnt[3005];
int power(int x,int y)
{
      if(y==0)return 1;
      int temp=power(x,y/2);
      temp=(temp*temp)%MOD;
      if(y&1)temp=(temp*x)%MOD;
      return temp;
}
int32_t main()
{ 
      getFaster;
      int tests=1;
      //cin>>tests;
      rep(ii,0,tests)
      { 
          int INV2=power(2,MOD-2);  
          int n,s;
          cin>>n>>s;
          int a[n];
          rep(i,0,n){cin>>a[i];cnt[a[i]]++;}
          int sum=accumulate(a,a+n,0LL);
          if(sum==s)
          {
                cout<<1<<endl;
                return 0;
          }
          if(a[0]<=s)
          dp[0][a[0]]=power(2,n-1);
          rep(i,1,n)
          {
                rep(j,0,s+1)
                {
                      int val=j-a[i];
                      if(val<0){dp[i][j]=dp[i-1][j];continue;}
                      if(val==0)
                      {
                            dp[i][j]=power(2,n-1)+dp[i-1][j];
                            while(dp[i][j]>=MOD)dp[i][j]-=MOD;
                            continue;
                      }
                      dp[i][j]=(INV2*dp[i-1][val])%MOD;
                      dp[i][j]+=dp[i-1][j];
                      while(dp[i][j]>=MOD)dp[i][j]-=MOD;
                }
          }
          int ans=dp[n-1][s];
          cout<<ans<<endl;
      } 
      return 0;                         
}

/*
 TIPS:
 1.) Check for corner cases (like 0 is exception case)
 2.) Check for global memory sizes,memory refreshments and its complexity 
 3.) Check for sorting criteria (if used 1-based indexing)
 4.) Check for numbers overflow (while multiplying and doing MOD)
 5.) Check for typecasting issues like int to float( while dividing numbers)
*/

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define IMP cout << "IMPOSSIBLE" << endl
#define Imp cout << "Impossible" << endl
#define imp cout << "impossible" << endl
#define M1 cout << "-1" << endl
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using vpint = vector<pint>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n = in();
    vint a = in(n);
    rep(i, n)
    {
        if (a[i] % 2 == 0)
        {
            if (a[i] % 6 != 0 && a[i] % 10 != 0)
            {
                puts("DENIED");
                return;
            }
        }
    }
    puts("APPROVED");
}

signed main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int main() {
 string S;
 cin >> S;
 ll ans = 0;
 char c_before = S[0];
 for (ll i = 1; i < S.size(); ++i) 
   if (c_before != S[i]) {
     ans++;
     c_before = S[i];
   }
 cout << ans << endl; 
 return 0;
}


Measured memory_bytes: 512
a=input()
l=["dreamer","eraser","dream","erase"]
for i in range(len(a)//5):
    for i in l:
        if a[-7:]==i:
            a=a[:-7]
        elif a[-6:]==i:
            a=a[:-6]
        elif a[-5:]==i:
            a=a[:-5]
        else:
            pass
if len(a)==0: 
    print("YES")
else:
    print("NO")

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

int main(){
  int a,b;
  cin >> a >> b;
  if(((a+b)/2)*2==a+b){
    cout << (a+b)/2 << endl;
  }
  else{
    cout << (a+b)/2+1 << endl;
  }
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long lint;

#define MOD ((lint)(1e9+7))

int H,W,A,B;
const int MAX_N = 200010;

lint fac[MAX_N], inv[MAX_N];

lint pw(lint x,lint y){
    lint ret = 1;
    while(y){
        if(y & 1){
            ret = (ret * x) % MOD;
        }
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ret;
}

lint cntPath(int x,int y){
    return (fac[x+y]*inv[x]%MOD)*inv[y]%MOD;
}

lint calc(int x,int y){
    return cntPath(x-1,y-1)*cntPath(H-x,W-y)%MOD;
}

int main(){

    scanf("%d%d%d%d",&H,&W,&A,&B);

    fac[0] = 1;
    for(int i=1;i<=H+W;i++){
        fac[i] = (fac[i-1] * i) % MOD;
    }
    inv[H+W] = pw(fac[H+W], MOD-2);
    for(int i=H+W-1;i>=0;i--){
        inv[i] = (inv[i+1] * (i+1)) % MOD;
    }

    lint ans = 0;
    int x=B+1;
    for(int y=H-A;y>=1;y--,x++){
        if(x>W)break;
        ans = (ans + calc(y,x))%MOD;
    }
    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for(int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }


int main() {
    int N;  cin >> N;
    vector<int> p(N); rep(i, N) cin >> p[i];

    vector<int> q(N);
    vector<int> _p(N);
    copy(all(p), _p.begin());
    copy(all(p), q.begin());
    sort(all(q));
    int cnt = 0;
    for (int i=1; i < N; ++i) {
        for (int j=i+1; j <= N; ++j) {
            copy(all(_p), p.begin());
            if (p[i-1] > p[j-1]) {
                int tmp = p[i-1];
                p[i-1] = p[j-1];
                p[j-1] = tmp;
                bool flag = true;
                rep(i, N) {
                    if (p[i] != q[i]) {
                        flag = false;
                    }
                }
                if (flag) {
                    YES;
                    return 0;
                }
                ++cnt;
            }
        }
    }

    if (cnt == 0) YES;
    else NO;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cmath>

using namespace std;

int main()
{
    string X;
    cin>>X;
    int i=0,arr[10];
    while(X[i]!='\0')
    {
        arr[i]=X[i]-'0';
        i++;
    }
    int len,minimum=753,diff;
    len=X.length();
    for(i=0; i<len-2; i++)
    {
        diff=abs((arr[i]*100)+(arr[i+1]*10)+arr[i+2]-753);
        if(diff<minimum)
            minimum=diff;
    }
    cout<<minimum<<endl;

    return 0;
}


Measured memory_bytes: 256