akhauriyash/Code-Regression huggingface dataset:
//
// Created on 2020/09/01.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {

    vector<int>list(100005,0);
    for (int i = 2; i < 100005; ++i) {
        for (int j = i + i; j < list.size(); j = j + i) {
            list[j] ++;
        }
    }

    vector<int>like_list(100005,0);
    for (int i = 3; i < 100005; i ++) {
        if(list[i] == 0 && list[(i+1)/2] == 0){
            like_list[i]++;
        }
        like_list[i] = like_list[i - 1]+like_list[i];
    }

    int q;
    cin>>q;
    for (int k = 0; k < q; ++k) {
        int l,r;
        cin>>l>>r;
        int ans = like_list[r]-like_list[l-2];
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3868
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		String s;
		Scanner scan = new Scanner(System.in);
		int[] c = new int[26];
		for(int i=0;i<c.length;i++){
			c[i]=0;
		}
		
		while(scan.hasNext()){
			s=scan.nextLine();
			char[] temp = s.toCharArray();
			for(int i=0;i<temp.length;i++){
				if(temp[i]>=65&&temp[i]<=90){
					c[temp[i]-65]+=1;
				}
				else if(temp[i]>=97&&temp[i]<=122){
					c[temp[i]-97]+=1;
				}
			}
		}
		scan.close();
		
		for(int i=0;i<c.length;i++){
			System.out.println((char)('a'+i)+" : " + c[i]);
		}
	}
}


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

using namespace std;

using int64 = long long;

int main() {
  int N;
  cin >> N;
  map< int, int > mp;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    mp[-x]++;
  }
  int ret = 0;
  for(auto _ : mp) {
    pair< int, int > p = _;
    p.first *= -1;

    vector< int64 > elems;
    for(int64 j = 31; j >= 0; j--) {
      int64 mul = (1LL << j);
      int64 rest = mul - p.first;
      if(rest > 0) elems.push_back(rest);
    }
    int rest = p.second;
    for(auto q : elems) {
      if(!mp.count(-q)) continue;

      if(q == p.first) {
        int get = rest / 2;
        rest -= get * 2;
        ret += get;
      } else {
        int get = min(rest, mp[-q]);
        mp[-q] -= get;
        rest -= get;
        ret += get;
      }
    }
    mp[_.first] = rest;
  }
  cout << ret << endl;
}

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILL(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};

ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


ll mod_comobination(ll n,ll r){
  if(n == r || !n || !r)return 1;
  ll n_ = n;
  REP(i,r){
    if(!i)continue;
    n_ *= (n-i);
    n_ %= MOD;
    n_ = (n_*modinv(i,MOD))%MOD;
  }
  return (n_*modinv(r,MOD))%MOD;
}


int main(){

  int x,y;
  cin >> x >> y;

  ll a,b;
  if((2*x - y) >= 0 && (2*y - x) >= 0){
    if(!((2*y - x)%3) && !((2*x - y)%3)){
      a = (2*y - x)/3,b = (2*x - y)/3;
    }else{
      cout << 0;
      return 0;
    }
  }else{
    cout << 0;
    return 0;
  }
  cout << mod_comobination(a+b,min(a,b));

  return 0;
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

double add(double a, double b) {
  if(abs(a + b) < 1e-10 * (abs(a) + abs(b))) return 0;
  return a + b;
}

struct PT {
  int n;
  double x, y;
  PT() {}
  PT(double x, double y) : x(x), y(y) {}
  PT operator - (PT p) {
    return PT(add(x, -p.x), add(y, -p.y));
  }
  double det(PT p) {
    return add(x * p.y, -y * p.x);
  }
};

bool cmp(PT f, PT s) {
  if(f.x != s.x) return f.x < s.x;
  return f.y < s.y;
}

vector<PT> convex(PT* m, int n) {
  sort(m, m + n, cmp);
  int k = 0;
  vector<PT> q(n * 2);
  rep(i, 0, n) {
    while(k > 1 && (q[k - 1] - q[k - 2]).det(m[i] - q[k - 1]) <= 0) k--;
    q[k++] = m[i];
  }
  int t = k;
  dep(i, n - 2, 0) {
    while(k > t && (q[k - 1] - q[k - 2]).det(m[i] - q[k - 1]) <= 0) k--;
    q[k++] = m[i];
  }
  q.resize(k - 1);
  return q;
}

int v, r;
PT m[101], mc[101];
int par[101];
vector<pair<double, P> > mt(1001);

int find(int x) {
  return par[x] = par[x] == x ? x : find(par[x]);
}

void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if(x != y) par[x] = y;
  return;
}

