akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
	int n, m, zx, zy;

	cin >> n >> m >> zx >> zy;

	for (size_t i = 0; i < n; i++)
	{
		int x;
		cin >> x;
		if (x > zx)
		{
			zx = x;
		}
	}
	for (size_t i = 0; i < m; i++)
	{
		int y;
		cin >> y;
		if (y < zy)
		{
			zy = y;
		}
	}
	if (zx < zy)
	{
		cout << "No War" << endl;
	}
	else
	{
		cout << "War" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#define INF (1<<21)
using namespace std;

class Point{
public:
  int x,y,c;
  Point(int x = 0,int y = 0,int c = 0):x(x),y(y),c(c){}
};

int main(){
  int i,j,k,l,h,w,sum,ans,gomi[20][20],G[11][11];
  bool f[20][20],f2[20][20];
  string str;
  while(1){
    Point u,v,g;
    cin >> w >> h;
    if(h == 0 && w == 0) break;
    ans = INF;
    sum = 0;

    for(i=0;i<h;i++){
      cin >> str;
      for(j=0;j<w;j++){
	gomi[i][j] = -1;
	f[i][j] = false;
	if(str[j] == 'o') gomi[i][j] = 0;
	else if(str[j] == 'x') f[i][j] = true;
	else if(str[j] == '*') gomi[i][j] = ++sum;
      }
    }
    
    for(i=0;i<sum;i++){
      for(j=i+1;j<=sum;j++){
	for(k=0;k<h;k++){
	  for(l=0;l<w;l++){
	    f2[k][l] = f[k][l];
	    if(gomi[k][l] == i){
	      u.y = k;
	      u.x = l;
	      f2[k][l] = true;
	    }
	    else if(gomi[k][l] == j){
	      g.y = k;
	      g.x = l;
	    }
	  }
	}
	
	queue <Point> Q;
	bool ff = true;
	u.c = 0;
	Q.push(u);
	while(!Q.empty()){
	  u = Q.front();
	  Q.pop();
	  if(g.x == u.x && g.y == u.y){
	    G[i][j] = G[j][i] = u.c;
	    ff = false;
	    break;
	  }
	  u.c++;
	  int dx[4] = {1,0,-1,0};
	  int dy[4] = {0,1,0,-1};
	  for(k=0;k<4;k++){
	    v = u;
	    v.x += dx[k];
	    v.y += dy[k];
	    if(v.x >= 0 && v.x < w && v.y >= 0 && v.y < h && !f2[v.y][v.x]){
		f2[v.y][v.x] = true;
		Q.push(v);
	      }
	   }
	}
	  if(ff){
	    ans = -1;
	    break;
	  }
      }
	if(ans == -1) break;
    }
    
      if(ans != -1){
	int a[11],be,af,A;
	for(i=0;i<=sum;i++) a[i] = i;
	do{
	  if(a[0] != 0) break;
	  A = 0;
	  be = a[0];
	  for(i=1;i<=sum;i++){
	    af = a[i];
	    A += G[be][af];
	    be = af;
	  }
	  ans = min(ans,A);
	} while(next_permutation(a,a+sum+1));
      }
      cout << ans << endl;
		
  }
  return 0;
}

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

 int n;

    bool visited[3000][3000];
    double dp[3000][3000];


double solve( int h, int t , double *p)
{

    if( visited[h][t]==true)
        return dp[h][t];

    else
    {


        if(h>t)
        {
            dp[h][t]=0;
            visited[h][t]=true;
            return 0;
        }


        else if(h==t && t==1)
        {
            dp[h][t]= p[t-1];
            visited[h][t]=true;
            return dp[h][t];
        }

        else if(h==0 && t==1)
        {
            dp[h][t]= 1- p[t-1];
            visited[h][t]=true;
            return dp[h][t];
        }

        else
        {


            dp[h][t] =   ( (h==0)?0: (p[t-1]*solve(h-1,t-1,p) ) )+ (1-p[t-1])*solve(h,t-1,p);
            visited[h][t]=true;
            return dp[h][t];
        }


    }


}
int main()
{

    cin>>n;

    double p[n];
    for(int i=0;i<n;i++)
        cin>>p[i];
for(int i=0;i<=n;i++)
        for(int j=0;j<=n;j++)
            visited[i][j]=false;


    double pro=0;

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

        pro+=solve(i,n,p);

    }
    cout.precision(9);
    cout<<fixed<<pro<<endl;

}





Measured memory_bytes: 78976
m=int(input())
n=int(input())

if m==1 and n==2:
    print(3)
elif m==1 and n==3:
    print(2)
elif m==2 and n==1:
    print(3)
elif m==3 and n==1:
    print(2)
elif m==2 and n==3:
    print(1)
