akhauriyash/Code-Regression huggingface dataset:
//bad_bat
#include<bits/stdc++.h>
using namespace std;

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define ll long long
#define all(x) x.begin(), x.end()
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2010
#define inf 1e14
#define MOD 1000000007

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

int main()

{

    ll n;
    cin >> n;
    vector<ll> v, ori;
    for(ll i = 0; i < n; i++)
    {

        ll x;
        cin >> x;
        v.pb(x);
    }
    ori = v;
    sort(all(v));
    ll idx = n-n/2;

    for(ll i = 0; i < n; i++)
    {

        if(ori[i] < v[idx]) cout << v[idx] << endl;
        else cout << v[idx-1] << endl;
    }
}


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

int main() {
  int n, m = 0, x = 0;
  string s;
  cin >> n >> s;
  for(int i = 0; i < n; i++) {
    if(s[i] == 'I') {
      x++;
    } else {
      x--;
    }
    if(m < x) {
      m = x;
    }
  }
  cout << m;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair < int, int > pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 200005;

int n, m, ret, a[MAXN], b[MAXN], c[MAXN];

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	ret = n = Read(), m = Read();
	for (int i = 1; i <= n; i ++)
	{
		a[i] = Read(), c[a[i]] ++;
		if (a[i] - c[a[i]] >= 0 && ++ b[a[i] - c[a[i]]] == 1)
			ret --;
	}
	while (m --)
	{
		int x = Read(), y = Read();
		if (a[x] - c[a[x]] >= 0 && !-- b[a[x] - c[a[x]]])
			ret ++;
		c[a[x]] --;
		a[x] = y;
		c[a[x]] ++;
		if (a[x] - c[a[x]] >= 0 && ++ b[a[x] - c[a[x]]] == 1)
			ret --;
		printf("%d\n", ret);
	}
}


Measured memory_bytes: 3840
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < (ll) b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= (ll) b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
 
const ll MAX= 3e5+100;

ll a[MAX],b[MAX],c[MAX];
int main(){
	fastio;
	ll x,y,na,nb,nc;
	cin>>x>>y>>na>>nb>>nc;
	f(i,1,na+1) cin>>a[i];
	f(i,1,nb+1) cin>>b[i];
	f(i,1,nc+1) cin>>c[i];
	sort(a+1,a+na+1);
	sort(b+1,b+nb+1);
	sort(c+1,c+nc+1);
	vi v;
	af(i,na,na-x+1) v.push_back(a[i]);
	af(i,nb,nb-y+1) v.push_back(b[i]);
	af(i,nc,1) v.push_back(c[i]); 
	sort(all(v));
	ll ans=0;
	af(i,v.size()-1,v.size()-x-y) ans+=v[i];
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 11376
#include <stdio.h>
using namespace std;
int main(void){
   int i,j,H,W;
  
   while(1){
     scanf("%d %d",&H,&W);
   if(H==0&&W==0)break;
    for ( i = 0; i < H; i++ ){
    for ( j = 0; j < W; j++ ){
        printf("#");
    }
    printf("\n");
 
        
    }
 printf("\n");


    
}

    
}




Measured memory_bytes: 2600
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { 
    answer();
   }
   static  void  answer()
   {
     Scanner sc = new Scanner(System.in);
     
     int a = sc.nextInt();
     
     int b = sc.nextInt();
     
     int c = sc.nextInt();
     
     if(a < b && b < c)
     {
       System.out.println("Yes");
     }
     else System.out.println("No");
   }
 }
    


Measured memory_bytes: 26208
package main

import (
	"fmt"
	"sort"
)

func main() {
	var d, g int
	fmt.Scan(&d, &g)

	c := make([]int, d)
	p := make([]int, d)
	for i := 0; i < d; i++ {
		fmt.Scan(&p[i], &c[i])
	}

	ans := 9999
	for bits := 0; bits < (1 << uint(d)); bits++ {
		sc, n := 0, 0
		usable := make([]int, d)
		for i := 0; i < d; i++ {
			usable[i] = i
		}
		for i := 0; i < d; i++ {
			if bits&(1<<uint(i)) > 0 {
				sc += c[i] + p[i]*100*(i+1)
				n += p[i]
				usable[i] = -1
			}
		}
		if sc >= g {
			ans = min(ans, n)
			continue
		}
		sort.Ints(usable)
		k := usable[len(usable)-1]
		if m := ceilDiv((g - sc), (100 * (k + 1))); m <= p[k]-1 {
			ans = min(ans, n+m)
		}
	}

	fmt.Println(ans)
}