signed main() {
  cin >> v >> r;
  rep(i, 0, v) cin >> m[i].x >> m[i].y, m[i].n = i, par[i + 1] = i + 1;
  rep(i, 0, v) mc[i] = m[i];
  rep(i, 0, r) {
    int a, b;
    cin >> a >> b;
    int x = abs(m[--a].x - m[--b].x);
    int y = abs(m[a].y - m[b].y);
    double dist = sqrt((x * x) + (y * y));
    mt.pb({dist, P(a, b)});
  }

  vector<PT> vp = convex(m, v);
  double ans = 0;

  rep(i, 0, vp.size()) {
    int x = abs(mc[vp[i].n].x - mc[vp[i + 1 % vp.size()].n].x);
    int y = abs(mc[vp[i].n].y - mc[vp[i + 1 % vp.size()].n].y);
    ans += sqrt(x * x + y * y);
    unite(vp[i].n, vp[i + 1 % (vp.size())].n);
  }

  sort(mt.begin(), mt.end());

  rep(i, 0, mt.size()) {
    P p = mt[i].second;
    if(find(p.first) != find(p.second)) {
      unite(p.first, p.second);
      ans += mt[i].first;
    }
  }
  cout << fixed << ans << endl;
}



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;

    auto countD = [](i64 x) {
        return (i64)(to_string(x).length());
    };

    i64 minf = 10000000;
    for (i64 a = 1; a * a <= N; a++) {
        if (N % a > 0) continue;
        i64 b = N / a;
        chmin(minf, max(countD(a), countD(b)));
    }
    cout << minf << endl;

    return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n;
ll p;
string s;
ll dp[maxn];
ll ans=0;

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

  cin>>n>>p;
  cin>>s;
  if (p==2) {
    for (int i=0; i<n; i++) {
      if ((s[i]-'0')%2==0) ans += i+1;
    }
  } else if (p==5) {
    for (int i=0; i<n; i++) {
      if ((s[i]-'0')%5==0) ans += i+1;
    }
  } else {
    ll cur = 0;
    dp[0] = 1;
    ll pw10 = 1;
    for (int i=n-1; i>=0; i--) {
      cur = (cur+pw10*(s[i]-'0')%p)%p;
      ans += dp[cur];
      dp[cur]++;
      pw10 = 10LL*pw10%p;
    }
  }
  cout<<ans<<endl;
  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 720
import sys
input = sys.stdin.readline
n=int(input())
G=[[]for _ in range(n+1)]
for _ in range(n-1):
    u,v,w=map(int,input().split())
    w%=2
    G[u].append((v,w))
    G[v].append((u,w))
ans=[-1]*(n+1)
#dfs?
stack=[1]
ans[1]=1
while stack:
    t=stack.pop()
    color_t=ans[t]
    for w in G[t]:
        ten,kyori=w
        if ans[ten]==-1:
            if kyori==0:
                ans[ten]=color_t
            else:
                ans[ten]=color_t+1
                ans[ten]%=2
            stack.append(ten)
print(*ans[1::], sep='\n')


Measured memory_bytes: 37172
#include <cstdio>

#define maxn 100000
#define ll long long

char com (char a) {
    if (a == 'S')
        return 'W';
    else
        return 'S';
}
inline int check (char a, char b, int n, char f[]) {
    char start1 = a;
    char start2 = b;
    char c;
    for (int i = 3; i <= n + 2; i++) {
        if (b == 'S' && f[i - 1] == 'o')
            c = a;
        if (b == 'S' && f[i - 1] == 'x')
            c = com(a);
        if (b == 'W' && f[i - 1] == 'o')
            c = com(a);
        if (b == 'W' && f[i - 1] == 'x')
            c = a;
        a = b;
        b = c;
    }
    if (a == start1 && b == start2)
        return 1;
    return 0;
}
inline void afisare(char a, char b, int n, char f[]) {
    char c;
    printf("%c%c", a, b);
    for (int i = 3; i <= n; i++) {
        if (b == 'S' && f[i - 1] == 'o')
            c = a;
        if (b == 'S' && f[i - 1] == 'x')
            c = com(a);
        if (b == 'W' && f[i - 1] == 'o')
            c = com(a);
        if (b == 'W' && f[i - 1] == 'x')
            c = a;
        printf("%c", c);
        a = b;
        b = c;
    }
}
char f[maxn + 2];

int main() {
    int n;
    scanf("%d", &n);
    char x = fgetc(stdin);
    for (int i = 1; i <= n; i++)
        f[i] = fgetc(stdin);
    f[n + 1] = f[1];
    char d1[] = {'S', 'W', 'S', 'W'};
    char d2[] = {'S', 'W', 'W', 'S'};
    int rep = 0;
    for (int i = 0; i <= 3 && rep == 0; i++) {
        rep = check(d1[i], d2[i], n, f);
        if (rep == 1)
            afisare(d1[i], d2[i], n, f);
    }
    if (rep == 0)
        printf("-1");
    return 0;
}