else:
    print(1)


Measured memory_bytes: 2940
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

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 I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def pr(g):
    string = ''
    for row in g:
        string += ''.join([str(x) for x in row])
        string += '\n'
    print(string)

A, B = LI()
def main():
    rev = False
    global A, B
    if A < B:
        A, B = B, A
        rev = True
    h = 100
    w = 100
    g = [[0 for _ in range(w)] for __ in range(h)]
    cnt = 0

    def fill(i=None, j=None):
        global A, B
        filled = False
        if i:
            st = i
        else:
            st = 0
        if j:
            stj = j
        else:
            stj = 0
        # l_i, l_j = 0, 0
        for i in range(st+1, h-1):
            if filled:
                break
            for j in range(w-1):
                if A == 0:
                    filled = True
                    l_i, l_j = i, j
                    break
                if i % 2 == 1 and j % 2 == 1:
                    g[i][j] = 1
                    A -= 1
        return l_i, l_j

    last_i, last_j = fill()

    def fill_left_up(i, j):
        cp_i = i
        if i-1 >= 0:
            while g[i-1][j] == 0:
                g[i-1][j] = 1
                i -= 1
                if i-1 < 0:
                    break
        i = cp_i
        if j-1 >= 0:
            while g[i][j-1] == 0:
                g[i][j-1] = 1
                j -= 1
                if j-1 < 0:
                    break

    first = True
    B -= 1
    for i in range(h-1):
        for j in range(w-1):
            if g[i][j] == 1 and B > 0:
                fill_left_up(i, j)
                B -= 1
                if first:
                    first = False
                else:
                    A += 1

    fill(last_i, last_j)

    A_symbol = '.'
    B_symbol = '#'
    if rev:
        A_symbol, B_symbol = B_symbol, A_symbol
    print(h, w)
    for i in range(h):
        for j in range(w):
            if g[i][j] == 1:
                print(A_symbol, end='')
            else:
                print(B_symbol, end='')
        print()



main()




Measured memory_bytes: 80668
#!/usr/bin/env python3

from itertools import permutations

def main():
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    pm = sorted(permutations(range(1, n + 1)))
    for i, x in enumerate(pm):
        if x == p:
            ip = i
        if x == q:
            iq = i
    print(abs(ip - iq))

if __name__ == "__main__":
    main()


Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> P;
typedef pair<ll, ll> PL;
const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}
 

int n;
int x[101],y[101];
ll h[101];
ll to[101][101];
ll mmm[101][101];

int main(){
    ll memem=-1;
    int ansx,ansy;
    ll ansh = -1;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i] >> h[i];
        to[x[i]][y[i]] = h[i];
        mmm[x[i]][y[i]]++;
        if(memem <= 0) memem = h[i];
    }

    int lllll;
    for(int i = 0; i < n; i++){
        if(h[i] != 0){
            lllll = i;
            break;
        }
    }

    ll mem,mem2;
    int flag;
    for(int i = 0; i <= 100; i++){
        for(int j = 0; j <= 100; j++){
            flag = -1;
            mem2 = 0;
            mem = -1;
            mem = h[lllll] + abs(x[lllll]-i) + abs(y[lllll]-j);
            for(int k = 0; k < n; k++){
                if(to[x[k]][y[k]] != max(mem-abs(i-x[k])-abs(j-y[k]), 0*1LL)){
                    flag = k;
                    break;
                }
            }
            if(flag == -1){
                cout << i << ' ' << j << ' ' << mem << endl;
                return 0;
            }
        }
    }

}

Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 200010
#define LL long long
int Adj[MAXN],V[MAXN*2],nxt[MAXN*2],c;
void AddEdge(int u,int v)
{
	c++;V[c]=v,nxt[c]=Adj[u];Adj[u]=c;
}
int dep[MAXN],f,dcnt,cnt1,cnt2,cnt3,n,m;
void dfs(int u)
{
	dcnt++;
	for(int i=Adj[u];i;i=nxt[i])
		if(!dep[V[i]])
		{
			dep[V[i]]=dep[u]+1;
			dfs(V[i]);
		}
		else if(dep[V[i]]%2==dep[u]%2)
			f=1;
}
int main()
{
	scanf("%d%d",&n,&m);
	int u,v;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	for(int i=1;i<=n;i++)
		if(!dep[i])
		{
			f=0,dcnt=0;
			dep[i]=1;
			dfs(i);
			if(f) cnt1++;
			else if(dcnt>1) cnt2++;
			else cnt3++;
		}
	LL ans=1LL*cnt1+cnt2*2LL+2LL*cnt1*cnt2+1LL*cnt1*(cnt1-1)+2LL*cnt2*(cnt2-1)+2LL*cnt3*n-1LL*cnt3*cnt3;
	printf("%lld\n",ans);
}

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

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