func ceilDiv(x, y int) int {
	if x%y > 0 {
		return x/y + 1
	}
	return x / y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 640
i = reversed(input())
s = "".join(list(i))
if s[0] == s[1] == s[2] == s[3]:
    print("No")
else:
    s = s.replace(s[0], '', 2)
    s = s.replace(s[0], '', 2)
    print("Yes" if len(s) == 0 else "No")

Measured memory_bytes: 3060
#!/usr/bin/env python3
import sys
from typing import NamedTuple, List

class Game(NamedTuple):
    c: List[int]
    s: List[List[int]]

def solve(D: int, c: "List[int]", s: "List[List[int]]", t: "List[int]"):
    from functools import reduce
    ans = [0]
    lasts = [0] * 26
    adjust = 0
    sum_c = sum(c)
    daily_loss = sum_c
    for day, tt in enumerate(t, 1):
        a = s[day-1][tt-1]
        adjust += day * c[tt-1] - lasts[tt-1] * c[tt-1]
        lasts[tt-1] = day        
        a -= daily_loss
        a += adjust
        ans.append(ans[-1]+a)
        daily_loss += sum_c
    return ans[1:]

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    D = int(next(tokens))  # type: int
    c = [int(next(tokens)) for _ in range(26)]  # type: "List[int]"
    s = [[int(next(tokens)) for _ in range(26)] for _ in range(D)]  # type: "List[List[int]]"
    t = [int(next(tokens)) for _ in range(D)]  # type: "List[int]"
    print(*solve(D, c, s, t), sep="\n")

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 10376
n = int(input())
a = list(input())
b = list(input())
c = list(input())

d = []
ans = 0
for i in range(n):
    if a[i] ==  b[i] == c[i]:
        ans += 0
    elif (a[i] == b[i]) or (b[i] == c[i]) or (a[i] == c[i]):
        ans += 1
    else:
        ans += 2
print(ans)

Measured memory_bytes: 3064
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "



int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		string s;
		cin >> s;
		sort (s.begin(),s.end());
		int min = 0;
		map<int,int> num;
		for (int i=0 ; i<(int)s.length() ; i++)
		{
			if(num.count((int)s.at(i) - 97)>0)
			num.at((int)s.at(i) - 97)++;
			else
			num[(int)s.at(i) - 97]=1;
		}
		for (int i=0 ; i<26 ; i++)
		{
			if(num.count(i) == 0)
			break;
			else
			min++;
		}
		if (min == 26) printf("None");
		else 
		cout << (char)(min+97) << endl;
		return 0;
}  

/*

*/


Measured memory_bytes: 3772
ans = []
readline = open(0).readline
writelines = open(1, 'w').writelines

while 1:
    N = int(readline())
    if N == 0:
        break
    items = [map(int, readline().split()) for i in range(N)]
    P, Q, R, C = map(int, readline().split())
    c = 0
    for s, p, q, r in items:
        if p <= P and q <= Q and r <= R and 4*p+9*q+4*r <= C:
            ans.append("%d\n" % s)
            c += 1
    if not c:
        ans.append("NA\n")
writelines(ans)


Measured memory_bytes: 6572
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

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

void solve() {
    int h,w;
    cin >> h >> w;
    VS s(h);
    REP(i,0,h) cin >> s[i];
    VVI d(h,VI(w,1<<30));
    d[0][0] = (s[0][0] == '#');
    deque<PII> q;
    q.emplace_back(0,0);
    while (!q.empty()) {
        auto p = q.front();
        q.pop_front();
        int x = p.first, y = p.second;
        REP(i,0,2) {
            int rx = x + dx[i];
            int ry = y + dy[i];
            if (rx < 0 || rx >= h) continue;
            if (ry < 0 || ry >= w) continue;
            if (d[rx][ry] <= (s[x][y] == '.' && s[rx][ry] == '#') + d[x][y]) continue;
            d[rx][ry] = (s[x][y] == '.' && s[rx][ry] == '#') + d[x][y];
            q.emplace_back(rx, ry);
        }
    }
    cout << d[h-1][w-1] << endl;
}

signed main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int n;
    ll x;
    cin >> n >> x;
    ll A[n];
    rep(i, 0, n) cin >> A[i];
    sort(A, A+n);
    int ans = 0;
    rep(i, 0, n) {
        x -= A[i];
        if (x < 0) break;
        if (x >= 0) ans++;
    }
    if (x > 0) ans--;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll modpow(ll a, ll b, ll mod) {
  if(b == 0) return 1;
  else if(b == 1) return a;
  else if(b % 2 == 0) {
    ll sub = modpow(a, b / 2, mod);
    return (sub * sub) % mod;
  }
  else { 
    return (a * modpow(a, b - 1, mod)) % mod;
  }
}

bool check(const vector<int> &vs) {
  const int n = vs.size();
  if(n % 2 == 0) {
    for(int i = 0; i < n / 2; i++) {
      if(vs[i * 2] != i * 2 + 1 or vs[i * 2 + 1] != i * 2 + 1) return false;
    }
  } else {
    if(vs[0] != 0) return false;
    for(int i = 1; i <= n / 2; i++) {
      if(vs[i * 2 - 1] != i * 2 or vs[i * 2] != i * 2) return false;
    }    
  }
  return true;
}

int main()
{
  int n;
  cin >> n;
  vector<int> vs(n);
  for(int i = 0; i < n; i++) {
    cin >> vs[i];
  }
  sort(vs.begin(), vs.end());
  if(check(vs)) {
    cout << modpow(2, n / 2, 1000000007ll);
  } else { 
    cout << 0 << endl;
  }
}

Measured memory_bytes: 640
from collections import deque

m, k = [int(i) for i in input().split()]

if k >= 2 ** m:
    print(-1)
    exit()

if k == 0:
    q = deque([])
    for i in range(2 ** m):
        q.append(i)
        q.appendleft(i)
    print(*q)
    exit()