Measured memory_bytes: 384
code = """

# distutils: language=c++
# distutils: include_dirs=[/home/contestant/.local/lib/python3.8/site-packages/numpy/core/include, /opt/atcoder-stl]
# cython: boundscheck=False
# cython: wraparound=False


cdef extern from "<atcoder/fenwicktree>" namespace "atcoder":
    cdef cppclass fenwick_tree[T]:
        fenwick_tree(int n)
        void add(int p, T x)
        T sum(int l, int r)

cdef class FenwickTree:
    cdef fenwick_tree[long long] *_thisptr
    def __cinit__(self, int n):
        self._thisptr = new fenwick_tree[long long](n)
    cpdef void add(self, int p, long long x):
        self._thisptr.add(p, x)
    cpdef long long sum(self, int l, int r):
        return self._thisptr.sum(l, r)
"""


import os,sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    open('atcoder.pyx','w').write(code)
    os.system('cythonize -i -3 -b atcoder.pyx')


from atcoder import FenwickTree

N,Q = list(map(int,input().split()))
A = list(map(int,input().split()))
fw = FenwickTree(N)
for i, a in enumerate(A):
    fw.add(i,a)

for i in range(Q):
    a,b,c = list(map(int,input().split()))
    if a==0:
        fw.add(b,c)
    else:
        print(fw.sum(b,c))

Measured memory_bytes: 70036
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;

namespace Competitive
{
    internal class Solution
    {
        public int sx, sy, tx, ty, xx, yy;
        public long MOD = 1000000007;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                sx = line[0];
                sy = line[1];
                tx = line[2];
                ty = line[3];
                xx = tx - sx;
                yy = ty - sy;
            }

            var ret = new StringBuilder();
            for (int i = 0; i < xx; i++)
            {
                ret.Append('R');
            }
            for (int i = 0; i < yy; i++)
            {
                ret.Append('U');
            }

            for (int i = 0; i < xx; i++)
            {
                ret.Append('L');
            }
            for (int i = 0; i < yy; i++)
            {
                ret.Append('D');
            }

            ret.Append('D');
            for (int i = 0; i < xx+1; i++)
            {
                ret.Append('R');
            }
            for (int i = 0; i < yy+1; i++)
            {
                ret.Append('U');
            }
            ret.Append('L');

            ret.Append('U');
            for (int i = 0; i < xx+1; i++)
            {
                ret.Append('L');
            }
            for (int i = 0; i < yy+1; i++)
            {
                ret.Append('D');
            }
            ret.Append('R');
            
            Console.WriteLine(ret.ToString());
        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 11304
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int k,x;
  cin >> k >> x;
  if(500*k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;
using plll = pair<ll,pll> ;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m,N,M,t,s;
  while(cin >> N >> M && N+M){
    vector<vector<plll>> v(N),v2(M);
    ll r,q;
    cin >> r;
    rep(i,r){
      cin >> t >> n >> m >> s;
      if(s){
        plll p = mp(n,mp(t,-1));
        v[n-1].push_back(p);
        v2[m-1].push_back(p);
      }
      else{
        v[n-1].back().se.se = t;
        for(int x = v2[m-1].size()-1; x >= 0; --x){
          if(v2[m-1][x].fi == n && v2[m-1][x].se.se == -1LL){
            v2[m-1][x].se.se = t;
            break;
          }
        }
      }
    }
    ll ts,te;
    cin >> q;
    ll inf = 1000000LL;
    rep(i,q){
      ll res = 0,ma = -1,mi = inf;
      cin >> ts >> te >> m;
      rep(j,v2[m-1].size()){
        auto u = v2[m-1][j].se;
        if(mi == inf){
          mi = max(ts,u.fi);
          ma = min(te,u.se);
        }
        else if(u.fi <= ma){
          mi = max(ts,min(mi,u.fi));
          ma = min(te,max(ma,u.se));
        }
        else{
          if(ma - mi > 0)
            res += ma - mi;
          mi = max(ts,u.fi);
          ma = min(te,u.se);
        }
//         if(v2[m-1][j].se.fi >= ts || v2[m-1][j].se.se <= te)
//           res += min(v2[m-1][j].se.se,te) - max(v2[m-1][j].se.fi,ts);
      }
      if(ma - mi > 0)
        res += ma - mi;
      cout << res << endl;
    }
  }
  return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	string s;
	int q;
	cin>>s>>q;
	deque<char> que;
	for(auto c: s)que.push_back(c);

	bool rev=false;
	rep(i,q){
		int t;
		cin>>t;
		if(t==1){
			if(rev)rev=false;
			else rev=true;
			continue;
		}
		int f;
		char c;
		cin>>f>>c;
		if(rev){
			if(f==1)que.push_back(c);
			else que.push_front(c);
		}else{
			if(f==1)que.push_front(c);
			else que.push_back(c);
		}
	}
	string ans;
	for(auto x:que)ans+=x;
	if(rev) reverse(all(ans));
	cout<<ans<<endl;
	return 0;
}

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

const int MOD = 998244353, N = 1E7 + 5;

int n;
long long ans = 1, pw[N], inv[N], fct[N], ifc[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    inv[1] = 1;
    for (int i = 2; i <= n; i++) {
        inv[i] = MOD - MOD / i * inv[MOD % i] % MOD;
    }
    fct[0] = ifc[0] = pw[0] = 1;
    for (int i = 1; i <= n; i++) {
        fct[i] = fct[i - 1] * i % MOD;
        ifc[i] = ifc[i - 1] * inv[i] % MOD;
        pw[i] = pw[i - 1] * 2 % MOD;
        (ans *= 3) %= MOD;
    }
    for (int i = n / 2 + 1; i <= n; i++) {
        long long cur = fct[n] * ifc[i] % MOD * ifc[n - i] % MOD;
        (cur *= pw[n - i] * 2) %= MOD;
        (ans += MOD - cur) %= MOD;
    }
    cout << ans;
}


Measured memory_bytes: 312704
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;


const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;




pii p[100005];

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

