akhauriyash/Code-Regression huggingface dataset:
/*{{{*/
#include<bits/stdc++.h>

typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define FORR(i,a,b) for(ll i=b-1;i>=a;i--)

#define DEBUG(x) cout<<#x<<": "<<x<<endl

using namespace std;
/*}}}*/

int main() {
  string s;
  ll n,k;
  cin >> n >> k;
  cin >> s;
  vector<ll> arr;
  ll ti = -1;
  ll ui = -1;
  bool onef = s[0] == '1';
  REP(i,n){
    if(s[i]=='1' && ti==-1){
      ti = i;
    }
    if(s[i]=='0' && ti!=-1){
      arr.push_back(i-ti);
      ti = -1;
    }
    if(s[i]=='0' && ui==-1){
      ui = i;
    }
    if(s[i]=='1' && ui!=-1){
      arr.push_back(i-ui);
      ui = -1;
    }
  }
  if(ti!=-1){
    arr.push_back(n-ti);
  }
  if(ui!=-1){
    arr.push_back(n-ui);
  }
  vector<ll> rui(arr.size(),0);
  REP(i,arr.size()){
    rui[i] = arr[i];
    if(i>0) rui[i] += rui[i-1];
  }
  vector<ll> cand;
  ll mk;
  if(onef){
    mk = arr.size()/2;
  } else {
    mk = (arr.size()+1)/2;
  }
  k = min(k,mk);
  REP(i,mk-k+1){
    ll ad = 0;
    if(onef){
      if(i==0) ad = rui[min((ll)arr.size()-1ll,2*i+2*k)];
      else ad = rui[min((ll)arr.size()-1ll,2*i+2*k)] - rui[2*i-1];
      //cout << 2*i << "-" << min((ll)arr.size()-1ll,2*i+2*k) << endl;
    } else {
      if(i==0) ad = rui[min((ll)arr.size()-1ll,2*(i+k)-1)];
      else ad = rui[min((ll)arr.size()-1ll,2*(i+k)-1)] - rui[2*i-2];
      //cout << max(2*i-1,0ll) << "-" << min((ll)arr.size()-1ll,2*(i+k)-1) << endl;
    }
    //cout << ad << endl;
    cand.push_back(ad);
  }
  ll ans = 0;
  REP(i,cand.size()) ans = max(ans,cand[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2932
from collections import Counter
from functools import reduce
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K * x)
        x = (x * x)
        n //= 2
    return (K * x)
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0
def modinv(a, m):
    g, x, y = xgcd(a, m)
    return x % m
def modmul(a,b):
    return a * b % 1000000007
def comb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(modmul, range(n, n - r, -1))
    under = reduce(modmul, range(1,r + 1))
    return over * modinv(under, 1000000007)

N,M = (int(x) for x in input().split())
ans = 1
if M == 1:
    print('1')
else:
    a = Counter(prime_factorize(M))
    for x in a.values():
        ans = ans * comb(N+x-1,x) % 1000000007
    print(ans)

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

int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  int s = 0;
  for (auto &e : l) {
    cin >> e;
    s += e;
  }
  bool r = true;
  for (auto e : l) {
    r &= e < s - e;
  }
  cout << (r ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, Q = map(int, input().split())
    S = input()

    v = [0] * (10**5 + 100)
    for i in range(N - 1):
        if S[i] == "A" and S[i + 1] == "C":
            v[i + 1] = 1

    for i in range(len(v) - 1):
        v[i + 1] += v[i]

    for _ in range(Q):
        l, r = map(int, input().split())
        l -= 1
        r -= 1
        print(v[r] - v[l])


if __name__ == '__main__':
    main()


Measured memory_bytes: 8548
from itertools import permutations

N = int(input())
*P, = map(int, input().split())
*Q, = map(int, input().split())
P = tuple(P); Q = tuple(Q)
for i, t in enumerate(permutations(range(1, N+1))):
    if t == P:
        a = i
    if t == Q:
        b = i
print(abs(a - b))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef int64_t Int;
using namespace std;

const Int MOD = 1e9+7;


int main(){
    int H, W, K;
    cin >> H >> W >> K;

    // A[i][j] : 高さ1の移動でiからjに移動する場合の総数
    vector<vector<int>> A(8, vector<int>(8, 0));

    rep(bits, 1<<(W-1)){
        vector<int> row(8), b(8);
        rep(i, 8) row[i] = i;

        int cur = bits; bool invalid = false;
        rep(j, W-1) {
            b[j] = cur & 1; cur >>= 1;
            if(b[j] == 1) swap(row[j], row[j+1]);
            if(j > 0 && b[j] == 1 && b[j-1] == 1) invalid = true;
        }
        if(invalid) continue;

         rep(i, W) A[i][row[i]]++;
    }
    
    // dp[i][j]:高さiまでで1からjに向かう道のりの数
    vector<vector<Int>> dp(110, vector<Int>(8, 0));
    rep(i, W) dp[0][i] = A[0][i];

    rep(i,H) rep(j,W){
        rep(k, W){
            dp[i+1][j] = (dp[i+1][j] + dp[i][k]*A[k][j]%MOD)%MOD;
        }
    }

    cout << dp[H-1][K-1] << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
using namespace std;
int gcd(int a, int b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	vector<int> GCD(N);
	GCD[0] = a[0];
	for (int i = 1; i < N;i++) {
		if (a[i] > GCD[i - 1]) GCD[i] = gcd(a[i], GCD[i - 1]);
		else GCD[i] = gcd(GCD[i - 1], a[i]);
	}
	cout << GCD[N - 1];
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<ll, ll> P;


int main(void) {
	int n, i;
	string s, t, u, v, ans;
	cin >> n >> s >> t;
	ans = s + t;
	for (i = 0;i < s.length();i++) {
		u = s[s.length() - 1 - i] + u;
		v = v + t[i];
		if (u == v) {
			ans = s + t.substr(i+1, n);
		}
	}
	cout << ans.length() << endl;
	return 0;
}

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

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

    int res = 0;
    char p2, p1, now;
    for (int i = 0; i < N; i++) {
        cin >> now;

        if (p2 == 'A' && p1 == 'B' && now == 'C') {
            res++;
        }

        p2 = p1;
        p1 = now;
    }

    cout << res;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



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

    int T=1;
    //cin >> T;
    while(T--){
       string s;
       cin>>s;
       int sum=0;
       rep(i, s.length()){
        sum+=(int)(s[i]-'0');
       }
       if(sum%9==0) cout<<"Yes"<<el;
       else cout<<"No"<<el;
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3900
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    int[] inputArray;
    Set<String> set = new HashSet<>();
    int K;

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] array = new int[N];

        for(int i=0; i<N; i++){
            array[i] = sc.nextInt();
        }

        int before = array[0];
        int sum = 0;
        int count = 1;
        int i = 1;
        while(i<N){

            int now = array[i];


            if(before == now){
                count++;
                if(i == N-1){
                    sum+=((count)/2);
                }
            } else {
                sum+=(count/2);
                count = 1;
            }

            before = array[i];
            i++;
        }

        System.out.println(sum);
    }

    void substring(String s, int num){
        for(int i=1; i<=num; i++){
            if(i > K){
                break;
            }
            for(int j=0; j<num; j++){
                if(j + i-1 < num){
//                    System.out.println(s.substring(j, j+i));
                    set.add(s.substring(j, j+i));
                } else {
                    break;
                }
            }
        }
    }

    void permutation(String s, String ans){
        if(s.length() <= 1){
            System.out.println(ans + s);
        } else {
            for(int i=0; i<s.length(); i++){
                permutation(s.substring(0, i) + s.substring(i + 1), ans + s.charAt(i));
            }
        }
    }
}

Measured memory_bytes: 23124
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let g: Vec<Vec<char>> = (0..n)
        .map(|_| itr.next().unwrap().chars().collect())
        .collect();

    let mut ans = 0;
    for i in 0..n {
        let mut ok = true;
        for j in 0..n {
            for k in 0..n {
                if g[j][(i + k) % n] != g[k][(i + j) % n] {
                    ok = false;
                    break;
                }
            }
            if !ok {
                break;
            }
        }
        if ok {
            ans += n;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
fun readInts() = readLine()!!.split(' ').map(String::toInt)

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val m  = n / 2
    val dd = readInts().sorted()
    val d1 = dd[m - 1]
    val d2 = dd[m]
    println(d2 - d1)
}


Measured memory_bytes: 54296
#include <bits/stdc++.h>
#define pb push_back
#define tam 3100
#define offset 100000
#define se second
#define fi first
#define forr(i,p,n) for(int i=p;i<n;i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
typedef pair<ll,ll> ii;
ll   H,W,N;
set<ii> existe;
set<ii> cuad[100];
bool valid(int posy,int posx)
{
    if (posy<=0|| posx<=0||posy>H|| posx>W)
        return 0;
    return 1;
}
int works(int posy,int posx)
{
    int auxsum=0;
    forr(i,0,3){
        forr(j,0,3){
            if (valid(posy+i,posx+j)==0)
                return 0;
            else{
                if (existe.find(ii(posy+i,posx+j))!=existe.end())
                    auxsum++;
                //cout<<posy+i<<" "<<posx+j<<" "<<mapa[posy+i][posx+j]<<endl;
            }
        }
    }
    return auxsum;
}
int main()
{
    cin>>H>>W>>N;
    vector<ii> lst;
    int Y,X;
    forr(i,0,N)
    {
        cin>>Y>>X;
        existe.insert(ii(Y,X));
        lst.pb(ii(Y,X));
    }
    
    int xx,yy;
    forr(i,0,lst.size())
    {
        X=lst[i].se;
        Y=lst[i].fi;
        //cout<<X<<" "<<Y<<endl;
        forr(delX,-2,1)
        {
            forr(delY,-2,3)
            {
                xx=X+delX;
                yy=Y+delY;
                //cout<<yy<<" "<<xx<<" "<<works(yy,xx)<<endl;
                cuad[works(yy,xx)].insert(ii(yy,xx));
            }
        }
        //cout<<endl;
    }
    ll resp=0;
    resp=(W-2)*(H-2);
    forr(i,1,10)
        resp-=cuad[i].size();
    cout<<resp<<endl;
    forr(i,1,10)
    cout<<cuad[i].size()<<endl;

}

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

int main(){
    int n, a, b, c;
    cin >> n;
    vector<vector<int>> dp(n+1, vector<int>(3,0));
    for(int i = 1; i <= n; i++){
        cin >> a >> b >> c;
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b;
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c;
        // cout << max({dp[i][0], dp[i][1], dp[i][2]}) << "\n";
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]});
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);

  vector<int> b;
  if (n % 2 == 0) {
    for (int i = n - 1; i >= 1; i -= 2) b.push_back(a[i]);
    for (int i = 0; i < n - 1; i += 2) b.push_back(a[i]);
  } else {
    for (int i = n - 1; i >= 0; i -= 2) b.push_back(a[i]);
    for (int i = 1; i < n - 1; i += 2) b.push_back(a[i]);
  }

  for (int i = 0; i < n; i++) {
    if (i) cout << " ";
    cout << b[i];
  }
  cout << endl;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
#define f(a, n) for (int a=0; a<n; a++)
#define F(a, n) for (int a=1; a<=n; a++)
using namespace std;
typedef long long LL;

struct node{
	bool bipartite = 1;
	int col = 0;
	vector<int> nei;
};
long long x, y, n, m, b, nb, s;
bool isb;
node A[100005];
bool colour (int i, int c){
	if (A[i].col == 0) {
		A[i].col = c;
	}
	else if (A[i].col == c) return 0;
	else {
		isb = 0;
		return 0;
	}
	for (int x: A[i].nei){
		colour (x, 3-c);
	}
	return 1;
}
int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(0);
	cin>>n>>m;
	F(i, m){
		cin>>x>>y;
		A[x].nei.push_back(y);
		A[y].nei.push_back(x);
	}
	F(i, n){
		isb = 1;
		if (colour (i, 1)){
			if (isb){
				if (A[i].nei.size()) b++;
				else s++;
			}
			else nb++;
		}
	}
	cout<<s*n*2 - s*s+ 2*b*b + 2*b*nb + nb*nb <<endl;
}


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

template <long long MOD> class modint {
  long long x;
  long long norm(long long v) {
    v %= MOD;
    return (v+MOD)%MOD;
  }
public:
  modint(long long v = 0) : x(norm(v)) {
  }

  modint operator+(modint other) {
    return norm(x+other.x);
  }

  modint& operator+=(modint other) {
    x = (*this + other).x;
    return *this;
  }

  modint operator-(modint other) {
    return norm(x-other.x);
  }

  modint& operator-=(modint other) {
    x = (*this - other).x;
    return *this;
  }

  modint operator*(modint other) {
    return norm(x*other.x);
  }

  modint operator*=(modint other) {
    x = (*this - other).x;
    return *this;
  }

  /*
    modint operator/(modint other) {
    return x*mod_pow(other.x, MOD-2)%MOD;
    }

    moding operator/=(modint other) {
    x = (*this / other).x;
    return *this;
    }
  */

  modint operator^(long long b) {
    if (b == 0) return 1;
    modint ret = *this ^ (b/2);
    ret = ret * ret;
    if (b % 2 == 1) ret = *this * ret;
    return ret;
  }

  long long value() {
    return x;
  }

  friend istream& operator>>(istream& in, modint& a) {
    long long x; in >> x;
    a = modint(x);
    return in;
  }

  friend ostream& operator<<(ostream& out, modint a) {
    out << a.x;
    return out;
  }
};


const long long MOD = 1000000007;
typedef modint<MOD> mint;
const int MAX_N = 100000;
int n;
string s;

mint dp[MAX_N][13];

void calc(int cur, int i, int x) {
  if (i == n-1) dp[i][cur%13] = 1;
  else {
    forn(j,13) {
      int d = (cur*x+j)%13;
      dp[i][d] += dp[i+1][j];
    }
  }
}

int main()
{
  cin >> s;

  n = s.size();

  int r[6] = {1,10,9,12,3,4};
  int ri = 0;
  for (int i = n-1; i >= 0; i--) {
    if (s[i] == '?') {
      forn(cur,10) calc(cur,i,r[ri]);
    } else {
      calc(s[i]-'0',i,r[ri]);
    }
    ri = (ri+1)%6;
  }

  cout << dp[0][5] << endl;

  return 0;
}


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
int main(){
    char a,b,c,d;
    cin >> a >> b >> c >> d;
    if (a==b && b == c) {
        cout << "Yes";
    }else if (b==c && c==d) {
        cout << "Yes";
    }else {
        cout << "No";
    }
}

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())
print(
  'R'*(tx-sx)+'U'*(ty-sy)+'L'*(tx-sx)+'D'*(ty-sy+1)+'R'*(tx-sx+1)+'U'*(ty-sy+1)+'L'+'U'+'L'*(tx-sx+1)+'D'*(ty-sy+1)+'R'
  )

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){

	int num,i,tmp,min,max;
	long long sum;

	min = 10000000;
	max = -10000000;
	sum = 0;

	cin >> num;

	for(i=0;i<num;i++){
		cin >> tmp;

		if(min > tmp) min = tmp;
		if(max < tmp) max = tmp;
		sum += tmp;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 2e5 + 10;
int N;
LL A[MAX];

map<LL, int> cnt;

int main(void) {
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    sort(A, A + N);
    reverse(A, A + N);
    int ans = 0;
    REP(i, N) {
        int now_cnt = cnt[A[i]];
        if (now_cnt > 0) {
            RREP(j, 31) {
                LL foo = (1 << j) - A[i];
                if (foo < A[i]) break;
                if ((A[i] == foo && now_cnt > 1) || (A[i] != foo && cnt.count(foo))) {
                    if (now_cnt == 1) cnt.erase(A[i]);
                    else cnt[A[i]]--;
                    if (cnt[foo] == 1) cnt.erase(foo);
                    else cnt[foo]--;
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define rep(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define rrep(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,ans=0;
    string s,t="MARCH";
    cin>>N;
    map<char,ll> mp;
    rep(i,0,N){
        cin>>s;
        ++mp[s[0]];
    }
    rep(i,0,5){
        rep(j,i+1,5){
            rep(k,j+1,5){
                ans += mp[t[i]]*mp[t[j]]*mp[t[k]];
            }
        }
    }
    put(ans);
}

Measured memory_bytes: 512
'''A - White Cells
https://atcoder.jp/contests/abc121/tasks/abc121_a

>>> main([3, 2], [2, 1])
1
>>> main([5, 5], [2, 3])
6
>>> main([2, 4], [2, 4])
0'''


def main(amount, portion):
    print((amount[0] - portion[0]) * (amount[1] - portion[1]))


if __name__ == "__main__":
    amount = list(map(int, input().split(' ')))
    portion = list(map(int, input().split(' ')))

    main(amount, portion)


Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
int main()
{
  int N;
  cin >> N;
   int ones = N%10;
   if (ones == 2 || ones == 4 || ones == 5 || ones == 7 || ones == 9)
  {
    cout << "hon";
  } else if (ones == 3) {
    cout << "bon";
  } else {
    cout << "pon";
  }
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
typedef long long ll;
const int MAX = 999999999;

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

    if(a * b % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b;char s[99];
int main(){
	scanf("%d%d%s",&a,&b,s);
	for(int i=0; i<a+b+1; i++){
		if(!(i==a && s[i] == '-' || i!=a && s[i]>='0' && s[i]<='9')){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


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

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let x: usize = it.next().unwrap().parse().unwrap();
    let y: usize = it.next().unwrap().parse().unwrap();
    let a: usize = it.next().unwrap().parse().unwrap();
    let b: usize = it.next().unwrap().parse().unwrap();
    let _c: usize = it.next().unwrap().parse().unwrap();
    let mut p: Vec<i64> = it.map(|s| s.parse().unwrap()).collect();
    let (p, q) = p.split_at_mut(a);
    let (q, r) = q.split_at_mut(b);
    p.sort();
    q.sort();
    let mut v = vec![];
    for a in p.iter().rev().take(x).chain(q.iter().rev().take(y)).chain(r.iter()) {
        v.push(*a);
    }
    v.sort();
    v.reverse();
    let ans = v[..(x + y)].iter().fold(0, |s, a| s + *a);
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 18252
#include <stdio.h>
int main(void)
{
    long long int a,b,x,c,d,e;
    scanf("%lld %lld %lld",&a,&b,&x);
    if(a==0)
    {
        e=(b/x)+1;
    }
    else
    {
        c=(a-1)/x;
        d=b/x;
        e=d-c;
    }

    printf("%lld",e);
    return 0;

}

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

typedef long long ll;

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

template<class T>
std::istream &operator >> (std::istream &in, std::vector<T> &tgt){
  T input; in >> input;
  tgt.push_back(input);
  return in;
}

template<class T>
std::ostream &operator << (std::ostream &out, std::vector<T> &tgt){
  for(int i=0;i<tgt.size();i++)
    out << tgt.at(i) << " ";
  return out;
}

bool dist(vector<int> &a, vector<int> &b){
  int len = a.size();
  int sum=0;
  rep(i,len)
    sum += (a[i]-b[i])*(a[i]-b[i]);
  double test = sqrt(sum);
  test = test - (int)test;
  if(test>DBL_EPSILON)
    return false;
  else
    return true;
}

int main(){

  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,d; cin >> n >> d;
  vector<vector<int>> p;
  rep(i,n){
    p.push_back(vector<int>());
    rep(j,d)
      cin >> p.back();
  }

  int c=0;
  rep(i,n){
    for(int j=i+1;j<n;j++){
      if(dist(p[i],p[j]))
        c++;
    }
  }

  cout << c << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int n; cin >> n;
    cout << 24 + 24 - n << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ed = (n*(n-1))/2;
    int key;
    int ret;
    if(n%2==0){
        key = n+1;
        ret = ed-(n/2);
    }else{
        key = n;
        ret = ed-((n-1)/2);
    }
    cout << ret << endl;
     for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(i+j!=key){
                cout << i << " " << j <<endl;
            }
        }
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void solve() {
  int N, Q, a, b, p, x;
  cin >> N >> Q;
  vector<int> counter; counter.reserve(N+1); FILL(counter, 0);
  vector<int> parentOf; parentOf.reserve(N+1); FILL(parentOf, -1);
  REP0(i, N-1) {
      cin >> a >> b;
      parentOf[b] = a;
  }
  REP0(i, Q) {
      cin >> p >> x;
      counter[p] += x;
  }
  FOR(i, 2, N+1) {
      counter[i] += counter[parentOf[i]];
  }
  REP1(i, N) cout << counter[i] << ((i!=N)? " " : "");
  cout << endl;

}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

Measured memory_bytes: 3968
A,B,C,D,E,F = map(int,input().split())

maxs = 0
maxw = 1
for i in range(0,F//100+1,B):
  for j in range(0,F//100-i+1,A):
    if i+j == 0:
      continue
    w = (i+j)*100
    for k in range(0,min(F-w,E*w//100)+1,D):
      l = min((F-w-k)//C * C,(E*w//100-k)//C * C)
      s = k+l
      #print(i,j,k,l,s/(s+w))
      if maxs/(maxs+maxw) <= s/(s+w):
        maxs = s
        maxw = w
print(maxs+maxw,maxs)


Measured memory_bytes: 41072
import java.io.*;
import java.util.*;
  
class Main{
      public static void main(String[] args) {
       int narabi =0;
       int count =0;
       Scanner sc = new Scanner(System.in);
           int n = sc.nextInt();
           int [] array = new int[n];
         for(int i=0; i<n; i++){
             array[i] = sc.nextInt();
           }
           
          for(int i=0; i<array.length-1; i++){
            for(int j=array.length-1; j>0; j--){
                if(array[j] < array[j-1]){
                    int a = array[j];
                    int b = array[j-1];
                    array[j] = b;
                    array[j-1]= a;
                    count++;
                }
              }
           }
            for(int k =0; k<array.length-1; k++){
            int number = array[k];
            System.out.print(number + " ");
             }
             System.out.println(array[array.length-1]);
             System.out.println(count);
        }

     }

Measured memory_bytes: 26352
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m != 0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}

int main() {
	ll a, b, c, d;
	ll cntc=0, cntd = 0;
	ll sc = 0, sd = 0, sbc = 0, sbd = 0, ax = 0, bx = 0;
	cin >> a >> b >> c >> d;
	sc = a / c;
	if (a % c == 0)sc--;
	sd = a / d;
	if (a % d == 0)sd--;
	sbc = b / c;
	sbd = b / d;
	ll x = lcm(c,d);
	ax = a / x;
	if (a % x == 0)ax--;
	bx = b / x;
	cout << (b-a+1)-(sbc - sc + sbd - sd - (bx - ax)) << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
N, K, Q = map(int, input().split())
A = (int(x) for x in sys.stdin.read().split())
score = [K - Q] * (N + 1)
for a in A:
    score[a] += 1
ans = "\n".join("No" if s <= 0 else "Yes" for s in score[1:])
print(ans)

Measured memory_bytes: 12624
#include <iostream>
using namespace std;
int main(void)
{
  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.length(); i++)
  {
    int chara = s.at(i) + n;
    if (chara > 'Z')
      chara = 'A' + chara % 'Z' - 1;
    cout << (char)(chara);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>

using namespace std;

long long int a, b;
char op;

int main() {
    ios::sync_with_stdio(false);
    
    cin >> a >> op >> b;
    
    if (op == '+')
        cout << a + b << '\n';
    else
        cout << a- b << '\n';
    
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

class C {
    public static void main(String... args) {
        final Scanner sc = new Scanner(System.in);
        final long a = sc.nextInt();
        final long b = sc.nextInt();
        final long c = sc.nextInt();
        System.out.println(a + b < c && 4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No");
    }
}
public class Main {
    public static void main(String... args) {
        C.main();
    }
}


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

int main(){
	int a,b,ans=0;
	cin>>a>>b;
	if(a<b)ans+=b+b-1;
	if(a==b)ans=a+b;
	if(a>b)ans+=a+a-1;
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  int i;
  for (i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end(), greater<int>());
  long long result = 0;
  for (i = k; i < n; i++) {
    result += h[i];
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 1024
S = input()
S = list(S.replace('RL', '11'))
lp,rp = 0,0
for i,s in enumerate(S):
    #l並びが終わったとき
    if (lp>0)&(s!='L'):
        S[i-lp-1] = int(S[i-lp-1])+lp//2
        S[i-lp-2] = int(S[i-lp-2])+lp-lp//2
        lp = 0
    #最後がL(RLで11になっていない)
    if (i==len(S)-1)&(s=='L'):
        lp += 1
        S[i] = 0
        S[i-lp] = int(S[i-lp])+lp//2
        S[i-lp-1] = int(S[i-lp-1])+lp-lp//2
    elif s=='L':
        lp += 1
        S[i] = 0
    elif s=='R':
        rp += 1
        S[i] = 0
    #R並びが終わったとき
    elif rp>0:
        S[i] = int(S[i+1]) + rp//2
        S[i+1] = int(s) + rp-rp//2
        rp = 0
print(' '.join(map(str, S)))


Measured memory_bytes: 10412
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> x >> y >> z;
	s = "NO";
	i = x;
	j = 1;
	while(i < x*y){
		if(i%y == z){
			s = "YES";
		}
		j++;
		i = x * j;
	}
	cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 10010000000
//#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL k;
    cin >> n >> k;
    vector<LL> p(n);
    vector<LL> c(n);
    vector<LL> is_visit(n);
    for(LL i=0; i<n; i++){
        cin >> p[i];
        p[i]--;
    }
    for(LL i=0; i<n; i++){
        cin >> c[i];
    }

    LL max_ans=-1*MAX;
    LL ans;
    LL idx;
    LL loop_sum;
    LL loop_cnt;
    //cout << loop_sum << endl;
    if(k<3*n){
        for(LL i=0; i<n; i++){
            idx=i;
            ans=0;
            idx=p[idx];
            ans+=c[idx];
            max_ans=max(max_ans,ans);
            for(LL j=1; j<k; j++){
                idx=p[idx];
                ans+=c[idx];
                max_ans=max(max_ans,ans);
            }
        }
    }else{
        for(LL i=0; i<n; i++){
            for(LL j=0; j<n; j++){
                is_visit[j]=0;
            }
            idx=i;
            is_visit[idx]++;
            loop_sum=0;
            loop_cnt=0;
            idx=p[idx];
            while(is_visit[idx]!=3){
                if(is_visit[idx]==2){
                    loop_cnt++;
                    loop_sum+=c[idx];
                }
                //cout << is_visit[idx] << endl;
                is_visit[idx]++;
                idx=p[idx];
            }
            //cout << loop_cnt << endl;
            if(loop_sum<0){
                idx=i;
                ans=0;
                idx=p[idx];
                ans+=c[idx];
                max_ans=max(max_ans,ans);
                for(LL j=1; j<3*n; j++){
                    idx=p[idx];
                    ans+=c[idx];
                    max_ans=max(max_ans,ans);
                }
            }else{
                LL num_loop=(k-3*n)/loop_cnt;
                LL res_k=(k-3*n)%loop_cnt+n;
                idx=i;
                ans=0;
                idx=p[idx];
                ans+=c[idx];
                max_ans=max(max_ans,ans);
                //cout << res_k << " " << num_loop << " " << loop_cnt << " " << res_k+loop_cnt*num_loop+2*n << endl;
                for(LL j=1; j<res_k; j++){
                    idx=p[idx];
                    ans+=c[idx];
                    max_ans=max(max_ans,ans);
                }
                ans+=loop_sum*num_loop;
                max_ans=max(max_ans,ans);
                for(LL j=0; j<2*n; j++){
                    idx=p[idx];
                    ans+=c[idx];
                    max_ans=max(max_ans,ans);
                }
            }
        }
    }

    cout << max_ans << endl;

    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
#define mod 1000000007
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define forr(c, n) for (int i = c; i < n; i++)
#define forli(n) for (lli i = 0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())

//FUNCTONS
lli llipower(lli x, lli y)
{
    lli res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x);
        y = y >> 1;
        x = (x * x);
    }
    return res;
}
lli llipowerp(lli x, lli y, lli p)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli gcd(lli a, lli b)
{
    if (!a)
        return b;
    return gcd(b % a, a);
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
template <typename T>
void printvec(vector<T> inp)
{
    for (int i = 0; i < inp.size(); i++)
    {
        cout << inp[i] << " ";
    }
    cout << endl;
}
template <typename T>
T ceildiv(T x, T y) { return 1 + ((x - 1) / y); }
lli modInverse(lli a, lli m)
{
    lli g = gcd(a, m);
    if (g != 1)
        return -1;
    else
        return llipowerp(a, m - 2, m);
}

int main()
{
    int n;
    cin>>n;
    int x,y;
    cin>>x>>y;
    vector<int> counts(n+1,0);
    
    int cyclen = y - x + 1;
    for(int i=2;i<n;i++){
        counts[i]+=max(0,x-i-1);
        counts[i] += max(0, n-y - i);

        
    }
    for(int i=x;i<=y;i++){
        for(int j=i+1;j<=y;j++){
            int mind=min(j-i,i-x+y-j+1);
            counts[mind]++;
        }
    }
    for(int i=1;i<x;i++){
        for(int j=x;j<=y;j++){
            int mind=min(j-i,x+y-i-j+1);
            //if (mind == 3)
             //   cout << "p " << i << " " << j << endl;
            counts[mind]++;
        }
    }
    for (int i = y+1; i <= n; i++)
    {
        if(i>n) break;
        for (int j = x ; j <= y; j++)
        {
            int mind = min(i-j, i+j+1-x-y);
            //if(mind==3) cout<<"p "<<i<<" "<<j<<endl;
            counts[mind]++;
        }
    }
    for(int i=1;i<x;i++){
        for(int j=y+1;j<=n;j++){
            if(j>n) break;
            int mind=min(j-i,x-i+1+j-y);
            counts[mind]++;
        }
    }
    counts[1] = n;
    for(int i=1;i<n;i++) cout<<counts[i]<<endl;
}


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

using namespace std;

bool judge(const vector<int>& v);

int main()
{
    size_t n;
    cin >> n;
    vector<int> p(n);
    for (size_t i = 0; i < n; ++i)
        cin >> p[i];
    cout << (judge(p) ? "YES" : "NO") << std::endl;

    return 0;
}

bool judge(const vector<int>& v)
{
    vector<int> i(v.size());
    iota(i.begin(), i.end(), 1);
    size_t c = 0;
    for (size_t s = 0; s < v.size(); ++s)
        c += ((i[s] == v[s]) ? 0 : 1);
    return (c == 0 || c == 2);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[7][7];
int row[7],col[7];
int main(){
	int n,m,k,black,ans=0;
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)
	    for(int j=0;j<m;j++)
	        cin>>a[i][j];
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<(1<<m);j++){
			black=0;
			for(int s=0;s<n;s++){
				for(int t=0;t<m;t++){
				    if(((i>>s)&1)==0&&((j>>t)&1)==0&&a[s][t]=='#')
				        black++; 
				}
			}
			if(black==k) ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3644
// https://atcoder.jp/contests/abc084/tasks/abc084_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// constexprな素数列挙(エラトステネスの篩)
// https://259-momone.hatenablog.com/entry/2018/05/06/015026
template <int_fast64_t max_N> struct Prime {
    bool sieve[max_N];
    constexpr Prime() : sieve() {
        for (int_fast64_t i = 0; i < max_N; ++i)
            sieve[i] = true;
        sieve[0] = sieve[1] = false;
        for (int_fast64_t i = 2; i < max_N; ++i) {
            for (int_fast64_t j = i * i; j < max_N; j += i)
                sieve[j] = false;
        }
    }
};

// BIT(Binary-Indexed-Tree) 別名：Fenwick Tree
template <typename T> struct BIT {
    int n;
    vector<T> d;
    BIT(int n = 0) : n(n), d(n + 1) {}
    // 要素iにxを加算
    void add(int i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }
    // 区間[0, i]の合計を求める（閉区間）
    T sum(int i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }
};

const int SZ = 1e5 + 1;
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    constexpr auto p = Prime<SZ>();
    BIT<int> bit(SZ);
    for (int i = 1; i < SZ; i += 2) {
        if (p.sieve[i] && p.sieve[(i + 1) / 2]) {
            bit.add(i, 1);
        }
    }
    int Q;
    cin >> Q;
    while (Q--) {
        int l, r;
        cin >> l >> r;
        cout << bit.sum(r) - bit.sum(l - 1) << "\n";
    }

    return 0;
}


Measured memory_bytes: 4372
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N;
    int K;
    cin >> N;
    cin >> K;
    
    int a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    
    int L = N*(N+1)/2;
    unsigned long b[L]; // 美しさ
    int  h = 0;
    for(int l=0; l<N; l++){
        for(int r=l; r<N; r++){
            b[h] = a[l];
            for(int k=l+1; k<=r; k++){
                b[h] += a[k];
            } 
            h++;
        }
    }
    
    // 2のべき乗
    unsigned long pow2(int n);

    unsigned long A = 0;
    for(int t=40; t>0; t--){
        int count = 0;
        unsigned long x = pow2(t-1);
        for(int h=0; h<L; h++){
            if(((A+x)&b[h])==(A+x)){
                count++;
            }
        }
        if(count >= K){
            A += x;
        }
    }
    
    cout << A << endl;
}

int fact(int n){
    if(n<=1){
        return 1;
    }else{
        return n * fact(n-1);
    }
}

unsigned long pow2(int n){
    unsigned long ans = 1;
    for(int i=0; i<n; i++){
        ans *= 2;
    }
    return ans;
}


Measured memory_bytes: 4096
// ------------------
// author: MatsuTaku
// date  : 27/02/2020
// ------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  constexpr int MAX = 1e6;
  vector<int> dp(MAX+1, MAX), dpo(MAX+1, MAX);
  dp[0] = dpo[0] = 0;
  vector<int> nf, nfo;
  for (int i = 1; i*(i+1)*(i+2)/6 <= MAX; i++) {
    const int v = i*(i+1)*(i+2)/6;
    nf.push_back(v);
    if (v%2==1)
      nfo.push_back(v);
  }
  for (int i = 1; i <= MAX; i++) {
    for (auto f : nf) {
      if (i-f<0) break;
      dp[i] = min(dp[i], dp[i-f]+1);
    }
    for (auto f : nfo) {
      if (i-f<0) break;
      dpo[i] = min(dpo[i], dpo[i-f]+1);
    }
  }

  int n;
  while (cin>>n and n > 0) {
    cout << dp[n]<<" "<<dpo[n]<<endl;
  }

  return 0;
}



Measured memory_bytes: 10556
n = int(input())
x = 0

for i in range(1,n+1):
    if i%3 ==0:
        print(" %d"%i, end="")
    else:
        x=i
        while(x):
            if x%10 ==3:
                print(" %d"%i, end="")
                break
            x //= 10
print()


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

using namespace std;
typedef long long int ll;

int main()
{
    int n;
    scanf("%d", &n);
    int h[n];
    for (int i=0; i<n; i++)
    {
        scanf("%d", &h[i]);
    }
    
    int cnt = 0;
    int max_cnt = 0;
    int pre_h = h[0];
    for (int i=1; i<n; i++)
    {
        if (h[i] <= pre_h) cnt++;
        else
        {
            if (max_cnt < cnt) max_cnt = cnt;
            cnt = 0;
        }
        pre_h = h[i];
    }
    if (max_cnt < cnt) max_cnt = cnt;

    printf("%d\n", max_cnt);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e6 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int ans = ((n + 999) / 1000) * 1000 - n;
	cout << ans;

	return 0;
}

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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> a(n);
  vector<pair<int, int>> p(m);
  rep(i, n) cin>>a[i];
  rep(i, m) {
    int b,c;
    cin>>b>>c;
    p[i]=make_pair(c, b);
  }

  int ans=0;
  int cnt=0;
  sort(a.begin(), a.end());
  sort(p.begin(), p.end());
  for (int i=m-1; i>=0; i--) {
    int b=p[i].second;
    int c=p[i].first;
    while (b>0&&a[cnt]<c&&cnt<n) { 
      a[cnt]=c;
      cnt++;
      b--;
    }
    if (cnt==n) break;
  }
  ll sum=0;
  rep(i, n) sum+=a[i];
  cout<<sum<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N =1e5+5;
const ll mod=1e9+7;
char s[N];
ll dp[N][13]={0};
int main()
{
    scanf("%s",s);
        int n=strlen(s)-1;

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

        if(s[i]=='?')
        {
            if(i==0)
            {
                for(int j=0;j<10;j++)
                    dp[i][j]=1;
            }
            else
            {
                for(int j=0;j<13;j++)
                {
                    for(int k=0;k<=9;k++)
                    {
                        dp[i][(j*10+k)%13]+=dp[i-1][j];
                        dp[i][(j*10+k)%13]%=mod;
                    }
                }
            }
        }
        else
        {
            if(i==0)
            {
                dp[i][s[i]-'0']=1;
            }
            else
            {
                for(int j=0;j<13;j++)
                {
                    dp[i][(j*10+s[i]-'0')%13]+=dp[i-1][j];
                    dp[i][(j*10+s[i]-'0')%13]%=mod;
                }

            }
        }
    }
    cout<<dp[n][5]<<endl;
    return 0;
}


Measured memory_bytes: 10624