if m == 1 and k == 1:
    print(-1)
    exit()

S = set(i for i in range(2 ** m))

q = deque([0, k])
S.remove(0)
S.remove(k)

for s in S:
    q.appendleft(s)
    q.append(s)

q.appendleft(0)
q.append(k)

print(*q)


Measured memory_bytes: 19816
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}

int main(){
  int n; 
  cin >> n;
  vector<pair<int, int>> red;
  vector<pair<int, int>> blue;
  for(int i=0; i<n; i++){
    int a, b;
    cin >> a >> b;
    red.push_back(make_pair(a, b));
  }
  for(int i=0; i<n; i++){
    int a, b;
    cin >> a >> b;
    blue.push_back(make_pair(a, b));
  }
  sort(red.begin(), red.end(), compare_by_a);
  sort(blue.begin(), blue.end(), compare_by_a);
  
  int count = 0;
  for(int i=0; i<n; i++){
    vector<int> leftThanBlue;
    for(int j=0; j<n; j++){
      if(red[j].first < blue[i].first) leftThanBlue.push_back(j);
    }
    int topOfUnderThanBlue = -1;
    int index = -1;
    for(int j=0; j<leftThanBlue.size(); j++){
      int checkingRedY = red[leftThanBlue[j]].second;
      if(checkingRedY < blue[i].second && checkingRedY > topOfUnderThanBlue){
        topOfUnderThanBlue = checkingRedY;
        index = leftThanBlue[j];
      }
    }
    if(index != -1){
      red.erase(red.begin() + index);
      count++;
    }
  }
  cout << count << endl;
  return 0;
}
  

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

typedef long long ll;

int main() {
    ll a, b;
    cin >> a >> b;
    
    if(a == 1 || b == 1) {
        cout << 1;
        return 0;
    }
    
    if(a % 2 == 0 && b % 2 == 0) cout << (a * b) / 2;
    if(a % 2 == 0 && b % 2 == 1) cout << (a * b) / 2;
    if(a % 2 == 1 && b % 2 == 0) cout << (a * b) / 2;
    if(a % 2 == 1 && b % 2 == 1) cout << 1 + (a * b - 1) / 2;
/*    
    ll p = a * b;
    if(p % 2 == 0) {
        cout << p / 2 << endl;
    } else {
        cout << (p + 1) / 2 << endl;
    }*/
    return 0;
}

Measured memory_bytes: 256
a = []
for _ in range(3):
    a.extend(list(input().split()))

n = int(input())
for _ in range(n):
    k = input()
    for i in range(9):
        if a[i] == str(k):
            a[i] = 0

ans = False

if a[0] == a[1] and a[1] == a[2] and a[2] == 0:
    ans = True

if a[3] == a[4] and a[4] == a[5] and a[5] == 0:
    ans = True

if a[6] == a[7] and a[7] == a[8] and a[8] == 0:
    ans = True

if a[0] == a[3] and a[3] == a[6] and a[6] == 0:
    ans = True

if a[1] == a[4] and a[4] == a[7] and a[7] == 0:
    ans = True

if a[2] == a[5] and a[5] == a[8] and a[8] == 0:
    ans = True

if a[0] == a[4] and a[4] == a[8] and a[8] == 0:
    ans = True

if a[2] == a[4] and a[4] == a[6] and a[6] == 0:
    ans = True

print("Yes" if ans else "No")

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