  int n,m;
  cin >> n >> m;
  priority_queue<D> q;

  rep1(i,n) {
    D tmp;
    cin >> tmp;
    q.push(tmp);
  }


  rep(i,m){
    D tmp;
    tmp = q.top();
    tmp /= 2;
    q.pop();
    q.push(tmp);
  }


  long ans = 0;

  while(!q.empty()){
    long tmp = q.top();
    ans+=tmp;
    q.pop();
  }

  cout << ans << endl;



  return 0;

}


Measured memory_bytes: 2420
#include<iostream>
using namespace std;
const int MAX_BURDEN = 45;
const int MAX_GRAM = 405;
const int INF = 1 << 30;


int nVal, MA, MB;

// val[i][0]: a_i
// val[i][1]: b_i
// val[i][2]: c_i
int val[MAX_BURDEN][3];

void read() {
    cin >> nVal >> MA >> MB;

    for (int i = 0; i < nVal; ++i) {
        for (int j = 0; j < 3; ++j) {
            cin >> val[i][j];
        }
    }
}


void work() {
    int dp[MAX_GRAM][MAX_GRAM];
    
    for (int i = 0; i < MAX_GRAM; ++i) {
        for (int j = 0; j < MAX_GRAM; ++j) {
            dp[i][j] = INF;
        }
    }
    dp[0][0] = 0;

    for (int i = 0; i < nVal; ++i) {
        for (int aGram = MAX_GRAM - 1; aGram >= 0; --aGram) {
            for (int bGram = MAX_GRAM - 1; bGram >= 0; --bGram) {
                if (dp[aGram][bGram] == INF) continue;
                
                dp[aGram + val[i][0]][bGram + val[i][1]] =
                    min(dp[aGram + val[i][0]][bGram + val[i][1]],
                        dp[aGram][bGram] + val[i][2]);
            }
        }
    }

    int ans = INF;
    for (int aGram = 0; aGram < MAX_GRAM; ++aGram) {
        for (int bGram = 0; bGram < MAX_GRAM; ++bGram) {
            if (!(aGram == 0 && bGram == 0) && aGram * MB == bGram * MA) {
                ans = min(ans, dp[aGram][bGram]);
            }
        }
    }

    cout << (ans == INF ? -1 : ans) << endl;
}


int main() {
    read();
    work();

    return 0;
}


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

typedef long long ll;

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

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

     vector<int> P(N);
     vector<int> Q(N);
    rep(i,N){
        cin >> P.at(i);
    }
    rep(i,N){
        cin >> Q.at(i);
    }

    int a = 0;
    int b = 0;
    vector<int> order(N);
    rep(i,N) order.at(i) = i+1;
    int i = 0;
    do{
        if(order == P) a = i;
        if(order == Q) b = i;
        i++;
    }while(next_permutation(order.begin(),order.end()));

    cout << abs(a-b) << endl;
    return 0;

} 


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define trace(x) cerr<<#x<<" is "<<x<<'\n';

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

int boss[200009];
mii sub;