int main(){
  int n;
  cin >> n;
  ll ans = 1;
  for(int i=0; i<n; ++i){
    ll x;
    cin >> x;
    ans = lcm(ans, x);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> p(N);
    rep(i,N) cin >> p[i];

    vector<int> a(N),b(N);
    rep(i,N) a[i] = b[N-1-i] = 30000*(i+1);
    rep(i,N) a[p[i]-1] += i;

    rep(i,N) cout << a[i] << " ";
    cout << endl;
    rep(i,N) cout << b[i] << " ";
    cout << endl;
} 


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

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

typedef long long ll;

class Node {
 public:
  int key;
  Node* parent;
  Node* left;
  Node* right;

  Node() {}
};

Node* NIL;
Node* root;

void Insert(const int& key) {
  Node* y = NIL;
  Node* x = root;
  Node* z = new Node();
  z->key = key;
  z->left = NIL;
  z->right = NIL;

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

Node* Find(Node* x, const int& value) {
  if (value == x->key) {
    return x;
  } else if (value < x->key && x->left != NIL) {
    return Find(x->left, value);
  } else if (value > x->key && x->right != NIL) {
    return Find(x->right, value);
  } else {
    return NIL;
  }
}

void PrintInorder(const Node* node) {
  if (node == NIL) return;
  PrintInorder(node->left);
  cout << " " << node->key;
  PrintInorder(node->right);
}

void PrintPreorder(const Node* node) {
  if (node == NIL) return;
  cout << " " << node->key;
  PrintPreorder(node->left);
  PrintPreorder(node->right);
}

int main() {
  root = NIL;
  int n;
  cin >> n;
  FOR(i, 0, n) {
    string str;
    cin >> str;
    if (str == "insert") {
      int key;
      cin >> key;
      Insert(key);
    } else if (str == "find") {
      int value;
      cin >> value;
      if (Find(root, value) != NIL) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    } else if (str == "print") {
      PrintInorder(root);
      cout << endl;
      PrintPreorder(root);
      cout << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 21904
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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 <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(x % y, y);
}
template <typename T>
struct SegmentTree {
    int n;
    vector<T> node;
    T calc(T a, T b) {
        return gcd(a, b);
    }
    T e = 0;
    SegmentTree(vector<T> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, e);
        for (int i = 0; i < sz; i++) {
            node[i + n - 1] = v[i];
        }
        for (int i = n - 2; i >= 0; i--) {
            node[i] = calc(node[2 * i + 1], node[2 * i + 2]);
        }
    }
    SegmentTree(T sz) {
        n = 1;
        while (n < sz) {
            n *= 2;
        }
        node.resize(2 * n - 1, e);
    }
    void update(int x, T val) {
        x = n + x - 1;
        node[x] = val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = calc(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    void add(int x, T val) {
        x = n + x - 1;
        node[x] += val;
        while (x > 0) {
            x = (x - 1) / 2;
            node[x] = calc(node[2 * x + 1], node[2 * x + 2]);
        }
    }
    T query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return e;
        if (a <= l && r <= b) return node[k];
        T vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
        T vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return calc(vl, vr);
    }
    T at(int x) {
        return node[n + x - 1];
    }
};
int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    SegmentTree<ll> segt(a);
    ll ans = 0;
    rep(i, n) {
        chmax(ans, gcd(segt.query(0, i), segt.query(i + 1, n)));
    }
    cout << ans << endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  string S;
  cin >> N >> S;
  ll ans = 0;
  rep(i, N){
    ll tmp=0;
    string a=S.substr(0, i);
    string b=S.substr(i, N-i);
    cerr << a + " " +b << endl;
    sort(ALL(a)); 
    a.erase(unique(ALL(a)), a.end());
    rep(i, a.size()){
      if(count(ALL(b), a[i])>0){
        tmp++;
      }
    }
    ans = max(tmp, ans);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3548
#include<stdio.h>
#define N 100000

int partition(int [], int, int);

int main()
{
  int i = 0,num,q,A[N];

  while(1)
   {
     scanf("%d",&num);
     if(num >= 1 && num <= N) break;
   }

  while(i<num)
   {
     scanf("%d",&A[i]);
     /*if(A[i] >= 1 && A[i] <= N)*/ i++;
   }

  q = partition(A,0,num);

  for(i = 0;i < num-1;i++)
   {
     if(i == q) printf("[%d] ",A[i]);
     else printf("%d ",A[i]);
   }
  printf("%d\n",A[i]);

  return 0;
}

int partition(int a[], int p, int r)
{
  int i,j,x,swap;
  x = a[r-1];
  i = p-1;

  for(j = p;j  < r;j++)
   {
     if(a[j] <= x)
      {
        i++;
        swap = a[i];
        a[i] = a[j];
        a[j] = swap;
      }
   }

  return i;
}


Measured memory_bytes: 2116
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	string S;
	cin >> S;
	int n = S.length();
	if(S[n-1] == 's'){
		S += "es";
	}else{
		S += "s";
	}
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 3628
// https://atcoder.jp/contests/abc065/tasks/abc065_a
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, a, b;
    cin >> x >> a >> b;
    if (b - a > x) {
        cout << "dangerous" << endl;
    } else if (a >= b) {
        cout << "delicious" << endl;
    } else {
        cout << "safe" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <tuple>
#include <algorithm>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	char arare;
	for (int i = 0; i < N; i++) {
		cin >> arare;
		if (arare == 'Y') {
			cout << "Four";
			return 0;
		}
	}
	cout << "Three";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    ull a, b, x;
    std::cin >> a >> b >> x;
    ull adiv, bdiv = b/x;

    if (a) {
        adiv = (a-1) / x; 
    } else {
        adiv = -1;
    }
    ull ans = bdiv - adiv;

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void) {
    string s = "";
    int countA = 0, countB = 0;
    cin >> s;
    int tmp = -1;
    for(int i = 0; i < s.size(); i++) {
        tmp = s[i] - '0';
        countA += tmp ^ (i % 2);
        countB += tmp ^ ((i + 1) % 2);
    }
    cout << min(countA, countB) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[2001];
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        for (int j = 0; j < i; j++)
        {
            if (a[j] == a[i])
            {
                i--;
                n--;
            }
        }
    }
    cout << n << endl;
}

Measured memory_bytes: 256
function Main(input){
abcde = input.split('\n');
a = parseInt(abcde[0].trim());
e = parseInt(abcde[4].trim());
k = parseInt(abcde[5].trim());

console.log((e-a) > k ? ":(" : "Yay!");

}
Main(require("fs").readFileSync("/dev/stdin","utf-8"));


Measured memory_bytes: 11468
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		FastReader scan = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		Task solver = new Task();
		int t = 1;
		while (t-- > 0)
			solver.solve(1, scan, out);
		out.close();
	}

	static class Task {

		public void solve(int testNumber, FastReader scan, PrintWriter out) {
			String s = scan.next();
			if(s.equals("Sunny")) out.println("Cloudy");
			else if(s.equals("Cloudy")) out.println("Rainy");
			else out.println("Sunny");
		}
	}

	static void shuffle(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static void shuffle(long[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100002];

ll frog1(ll h[], ll n){
	if(n==1)
		return 0;
	if(n==2){
		return abs(h[2]-h[1]);
	}
	if(dp[n]!=-1)
		return dp[n];

	return dp[n] = min(abs(h[n] - h[n-1]) + frog1(h,n-1),abs(h[n] - h[n-2]) + frog1(h,n-2));
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll h[n+1];
    for(int i=1;i<=n;i++){
    	cin>>h[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<frog1(h,n);
}


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

int main(){
  int n;
  cin>>n;
  int money=100000;
  for(int i=0;i<n;i++){
    money*=1.05;
    if(money%1000!=0){
      money-=money%1000;
      money+=1000;
    }
  }
  cout<<money<<endl;
  return 0;
}

Measured memory_bytes: 1160
package main

import "fmt"

func max(a ...int) int {
	m := a[0]
	for i, v := range a {
		if i == 0 {
			continue
		}
		if m < v {
			m = v
		}
	}
	return m
}
func main() {
	// Code for B - K Cakes
	var K, T int
	fmt.Scan(&K, &T)

	a := make([]int, T)
	var maxNum int
	var sum int
	for i := 0; i < T; i++ {
		fmt.Scan(&a[i])
		if maxNum < a[i] {
			maxNum = a[i]
		}
		sum += a[i]
	}

	ans := max(0, maxNum-(sum-maxNum)-1)
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>

using namespace std;
using lli = long long int;
// #define DEBUG
#ifdef DEBUG
#define debug(var) cout << (#var) << ": " << (var) << endl;
template<class T> void dump_array_impl(const T& a) {
  bool first = true;
  for (auto&& x : a) {
    if (!first) cout << ", "; else first = false;
    cout << x;
  }
}
#define debug_array(a) cout<<(#a)<<": ";dump_array_impl(a);cout<<endl
#else
#define debug(var) {}
#define debug_array(a) {}
#endif
template<class T> void read_n(vector<T>& v, size_t n) {
  v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i];
}
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
int main() {
  cin >> n;
  lli sign = 1;
  if (n<0) { n=-n; sign=-1; }
  lli y = 0;
  lli b = 1;
  for (; n!=0; b<<=1) {
    if (n&b) {
      y |= b;
      n -= sign*b;
    }
    sign = -sign;
  }
  bool f = false;
  for (lli m=1ll<<31; m>0; m>>=1) {
    if (y&m) f = true;
    if (f) cout << (y&m ? '1' : '0');
  }
  if (!f) cout << '0';
  cout << endl;
  return 0;
}


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

int main() {
    long long n,k,x,y,ans=0;
    cin>>n>>k>>x>>y;
    for(int i=1;i<=n;i++){
        if(i<=k){
            ans=ans+x;
        }
        else{
            ans=ans+y;
        }
    }
    cout<<ans<<endl;

    return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;



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

	ll N, K;
	cin >> N >> K;

	if ((N+1)/2 / K >= 1)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;

	}

	//system("pause");
}


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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

const long long mod = 1000000007;
const long long inf = 1e18;

int arr[100002];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int k;
        cin>>k;
        arr[k]+=1;
        arr[k-1]+=1;
        arr[k+1]+=1;
    }
    int ans=0;
    for(int i=0;i<100002;i++){
        if(arr[i]>ans){
            ans=arr[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n;
	int i;
	int sum = 0;
	int maxd=101;
	cin >> n;
	vector<int>a(n, 0);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<int>());
	for (i = 0; i < n; i++) {
		if (a[i] < maxd) {
			maxd = a[i];
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> r(N);
  
  for(int i = 0; i < M; i++){
    int a, b;
    cin >> a >> b;
    r.at(a - 1)++;
    r.at(b - 1)++;
  }
  
  for(int i = 0; i < r.size(); i++)
    cout << r.at(i) << endl;
}

Measured memory_bytes: 3620
fun main(args: Array<String>) {

    val n = readLine()!!.toInt()
    val x = readLine()!!.split(" ").map { it.toInt() }

    var min = Int.MAX_VALUE
    
    for(p in 1..100){
        var sum = 0
        for(i in 0 until n){
            sum += (x[i] - p) * (x[i] - p)
        }
        if(sum < min) min = sum
    }

    println(min)
}

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

int main() {
	string S, A = "", B = "";
	cin >> S;
	long long Q, NOW = 0;
	cin >> Q;
	for (int i = 0; i < Q; i++) {
		long long T;
		cin >> T;
		if (T == 1) NOW = 1 - NOW;
		else {
			long long F;
			char C;
			cin >> F >> C;
			if (F == 1) {
				if (NOW == 0) A += C;
				else B += C;
			}
			else {
				if (NOW == 0) B += C;
				else A += C;
			}
		}
	}
	if (NOW == 0) {
		reverse(A.begin(), A.end());
		cout << A << S << B << endl;
	}
	else {
		reverse(S.begin(), S.end());
		reverse(B.begin(), B.end());
		cout << B << S << A << endl;
	}
}


Measured memory_bytes: 1088
n = gets.to_i
arr = gets.chomp.split(' ').map(&:to_i)
count, max = 0, 0
0.upto(n - 2) do |i|
  if arr[i] >= arr[i + 1]
    count += 1
  else
    max = [max, count].max
    count = 0
  end
end
max = [max, count].max
puts max

Measured memory_bytes: 12036
#include <iostream>
 
using namespace std;
 
int main(void) {
  int N, L;
  cin >> N >> L;
  int S = 0;
  for (int i = 0; i < N; i++) {
    S += L + i;
  }
  if (L <= 0 && L + N - 1 >= 0) {
    cout << S << endl;
  } else {
    if (L > 0) {
      cout << S - L << endl;
    } else {
      cout << S - (L + N - 1) << endl;
    }
  }
  return 0;
}


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

int main() {
 int R,G,T;
  cin>>R>>G;
  T=(R+G)/2;
  if(R%2==G%2){
    T=T;
  }
  else{
    T++;
  }
    
  
  cout<<T<<endl;
}
      
    




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf 200000000000000000LL
#define N 200050
using namespace std;
typedef long long ll;

int n, q;

ll A[N], bit[N], ans, S, T;

void upd(int l, int r, int x)
{
	if(1 <= l && l <= n + 1) for(int i = l; i < N; i += (i&-i)) bit[i] += x;

	if(1 <= r + 1&& r + 1 <= n + 1) for(int i = r + 1; i < N; i += (i&-i)) bit[i] -= x;
}

ll query(int x)
{
	ll aux = 0;

	if(x <= 0 || x > n + 1) return inf;

	for(int i = x; i > 0; i -= (i&-i)) aux += bit[i];

	return aux;
}

int32_t main()
{
	scanf("%d %d %lld %lld", &n, &q, &S, &T);

	for(int i = 1; i <= n + 1; i++) scanf("%lld", &A[i]), upd(i, i, A[i]);

	for(int i = 1; i <= n; i++) ans += (A[i] <= A[i + 1] ? (- A[i + 1] + A[i])*S : (A[i] - A[i + 1])*T);

	for(int i = 1; i <= q; i++)
	{
		int li, ri, xi;

		cin>>li>>ri>>xi;

		li ++, ri ++;

		ll Hl = query(li);

		ll Hr = query(ri);

		ll H_depois = query(ri + 1);

		ll H_antes = query(li - 1);

		upd(li, ri, xi);

		ll dl = 0, dr = 0;

		if(H_antes != inf && H_antes <= Hl) dl -= abs(Hl - H_antes)*S ;

		else if(H_antes  != inf) dl += abs(Hl - H_antes)*T;

		if(Hr <= H_depois && H_depois != inf) dr -= abs(H_depois - Hr)*S ;

		else if(H_depois != inf) dr += abs(H_depois - Hr)*T;

		ans = ans - dl - dr;

		Hl += xi, Hr += xi;

		dl = 0, dr = 0;

		if(H_antes <= Hl&& H_antes != inf) dl -= abs(Hl - H_antes)*S ;

		else if(H_antes != inf) dl += abs(Hl - H_antes)*T;

		if(Hr <= H_depois && H_depois != inf) dr -= abs(H_depois - Hr)*S ;

		else if(H_depois != inf) dr += abs(H_depois - Hr)*T;

		ans += dl + dr;

		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 6344
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  string S,T;
  cin >> S >> T;
  bool ans = true;
  int count[26][26];
  for (int i = 0; i < 26; i++) {
    for (int j = 0; j < 26; j++) {
      count[i][j] = 0;
    }
  }

  for (int i = 0; i < (int)S.size(); i++) {
    int c = S[i] - 'a';
    int d = T[i] - 'a';
    count[c][d]++;
  }

  for (int i = 0; i < 26; i++) {
    int cnt = 0;
    for (int j = 0; j < 26; j++) {
      if (count[i][j] > 0) {
        cnt++;
      }
    }
    if (cnt >= 2) {
      ans = false;
    }
  }
  for (int i = 0; i < 26; i++) {
    int cnt = 0;
    for (int j = 0; j < 26; j++) {
      if (count[j][i] > 0) {
        cnt++;
      }
    }
    if (cnt >= 2) {
      ans = false;
    }
  }

  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl; 
  return 0;
}

Measured memory_bytes: 3916
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)


struct Problem {
	
	void Solve() {
		UL N; cin >> N;
		bool m = false;
		ULL ans = 0;
		rep(i, N) {
			UL a; cin >> a;
			if (m && a > 0) { ans++; a--; }
			m = a % 2 == 1;
			ans += a / 2;
		}
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn=new Scanner (System.in);
		int a=stdIn.nextInt();
		
		if(a/100==a%10)
		System.out.println("Yes");
		else
			System.out.println("No");
			
	}

}


Measured memory_bytes: 20820
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int solve(const string& S, const vector<pair<char, int>>& query){
    int L = -1, R = S.size();
    while(R-L > 1){
        int mid = (L+R)/2;
        int pos = mid;
        for(auto& q : query){
            if(S[pos] != q.first) continue;
            pos += q.second;
            if(pos < 0 || S.size() <= pos) break;
        }
        if(pos < 0) L = mid;
        else R = mid;
    }
    return L + 1;
}

int main(){
    int N, Q; cin >> N >> Q;
    string s; cin >> s;
    vector<pair<char, int>> query;
    for(int i=0;i<Q;i++){
        string t, d; cin >> t >> d;
        query.emplace_back(t[0], d[0]=='R'?1:-1);
    }
    int res = N - solve(s, query);
    reverse(s.begin(), s.end());
    for(auto& q : query) q.second = -q.second;
    res -= solve(s, query);
    cout << res << endl;
}

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

int main() {
    string S;
    cin >> S;
    bool is_ok = true;
    if (S[0] != 'A')
        is_ok = false;

    int cnt = 0;
    for (int i = 1; i < S.size(); i++) {
        if (isupper(S[i])) {
            if (i == 1 || i == S.size() - 1 || S[i] != 'C')
                is_ok = false;
            cnt++;
        }
    }
    if (cnt != 1)
        is_ok = false;

    if (is_ok) {
        cout << "AC" << endl;
    } else {
        cout << "WA" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a >= 13) {
            System.out.println(b);
        } else if (a <= 5) {
            System.out.println(0);
        } else {
            System.out.println(b/2);
        }
    }
}

Measured memory_bytes: 23252
import java.util.Scanner;

public class Main{
	public static void main(String[]args) {
		
		Scanner sc=new Scanner(System.in);
		
		int N=sc.nextInt();
		int D=sc.nextInt();
		
		int num=N-2*D-2;
		
		if(2*D+1>=N) {
			System.out.println(1);
		}else {
		int x=(int)Math.ceil(num/(2*D+1));
		System.out.println(x+2);
		}
		sc.close();
	}
}

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

#define lld long long
#define pi pair<int,int>
#define pl pair<lld,lld>
#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())

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

Measured memory_bytes: 3620
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>

using namespace std;

const int N = 1e5 + 5;
int n;
int a[N];
int maxi, mini;

int main() 
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	mini = a[0];
	maxi = a[n - 1];
	if (maxi - mini > 1)
	{
		cout << "No";
		exit(0);
	}
	if (maxi == mini && (n >= maxi * 2 || maxi == n - 1))
	{
		cout << "Yes";
		exit(0);
	}
	if (maxi == mini)
	{
		cout << "No";
		exit(0);
	}
	int cnt = 0;
	for (int i = 0 ; i < n; i++)
	{
		if (a[i] == mini)
		{
			cnt++;
		}
	}
	if (cnt > mini)
	{
		cout << "No";
		exit(0);
	}
	maxi = maxi - cnt;
	if (maxi == 0 && n - cnt > 0)
	{
		cout << "No";
		exit(0);
	}
	if ((n - cnt) >= maxi * 2)
	{
		cout << "Yes";
		exit(0);
	}
	else
	{
		cout << "No";
		exit(0);
	}

}


Measured memory_bytes: 640
using System;
using static AtCoderTemplate.MyLibrary;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ToIntArray(Console.ReadLine().Split(' '));
            int a = input[0],b = input[1];
            double h = input[2],m = input[3];
            double drB = m * 360 / 60;
            double drA = (h * 360 + drB) / 12;
            double[] PA = calcXY(a, drA);
            double[] PB = calcXY(b, drB);
            double len = Math.Sqrt(Math.Pow((PA[0] - PB[0]),2) + Math.Pow((PA[1] - PB[1]),2));
            Console.WriteLine(len);

            //Console.WriteLine("Hello World!");
        }
    }
    //2回位使ったら追加する
    class MyLibrary
    {
        public static int[] ToIntArray(string[] stringArray)
        {
            int length = stringArray.Length;
            int[] intArray = new int[length];
            for (int i = 0; i < length; i++)
            {
                intArray[i] = int.Parse(stringArray[i]);
            }
            return intArray;
        }
        public static double[] calcXY(int r, double degree)
        {
            int rotation = (int)degree;
            double[] YX = new double[2];
            double radian = degree  * Math.PI/180;
            YX[1] = Math.Sin(radian) * r;
            YX[0] = Math.Cos(radian) * r;
            return YX;
        }
    }
}

Measured memory_bytes: 27900
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


def main():
    N, M, K = map(int, input().split())
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(1,N):
        ans += i * (N - i) * M * M
        ans %= mod

    for j in range(1,M):
        ans += j * (M - j) * N * N
        ans %= mod

    ans *= cmb(N*M-2,K-2,mod)
    print(ans%mod)
    



if __name__ == "__main__":
    main()

Measured memory_bytes: 129620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
struct Edge {
  int to, id;
  Edge(int to, int id): to(to), id(id) {}
};
 
vector<Edge> g[55];
 
vector<int> es;
bool dfs(int v, int tv, int p=-1) {
  if (v == tv) return true;
  for (Edge e : g[v]) {
    if (e.to == p) continue;
    if (dfs(e.to, tv, v)) {
      es.push_back(e.id);
      return true;
    }
  }
  return false;
}
 
int main() {
  int n, m;
  cin >> n;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].emplace_back(b, i);
    g[b].emplace_back(a, i);
  }
 
  cin >> m;
  vector<ll> eset(m);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    es = vector<int>();
    dfs(a,b);
    for (int e : es) {
      eset[i] |= 1ll<<e;
    }
  }
 
  ll ans = 0;
  rep(i,1<<m) {
    ll mask = 0;
    rep(j,m) {
      if (i>>j&1) mask |= eset[j];
    }
    int white = __builtin_popcountll(mask);
    ll now = 1ll<<(n-1-white); // 2^(n-1-white)
    if (__builtin_popcountll(i)%2 == 0) ans += now;
    else ans -= now;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,A,f=0;
  cin>>N;
  vector<int> Ao(N);
  for(int i=0;i<N;i++){
    cin>>A;
    if(A%2==0){
      if(A%3!=0&&A%5!=0) f=1;
    }  
  }
  
  
  
  if(f==1) cout<<"DENIED";
  else cout<<"APPROVED";
  

}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() { 
 
  int64_t h,w,K,ans=0;
  cin>>h>>w>>K;
  vector<string> A(6),cA(6),bA(6);
  vector<int> B(h);
  for(int i=0; i<h; i++){cin>>A[i];for(int j =0; j<6-w; j++){A[i].push_back('a');}}
  for(int i=h; i<6; i++){A[i] = "aaaaaa";}
  cA=A;
//   for(int p=0; p<6; p++){
// cout<<cA[p]<<endl;
//      }
bool next=false;
  for (int i = 0; i < (1 << 6); i++) {
    next = false;
    for(int k = 0; k<6; k++){
      if(i & (1<<k)){
        cA[k]="aaaaaa";
        if(k+1 >h) next = true;
      }
    }
    if(next){cA=A;continue;}
    bA=cA;
    for (int i2 = 0; i2 < (1 << 6); i2++) {
      next =false;
    int tmp=0;
    // if(!next)next=false;
    for(int k2 = 0; k2<6; k2++){
      if(i2 & (1<<k2)){
        if(k2+1>w)next=true;
        for(int h2 =0; h2<6; h2++){
         cA[h2][k2]='a'; 
        }
      }
    }
    if(next){cA=bA;continue;}

    for(int p=0; p<6; p++){
    for(int p2=0; p2<6; p2++){
    if(cA[p][p2]=='#' && !next)tmp++;
    }
    }
    // for(int p=0; p<6; p++){
    //   cout<<cA[p]<<endl;
    // }cout<<endl;

    // cout<<tmp<<endl;
    if(tmp == K){ans++; 

    // for(int p=0; p<6; p++){
    //   cout<<cA[p]<<endl;
    // }cout<<endl;cout<<i<<" "<<i2<<endl;
    }
    cA=bA;
   }
    cA=A;
   }

  cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int N,K;cin>>N>>K;
	string s;cin>>s;
	char temp='s';int count=0;int sum=0;int k=0;
	rep(i,0,N){
		if(s.at(i)==temp) count++;
		else{ sum+=count;count=0;temp=s.at(i);k++; }
	}sum+=count;
    //cout<<sum<<endl;
    if(k%2==0){
        k=k/2;
	    if(K<=k-1) sum+=2*K;
	    else sum+=2*k-1;
    }else{
	    sum+=2*min(k/2,K);
    }
	cout<<sum<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <stack>
#include <cstdio>
using namespace std;
// int a[10];
// bool ans;
// void dfs(int i,int r,int l){
// 	if(i==10)ans=1;
// 	if(ans)return;
// 	if(a[i]<r&&a[i]<l)return;
// 	if(r<a[i])dfs(i+1,a[i],l);
// 	if(l<a[i])dfs(i+1,r,a[i]);

// }
// int main(){
// 	int t;
// 	cin>>t;
// 	while(t--){
// 		ans=0;
// 		for(int i=0;i<10;i++)cin>>a[i];
// 		dfs(0,0,0);
// 		if(ans)cout<<"YES"<<endl;
// 		else cout<<"NO"<<endl;
// 	}
// }

int main(){
	int a[10];
	for(int i=0;i<10;i++)cin>>a[i];
	sort(a,a+10);
	for(int i=9;i>=7;i--)cout<<a[i]<<endl;
	return 0;
}

Measured memory_bytes: 1176
n=int(input())
k=[2]
mod=10**9+7
for i in range(2,n+1):
    for j in range(len(k)):
        if i%k[j]==0:
            break
    else:
        k.append(i)
h=[1 for i in range(len(k))]
for i in range(2,n+1):
    c=0
    while i!=1:
        if i%k[c]==0:
            i=i/k[c]
            h[c]+=1
        else:
            c+=1
p=1
for i in range(len(k)):
    p=(p*h[i])%mod
print(p)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define endl            "\n"
#define forn(i,x1,n)     for(int i=x1; i<n; i++)
#define forit(it, m)    for(decltype(m)::iterator it = m.begin(); it!=m.end(); ++it)
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x1)      __builtin_popcountll(x1)
#define zrobits(x1)      __builtin_ctzll(x1)
#define mod             1000000007
#define inf             1e18
#define ps(x1,y)         fixed<<setprecision(y)<<x1
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x1)            int x1; cin>>x1; while(x1--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void zeus()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int32_t main() {

    zeus();

    string n; cin >> n;

    int sum = 0;

    forn(i, 0, n.length()) {
        sum += (n[i] - '0');
    }

    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }



}








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


int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A.at(i);
    while (true) {
        sort(A.begin(), A.end());
        int position = distance(A.begin(), upper_bound(A.begin(), A.end(), 0));
        ll mod = A.at(position);
        for (auto i = position + 1; i < N; ++i) {
            A.at(i) %= mod;
        }
        if (position == N - 1) {
            cout << A.at(position) << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3984