int main(){
  string S;
  cin >> S;
  if(S.at(0) != S.at(1) && S.at(1) != S.at(2) && S.at(2) != S.at(0)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll n,m;cin>>n>>m;ll r;ll b,c;
    unordered_map <ll,ll> mp;ll sum=0;
    for(ll i=0;i<n;++i)
    {
        cin>>r;sum+=r;
        auto it=mp.find(r);
        if(it!=mp.end()){it->second++;}
        else
        {
            mp.insert(make_pair(r,1));
        }
    }
    map <ll,ll> omp(mp.begin(),mp.end());
    for(ll i=0;i<m;++i)
    {
        cin>>b>>c;
        for(auto it=omp.begin();it!=omp.end();++it)
        {
            if(it->first>=c){break;}
            ll ran=min(b,it->second);
            sum+=((c-it->first)*ran);
            auto it1=omp.find(c);
            if(it1!=omp.end()){it1->second+=ran;}
            else{omp.insert(make_pair(c,ran));}
            b=b-ran;
            it->second=it->second-ran;
            if(it->second==0){omp.erase(it->first);}
            if(b<=0){break;}
        }
    }
    cout<<sum;
}

Measured memory_bytes: 10660
#include<iostream>
using namespace std; //or std::cin et al.

int main() {
	int n,a;
	long long sum,min,max;
	int i;
	
	cin >> n;
	if (n != 0) {
	    cin >> a;
	    min = max = sum = a;
	}
	for ( i = 1; i < n; i++ ) {
		cin >> a;
		sum += a;
		min =  min > a?a:min;
		max =  max < a?a:max;
	}
	cout << min << " " << max << " " << sum << endl;
	
	return 0;
}


Measured memory_bytes: 3112
#include <iostream>

using namespace std;

bool flag;
void Search(int a[], int pos, int b, int c)
{
	if(pos == 10)
	{
		flag = true;
	}
	if(b > a[pos] && c > a[pos])
	{
		return;
	}
	if(b < a[pos])
	{
		Search(a, pos + 1, a[pos], c);
	}
	if(c < a[pos])
	{
		Search(a, pos + 1, b, a[pos]);
	}
}

void solve()
{
	int N;
	cin >> N;
	while(N--)
	{
		flag = false;
		int A[10];
		for(int i = 0; i < 10; ++i)
		{
			cin >> A[i];
		}
		int B = 0, C = 0;
		Search(A, 0, B, C);
		if(flag)
		{
			cout << "YES" << endl;
		}
		else
		{
			cout << "NO" << endl;
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(void){
	ll d,n,m,i,sum,high,low,mid;
	while(1){
		cin>>d;
		if(d==0)break;
		cin>>n>>m;
		ll a[n+1],b[m];
		a[0]=0;
		for(i=1;i<n;i++) cin>>a[i];
		a[n]=d;
		for(i=0;i<m;i++) cin>>b[i];
		sort(a,a+n+1);
		sum=0;
		for(i=0;i<m;i++){
			high=n; low=0;
			while(high>=low){
				mid=(high+low)/2;
				if(a[mid]>=b[i]) high=mid-1;
				else low=mid+1;
//				cout<<high<<' '<<low<<endl;
			}
//			cout<<a[high]<<endl;
			sum+=min(abs(b[i]-a[high]),abs(b[i]-a[low]));
		}
		cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 4012
A = [list(map(int, input().split())) for _ in range(3)]
N = int(input())

m = []
M = [[False, False, False], [False, False, False], [False, False, False]]
for _ in range(N):
    b = int(input())
    for j in range(3):
        for i in range(3):
            if b == A[j][i]:
                M[j][i] = True


ans = False
for j in range(3):
    if M[j].count(True) == 3:
        ans = True


for i in range(3):
    for j in range(3):
        if not M[j][i]:
            break
    else:
        ans = True

if M[0][0] and M[1][1] and M[2][2]:
    ans = True
if M[2][0] and M[1][1] and M[2][0]:
    ans = True

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#define _ ios::sync_with_stdio(false)
using namespace std;
typedef long long int ll;
const int MAXN=100000+10;
int vis[30]={0};
int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        int x=s[i]-'a';
        if(vis[x]){
            printf("no\n");
            return 0;
        }
        vis[x]=1;
    }
    printf("yes\n");
}



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

const int mod = 1000000007;

long long pow_mod(long long m, long long n){
    // ?????°m?????????mod?????????
    if(n == 0){
        return 1;
    } else if(n%2 == 0){
        return pow_mod(m * m % mod, n/2);
    } else {
        return pow_mod(m * m % mod, (n-1)/2) * m % mod;
    }
}

int main(){
    long long m, n;
    cin >> m >> n;
    cout << pow_mod(m, n) << endl;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb emplace_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repi(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;

int main() {
    // your code goes here
    string s;
    cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

Measured memory_bytes: 3596
"use strict";

const main = arg => {
  const input = arg.trim().split("\n");
  const S = parseInt(input[0].split(" ")[0]);
  const W = parseInt(input[0].split(" ")[1]);
  if (S <= W) {
    console.log("unsafe");
  } else {
    console.log("safe");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9 + 7;

int main() {
    int n, m;
    cin >> n >> m;
    map<int, int> mpc, mpr;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        a--;
        if (mpc.find(a) != mpc.end()) {
            cout << 0 << endl;
            return 0;
        }
        mpc[a] = i;
    }
    for (int i = 0; i < m; i++) {
        int b;
        cin >> b;
        b--;
        if (mpr.find(b) != mpr.end()) {
            cout << 0 << endl;
            return 0;
        }
        mpr[b] = i;
    }
    ll r, c, x, ans;
    r = c = x = 0;
    ans = 1;

    for (int v = n * m - 1; v >= 0; v--) {
        bool bc = mpc.find(v) != mpc.end(), br = mpr.find(v) != mpr.end();
        if (bc && br) {
            x += r + c;
            c++;
            r++;
        } else if (bc) {
            ans = ans * r % mod;
            x += r - 1;
            c++;
        } else if (br) {
            ans = ans * c % mod;
            x += c - 1;
            r++;
        } else {
            ans = ans * x % mod;
            x--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<queue>
#include<cstdio>

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

using namespace std;

const int INF=1<<29;

class edge{
public:
	int v,cost;
	edge(int v,int cost):v(v),cost(cost){}
};

int main(){
	for(int n,m,k;scanf("%d%d%d",&n,&m,&k),n;){
		vector<edge> G[100];
		int d[100][100];
		rep(u,n) rep(v,n) d[u][v]=(u==v?0:INF);
		rep(_,m){
			int u,v,cost; scanf("%d%d%d",&u,&v,&cost);
			d[u][v]=d[v][u]=cost;
			G[u].push_back(edge(v,cost));
			G[v].push_back(edge(u,cost));
		}

		rep(w,n) rep(u,n) rep(v,n) d[u][v]=min(d[u][v],d[u][w]+d[w][v]);

		double dp[100][100]={}; // dp[u][v] := ( u->v 間の最短経路の個数 )
		rep(u,n) rep(i,G[u].size()) {
			int v=G[u][i].v,cost=G[u][i].cost;
			if(d[0][u]+cost+d[v][n-1]==d[0][n-1]) dp[u][v]=1;
		}
		rep(w,n) rep(u,n) rep(v,n) dp[u][v]+=dp[u][w]*dp[w][v];

		rep(_,k){
			int c; scanf("%d",&c);
			printf("%.9f\n",dp[0][c]*dp[c][n-1]/dp[0][n-1]);
		}
		puts("");
	}

	return 0;
}

Measured memory_bytes: 1308
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int a[1100];
bool b[1100000];
int main()
{
	int n;
	cin>>n;
	memset(b,0,sizeof(b));
	long long maxx=999999;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]=1;
	}
	int l=0;
	for(int i=1;i<=n;i++)
	{
		int x=a[i];
		for(int j=i+1;j<=n;j++)
		{
			x*=10;
			x+=a[j];
			if(x>999999)
				break;
			b[x]=1;
		}
	}
	for(int i=0;i<=maxx;i++)
	{
		if(!b[i])
		{
			cout<<i<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 4176
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-6;
const double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
int c[110000];
int ans[110000];
pair<pair<int,int>,int>q[110000];
int main(){
	int a;scanf("%d",&a);
	int b;scanf("%d",&b);
	for(int i=0;i<b;i++)scanf("%d",c+i);
	int d;scanf("%d",&d);
	for(int i=0;i<d;i++){
		int x,y;scanf("%d%d",&x,&y);
		q[i]=make_pair(make_pair(x,y),i);
	}
	std::sort(q,q+d);
	int left=0;
	int right=a;
	long long sa=0;
	int dir=0;
	int at=0;
	int las=0;
	for(int i=0;i<b;i++){
		while(at<d&&q[at].first.first<c[i]){
			int st=q[at].first.second;
			int mv=q[at].first.first-las;
			if(st<left)st=left;
			if(st>right)st=right;
			st+=sa-left;
			if(dir%2)st+=mv;
			else st-=mv;
			if(st<0)st=0;
			if(st>a)st=a;
			ans[q[at].second]=st;
			at++;
		}
		if(dir%2==0){
			long long to=sa-(c[i]-las);
			sa=to;
			if(to<0){
				int ad=-to;
				if(-to+left>right){
					left=right;
					sa=0;
				}else{
					left+=ad;
					sa=0;
				}
			}
		}else{
			long long to=sa+(c[i]-las)+(right-left);
			sa+=(c[i]-las);
			if(to>a){
				int ad=to-a;
				if(sa>a){
					sa=a;
					right=left;
				}else{
					right-=ad;
				}
			}
		}
		las=c[i];
	//	printf("%d: %d %lld %d %d\n",i,las,sa,left,right);
		dir++;
	}
	while(at<d){
		int st=q[at].first.second;
		int mv=q[at].first.first-las;
		if(st<left)st=left;
		if(st>right)st=right;
		st+=sa-left;
		if(dir%2)st+=mv;
		else st-=mv;
		if(st<0)st=0;
		if(st>a)st=a;
		ans[q[at].second]=st;
		at++;
	}
	for(int i=0;i<d;i++)printf("%d\n",ans[i]);
}

Measured memory_bytes: 3072
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
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; }


using namespace std;

int main(){

    int A, B;
    cin >> A >> B;
    if (1 <= A && A <= 9 && 1 <= B && B <= 9){
        cout << A*B << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
import math
N, H = map(int, input().split())
A = [0] * N
B = [0] * N
for i in range(N):
    a, b = map(int, input().split())
    A[i] = a
    B[i] = b

B.sort(reverse=True)
def calc():
    maxa = max(A)
    cnt = 0
    h = H
    for b in B:
        if maxa < b:
            cnt += 1
            h -= b
        if h <= 0:
            return cnt

    # 投げて倒せるまでmaxaで切り続ける
    cnt += math.ceil(h/maxa)
    return cnt

print(int(calc()))


Measured memory_bytes: 11312
N=int(input())
a=5
b=2
cnt_a=0
cnt_b=0
while a<N:
    cnt_a+=(N//a)//2
    a*=5
while b<N:
    cnt_b+=(N//b)//2
    b*=2
print(0 if N%2==1 else cnt_a)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using static Assistant.Input;
using System.Linq;
using Assistant;
using System.Text;

namespace AOJ_0365
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            int N = S.Length;
            var k = ReadInt;

            List<int>[] index = new List<int>[26].Select(x => new List<int>()).ToArray();
            for (int i = 0; i < N; i++)
            {
                int a = S[i] - 'a';
                index[a].Add(i);
            }

            StringBuilder ans = new StringBuilder();

            BIT bit = new BIT(N + 2);
            int[] count = new int[26];
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < 26; j++)
                {
                    if (index[j].Count == count[j]) continue;
                    int pos = index[j][count[j]];
                    long v = pos - bit.Sum(1, pos + 1);

                    if (k >= v)
                    {
                        k -= (int)v;
                        count[j]++;
                        ans.Append((char)('a' + j));
                        bit.Add(pos + 1, pos + 1, 1);
                        break;
                    }
                }
            }

            Console.WriteLine(ans);
        }


    }

    class BIT
    {
        long[] bit0, bit1;  //1-indexed
        int n;
        public BIT(int n)
        {
            bit0 = new long[n + 1];
            bit1 = new long[n + 1];
            this.n = n;
        }

        public long Sum(int l, int r)
        {
            long ret = 0;
            ret += Sum(bit0, r) + Sum(bit1, r) * r;
            ret -= Sum(bit0, l - 1) + Sum(bit1, l - 1) * (l - 1);
            return ret;
        }

        long Sum(long[] bit, int i)
        {
            long s = 0;
            while (i > 0)
            {
                s += bit[i];
                i -= i & -i;
            }
            return s;
        }

        public void Add(int l, int r, int a)
        {
            Add(bit0, l, -a * (l - 1));
            Add(bit1, l, a);
            Add(bit0, r + 1, a * r);
            Add(bit1, r + 1, -a);
        }

        void Add(long[] bit, int i, int a)
        {
            while (i <= n)
            {
                bit[i] += a;
                i += i & -i;
            }
        }
    }
}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        //drawmap
        //drawarray
    }
}



Measured memory_bytes: 24780
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextLong()
    val b = sc.nextLong()
    val c = sc.nextLong()
    val left = 4 * a * b
    val right = (c-a-b)*(c-a-b)
    if (c - a - b > 0 && left < right) {
        println("Yes")
    } else {
        println("No")
    }
}

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

char chess(int h,int w){
    if((h+w)%2==0){
        return '#';
    }
    return '.';
}

int main(void)
{
    int H,W;
    while(true){
        cin>>H>>W;
        if(H==0 && W==0){
            break;
        }
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cout<<chess(i,j);
        }
        cout<<endl;
        }
    cout<<endl;
}
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <queue>
#include <sstream>
#include <cmath>
#include <functional>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define reps(s,i,n) for(int i=s;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define skip(i,n,p) for(int i=0;i<n;i+=p)
#define all(a)  (a).begin(),(a).end()
#define int64 long long
#define debug cerr << __FILE__ << ":" << __LINE__ << endl;
#define INF 2147483647

struct Init {
    Init() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout.precision(20);
        cout << fixed;
    }
} init;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {
    for(int i = 0; i < (int) v.size(); i++) {
        ostr << v[i] << (i + 1 != v.size() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const map<_K, _V>& v) {
    ostr << "{";
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << (*iter).first << ": " << (*iter).second << ", ";
    }
    ostr << "}";
    return ostr;
}

template <typename _K>
ostream& operator << (ostream& ostr, const set<_K>& v) {
    for (auto iter = v.begin(); iter != v.end(); ++iter) {
        ostr << *iter << (iter != v.end() ? " " : "");
    }
    return ostr;
}

template <typename _K, typename _V>
ostream& operator << (ostream& ostr, const pair<_K, _V>& v) {
    ostr << v.first << " " << v.second;
    return ostr;
}

int64 powmod(int64 n, int64 count, int64 mod) {
    if (count == 0) return 1;
    if (count % 2 == 0) {
        int64 t = powmod(n, count / 2, mod);
        return t * t % mod;
    }
    return n * powmod(n, count - 1, mod) % mod;
}

int64 ncr(int64 n, int64 r, int64 mod) {
    int64 a;
    if (n < r) a = min(n, r - n);
    else a = min(n - r, r);

    int64 res = 1;
    rep(i, a) {
        res = res * (n - i) % mod;
        res = res * powmod(i + 1, mod - 2, mod) % mod;
    }

    return res;
}

vector<vector<int>> aaa;
int dfs(int n, int _min, int _max, vector<int> v) {
    if (v.size() == n) {
        aaa.push_back(v);
        return 0;
    }

    reps(_min, i, _max + 1) {
        vector<int> v2 = v;
        v2.push_back(i);
        dfs(n, i, _max, v2);
    }

    return 0;
}

int main() {
    int N, M, Q; cin >> N >> M >> Q;

    vector<vector<int>> V(Q);
    rep(i, Q) {
        vector<int> v(4);
        cin >> v[0] >> v[1] >> v[2] >> v[3];
        v[0]--;
        v[1]--;
        V[i] = v;
    }

    dfs(N, 1, M, vector<int>());

    int ans = 0;
    rep(i, aaa.size()) {
        vector<int> L = aaa[i];
        int a = 0;
        rep(j, Q) {
            vector<int> v = V[j];
            if (L[v[1]] - L[v[0]] == v[2]) {
                a += v[3];
            }
        }
        ans = max(ans, a);
    }

    cout << ans << endl;
}


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

using namespace std;

int main()
{
	string s[3];
	for (auto&& si : s)
	{
		cin >> si;
		reverse(si.begin(), si.end());
	}
	int r = s[0].back();
	s[0].pop_back();
	while (s[r-'a'].size() > 0)
	{
		int tmp = s[r-'a'].back();
		s[r-'a'].pop_back();
		r = tmp;
	}
	cout << (char)(r-'a'+'A') << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <chrono>
#include <string>
using namespace std;

// 💖 Hi, thanks for using ICIE! 💖
// 🔧 To use a custom code template, press Ctrl+Shift+P and select "ICIE Template configure" from the list 🔧
// 📝 If you spot any bugs or miss any features, create an issue at https://github.com/pustaczek/icie/issues 📝

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int num;
    int c[4] = {0, 0, 0, 0};
    string tmp;
    cin >> num;
    for (int i = 0; i < num; i++)
    {
        cin >> tmp;
        if (tmp == "AC")
            c[0]++;
        else if (tmp == "WA")
            c[1]++;
        else if (tmp == "TLE")
            c[2]++;
        else
            c[3]++;
    }
    cout << "AC x " << c[0] << endl;
    cout << "WA x " << c[1] << endl;
    cout << "TLE x " << c[2] << endl;
    cout << "RE x " << c[3] << endl;
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n=len(s);
    ll ans=0;
    char now='A';
    rep(i,n){
      if(now!=s[i]){
        ans++; 
        now=s[i];
      }else{
        if(i==n-1) break;
        ans++;
        i++;
        now='A';
      }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 720
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class AtCoder_xab{
  public static void Main(){

    var input = Console.ReadLine().Split();
    int x = int.Parse(input[0]);
    int a = int.Parse(input[1]);
    int b = int.Parse(input[2]);

    string ans;
    if(Math.Abs(a-x) < Math.Abs(b-x)) ans = "A";
    else ans = "B";
    Console.WriteLine(ans);
    
  }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll count = 0;
  deque<ll> b;
  rep(i, n){
    if(i % 2 == 0) b.push_back(a[i]);
    else b.push_front(a[i]); 
  }
  if(n % 2) reverse(b.begin(), b.end());

  for(auto it = b.begin(); it != b.end(); ++it){
    cout << *it << ' ';
  }
  cout <<endl;
}


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

int h,w,n;
vector<string> mp(31);
vector<string> tmp;

bool cal(){
  bool f=1;
  while(f){
    f=0;
    for(int i=0;i<w;i++)
      for(int j=1;j<h;j++)
	for(int k=j;k>0;k--)
	  if(mp[k][i]=='.'&&mp[k-1][i]!='.')swap(mp[k][i],mp[k-1][i]);
    
    bool used[30][30]={};
    for(int i=0;i<h;i++){
      int c=1,p=0;
      for(int j=1;j<=w;j++)
	if(mp[i][p]==mp[i][j])c++;
	else if(c<n)c=1,p=j;
	else {
	  for(int k=0;k<c;k++)used[i][p+k]=1;
	  c=1,p=j;
	}
    }
        
    for(int i=0;i<w;i++){
      int c=1,p=0;
      for(int j=1;j<=h;j++)
	if(mp[p][i]==mp[j][i])c++;
	else if(c<n)c=1,p=j;
	else {
	  for(int k=0;k<c;k++)used[p+k][i]=1;
	  c=1,p=j;
	}
    }
  
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	if(mp[i][j]!='.'&&used[i][j])mp[i][j]='.',f=1;
  }
  
  bool res=1;
  for(int i=0;i<w;i++)res&=mp[h-1][i]=='.';
  return res;
}


bool solve(int x,int y){
  mp=tmp;
  if(x+1<w)swap(mp[y][x],mp[y][x+1]);
  return cal();
}

int main(){
  cin>>h>>w>>n;
  for(int i=0;i<h;i++)cin>>mp[i],mp[i]+='?';
  mp[h]="???????????????????????????????";
  tmp=mp;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++)
      if(solve(j,i)){cout<<"YES"<<endl;return 0;}
  
  cout<<"NO"<<endl;
  return 0;
}

Measured memory_bytes: 3208
n, k, q = map(int, input().split())
p = k - q
point = [k-q]*n

for _ in range(q):
    a = int(input())-1
    point[a] += 1

if k-q > 0:
    for _ in range(n):
        print('Yes')
    exit()

for i in range(n):
    if point[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 11488
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a,b;
    cin>>a>>b;
    for(int i=0;i<a.size()+b.size();i++){
        if(i%2) cout<<b[i/2];
        else cout<<a[i/2];
    }
    cout<<endl;
}

Measured memory_bytes: 256
#define  REP(i, s, e) for (int i = s; i <= e; i++)
#define DREP(i, s, e) for (int i = s; i >= e; i--)
#define DEBUG fprintf(stderr, "Passing [%s] in Line %lld\n", __FUNCTION__, __LINE__)

#define chkmax(a, b) a = max(a, b)
#define chkmin(a, b) a = min(a, b)

#include <iostream>
#define int long long
using namespace std;
const int maxn = 3000 + 10;
int n, MOD;

inline int power_pow(int base, int b, const int MOD = ::MOD)
{
	int ans(1);
	while (b)
	{
		if (b & 1) (ans *= base) %= MOD;
		(base *= base) %= MOD;
		b >>= 1;
	}
	return ans;
}
#define inv(x) power_pow(x, MOD - 2)
int fac[maxn], Inv[maxn], s[maxn][maxn];
inline void init(const int MOD = ::MOD)
{
	fac[0] = 1;
	REP(i, 1, n) fac[i] = fac[i-1] * i % MOD;
	Inv[n] = inv(fac[n]);
	DREP(i, n-1, 0) Inv[i] = Inv[i+1] * (i+1) % MOD;
	REP(i, 0, n) s[i][0] = 1;
	REP(i, 1, n)
		REP(j, 1, i)
		s[i][j] = (s[i-1][j] * (j + 1) % MOD + s[i-1][j-1]) % MOD;
}
#define C(n, m) (0 <= m && m <= n ? fac[n] * Inv[m] % mod * Inv[n-m] % mod : 0)
signed main()
{
#ifdef CraZYali
	freopen("E.in", "r", stdin);
	freopen("E.out", "w", stdout);
#endif
	cin >> n >> MOD;
	const int mod = MOD;
	init();
	int ans = power_pow(2, power_pow(2, n, MOD - 1));
	REP(i, 1, n)
	{
		int f(0);
		REP(j, 0, i)
			(f += s[i][j] * power_pow(power_pow(2, n - i), j) % mod) %= mod;
		(f *= power_pow(2, power_pow(2, n-i, MOD-1))) %= mod;
		(ans += (i & 1? -f : f) * C(n, i) % mod) %= mod;
	}
	cout << (ans % mod + mod) % mod << endl;
	return 0;
}


Measured memory_bytes: 69248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n;
    cin >> n;
    
    vector<int> f(n+1, 0);
    for (int i = 1; i <= n; i++)
        for (int j = i; j <= n; j += i)
            f[j]++;
    
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += (ll)i * f[i];
    }
    
    cout << ans << endl;
    
    return 0;
}


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

signed main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    int n;
    std::cin >> n;

    for (int i = 1; i <= 47000; i++) {
        if ((int) std::floor(1.08 * i) == n) {
            std::cout << i;
            return 0;
        }
    }

    std::cout << ":(";

    return 0;
}

Measured memory_bytes: 3648
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
  a[i] -= i
a.sort()
if n%2 == 1:
  m = a[n//2]
else:
  m = (a[n//2]+a[n//2-1])//2

s = 0
for x in a:
  s += abs(x-m)
print(s)

Measured memory_bytes: 26836
#include<iostream>

using namespace std; 

int main(void)
{
  long long a,b,c,d;
  cin>>a>>b>>c;
  d=c-a-b;
  
  if((d>0)&&(4*a*b)<(d*d)){
    puts("Yes");
  }else{
    puts("No");
  }
  
  return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)
import Data.List (sort, group)

getInts :: IO [Int]
getInts = map (fst . fromJust . B.readInt) . B.words <$> B.getLine


isAllTruth::[(Int,Int)]->Int->Bool
isAllTruth doublePair op = all (\((a,b),v) -> a == v && b == 2) $ zip doublePair [op,op+2..]

main = do
  n <- readLn
  an <- getInts
  let an' = map (\x->(head x,length x)) . group $ sort an
  print $ let ans = mod (2^(div n 2)) (10^9+7) in if even n then
      if isAllTruth an' 1 then ans else 0
    else
      if (fst (head an') == 0) && (snd (head an') == 1)  && isAllTruth (tail an') 2 then ans else 0

Measured memory_bytes: 15740
#pragma GCC target ("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k) {
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= MOD;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    return x * modinv(y, MOD) % MOD;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
b = inpl()
p = []
m = 0
c = 0
for i in range(n):
    if a[i] - b[i] < 0:
        m += b[i]-a[i]
        c += 1
    elif a[i]-b[i] > 0:
        p.append(a[i] - b[i])
p.sort(reverse = True)
if m > sum(p):
    print(-1)
    quit()
for x in p:
    if m <= 0:
        break
    c += 1
    m -= x
print(c)



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

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#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 UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define FI first
#define SE second
using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}

vector<int> kmp_table(string t){
  vector<int> res = vector<int>(t.size(), 0);
  int j = 0;
  for(int i = 1; i < t.size(); i++){
    if(t[i] == t[j]){
      j++;
    }else{
      j = 0;
    }
    res[i] = j;
  }
  return res;
}

// s: text, t: pattern
vector<int> kmp_search(string s, string t){
  vector<int> res;
  vector<int> shift = kmp_table(t);

  // i: text index, p: pattern index
  int i = 0, p = 0;
  while(i < s.size() && p < t.size()){
    if(s[i] == t[p]){
      i++;
      p++;
    }else if(p == 0){
      i++;
    }else{
      p = shift[p - 1];
    }
    if(p == t.size()){
      res.push_back(i - p);
      p = shift[p - 1];
    }
  }

  return res;
}

int main(int argc, char const* argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string t, p;
  cin >> t >> p;
  auto res = kmp_search(t, p);
  rep(i, sz(res))cout << res[i] << endl;
	return 0;
}



Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    cin>>n;
    vector<int> b;
    rep(i,n-1){
        int x;
        cin>>x;
        b.pb(x);
    }
    int ans=0;
    rep(i,n){
        if(i==0){
            ans+=b[i];
        }
        else if(i==n-1){
            ans+=b[n-2];
        }
        else{
            ans+=min(b[i-1],b[i]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
url = "https://atcoder.jp//contests/abc066/tasks/arc077_a"

def main():
    input()
    t = list(map(int, input().split()))
    left = []
    right = []
    ans = [0] * len(t)
    for i in range(len(t)):
        if (len(t) - (i + 1) ) % 2 == 0:
            left.append(t[i])
        else:
            right.append(t[i])
    print(' '.join([str(v) for v in left[::-1]]), ' '.join([str(v) for v in right]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 26176