void solve()
{
	int n,i;
	cin>>n;
	for(i=1;i<n;i++)
	{
		cin>>boss[i];
		sub[boss[i]]++;
	}
	for(i=1;i<=n;i++)
	{
		cout<<sub[i]<<'\n';
	}
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 13824
#include <bits/stdc++.h>
#define tax 1.08
using namespace std;
int main(){
	int x, qnt = -1, iup, ido;
	double up, down;
	cin >> x;
	up = (double)x / tax;
	down = floor(up);
	up = ceil(up);
	iup = floor(up * tax);
	ido = floor(down * tax);
	//cout << up << ' ' << down;
	if(iup == x) qnt = up;
	else if(ido == x) qnt = down;
	if(qnt > 0){
		cout << qnt << "\n";
	}else
		cout << ":(\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
using namespace std;
int main(){

	int a, b, d, r;

	double f;

	cin >> a >> b;

	d = a / b;
	r = a%b;
	f =1.0*a / b;


	cout << d << " " << r << " " << fixed<<setprecision(5)<<f << endl;

	return 0;
}


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

int main(){
    char a;
    cin >> a;
    if(isupper(a)){
        cout << "A";
    }else{
        cout << "a";
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    string S, T;
    cin >> S;
    cin >> T;
    map<char, char> mpS, mpT;
    REP(i, S.size()) {
        if (mpS.count(S[i]) == 0) mpS[S[i]] = T[i];
        else if (mpS[S[i]] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
        if (mpT.count(T[i]) == 0) mpT[T[i]] = S[i];
        else if (mpT[T[i]] != S[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back 
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

int fac(int n)
{
    if(n<2) return 1;
    return n*fac(n-1);
}

void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U;
    int x;
    cin>>n;
    vi a(n),b(n);
    rep(i,0,n) cin>>a[i];
    rep(i,0,n) cin>>b[i];
    vi perm(n);
    rep(i,0,n)
    {
        perm[i]=i+1;
    }
    while(1)
    {
        if(perm==a) break;
        next_permutation(all(perm));
        count++;
    }
    sortA(perm);
    while(1)
    {
        if(perm==b) break;
        next_permutation(all(perm));
        flag++;
    }
    cout<<abs(flag-count);
    // cout<<count;
}


signed main()
{
 //   #ifndef ONLINE_JUDGE 
//       freopen("input.txt","r",stdin);
 ////      freopen("output.txt","w",stdout);
 //   #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(100,0);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  cout << a[99] - a[100-n] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>

using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];


void solve()
{
    int n;
    cin>>n;

    vi a(n), b(n);

    rep(i, n) cin>>a[i]>>b[i];

    sort(all(a));
    sort(all(b));

    int mn, mx;

    if(n%2 != 0)
    {
        mn = a[n/2];
        mx = b[n/2];

        cout<<mx - mn + 1<<endl;
        return;
    }

    mn = (a[n/2 - 1] + a[n/2])/2;
    mx = (b[n/2 - 1] + b[n/2])/2;

    // cout<<q-p+1<<endl;
    int f1 = 0, f2 = 0;
    if((a[n/2 - 1] + a[n/2])%2!=0) f1++;
    if((b[n/2 - 1] + b[n/2])%2!=0) f2++;


    if(f1 == 0 && f2 == 0)
    {
        cout<<(2*mx - 2*mn + 1)<<endl;
    }

    else if(f1 == 1 && f2 == 0)
    {
        cout<<(2*mx - 2*mn)<<endl;
    }
    else if(f1 == 0 && f2 == 1)
    {
        cout<<(2*mx - 2*mn + 2)<<endl;
    }
    else
    {
        cout<<(2*mx - 2*mn + 1)<<endl;
    }




}

int main()
{

    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    // cin>>T;
    int t=0;
    while(t++<T)
    {
        // cout<<"Case #"<<t<<":"<<' ';
        solve();
        // cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 16396
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  while(1){
    int n,m;
    cin >> n >> m;
    if(n==0 &&m==0){
      break;
    }
    vector<int> s1(n);
    vector<int> s2(m);
    int sum1=0;
    int sum2=0;
    rep(i,n){
      cin >> s1[i];
      sum1+=s1[i];
    }
    rep(i,m){
      cin >> s2[i];
      sum2+=s2[i];
    }
 
    int ans=200;
    int ans_n=-1,ans_m=-1;
    int Sum1=0,Sum2=0;
    rep(i,n)rep(j,m){
      Sum1=sum1-s1[i]+s2[j];
      Sum2=sum2-s2[j]+s1[i];
      if(Sum1==Sum2){
	if(s1[i]+s2[j]<ans){
	  ans=min(s1[i]+s2[j],ans);
	  ans_n=s1[i];
	  ans_m=s2[j];
	}
      }
    }
      if(ans_n==-1&&ans_m==-1){
	cout << -1 << endl;
      }
      else{
	cout << ans_n << " " << ans_m << endl;
      }
  }
  
  
  return 0;
  
}



Measured memory_bytes: 3084
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A[]=new int[100005];
		int ans=N;
		int max=0;
		int sec=0;
		for(int i=0;i<N;i++){
			int a=stdIn.nextInt()-1;
			A[a]++;
			if(a+1>max)
				max=a+1;
		}
		for(int i=0;i<max;i++){
			if(A[i]==2)
				sec++;
			else
				if(A[i]>2){
					if(A[i]%2==0){
						ans-=A[i]-2;
						sec++;
					}
					else
						ans-=A[i]-1;
				}
		}
		if(sec%2==0)
			ans-=sec;
		else{
			ans-=sec;
			ans--;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 49756
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N; int n = N;
    int ans = 0;
    while(n){
        ans += n%10; n /= 10;
    }
    if(N%ans == 0) cout << "Yes";
    else cout << "No";
    cout << endl;
    return 0;
}



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

int main() {

  int n,k;
  cin >> n >> k;
  int a[n+1];
  for(int i=0;i<n;i++)cin >> a[i];
  sort (a,a+n,greater<int>());
  int64_t ans=0;
  for(int i=0;i<n;i++){
    if(k!=0)k--;
    else ans+=a[i];
  }
  cout << ans << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(int)1e9;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0); ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};



signed main(){
  char a,b;cin>>a>>b;

  if(a==b){
    cout<<'H'<<endl;
  }else{
    cout<<'D'<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
input = readlines.first.to_s
dna_list = ['A', 'C', 'G', 'T']

answer_count = 0
tmp_count = 0
input.split('').each do |str|
   if dna_list.include?(str)
     tmp_count += 1
   else
     answer_count = [answer_count, tmp_count].max
     tmp_count = 0
   end
end

puts answer_count

Measured memory_bytes: 14324
#include <stdio.h>
#include <string.h>

char saisyo(const char* s) {
	return s[0];
}

char saigo(const char* s) {
	return s[strlen(s) - 1];
}

int main(void) {
	char A[16], B[16], C[16];
	if (scanf("%15s%15s%15s", A, B, C) != 3) return 1;
	puts(saigo(A) == saisyo(B) && saigo(B) == saisyo(C) ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  char t = s[0];
  for (int i = 1; i < 4; i++) {
    if (t == s[i]) {
      cout << "Bad" << endl;
      exit(0);
    }
    t = s[i];
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
mod = 10 ** 9 + 7

n,m = map(int,input().split())
if n in [0,1]:
    print(1)
    sys.exit()
    
if not m == 0: lis = [int(input()) for x in range(m)]
else: lis = [-1]
val1 = 1
if 1 in lis: val2 = 0
else: val2 = 1

if lis[0] == 1 and len(lis) >= 2:
    flg = lis[1]
    nex = 1
else:
    flg = lis[0]
    nex = 0
#print(lis)
for x in range(2,n):
    if x == flg: #x in lis
        #print(flg)
        nex += 1
        try: flg = lis[nex]
        except:flg = 0
        now = 0
    else:
        now = (val1 + val2) % mod
    val1,val2 = val2,now
    
print((val1 + val2) % mod)
    


Measured memory_bytes: 49240
#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 a,b,n,ans,floor,dummy=0;
    cin >> a >> b >> n;
    if(b > n){
        floor = a*n/b;
    }else{
        ll c = b*(n/b);
        for(ll i = b-1; i <= n; i+=b){
            floor = a*i/b - a*(i/b);
            if(floor > dummy){
                dummy = floor;
            }else{
                break;
            }
        }
        for(ll i = n; i >= c; i--){
            floor = a*i/b - a*(i/b);
            if(floor > dummy){
                dummy = floor;
            }else{
                break;
            }
        }
        floor = dummy;
    }
    cout << floor << endl;
    return 0;
}

Measured memory_bytes: 3676
S = list(input())
N = len(S)
P = N-1
ans = 0
for i in range(N-2,-1,-1):
    if i == P-1 and S[i+1] == 'B':
        P -= 1
    if S[i] == 'B' and S[i+1] == 'W':
        S[i] = 'W'
        ans += P - i
        P -= 1
print(ans)

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

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int a, b; readV(a, b);
  writeln(a+b == 15 ? "+" : a*b == 15 ? "*" : "x");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int>P;

struct segtree{
  int n;
  vector<P>lazy;

  segtree(int sz){
    n = 1; while( n < sz ) n<<=1;
    lazy.resize(2*n-1);
    for(int i=0;i<2*n-1;i++)lazy[i]=P(0,0);
  }

  void eval(int k,P x,int l,int r){
    if(x.second==0)return ;
    if(lazy[k].second==0)lazy[k]=x;
    else if(lazy[k].second+1==x.first)lazy[k].second=x.second;
    else lazy[k]=P(1e9,1e9);
  }

  void add(int a,int b,int x,int k=0,int l=0,int r=-1){
    if(r==-1)r=n;
    if(b<=l || r<=a)return;
    if(a<=l&&r<=b){ eval(k,P(x,x),l,r); }
    else{
      eval(k*2+1,lazy[k],l,r);
      eval(k*2+2,lazy[k],l,r);
      lazy[k]=P(0,0);
      add(a,b,x,2*k+1,l,(l+r)/2);
      add(a,b,x,2*k+2,(l+r)/2,r);
    }
  }
};

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

int main(){
  int n,K,t,sum=0;
  cin>>n>>K>>t;
  segtree S(n);
  r(i,t){
    int l,r,x;
    cin>>l>>r>>x; l--; r--;
    S.add(l,r+1,x);
  }
  r(i,n)S.add(i,i+1,K+1);
  r(i,S.n*2-1){
    if(S.lazy[i].first==1 && S.lazy[i].second==K+1){
      sum++;
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 7076
#include<bits/stdc++.h>
#define il inline
#define vd void
typedef long long ll;
il int gi(){
	int x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return x*f;
}
char S[510][510];
char A[510][510];
int main(){
	int n=gi(),m=gi();
	for(int i=1;i<=n;++i)scanf("%s",S[i]+1);
	memcpy(A,S,sizeof S);
	for(int i=1;i<=n;++i)A[i][1]='#';
	for(int i=1;i<=n;i+=2)
		for(int j=1;j<m;++j)
			A[i][j]='#';
	for(int i=1;i<=n;++i)printf("%s\n",A[i]+1);
	puts("");
	memcpy(A,S,sizeof S);
	for(int i=1;i<=n;++i)A[i][m]='#';
	for(int i=2;i<=n;i+=2)
		for(int j=2;j<=m;++j)
			A[i][j]='#';
	for(int i=1;i<=n;++i)printf("%s\n",A[i]+1);
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>

using namespace std;

/* typedef */
typedef long long ll;

/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;

/* global variables */

/* function */

/* main */
int main(){

    bitset<64> bs(0);

    int q, op, x;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> op;
        switch(op) {
            case 0:  // test(i): Print 1 if i-th flag is ON, otherwise 0
                cin >> x;
                cout << bs.test(x) << '\n';
                break;
            case 1:  // set(i): Set i-th flag to ON
                cin >> x;
                bs.set(x);
                break;
            case 2:  // clear(i): Set i-th flag to OFF
                cin >> x;
                bs.reset(x);
                break;
            case 3:  // flip(i): Inverse i-th flag
                cin >> x;
                bs.flip(x);
                break;
            case 4:  //  all: Print 1 if all flags are ON, otherwise 0
                cout << bs.all() << '\n';
                break;
            case 5:  // any: Print 1 if at least one flag is ON, otherwise 0
                cout << bs.any() << '\n';
               break;
            case 6:  // none: Print 1 if all flags are OFF, otherwise 0
                cout << bs.none() << '\n';
                break;
            case 7:  // count: Print the number of ON flags
                cout << bs.count() << '\n';
                break;
            case 8:  // val: Print the decimal value of the state
                cout << bs.to_ullong() << '\n';
                break;
        }
    }


}



Measured memory_bytes: 3104
import std.stdio, std.conv, std.string, std.math, std.regex, std.range, std.ascii, std.algorithm;

void main(){
	auto a = readln.chomp.to!int;
	auto b = readln.chomp.to!int;
	auto c = readln.chomp.to!int;
	auto d = readln.chomp.to!int;
	auto e = readln.chomp.to!int;
	auto k = readln.chomp.to!int;

	if((b-a) <= k && (c-a) <= k && (d-a) <= k && (e-a) <= k && (c-b) <= k && (d-b) <= k && (e-b) <= k && (d-c) <= k && (e-c) <= k && (e-d) <= k){
		writeln("Yay!");
	} else {
		writeln(":(");
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int f[100005];
int a[100005];
int main() {
    int n,max=0;
    cin>>n;
    for(int i=1;i<=n;i++) {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++) {
        if(a[i]>=a[i+1]) f[i+1]=f[i]+1;
        else f[i+1]=0;
        if(f[i+1]>max&&(i+1)<=n) max=f[i+1];
    }
    cout<<max<<endl;
    return 0;
}

Measured memory_bytes: 1024
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a, b;
	cin>>a>>b;
	cout<<max({a+b,a-b,a*b});
	return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
src = [input() for i in range(H)]

x = y = p = 0
while x < W-1 or y < H-1:
    if x < W-1 and src[y][x+1] == '#':
        p += 1
        x += 1
    elif y < H-1 and src[y+1][x] == '#':
        p += 1
        y += 1
    else:
        print('Impossible')
        exit()

c = 0
for row in src:
    c += row.count('#')
print('Possible' if p+1==c else 'Impossible')

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

int main(){
    int N, n, j;
    cin >> N;
    vector<int> A(N);
    j = 1;
    for (int i = 0; i < A.size(); i++)
    {
        cin >> n;
        A[n-1] = j++;
    }
    
    for (int i : A)
    {
        cout << i << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3788
def main():
    numbers = list(map(int, input().split()))
    numbers.sort()
    answer = 0
    diff = [numbers[2] - numbers[0], numbers[2] - numbers[1]]
    if diff[0] % 2 == diff[1] % 2:
        answer += diff[0] // 2 + diff[1] // 2
        if diff[0] % 2:
            answer += 1
    else:
        answer += (diff[0] + 1) // 2 + (diff[1] + 1) // 2
        answer += 1
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{

 int a;
 int b;
 int d;
 int r;
 double f;

 scanf("%d%d", &a, &b);

 d = a / b;
 r = a % b;

 double x = static_cast<double>(a);
 double y = static_cast<double>(b);

 f = x / y;

 printf("%d%s%d%s%f\n", d," ", r, " ", f);

}

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

int main(){
  int A,B;
  int ans=0;
  cin >> A >> B;
  for(int i=0;i<2;i++){
    ans+=max(A,B);
    if(max(A,B)==A){
      A--;
    }
    else{
      B--;
    }
  }
  cout << ans << endl;
}

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

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

    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        int cnt = 0;
        for (int j = 1; j <= i; j++) {
            if (i % j == 0) cnt++;
        }
        if (cnt == 8) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target ("sse4")
using namespace std;
#define PB push_back
#define all(x) (x).begin(),(x).end()
#define MEM(x,a) memset((x),a,sizeof((x)))
#define F first
#define S second
#define imx INT_MAX
#define inI(x) scanf("%d",&x)
#define inI2(x,y) scanf("%d %d",&x,&y)
#define inI3(x,y,z) scanf("%d %d %d",&x,&y,&z)
const long long MOD = (long long)(1e9+7);
const long long MMX = (long long)(1e18);
typedef long long LL;
int a,b,ss,x;
int main()
{
    scanf("%d %d",&a,&b);
    for(int i=0;i<b;i++)
    {
        scanf("%d",&x);
        ss+=x;
    }
    if(ss>=a)printf("Yes");
    else printf("No");
}

Measured memory_bytes: 256
x,n = map(int, input().split())
l = list(map(int, input().split()))
i = 0
if x not in l:
  print(x)
while x-i in l or x+i in l:
  i += 1
  if x-i not in l:
    print(x-i)
    break
  if x+i not in l:
    print(x+i)
    break

Measured memory_bytes: 9184
"""
B,"s/BC/X"したうえで、
置換できないB,Cで区切って、(re.finditer(r"[AX+"])
各区間でAをすべて右側に寄せるAの移動回数の和 例: AXAXAXA -> XXXAAAA にするには6回
"""
import re
s = input()
s = s.replace("BC", "X")
m = re.search(r"[AX]+", s)
res = 0
for m in re.finditer(r"([AX]+)", s): # それぞれの[AX]+のパターンについてloop
    count = 0 #
    # 時間なくて、index間違えたくないので、逆順にした
    # (AXAXAXA -> XXXAAAA にするんじゃなくて AXAXAXA -> AAAAXXXにする回数)
    t = ''.join(list(reversed(str(m.groups()[0]))))
    for i in range(len(t)):
        if t[i] == "A":
            # Aが見つかったらXの一番右端に持ってくるのに必要な回数をカウント。例えば、
            # AAAXXXAA で4つめのAを探索しているのなら
            # AAAAXXXA にするのに必要な回数は3 と数えたい
            # Aのindex 6 - (既に見つかっているAの数) 3 = 3 で求められる
            res += (i - count)
            count += 1
print(res)

Measured memory_bytes: 5096
mod = 10**9 + 7

K = list(map(int, list(input())))
D = int(input())
keta = len(K)

dp = [[[0]*D for i in range(2)] for j in range(keta+1)]
dp[0][1][0] = 1

from itertools import product
for i, j, k in product(range(keta), range(2), range(D)):
    max_n = K[i] if j else 9
    for l in range(max_n+1):
        dp[i+1][j and l == max_n][(k+l)%D] += dp[i][j][k]
        dp[i+1][j and l == max_n][(k+l)%D] %= mod

ans = 0
for i in range(2):
    ans += dp[-1][i][0]
    ans %= mod
print(max(0, (ans - 1)%mod))

Measured memory_bytes: 63452
from collections import deque

s = input()
q = deque()
for c in s:
    if c == '0':
        q.append('0')
    elif c == '1':
        q.append('1')
    elif c == 'B':
        if len(q) == 0:
            continue
        q.pop()

print(''.join(q))

Measured memory_bytes: 3316