akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define Vsort(a) sort(a.begin(), a.end())
#define rep(i,a,b) for(int i = a; i < (b); i++)
#define P pair<int, int>
using namespace std;

const int64_t mod = 1000000007;

int main() { 
  int64_t n, sum = 0, ans = 0, b;
  cin >> n;
  vector<int64_t> a(n);
  rep(i,0,n){
    cin >> a[i];
    sum += a[i];
  }
  rep(i,0,n-1){
    sum -= a[i];
    b = sum % mod;
    ans += a[i] * b;
    ans %= mod;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4848
#include <iostream>

int main(void){
    int S, h, m, s;
    std::cin >> S;
    h = S/3600;
    S = S%3600;
    m = S/60;
    s = S%60;
  
    std::cout << h << ":" << m <<":" << s <<std::endl;
    return 0;
} 



Measured memory_bytes: 3080
#include<iostream>
#include<cmath>

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  
  int no_rm = 0;
  int with_rm = 0;
  if(K % 2 == 0){
    for(int i = N; i >= 1; i--){
      if(i % K == 0) no_rm++;
      else if(i % K == K/2) with_rm++;
    }
  }else{
    for(int i = N; i >= 1; i--){
      if(i % K == 0) no_rm++;
    }
  }
  long long int ans = 0LL;
  ans = pow(no_rm,3) + pow(with_rm,3);
  
  cout << ans;
  
}


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

int main() {
	// your code goes here
	long long n;
	cin >> n;
	long long hiro=1;
	for(int i=n;i>=1;i--){
		hiro=(hiro*i)%1000000007;
	}
	cout << hiro << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define re(i,n) for(i=0;i<n;i++)
#define bre(i,n) for(i=n;i>0;i--)
#define rep(i,l,r) for(i=l;i<r;i++)
#define brep(i,l,r) for(i=r;i>l;i--)
const int inf=1145141919810893;
const int mod=1000000007;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
template<int H,int W>int wa(int x1,int y1,int x2,int y2,int(&p)[H][W]){
	return p[y2][x2]-p[y2][x1]-p[y1][x2]+p[y1][x1];
}
struct Unif{
	vector<int> e;
	vector<int> rank;
	Unif(int n):e(n,-1),rank(n,1){}
	void uni(int a,int b){
		if(e[a]!=-1)
			uni(e[a],b);
		else if(e[b]!=-1)
			uni(a,e[b]);
		else{
			if(a==b)
				return;
			int ra=rank[a],rb=rank[b];
			if(ra>=rb){
				e[b]=a;
				if(ra==rb)
					rank[a]++;
			}
			else
				e[a]=b;
		}
	}
	bool find(int a,int b){
		if(e[a]!=-1)
			return find(e[a],b);
		else if(e[b]!=-1)
			return find(a,e[b]);
		else
			return a==b;
	}
	int num(int a){
		if(e[a]!=-1)
			return num(e[a]);
		else
			return a;
	}
};
int A,B,C,D,N,M,K,S,T,H,W;
signed main(){
	int i,j,k;
	cin>>N>>K;
	int ans=0;
	rep(i,K+1,N+1){
		if(K==0)
			ans+=N;
		else{
			ans+=(N/i)*(i-K);
			if(N%i>0&&N%i>=K)
				ans+=N%i-K+1;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)


#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
    return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////

int main()
{
    FASTIO;

    ll n, m;

    cin >> n >> m;



    vector<pair<ll,ll>>v;

    for(int i=0; i<n; i++)
    {
        ll a, b;

        cin >> a >> b;

        v.pb(mp(a,b));
    }

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


    ll sum = 0;

    for(int i=0; i<n; i++)
    {
        if(m<=0)
        {
            break;
        }
        else
        {

            if(v[i].second<=m)
            {
                sum += (v[i].first*v[i].second);
                m -= v[i].second;
            }
            else
            {
                sum += (v[i].first*m);
                m -= m;

            }
        }
    }

    cout << sum << endl;





    return 0;
}



Measured memory_bytes: 2420
import sys

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001


P = str(input()).upper()
line = []

while True:
    tmp_line = str(input())
    if tmp_line == 'END_OF_TEXT':
        break
    line += tmp_line.upper().split()

ans = 0

for tmp_word in line:
    if tmp_word == P:
        ans += 1

print("%d"%(ans))


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

int main(){
    int N,Y;
    cin >> N >> Y;
    Y /= 1000;
    int man_max = Y / 10 + 1;
    rep(i,man_max){
        int gosen_max = (Y - 10 *i)/5 +1;
        rep(j,gosen_max){
            int k = N - i -j;
            if (i * 10 + j * 5 + k == Y){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl; 

    return 0;
}

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


// ------------------------

void solve() {
    int A[3][3];
    rep(i, 3) rep(j, 3) cin >> A[i][j];
    int N; cin >> N;
    vector<int> b(N); rep(i, N) cin >> b[i];
    bool B[3][3];
    rep(i, 3) rep(j, 3) B[i][j] = false;

    rep(itr, N){
        rep(i, 3){
            rep(j,3){
                if( A[i][j] == b[itr] ) B[i][j] = true;
            }
        }
    }

    bool tate = false;
    bool yoko = false;
    bool naname = false;
    rep(i, 3){
        if((B[i][0] == true) && (B[i][1] == true) && (B[i][2] == true)) yoko = true;
        if((B[0][i] == true) && (B[1][i] == true) && (B[2][i] == true)) tate = true;
    }
    if((B[0][0] == true) && (B[1][1] == true) && (B[2][2] == true) ) naname = true;
    if((B[0][2] == true) && (B[1][1] == true) && (B[2][0] == true) ) naname = true;


    if(yoko | tate | naname){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }


const int INF = 1<<29;
int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10, INF));
    for (int i = 0; i < 10; ++i) for (int j = 0; j < 10; ++j) cin >> c[i][j];
    for (int k = 0; k < 10; ++k)
        for (int i = 0; i < 10; ++i) 
            for (int j = 0; j < 10; ++j)
                chmin(c[i][j], c[i][k] + c[k][j]);
    long long res = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            int A; cin >> A;
            if (A == -1) continue;
            res += c[A][1];
        }
    }
    cout << res << endl;
}

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

int main() {
    string s;
    int n;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) {
      for(int j = 0; j < n; j++) {
        if(s[i]=='Z') s[i] = 'A';
        else s[i]++;
        }
    }    
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	 int n,m,xc,yc;
	 int x[1000]={0},y[1000]={0};
	 cin>>n>>m>>xc>>yc;
	 for(int i=0;i<n;i++)
	 cin>>x[i];
	 for(int i=0;i<m;i++)
	 cin>>y[i];
	 int flag=1;
	 for(int i=xc+1;i<=yc;i++)
	 {  flag=0;
	 	for(int j=0;j<n;j++)
	     {
	     	if(i>x[j])continue;
	     	else 
			 {flag=1;
			 	break;
			 }
		 }
		 if(flag==1)continue;
	 for(int j=0;j<m;j++)
	 {
	 	if(i<=y[j])continue;
	     	else 
			 {flag=1;
			 	break;
			 }
	 }
	 if(flag==0)break;
	 }
	 if(flag==0)
	 {
	 	cout<<"No War"<<endl;
	 }
	 else
	 {
	 	 cout<<"War"<<endl;
	 }
 } 

Measured memory_bytes: 256
N = int(input())
A = [[] for _ in range(N)]
for i in range(N):
    Ai = int(input())
    for _ in range(Ai):
        x, y = map(int, input().split())
        A[i].append((x - 1, y))


def countBit(x):
    if x == 0:
        return 0
    else:
        return countBit(x >> 1) + (x & 1)


res = 0
for bits in range(2 ** N):
    bits_ = bin(bits)
    consistency = True
    for i, testimony in enumerate(A):
        if not ((bits >> i) & 1):
            continue
        for t in testimony:
            if ((bits >> t[0]) & 1) ^ t[1]:
                consistency = False

    if consistency:
        res = max(res, countBit(bits))

print(res)


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

#define ll long long
#define p_q priority_queue
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)

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

    int x;
    cin>>x;

    if(500*k>=x){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}



Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let n: usize = sc.get();
    let a: Vec<i64> = sc.vec(n);
    let mut p = 0;
    let mut ans1 = 0;
    for i in 0..n {
        let mut s = p + a[i];
        if i == 0 && s >= 0 {
            ans1 += s.abs()+1;
            s = -1;
            p = s;
            continue;
        }
        if s * p > 0 || s == 0 {
            ans1 += s.abs()+1;
            s = if p > 0 { -1 } else { 1 };
        }
        p = s;
    }
    let mut p = 0;
    let mut ans2 = 0;
    for i in 0..n {
        let mut s = p + a[i];
        if i == 0 && s <= 0 {
            ans2 += s.abs()+1;
            s = 1;
            p = s;
            continue;
        }
        if s * p > 0 || s == 0 {
            ans2 += s.abs()+1;
            s = if p > 0 { -1 } else { 1 };
        }
        p = s;
    }
    println!("{}", min(ans1, ans2));
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

bool compare(pair<int, string> a, pair<int, string> b) {
    if(a.first == b.first) {
        return a.second < b.second;
    }
	return a.first > b.first;
}

int main(int argc, char *argv[])
{
	int N;
	vector<pair<int, string>> v;
	map<string, int> mp;

	cin >> N;

	for (int i = 0; i < N; i++) {
		string S;
		cin >> S;
		mp[S] += 1;
	}

	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		pair<int, string> p;
		p = make_pair(itr->second, itr->first);
		v.push_back(p);
	}
	sort(v.begin(), v.end(), compare);
	int i = 0;
	for (auto p : v) {
		if (i == 0) {
			cout << p.second << endl;
			i = p.first;
		} else {
			if (i == p.first) {
				cout << p.second << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 30960
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

//const int dx[] = { -1, 0, 0, 1 }, dy[] = { 0, -1, 1, 0 };
const int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }


int main()
{
	cin.sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vs fld(h);
	REP(i, h) cin >> fld[i];
	int ans = 0;
	set<pii> st;
	REP(i, h)REP(j, w) st.emplace(i, j);
	for (ans = 0;; ans++)
	{
		vector<pii> col;
		for(auto i: st)
		{
			int x = i.first, y = i.second;
			if (fld[x][y] == '.') continue;
			int cnt = 0;
			REP(k, 8)
			{
				int nx = x + dx[k], ny = y + dy[k];
				if (!valid(nx, ny, h, w)) continue;
				if (fld[nx][ny] == '.') cnt++;
			}
			if (cnt >= fld[x][y] - '0') col.emplace_back(i);
		}
		if (col.empty()) break;
		st.clear();
		for (auto i : col)
		{
			fld[i.first][i.second] = '.';
			REP(k, 8)
			{
				int nx = i.first + dx[k], ny = i.second + dy[k];
				if (!valid(nx, ny, h, w)) continue;
				st.emplace(nx, ny);
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 50844
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 1e5+10;
const int N = 1e5+10;
const int E = 2e5+10;  
double x;
double y;

int main(){
	cin>>x;
	y = 100;
	ll ans = 0 ;
	while(y<x){
		y = floor(y*1.01);
		ans++; 
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3720
#include <stdio.h>

int main(void) {
  int N;
  scanf("%d", &N);

  int even = 0;
  int A[10000];
  for(int i = 0; i < N; i++) {
    int a;
    scanf("%d", &a);
    if((a % 2) == 0) {
      A[even++] = a;
    }
  }

  int ans = 0;
  while(even > 0) {
    if((A[even-1] % 2) == 0) {
      A[even-1] /= 2;
      ans++;
    } else {
      even--;
    }
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ll long long int
#define mx 10000003;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n+7];
    for(int i=1;i<=n;i++) cin>>a[i];
    ll dp[n+7];
    for(int i=1;i<=n;i++) dp[i]=12345678901234;
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=2;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i-j>0){
                dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
            }
        }
    }
    cout<<dp[n]<<endl;

}

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

const double PI=acos(-1.0);
#define ll long long
int main()
{

	
	 ll i,j,k;
	 ll n;

	cin>>n;
  	ll a[n];
    ll sum=1,sum2=1000000000000000000;
	
	for ( i = 0,j = 0; i < n; ++i)	
	{
		cin>>a[i];
		if(a[i]==0)j=1;
		
	}
	if(j==0){
	
	sort(a,a+n);
	for ( i = n-1,k=0; i > -1; --i)
	{
		
		if(a[i]<=(sum2/sum))
		{
			sum*=a[i];				
		}
		else {k=1;break;}
	}

	if(k!=1){
		ll sum3=sum;
		cout<<sum3<<endl;
	}
	else cout<<"-1\n";
	
	
	}
	else cout<<"0\n";
	return 0;
}

Measured memory_bytes: 4384
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int nxt_ind(int x, const int n) {
    if (x<n-1) return x+1;
    else return 1;
}

int main(int argc, char const *argv[]) {
    int n,k; cin>>n>>k;
    int m = (n-1)*(n-2)/2;
    if (k > m) {
        cout << -1 << '\n';
        return 0;
    }

    vector<vector<int>> g(n);

    int o = m-k;

    for (int i = 1; i < n; ++i) {
        g[0].push_back(i);
    }

    for (int i = 1; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            if (o==0) break;
            g[i].push_back(j);
            o--;
        }
    }

    int sz = 0;
    rep(i,n) sz+=(int)g[i].size();
    cout << sz << '\n';

    rep(i,n) {
        for (auto &&e: g[i]) {
            cout << i+1 << ' ' << e+1 << '\n';
        }
    }

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

char s[100];
int main() {
  int n;
  scanf("%d", &n);
  vector<int> cnt(26, INF);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s);
    vector<int> cur(26);
    for (int j = 0; s[j]; ++j) {
      cur[s[j] - 'a']++;
    }
    for (int j = 0; j < 26; ++j) {
      cnt[j] = min(cur[j], cnt[j]);
    }
  }
  int m = 0;
  for (int i = 0; i < 26; ++i) {
    while (cnt[i]--) s[m++] = (char)('a' + i);
  }
  s[m] = 0;
  puts(s);
  return 0;
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using P   = pair<int, int>;
using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();
    for(int i=0;i<n-8;i++){
        cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
# Bugged

n = int(input())
s = []
for i in range(n):
    s.append(int(input()))

a = []
for ss in s:
    if ( ss%10!=0 ):
        a.append(ss)
ssum = sum(s)
if ( ssum%10!=0 ):
    print(ssum)
else:
    if ( len(a)==0 ):
        print(0)
    else:
        print(ssum-min(a))

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

int main() {
  	int x, n;
  	scanf("%d %d", &x, &n);
  	if(n==0){
      	cout << x << endl;
      	return 0;
    }
  	vector<int> vec;
  	string s;
  	while(cin>>s) {
    	vec.push_back(stoi(s));
    }
  	sort(vec.begin(), vec.end());
  	for(int d = 0; d < 100; d++) {
      	int min = x - d;
		if(find(vec.begin(), vec.end(), min) == vec.end()){
			cout << min << endl;
          	return 0;
        }
      	int max = x + d;
      	if(find(vec.begin(), vec.end(), max) == vec.end()){
			cout << max << endl;
          	return 0;
        }
    }
	return 0;
}

Measured memory_bytes: 3684
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    long long hoge=0;
    
    for(int i=0;i<n;i++){
        if(i==0) hoge=k;
        else hoge*=k-1;
    }
    
    cout<<hoge<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  cout << (N+1)/2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main(){
    int x; cin >> x;
    if(x < 1200)print("ABC");
    else print("ARC");
}

Measured memory_bytes: 256
n,s=int(input()),input()
r=[0]*n
g=[0]*n
b=[0]*n
for i in range(n):
    if s[i]=="R":
        r[i]=1
    elif s[i]=="G":
        g[i]=1
    else:
        b[i]=1
for i in range(n-1):
    r[i+1]+=r[i]
    g[i+1]+=g[i]
    b[i+1]+=b[i]
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if s[i]!=s[j]:
            if {s[i],s[j]}=={"R","G"}:
                ans+=b[-1]-b[j]
                if 2*j-i<n and s[2*j-i]=="B":
                    ans-=1
            if {s[i],s[j]}=={"R","B"}:
                ans+=g[-1]-g[j]
                if 2*j-i<n and s[2*j-i]=="G":
                    ans-=1
            if {s[i],s[j]}=={"B","G"}:
                ans+=r[-1]-r[j]
                if 2*j-i<n and s[2*j-i]=="R":
                    ans-=1           
print(ans) 

Measured memory_bytes: 69464
#include<stdio.h>

int a[1000000],n;
int binarysearch(int key){
	int left = 0;
	int right = n;
	int mid;
	while(left<right){
		mid = (left + right)/2;
		if( key == a[mid] )return 1;
		if( key > a[mid] )left = mid+1;
		else if( key < a[mid] )right = mid;
	}
	return 0;
}
	
	int main(){
		int i,q,k,sum = 0;
		 
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d",&a[i]);
		}
		scanf("%d",&q);
		for(i=0;i<q;i++){
			scanf("%d",&k);
			if(binarysearch(k))sum++;
		}
		printf("%d\n",sum);
		return 0;
	}

Measured memory_bytes: 980
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=405;
const int mod=1e7;
int n;
ll ans;
int a[4];
class tile{
public:
	int c[4],cnt;
	tile(){
		memset(c,0,sizeof(c));
	}
	tile(int a[]){
		rep(i,4)c[i]=a[i];
	}
	bool operator <(const tile &other)const{
		rep(i,3)if(c[i]!=other.c[i])return c[i]<other.c[i];
		return c[3]<other.c[3];
	}
	bool operator ==(const tile &other)const{
		rep(i,4)if(c[i]!=other.c[i])return false;
		return true;
	}
	tile Rotate(){
		tile res=tile();
		rep(i,4)res.c[i]=c[(i+3)%4];
		return res;
	}
	tile change(){
		cnt=0;
		tile t[4];
		rep(i,4)t[0].c[i]=c[i];
		REP(i,3)t[i]=t[i-1].Rotate();
		sort(t,t+4);
		rep(i,4)if(t[i]==t[0])cnt++;
		return t[0];
	}
	int get_hash(){
		int hsh=0;
		rep(i,4)hsh=((1LL*hsh*101%mod)+c[i])%mod;
		return hsh;
	}
	void debug(){
		rep(i,4)printf("%d ",c[i]);
		puts("");
	}
}t[maxn];
int mp[mod+5];

int main(){
	scanf("%d",&n);
	rep(i,n){
		rep(j,4)scanf("%d",&a[j]);
		t[i]=tile(a);
		mp[t[i].change().get_hash()]++;
	}
	rep(i,n)
		for(int j=i+1;j<n;j++){
		tile A=t[i],B=t[j];
		int C=A.change().get_hash(),D=B.change().get_hash();
		mp[C]--;
		mp[D]--;
		rep(C,4){
			vector<int>ch;
			int cur1=0,cur2=0;
			ll res=1LL;
			rep(k,4){
				a[0]=A.c[cur1],a[1]=A.c[(cur1+3)%4],a[2]=B.c[cur2],a[3]=B.c[(cur2+3)%4];
				tile now=tile(a);
				int NOW=now.change().get_hash();
				res*=1LL*mp[NOW]*now.cnt;
				if(mp[NOW])mp[NOW]--,ch.push_back(NOW);
				cur1=(cur1+3)%4;
				cur2=(cur2+1)%4;
			}
			ans+=res;
			B=B.Rotate();
			rep(i,ch.size())mp[ch[i]]++;
		} 
		mp[C]++;
		mp[D]++;
	}
	printf("%lld",ans/3);
	return 0;
}
/*
6
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0
*/

Measured memory_bytes: 37248
#include <iostream>
#include <vector>

using namespace std;

int main(void){
    int N;
    int sum = 1;
    int max;
    cin >> N;
    std::vector<int> v(N);

for(int i = 0; i < N; ++i)
    cin >> v[i];

max = v[0];

for(int i = 1; i < N; ++i){
    if(v[i] >= max){
    sum += 1;
    max = v[i];
    }
}

std::cout << sum << endl;

 return 0;    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=100000000;
const int MOD=1000000007;

int main()
{
 int n;
 ll sum=0;
 cin >> n;
 int a[n];
 for(int i=0;i<n;i++) cin >> a[i];
 for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      sum+=a[i]*a[j];
 	}
 }
 cout << sum;
 return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
q=int(input())
BC=[list(map(int,input().split())) for _ in range(q)]

num=sum(A)
N={}
for i in A:
   if i not in N:N[i]=0
   N[i] +=1

for b,c in BC:
    if b not in N:
        print(num)
        continue
    dig=c-b
    num +=dig*N[b]
    print(num)
    if c not in N:N[c]=0
    N[c] +=N[b]
    N[b]=0

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

using ll=long long; 

void solve(){
	string s;
	string ans;
	cin>>s;
	for(int i=0; i<s.size(); i++){
		if(i%2==0){
			ans.push_back(s[i]);
		}
	}
	cout<<ans<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

using namespace std;

int main()
{
    double n,t,a,i,j=0,d=0,m=100005;
    cin>>n>>t>>a;
    double p[10000],r;
    double h;
    for(i=1; i<=n; i++)
    {
        r=0;
        cin>>h;
        r=(0.006*h);
        d=abs(a-(t-r));
       // cout<<d<<endl;
        if(m>d)
        {
                m=d;
              //  cout<<m<<endl;
                j=i;
        }

    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main(){
int b,k,i,d=1000,x,y,z;
char a[11];
scanf ("%s ",a);
for(i=0;i< strlen(a)-2 ;i++)
{
x=a[i]-'0';
y=a[i+1]-'0';
z=a[i+2]-'0';
b=(100*x)+(10*y)+z;
if(d>abs(b-753)){
	d=abs(b-753);
	}
}
	printf ("%d",d);
	return 0;
	}

Measured memory_bytes: 128
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
// define
#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()
// typedef
typedef long long lint;
typedef double Double;
typedef pair<int, int> pii;
//
typedef vector< int > Array;
typedef vector< Array > Matrix;
typedef vector< Double > DArray;
typedef vector< DArray > DMatrix;
typedef vector< string > SArray;
typedef vector< pii > PArray;
// popcount
inline int POPCNT(int _x) { return __builtin_popcount(_x); }
inline int POPCNT(lint _x) { return __builtin_popcountll(_x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
Double EPS = 1e-9;
// in range
inline bool in_range(int _v, int _mx, int _mi) { return _mi <= _v && _v < _mx; }
inline bool in_range(Double _v, Double _mi, Double _mx) { return -EPS < _v - _mi && _v - _mx < EPS; }
inline bool in_range(int _x, int _y, int _W, int _H) { return 0 <= _x && _x < _W && 0 <= _y && _y < _H; }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};

int n;
string data[1010];

int level[1010];

void solve() {
	for_(i,0,n) {
		int cnt = 0, len = size_of(data[i]);
		
		for_(j,0,len) {
			if (data[i][j] == '.') {
				cnt++;
				data[i][j] = ' ';
			} else {
				break;
			}
		}
		
		level[i] = cnt;
	}
	
	int prev = level[0];
	
	for_(i,1,n) {
		int pos = level[i] - 1;
		
		if (prev <= level[i]) {
			data[i][pos] = '+';
		} else if (prev > level[i]) {
			data[i][pos] = '+';
			
			for_rev(j,i - 1, 0) {
				if (data[j][pos] == '+') break;
				data[j][pos] = '|';
			}
		}
		
		prev = level[i];
	}
	
	for_(i,0,n) cout << data[i] << endl;
}

int main() {
	while (cin >> n, n) {
		for_(i,0,n) cin >> data[i];
		solve();
	}
	return 0;
}

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

using namespace std;


using ull = unsigned long long;


int main() {
    ull X;
    cin >> X;

    ull t = 0;
    ull now = 100;
    while (now < X) {
        t++;
        now = now + ((ull)((double)(now) * 0.01));
    }
    cout << t << endl;
}


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int N;
const int MAX_N = 100;
ll T[MAX_N];

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

ll lsm(ll a, ll b){
  return a / gcd(a, b) * b;
}

int main()
{
  cin >> N;
  rep(i, 0, N)cin >> T[i];

  ll ans = 1;
  rep(i, 0, N){
    // cout << ans << T[i] << endl;
    ans = lsm(ans, T[i]);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int n, _min;
    string s[36], t[36], p[10]={""}, c[10]={""}, d[10]={""};
    bool f=true, g=true;
    cin>>n;
    for (int i=0; i<n; i++)
    {
        cin>>s[i];
        swap(s[i][0], s[i][1]);
        p[s[i][0]-'0']+=s[i][1];
        t[i]=s[i];
    }
    for (int i=0; i<n-1; i++)
    {
        for (int j=0; j<n-1; j++)
        {
            if (s[j][0]>s[j+1][0]) swap(s[j], s[j+1]);
        }
    }
    for (int i=0; i<n; i++) c[s[i][0]-'0']+=s[i][1];
    for (int i=1; i<10; i++) if (p[i]!=c[i]) f=false;
    for (int i=0; i<n; i++)
    {
        _min=i;
        for (int j=i; j<n; j++)
        {
            if (t[_min][0]>t[j][0]) _min=j;
        }
        if (_min!=i) swap(t[i], t[_min]);
    }
    for (int i=0; i<n; i++) d[t[i][0]-'0']+=t[i][1];
    for (int i=1; i<10; i++) if (p[i]!=d[i]) g=false;
    for (int i=0; i<n; i++)
    {
        swap(s[i][0], s[i][1]);
        swap(t[i][0], t[i][1]);
    }
    for (int i=0; i<n; i++)
    {
        if (i!=n-1) cout<<s[i]<<' ';
        else cout<<s[i]<<'\n';
    }
    cout<<(f ? "Stable\n" : "Not stable\n");
    for (int i=0; i<n; i++)
    {
        if (i!=n-1) cout<<t[i]<<' ';
        else cout<<t[i]<<'\n';
    }
    cout<<(g ? "Stable\n" : "Not stable\n");
    return 0;
}



Measured memory_bytes: 3160
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=1;i<=n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int i,j,k;
  int n,m,a,b;
  int s,g,v,p;
  int cost[25][25]={};

  cin>>n>>m;

  rep(i,n)rep(j,n)cost[i][j]=INF;
  rep(i,n)cost[i][i]=0;

  rep(i,m){
    scanf("%d,%d,",&a,&b);
    scanf("%d,%d",&cost[a][b],&cost[b][a]);
  }
  scanf("%d,%d,%d,%d",&s,&g,&v,&p);

  rep(k,n)rep(i,n)rep(j,n)
    cost[i][j]=min(cost[i][j],cost[i][k]+cost[k][j]);

  cout<<v-p-cost[s][g]-cost[g][s]<<endl;

}

Measured memory_bytes: 3248
def solve(n):
    for a in range(1,3501):
        for b in range(1,3501):
            num = n * a * b
            deno = 4 * a * b - n * a - n * b
            if deno > 0 and num >= deno and num % deno == 0:
                c = num / deno
                print a,b,c
                return
    print 'NotFound!'
    return

n = int(raw_input())
solve(n)


Measured memory_bytes: 2948
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S, T = input().split()
A, B = MAP()
U = input()

if U == S:
	A -= 1
else:
	B -= 1
print(A, B)


Measured memory_bytes: 5832
import sys
sys.setrecursionlimit(100000)

MOD = 10**9 + 7
N, K = map(int,input().split())

G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int,input().split())
    a, b = a-1, b-1

    G[a].append(b)
    G[b].append(a)

# 頂点nowを根とする部分木の色の塗り方 (parが親の時)
#   ただしnowはすでに塗られているとする
def dfs(now, par):
    if K < len(G[now]): return 0

    res = 1

    if par == -1:
        colors = K-1
        for i in range(len(G[now])):
            res *= colors-i
            res %= MOD
    else:
        colors = K-2
        for i in range(len(G[now])-1):
            res *= colors-i
            res %= MOD

    for c in G[now]:
        if c == par: continue
        
        res *= dfs(c, now)
        res %= MOD
    
    return res

print(K * dfs(0,-1) % MOD)


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

int n, m = 0;
int l[2000];

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> l[i];

	sort(l, l + n);

	for (int i = 2; i < n; i++) {
		for (int j = 0; j < i - 1; j++) {
			for (int k = j + 1; k < i; k++) {
				if (l[i] < l[j] + l[k])
					m++;
			}
		}
	}

	cout << m << endl;

	return 0;
}

Measured memory_bytes: 256
def linerSearch(array, key)
  i = 0
  array.push(key)
  while array[i] != key
    i += 1
    if i == array.length - 1
      array.pop
      return false
    end
  end
  array.pop
  return true
end

n = gets.to_i
s = gets.chomp.split(' ').map(&:to_i)
q = gets.to_i
t = gets.chomp.split(' ').map(&:to_i)
count = 0

q.times do |i|
  count += 1 if linerSearch(s, t[i])
end
puts count

Measured memory_bytes: 9048
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

H, W, K = map(int, input().split())

C = [0] * H
for i in range(H):
    C[i] = input()

ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        val = 0
        for y in range(H):
            if i & 1 << y > 0:
                continue
            for x in range(W):
                if j & 1 << x > 0:
                    continue
                if C[y][x] == '#':
                    val += 1
        if val == K:
            ans += 1
print(ans)

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vector<vi> adj(n);
    rep(i,n-1){
        int a,b; cin>>a>>b; a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    vi dist1(n,-1), dist2(n,-1);
    queue<int> que;
    que.push(0);
    dist1[0] = 0;
    while(que.size()){
        int v = que.front(); que.pop();
        for(auto u:adj[v]){
            if (dist1[u]!=-1) continue;
            dist1[u] = dist1[v]+1;
            que.push(u);
        }
    }
    que.push(n-1);
    dist2[n-1] = 0;
    while(que.size()){
        int v = que.front(); que.pop();
        for(auto u:adj[v]){
            if (dist2[u]!=-1) continue;
            dist2[u] = dist2[v]+1;
            que.push(u);
        }
    }
    int fennec=0, snuke=0;
    rep(i,n){
        if (dist1[i]<=dist2[i]){
            fennec++;
        }else{
            snuke++;
        }
    }
    if (fennec>snuke){
        cout<<"Fennec\n";
    }else{
        cout<<"Snuke\n";
    }
    return 0;
}


Measured memory_bytes: 6528
//ITP1_7_D
#include<iostream>
using namespace std;

int main()
{
	int n,m,l,i,j,k;
	cin>>n>>m>>l;
	
	int Anm[101][101]={},Bml[101][101]={};
	long Cnl[101][101]={};
	for(i=0;i<n;i++){
		for(k=0;k<m;k++){
			cin>>Anm[i][k];
		}
	}
	for(k=0;k<m;k++){
		for(j=0;j<l;j++){
			cin>>Bml[k][j];
		}
	}
	
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=0;k<m;k++){
				Cnl[i][j]+=Anm[i][k]*Bml[k][j];
			}
		}
	}
	
	for(i=0;i<n;i++){
		for(j=0,k=0;j<l;j++,k++){
			if(k!=0){
				cout<<" ";
			}
			cout<<Cnl[i][j];
		}
		cout<<endl;
	}
	
		
	return 0;
}

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

int main()
{
  int n, m;

  cin >> n >> m;

  int sum = 0, tmp = 0;
  for(int i = 0; i < m; i++){
    cin >> tmp;
    sum += tmp;
  }

  if(n - sum >= 0){
    cout << n - sum;
  }
  else{
    cout << -1;
  }
    
  return 0; 
}


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

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int kazu,i,j,smi;
		Scanner sca = new Scanner(System.in);
		kazu=sca.nextInt();
		String hai1[]=new String[kazu],hai2[]=new String[kazu],hz;
		int order1[]=new int[kazu], order2[]=new int[kazu],hzi;
		for(i=0;i<kazu;i++){
			hai2[i]=hai1[i]=sca.next();
			order2[i]=order1[i]=i;
		}
       for(i=0;i<kazu-1;i++){
    	   for(j=kazu-1;j>0;j--){
    		   if((int)(hai1[j].charAt(1))<(int)(hai1[j-1].charAt(1))){
    			   hz=hai1[j];
    			   hai1[j]=hai1[j-1];
    			   hai1[j-1]=hz;
    			   hzi=order1[j];
    			   order1[j]=order1[j-1];
    			   order1[j-1]=hzi;
    		   }
    	   }
	}
  for(i=0;i<kazu;i++){
    if(i!=kazu-1){	 
     System.out.print(hai1[i]+" ");
     }else{
    	 System.out.println(hai1[i]);
     }
     }
     System.out.println(hantei(order1,hai1));
 /*select sort*/ 
		for(i=0;i<kazu;i++){
			smi=i;
			for(j=i+1;j<kazu;j++){
				if((int)(hai2[smi].charAt(1))>(int)(hai2[j].charAt(1))){
					smi=j;
				}
				}
			if(smi!=i){
				hz=hai2[smi];
				hai2[smi]=hai2[i];
				hai2[i]=hz;
 			   hzi=order2[smi];
 			   order2[smi]=order2[i];
 			   order2[i]=hzi;				
			}
		}
	     for(i=0;i<kazu;i++){
	    	    if(i!=kazu-1){	 
	    	     System.out.print(hai2[i]+" ");
	    	     }else{
	    	    	 System.out.println(hai2[i]);
	    	     }
	    }
	    	     System.out.println(hantei(order2,hai2));
     
}
	static String hantei(int[] index,String[] data){
		int i;
		for(i=0;i<data.length-1;i++){
			if((data[i].charAt(1))==(data[i+1].charAt(1))){
				if(index[i]>index[i+1]){
					return "Not stable";
				}
				}
		}
		return "Stable";
		
	}
}


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

int main() {
  int N, l, r, M;
  cin >> N;
  M = 0;
  
  for (int i = 0; i < N; i++) {
    cin >> l >> r;
    M += (r - l + 1);
  }
  
  cout << M << endl;
}

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

int main() {
	string s;
	cin >> s;
	s.replace(5, 1, " ");
	s.replace(13, 1, " ");
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()

using namespace std;
using ll = int64_t;

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

  int N;
  cin >> N;
  vector<int> a(N);
  int sum = 0;
  for (int& i : a) {
    cin >> i;
    sum += i;
  }

  auto get_distance = [&](int i) {
    return abs(sum - a[i] * N);
  };

  int answer = 0;
  for (int i = 0; i < N; i++) {
    if (get_distance(i) < get_distance(answer)) {
      answer = i;
    }
  }
  cout << answer << "\n";

  return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

struct Unifind{
	vector<int> par;

	Unifind(){}
	Unifind(int n) :
		par(n+1, -1)
	{}
	int root(int x){
		if(par[x] < 0) return x;
		return par[x] = root(par[x]);
	}
	int size(int x){
		return -par[root(x)];
	}
	bool same(int a, int b){
		return root(a) == root(b);
	}
	bool marge(int a, int b){
		a = root(a), b = root(b);
		if(a == b) return false;
		if(par[a] > par[b]) swap(a, b);
		par[a] += par[b];
		par[b] = a;
		return true;
	}
};

map<llong, int> PrimeFact(llong n){
	map<llong, int> ret;
	while(n % 2 == 0){
		ret[2]++;
		n /= 2;
	}
	for(llong i = 3; i*i <= n; i += 2){
		while(n%i == 0){
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1)
	ret[n]++;

	return ret;
}

int main(){
	llong N;
	vector<llong> a,b;
	Unifind uf;

	cin >> N;
	a.resize(N);
	uf = Unifind(200000);
	for(int i = 0; i < N; i++){
		cin >> a[i];
		auto m = PrimeFact(a[i]);
		for(auto x : m)
			uf.marge(i, x.first+100000);
	}


	b = a;
	sort(BE(b));

	bool check = true;
	llong use[100001] = {};
	for(int i = 0; i < N; i++){
		int real = lower_bound(BE(b), a[i]) - b.begin() + use[a[i]];
		if(!uf.same(i,real)){
			check = false;
			break;
		}
		use[a[i]]++;
	}

	cout << check << endl;

	return 0;
}


Measured memory_bytes: 6032
#include<iostream>
using namespace std;
#define FIO \
    freopen("input.txt","r",stdin); \
    freopen("output.txt","w",stdout);
int main()
{
   //FIO;
   int a,b,c; cin>>a>>b>>c;
   int k; cin>>k;
   while(k)
   {
       if( a < b)
         break;
        b *= 2;
        k--;
   }
  // cout<<k<<endl;
   while(k--)
   {
      if(b < c)
        break;
       c *= 2;
   }
  // cout<<a<<' '<<b<<' '<<c<<endl;
   if(a < b && b < c)
     cout<<"Yes\n";
   else
     cout<<"No\n";
   
}

Measured memory_bytes: 2908