akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T3;
const int INF = 1000000000;

const double PI = 3.1415926535;
int main(){
	double r;
	cin >> r;
	printf("%.14lf\n",2*r*PI);
}


Measured memory_bytes: 3780
#![allow(non_snake_case, unused_mut)]
use std::collections::HashMap;
fn main() {
    proconio::input! {
        n:usize,
        A:[usize;n]
    }
    let mut B = HashMap::new();
    for i in 0..n {
        *B.entry(A[i]).or_insert(0) += 1;
    }
    let mut sum = 0;
    for (_, &v) in B.iter() {
        sum += combination(v);
    }
    for i in 0..n {
        let val = B.get(&A[i]).unwrap();
        let ans = sum + 1 - val;
        println!("{}", ans);
    }
}

fn combination(v: usize) -> usize {
    if v <= 1 {
        0
    } else {
        v * (v - 1) / 2
    }
}


Measured memory_bytes: 11440
#include<iostream>   
#include<string>
#include<vector>
using namespace std; 
 
int main()
{
	int N;   
	int onaji = 0; 
	int ans = 0;
	string a = "zero";
	cin >> N; 
	vector <string> w(N); 
	for (int i = 0; i < N; i++)
	{
		cin >> w.at(i); 

	}  
	for (int p = 0; p <N; p++)
	{


		for (int z = 0; z < N; z++)
		{
			
				if (w.at(p)==w.at(z))
				{
					onaji += 1;
				}
		} 
		
	} 
	if (onaji>N)
	{
		cout << "No" << "\n";
	} 
	else
	{ 
		int saizu=0;
		string c;
		string d;
		for (int q = 0; q <N-1; q++)
		{ 
			
			c = w.at(q); 
			d = w.at(q + 1);
			saizu = c.size();
			if (c.at(saizu-1)!=d.at(0))
			{
				ans += 1;
			} 

		} 
		if (ans>0)
		{
			cout << "No" << "\n";
		} 
		else
		{
			cout << "Yes" << "\n";
		}
	}


	
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+10;
struct edge{
	int next,to;
}a[maxn<<1];
int head[maxn],cnt;
void add(int x,int y)
{
	a[++cnt].next=head[x];
	a[cnt].to=y;
	head[x]=cnt;
}
bool vis[maxn];
int fa[maxn];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		add(x,y);add(y,x);
	}
	queue<int> q;
	vis[1]=1;
	q.push(1);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=head[x];i;i=a[i].next)
		{
			int u=a[i].to;
			if(vis[u])continue;
			vis[u]=1;
			fa[u]=x;q.push(u);
		}
	}
	for(int i=2;i<=n;i++)
	if(!fa[i]){
	printf("No\n");return 0;}
	printf("Yes\n");
	for(int i=2;i<=n;i++)
	printf("%d\n",fa[i]);
	return 0;
}

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


int main() {

    int num;
    cin>>num;
    
    if(num>=400 && num<=599){
        cout<<"8";
    }
    else if(num>=600 && num<=799){
        cout<<"7";
    } else if(num>=800 && num<=999){
        cout<<"6";
    } else if(num>=1000 && num<=1199){
        cout<<"5";
    } else if(num>=1200 && num<=1399){
        cout<<"4";
    } else if(num>=1400 && num<=1599){
        cout<<"3";
    } else if(num>=1600 && num<=1799){
        cout<<"2";
    }
    else if(num>=1800 && num<=1999){
        cout<<"1";
    }

    return 0;
}

Measured memory_bytes: 3600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)

	in := make([]int, n)
	for i := 0; i < n; i++ {
		in[i] = nextInt(sc)
	}

	idx := partition(in, 0, n-1)
	for i, v := range in {
		if i != 0 {
			fmt.Print(" ")
		}
		if i == idx {
			fmt.Print("[" + strconv.Itoa(v) + "]")
		} else {
			fmt.Print(v)
		}
	}
	fmt.Println()
}

func partition(A []int, p int, r int) int {
	x := A[r]
	i := p
	for j := p; j < r; j++ {
		if A[j] <= x {
			A[i], A[j] = A[j], A[i]
			i++
		}
	}
	A[i], A[r] = A[r], A[i]
	return i
}



Measured memory_bytes: 3184
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

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

    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 3604
#include <iostream>

int main()
{
  int array[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  
  std::cin >> K;
  std::cout << array[K - 1];
  return 0;
}

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

typedef long long ll;

int main(){
    int d;
    cin >> d;
    int c[26];
    for(int i = 0; i < 26; i++) cin >> c[i];
    int s[d][26];
    for(int i = 0; i < d; i++){
        for(int j = 0; j < 26; j++){
            cin >> s[i][j];
        }
    }
    int last[26] = {};
    ll sat = 0;
    for(int i = 1; i <= d; i++){
        int t;
        cin >> t;
        sat += s[i-1][t-1];
        last[t-1] = i;
        ll dec = 0;
        for(int j = 0; j < 26; j++) dec += (ll)c[j]*(i-last[j]);
        sat -= dec;
        cout << sat << endl;
    }
    return 0;
}

Measured memory_bytes: 3672
object Main extends App {
	val N = scala.io.StdIn.readInt
	val A = scala.io.StdIn.readLine.split(" ").map(_.toInt)

	val map = scala.collection.mutable.Map[Int,Int]()

	for(x <- A){
		map.put(x - 1, map.getOrElse(x - 1, 0) + 1)
		map.put(x    , map.getOrElse(x    , 0) + 1)
		map.put(x + 1, map.getOrElse(x + 1, 0) + 1)
	}
	println(map.maxBy(_._2)._2)
}


Measured memory_bytes: 55888
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

//const (
//	MaxIntValue = int(^uint(0) >> 1)
//)

func main() {
	X := readLineInt()
	fmt.Println(X[2], X[0], X[1])
}

/////////////////////////////////////////
var scanner = bufio.NewScanner(os.Stdin)

func init() {
	//scanner.Split(bufio.ScanWords)
}
func readLine() string {
	scanner.Scan()
	return scanner.Text()
}

func readLineInt() []int {
	t := strings.Split(readLine(), " ")
	result := make([]int, len(t))
	for i, v := range t {
		r, _ := strconv.Atoi(v)
		result[i] = r
	}
	return result
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define MAX_SIZE 10000

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;

const ll MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1.0);
const db ERR = 1e-8;
const int MAXN = 1e7;


int main(int argc, char const *argv[]){
    string s;
    cin>>s;
    int a,b,c;
    a=b=c=0;
    for(int i=0;i<s.length();i++){
        int k=s[i]-'a';
        if(k>=3){
            printf("No\n");return 0;
        }
        if(k==0)a++;
        else if(k==1)b++;
        else c++;
    }

    if(a==b&&b==c){
        printf("Yes\n");
    }
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 256
L=list()
K=list()
while True:
    x,y=map(int,input().split())
    if x==0 and y==0:
        for i in range(len(L)):
            print(L[i],end=" ")
            print(K[i])
        break
    else:
        if x<y:
            L.append(x)
            K.append(y)
        else:
            L.append(y)
            K.append(x)



Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
const int maxn=100005;

int S[maxn];
int n,q;

int main() {
	cin>>n>>q;
	for (int i=0;i<q;i++) {
		bool op; cin>>op;
		if (op) {
			int k; cin>>k;
			int ans=0;
			for (int i=k;i>0;i-=i&-i)
				ans+=S[i];
			cout<<ans<<'\n';
		}
		else {
			int s,t,x; cin>>s>>t>>x;
			for (int i=s;i<=n;i+=i&-i)
				S[i]+=x;
			for (int i=t+1;i<=n;i+=i&-i)
				S[i]+=-x;
		}
	}
}


Measured memory_bytes: 3440
#include <stdio.h>
#define int long long

int min(int a, int b){
	return a <= b ? a : b;
}

signed main(){
	int A, B, C;
	scanf("%lld%lld%lld", &A, &B, &C);
	printf("%lld\n", min(A * B * (C % 2), min(A * (B % 2) * C, (A % 2) * B * C)));
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <queue>
#include <vector>
#include <string.h>
#include <algorithm>
using namespace std;
const int MAX = 1e5+10;
vector<int> vs[MAX];
int df[MAX], ds[MAX],n;
int pastf[MAX], pasts[MAX];
void bfs(int s, int dare){
	memset(pastf,0,sizeof(pastf));
	memset(pasts,0,sizeof(pasts));
	pastf[0] = 1;pasts[n-1] = 1;
	queue<pair<int, int> > que;
	que.push(make_pair(s,0));
	while(!que.empty()){
		int now = que.front().first;
		int cost = que.front().second;
		que.pop();
		if(dare == 1)df[now] = cost;
		else ds[now] = cost;
		int nowsize = (int)vs[now].size();
		for(int i = 0; i < nowsize; i ++){
			int nex = vs[now][i];
			if(dare == 1 && !pastf[nex]){
				pastf[nex] = 1;
				que.push(make_pair(nex,cost+1));
			}else if(dare != 1 && !pasts[nex]){
				pasts[nex] = 1;
				que.push(make_pair(nex,cost+1));
			}
		}
	}
}
int main(){
	int l, r;
	scanf("%d",&n);
	for(int i = 0; i < n-1; i ++){
		scanf("%d %d",&l,&r);
		l--;r--;
		vs[l].push_back(r);
		vs[r].push_back(l);
	}
	bfs(0,1);
	bfs(n-1,-1);
	int countf = 0, counts = 0;
	for(int i = 0; i < n; i ++){
		if(df[i] > ds[i]) counts++;
		else countf++;
	}
	if(countf > counts)cout << "Fennec\n";
	else cout << "Snuke\n";
	return 0;
}

Measured memory_bytes: 7492
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

a,b = map(int,input().split())
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass
def gcd(a, b):
    while(b != 0):
        a, b = b, a % b
    return a
    
def lcm(m,n):
    return (m*n)//gcd(m,n)

ab = gcd(a,b)
primes = prime_factor(ab)
print(len(primes)+1)

Measured memory_bytes: 3316
#define NDEBUG

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include <assert.h>
// for DEBUG {{{
#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))
// }}}

typedef long long ll;
#define FOR(i,min,max) for ((i) = (min); (i) < (max); (i)++)

int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}
void merge_int(int *a, int *b, int lower, int sep, int upper) {// {{{
	int i_lower = lower;
	int i_upper = sep;
	int i_b = 0;
	while ((i_lower < sep) && (i_upper < upper)) {
		if (a[i_lower] < a[i_upper]) {
			b[i_b++] = a[i_lower++];
		} else {
			b[i_b++] = a[i_upper++];
		}
	}
	if (i_lower >= sep) {
		while (i_upper < upper) {
			b[i_b++] = a[i_upper++];
		}
	} else {
		while (i_lower < sep) {
			b[i_b++] = a[i_lower++];
		}
	}
	for (i_lower = 0; i_lower < i_b; i_lower++) {
		a[i_lower+lower] = b[i_lower];
	}
}// }}}
void merge_sort_int(int *a, int *b, int lower, int upper) {// {{{
	int sep;
	if ((lower == upper) || (lower + 1 == upper)) {
		return;
	}
	sep = (lower + upper) / 2;
	merge_sort_int(a,b,lower,sep);
	merge_sort_int(a,b,sep,upper);
	merge_int(a,b,lower,sep,upper);
}// }}}


#define N_MIN 2
#define N_MAX 500000

int main(int argc, char **argv) {
	int n;
	fscanf(stdin,"%d",&n) > 0;
	double ret;
	if (n % 2 == 0) {
		ret = 0.5;
	} else {
		int odd = n / 2 + 1;
		ret = (double)odd / (double)n;
	}
	fprintf(stdout,"%.10lf\n",ret);
	return 0;
}



Measured memory_bytes: 256
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace std;
//using namespace __gnu_pbds;
#define ll long long
#define M 1000000007LL
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(v) ((ll)v.size())
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pii pair<ll,ll> 
#define mod 1000000007
#define MAXN 300002
int main() {
       ll t;
       ios::sync_with_stdio(0);
       cin.tie(0);
       cout.tie(0);
      ll n;
      cin>>n;
      ll mn=0,ans=0;

      for(ll i=0;i<n;i++)
      {
        ll x;
        cin>>x;
       // cout<<x<<" "<<mn<<endl;
        if(x>=mn)
          ans++;
        mn=max(mn,x);
      }
      cout<<ans;
       return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
const ll D=60;
const ll MAX_N=200005;
int main() {
    ll n,k;
    cin >> n >> k;
    ll to[D][MAX_N];
    for(ll i=0;i<n;i++){
        cin >> to[0][i];
        to[0][i]--;
    }
    for(ll i=0;i<D-1;i++){
        for(ll j=0;j<n;j++){
            to[i+1][j]=to[i][to[i][j]];
        }
    }
    ll v=0;
    for(ll i=D-1;i>=0;i--){
        ll l = 1ll<<i;
        if(l<=k){
            v=to[i][v];
            k-=l;
        }
    }
    cout << v+1 << endl;
}


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

int main() {
 int n ;
  cin >>n;
  int ans = 0;
  vector<int> v(n),c(n);
  for(int i=0;i<n;i++){
    cin >> v.at(i);
  }
  for(int i=0;i<n;i++){
    cin >> c.at(i);
  }
  for(int i=0;i<n;i++){
    if (v.at(i) > c.at(i))
      ans +=(v.at(i)-c.at(i));
  }
  cout << ans ;
}


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

int main() {
  unsigned int a, b, k;
  std::cin >> a >> b >> k;

  unsigned int counter = 1;
  unsigned int ans = std::__gcd(a, b);

  while (counter != k) {
    ans -= 1;
    if (a % ans == 0 && b % ans == 0) {
      counter += 1;
    }
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
struct edge {
    int to; 
    int weight;
    edge(int t, int w) : to(t),weight(w) {}
};
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N, M;
int ans = 0;
vector<bool> seen;
void dfs(const Graph &G, int v,int cnt) {
    seen.at(v) = true; // v を訪問済にする
    cnt++;
    if(cnt == N) ans++;
    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) {
        if (seen.at(next_v)) continue; // next_v が探索済だったらスルー
        dfs(G,next_v,cnt); // 再帰的に探索
    }
    seen.at(v) = false;
    cnt--;
}

int main(){

    // 頂点数と辺数
    cin >> N >> M;

    // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    // 頂点 0 をスタートとした探索
    seen.assign(N,false); // 全頂点を「未訪問」に初期化
    dfs(G,0,0);
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<double> x(N);
  vector<string> u(N);
  double sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> x.at(i) >> u.at(i);
  }
  for(int i = 0; i < N; i++) {
    if(u.at(i) == "JPY") {
      sum = sum + x.at(i);
    }
    else {
      sum = sum + 380000 * x.at(i);
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
//---Vaidik Patel---//
//-------------------Proud to be Indian--------------------------------//
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp> // include the associative containers or group of templates such as set,multi multimap, map etc.
#include<ext/pb_ds/tree_policy.hpp> // include the tree_order_statistics_node update
using namespace __gnu_pbds;
#define int long long int
#define ld long double
#define pii pair<int,int>
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; // find_by_order()
#define deb1(x) cout<<#x<<" : "<<x<<"\n";
#define deb2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<"\n";
#define deb4(x,y,z,w) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<"\t"<<#w<<" : "<<w<<endl;
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rFOR(i,a,b) for(int i=a;i>=b;i--)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define vvi vector<vector<int>>
#define M 1000000007
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int powermodm(int x,int n,int m)
{int ans=1;   while(n){if(n&1){ans=(ans*x)%m;}x=(x*x)%m;n=n>>1;}return ans;}

void solve()
{
    int n;
    cin>>n;
    vi a(n);
    FOR(i,0,n)
    {
        cin>>a[i];
    }
    vi ans;
    ans.pb(a[0]);
    FOR(i,1,n-1)
    {
        if(i-1>=0 && i+1<n)
        {
            if(a[i-1]<=a[i] && a[i]>a[i+1])
            {
                ans.pb(a[i]);
            }
            else if(a[i-1]>=a[i] && a[i]<a[i+1])
            {
                ans.pb(a[i]);
            }
        }
    }
    ans.pb(a[n-1]);

    // for(auto it:ans)
    // {
    //     cout<<it<<" ";
    // }cout<<"\n";
    int curr=1000,stk=0;

    for(int i=0;i<ans.size()-1;i++)
    {
        if(ans[i]>=ans[i+1])
            continue;
        int tt=curr/ans[i];
        curr%=ans[i];
        curr+=tt*ans[i+1];
    }
    cout<<curr<<"\n";
}
signed main()
{
    
    FIO
    int t;
    t=1;
    //cin>>t;
    FOR(i,0,t)
    {
        solve();
        //cout<<"Case #"<<i+1<<": "<<ans<<"\n";
    }
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
typedef vector<int> vi;
typedef long long lint;
typedef unsigned int uint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
typedef unsigned long long ulint;
#define endl '\n'
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rint register int
#define SZ(x) (int((x).size()))
#define all(x) (x).begin(), (x).end()
#define reveal(x) cerr << #x << " = " << (x) << endl
#define rep(it, f, e) for (rint it = (f); it <= (e); ++it)
#define per(it, f, e) for (rint it = (f); it >= (e); --it)
#define repe(it, x) for (auto it = (x).begin(); it != (x).end(); ++it)
const int MAXN = 505;
int val[MAXN][MAXN], p[MAXN * MAXN], apr[MAXN][MAXN], que[MAXN * MAXN * 2];
const int fx[] = {1, -1, 0, 0};
const int fy[] = {0, 0, 1, -1};
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);
	int n;
	cin >> n;
	memset(val, -1, sizeof(val));
	rep (i, 1, n) rep (j, 1, n) {
		apr[i][j] = 1;
		val[i][j] = min(min(i - 1, n - i), min(j - 1, n - j));
	}
	int res = 0;
	rep (i, 1, n * n) {
		int x, y, p;
		cin >> p; --p;
		x = p / n, y = p % n;
		apr[++x][++y] = 0;
		res += val[x][y];
		int ll = 0, rr = 0;
		que[rr++] = x;
		que[rr++] = y;
		while (ll < rr) {
			x = que[ll++], y = que[ll++];
			for (int k = 0; k != 4; ++k) {
				int nx = x + fx[k], ny = y + fy[k];
				if (~val[nx][ny] && val[nx][ny] > val[x][y] + apr[x][y]) {
					que[rr++] = nx, que[rr++] = ny, val[nx][ny] = val[x][y] + apr[x][y];
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 7512
#include<stdio.h>
#define MAX(x,y) ((x>y)?(x):(y))
#define MIN(x,y) ((x<y)?(x):(y))

double x,max=-1.0,min=200000000.0;

int main(){
	while(scanf("%lf",&x)!=EOF){
		max=MAX(max,x);
		min=MIN(min,x);
	}
	printf("%lf\n",max-min);
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int t[105], v[105];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> t[i];
		if (i > 0)
		{
			t[i] += t[i - 1];
		}
	}
	REP(i, N)
	{
		t[i] *= 2;
	}
	REP(i, N)
	{
		cin >> v[i];
	}

	vector< pair<double, double> > b;
	b.push_back(pair<double, double>(0.0, 0.0));
	FOR(i, t[N - 1], 1)
	{
		int mv = 0;
		REP(j, N)
		{
			if (t[j] > i)
			{
				mv = v[j];
				break;
			}
			if (t[j] == i)
			{
				mv = std::min(v[j], v[j + 1]);
				break;
			}
		}
		double s = std::min(b[i - 1].second + 0.5, (double)mv);
		b.push_back(pair<double, double>(i / 2.0, s));
	}
	b.push_back(pair<double, double>((double)(t[N - 1]) / 2.0, 0.0));

	IREP(i, b.size() - 2)
	{
		double s = std::min(b[i + 1].second + 0.5, b[i].second);
		b[i].second = s;
	}

	double ans = 0;
	REP(i, b.size() - 1)
	{
		ans += (b[i].second + b[i + 1].second)*0.5*0.5;
	}
	cout << OF64 << ans << endl;
	return 0;
}

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

map<string, int> f;

main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, mf = 0;
	string s;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> s;
		f[s]++;
		mf = max(mf, f[s]);
	}
	for (auto i : f)
		if (i.second == mf) cout << i.first << '\n';
}


Measured memory_bytes: 23808
N = int(input())
A = []
for i in range(N):
  A.append(list(map(int, input().split())))
#試合にコードを割り当てる
#of[l] = 前の番号の競技者の「既に数え上げた試合の数」
#r = 相手
#l = じぶん
def code(l, r, of):
  if l > r:
      l, r = r, l
  return of[l] + r - l - 1
#オフセットを作る。重複の試合を取り除くため、
#1ならN - 1試合、2ならN - 2試合...という風にする
of = [0] * (N + 1)
for i in range(N):
  of[i + 1] = of[i] + N - i - 1
#print(of)
#試合の前後関係を持つグラフ
#たぶんDAGになっている。なってないなら試合組めないと思う
g = [[] for _ in range(N * (N - 1) // 2)]
for i in range(N):
  for j in range(N - 2):
      fcode = code(i, A[i][j] - 1, of)
      tcode = code(i, A[i][j + 1] - 1, of)
      g[fcode].append(tcode)
#print(g)
def sort_topologically(g):
  n = len(g)
  #ecはコードによる試合頂点の入次数を記録
  ec = [0] * n
  for i in range(n):
    for e in g[i]:
      ec[e] += 1
  #print(ec)
  #retは入次数0の頂点を順にとってきている
  ret = [0] * n
  q = 0
  for i in range(n):
    if ec[i] == 0:
      ret[q] = i
      q += 1
  #p = 参照中の入次数0の試合
  #q = 入次数0の頂点数
  #while文はp == qの時点で終わる
  #for文では、入次数0の頂点pから出る有向辺を除去する
  #その上で入次数0の頂点が増えればretへ追加
  #このretは確かにトポロジカル順序になる
  p = 0
  #print(ret)
  while p < q:
    for to in g[ret[p]]:
      ec[to] -= 1
      if ec[to] == 0:
        ret[q] = to
        q += 1
    p += 1
  #ソートが終わったなら全ての辺は除去済みのはずである
  #このグラフは一応連結しているはずなので閉路検知ができる
  for i in range(n):
    if ec[i] > 0:
      return None
  return ret

od = sort_topologically(g)
#print(od)
#Noneなら閉路を持つので試合構築不可能
if not od:
  print(-1)
else:
  #dp = トポロジカル順序を持つ順序集合の先頭からi番目までを見た際の最大パス長
  dp = [1] * (N * (N - 1) // 2)
  for i in range(N * (N - 1) // 2):
    for e in g[od[i]]:
      dp[e] = max(dp[e], dp[od[i]] + 1)
  #print(dp)
  print(max(dp))



Measured memory_bytes: 121008
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int A, B, ans=0;
    cin >> A >> B;
    for(int i=A; i<=B; i++){
        string s=to_string(i);
        int sum=0;
        for(int j=0; j<s.size(); j++){
            if(s[j]==s[s.size()-1-j]){
                sum++;
            }
        }
        if(sum==s.size()){
            ans++;
        }
    }
    cout << ans << endl;
    
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

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

void solve() {

}

const ll mod = 1000000007LL;
  
int main() {
  int n;
  cin >> n;
  vector<ll> A(n);
  ll sum = 0;
  rep(i,n) {
    cin >> A[i];
    ( sum += A[i] ) %= mod;
  }
  ll ans = 0;
  for(int i=n-1;i>=1;--i) {
    sum -= A[i];
    while( sum < 0LL ) ( sum += mod ) %= mod;
    ( ans += ( ( sum * A[i] ) % mod ) ) %= mod;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 4764
#include <iostream>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <stdio.h> 
#include <map>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <deque>
#include <sstream>
#include <vector>
#include <algorithm>

typedef long long ll;
using namespace std;

int main() {
	string s;
	cin>>s;
	int q;
	cin>>q;
	bool flag = false;
	vector<char> left, right;
	for (int i=0; i<q; i++) {
		int t;
		cin>>t;
		if(t==1) {
			flag = !flag;
		} else {
			int a;
			char ch;
			cin>>a;
			cin>>ch;
			if(a==1 && !flag || a==2 && flag) {
				left.push_back(ch);
			} else {
				right.push_back(ch);
			}
		}
	}
	
	if(flag) {
		for (int i=right.size()-1; i>=0; i--) {
			cout << right[i];
		}
		reverse(s.begin(), s.end());
		cout << s;
		for (int i=0; i<left.size(); i++) {
			cout << left[i];
		}
	} else {
		for (int i=left.size()-1; i>=0; i--) {
			cout << left[i];
		}
		cout << s;
		
		for (int i=0; i<right.size(); i++) {
			cout << right[i];
		}
	}
	
	return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        long k = Long.parseLong(br.readLine());
        int result = 0;
        double money = 100;
        while (money < k) {
            money = Math.floor(money * 1.01);
            result++;
        }
        System.out.println(result);
    }
}


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

using namespace std;

const int N = 100017;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, k;
long long F[N];
vector<int> g[N];

bool read() {
    if (!(cin >> n >> k))
        return false;

    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        cin >> u >> v;
        g[u - 1].emplace_back(v - 1);
        g[v - 1].emplace_back(u - 1);
    }

    return true;
}

long long binpow(long long a, int n, long long MOD) {
    auto res = 1ll;

    for (; n > 0; n /= 2, a = a * a % MOD)
        if (n & 1)
            res = res * a % MOD;

    return res;
}

long long binomial(int n, int k) {
    return k > n ? 0ll : F[n] * binpow(F[k] * F[n - k] % MOD, MOD - 2, MOD) % MOD;
}

void dfs(int v, int pr, long long& ans) {
    auto cnt = g[v].size() - (pr != -1);
    ans *= binomial(k - 1 - (pr != -1), cnt) * F[cnt] % MOD;
    ans %= MOD;

    for (auto to : g[v])
        if (to != pr)
            dfs(to, v, ans);
}

void solve() {
    F[0] = 1;
    
    for (int i = 1; i <= k; ++i)
        F[i] = i * F[i - 1] % MOD;

    auto ans = static_cast<long long>(k);
    dfs(0, -1, ans);
    cout << ans << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 9216
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

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

const int mod=1e9+7;

int main(){
  string S;
  cin >> S;
  vector<vector<ll>> dp(S.size()+1, vector<ll>(4));
  dp[0][0]=1;
  rep(i,S.size()){
    if(S[i]=='A' || S[i]=='?'){
      rep(j,4)
        dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
      dp[i+1][1] = (dp[i+1][1]+dp[i][0])%mod;
    }
    if(S[i]=='B' || S[i]=='?'){
      rep(j,4)
        dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
      dp[i+1][2] = (dp[i+1][2]+dp[i][1])%mod;
    }
    if(S[i]=='C' || S[i]=='?'){
      rep(j,4)
        dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
      dp[i+1][3] = (dp[i+1][3]+dp[i][2])%mod;
    }
  }
  cout << dp[S.size()][3] << endl;
  return 0;
}

Measured memory_bytes: 7424
#include <stdio.h>
int main(void){
    // Your code here!
    int n;
    scanf("%d", &n);
    n /= 100;
    switch(n){
        case 4:
        case 5:
            printf("8\n");
            break;
        case 6:
        case 7:
            printf("7\n");
            break;
        case 8:
        case 9:
            printf("6\n");
            break;
        case 10:
        case 11:
            printf("5\n");
            break;
        case 12:
        case 13:
            printf("4\n");
            break;
        case 14:
        case 15:
            printf("3\n");
            break;
        case 16:
        case 17:
            printf("2\n");
            break;
        case 18:
        case 19:
            printf("1\n");
            break;
    }
}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    char a;
    cin >> a;

    if ('a' <= a && a <= 'z') {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }

}


Measured memory_bytes: 3632
#import math
#S=input()
#int(input())
N,K=map(int,input().split())
#H = list(map(int,input().split()))
#AB=[list(map(int,input().split())) for _ in range(M)]
l = []
for _ in range(K):
    d = int(input())
    A = list(map(int,input().split()))
    l += A
print(N - len(set(l)))

Measured memory_bytes: 9028
#include <stdio.h>
int main(void){
    
    int n, i=0;
    int l[10000];
    
    scanf("%d", &n);
    
    while(n!=0){
        
         int count=0;
         double sum=0, ave=0;
        
        for(int i=1; i<=n; i++){
            scanf("%d", &l[i]);
        }
        
        for(int i=1; i<=n; i++){
            sum += l[i];
        }
        
        ave = sum / n;
        
        for(int i=1; i<=n; i++){
            if(l[i]<=ave){count++;}
        }
        
        printf("%d\n", count);
        
        scanf("%d", &n);
        
    }
    
}


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

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    s[k - 1] -= 'A' - 'a';
    cout << s << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Pair> list = new ArrayList<>(n);
		for (int i = 0; i < n; i++) {
			list.add(new Pair(sc.nextInt(), sc.nextInt()));
		}
		Collections.sort(list, new ComparatorByKey());
		PriorityQueue<Integer> queue = new PriorityQueue<>(Collections.reverseOrder());
		int[] dp = new int[m + 1];
		dp[0] = 0;
		int j = 0;
		for (int i = 1; i <= m; i++) {
			while (j < list.size() && list.get(j).key <= i) {
				queue.add(list.get(j).value);
				j++;
			}
			if (queue.isEmpty()) {
				dp[i] = dp[i - 1];
			} else {
				dp[i] = dp[i - 1] + queue.poll();
			}
		}
		System.out.println(dp[m]);
	}
}
class Pair {
	public int key;
	public int value;
	public Pair(int key, int value) {
		this.key = key;
		this.value = value;
	}
}

class ComparatorByValue implements Comparator<Pair> {
	@Override
	public int compare(Pair sort1, Pair sort2) {
		if (sort1.value == sort2.value) {
			return 0;
		} else if (sort1.value > sort2.value) {
			return 1;
		} else {
			return -1;
		}
	}
}

class ComparatorByKey implements Comparator<Pair> {
	@Override
	public int compare(Pair sort1, Pair sort2) {
		if (sort1.key == sort2.key) {
			return 0;
		} else if (sort1.key > sort2.key) {
			return 1;
		} else {
			return -1;
		}
	}
}

Measured memory_bytes: 95508
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> v(n);
  vector<int> c(n);
  for(int i= 0;i<n; i++)  cin>>v.at(i);
  for(int i= 0;i<n; i++)  cin>>c.at(i);
  int x=0, y=0;
  for(int i=0; i<n;i++){
    if(v.at(i)-c.at(i)>0){
      x +=v.at(i);
      y +=c.at(i);
    } 
  }
  cout<<x-y<<endl;
  
}

Measured memory_bytes: 256
//#include <stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
#define PI 3.14159265359;

class Hoge{
  public:
					long int i0;
					int i1,N0;
					string s0;
					int* iarray0;
					Hoge(int);
					void func0();
					void array0();
	void printarray0();
	~Hoge();
  private:
	
	void inputarray(int*,int);
	void inputarray2(int*,int*,int);
	void printarray(int*,int);
					};


Hoge::Hoge(int itemp){
	
	i0=itemp;
	//cout<<"i0="<<i0<<endl;
	
									}

void Hoge::func0(){
	//cout<<"N0?"<<endl;
	cin>>N0;
	cout<<N0+N0*N0+N0*N0*N0<<endl;
	//iarray0=new int[N0];
	//int N1=3;int N2=2;
	//int* iarray1=new int[N1];
	//int* iarray2=new int[N1];

	//inputarray(iarray0,N0);
	//printarray(iarray0,N0);
	//inputarray2(iarray1,iarray2,N1);
	
	//delete [] iarray1;
	//delete [] iarray2;
	
								}


void Hoge::array0(){

	cout<<"N0?";
	cin>>N0;
	
	
	for (int i0=0;i0<N0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray0[i0];
		
		
	}
}

void Hoge::inputarray(int* itemp,int itempn){
	
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
	}
}
void Hoge::inputarray2(int* itemp,int* itemp2,int itempn){
	
	int* iarray=itemp;
	int* iarray2=itemp2;
	int n0=itempn;
	
	for (int i0=0;i0<n0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
		cin>>iarray2[i0];
	}
}

void Hoge::printarray(int* itemp,int itempn){
	
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		cout<<"iarray["<<i0<<"]="<<iarray[i0]<<endl;
	
	}
}
	
	void Hoge::printarray0(){
							 
							 for (int i0=0;i0<N0;i0++){
			cout<<"iarray0["<<i0<<"]="<<iarray0[i0]<<endl;
			
							 
							 }
	
	
}
Hoge::~Hoge(){
	
	//delete [] iarray0;
							}
int main(){
				int N=0;
				//cin>>N;
	Hoge* hoge=new Hoge(N);
	hoge->func0();
	
	return 0;
	delete hoge;
}//end of main

Measured memory_bytes: 3632
#include <cstdio>
#include <utility>
#include <algorithm>

const int MAXN = (int)1e5 + 1;

std::pair<int,int> a[MAXN];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &a[i].first);
    a[i].second = i;
  }
  std::sort(a + 1, a + n + 1);
  for (int i = 1; i <= n; ++i) {
    printf("%d ", a[i].second);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 1536
/*input
21
0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1
1 1 1 0 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1 1 0
0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1
0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0
1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0
0 1 1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1
0 1 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 0
0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1
0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 0 1 0 1 1 1
0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1
0 1 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 0 1 1 0
0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 0 0 0 1
0 1 1 0 0 1 1 1 1 0 0 0 1 0 1 1 0 1 0 1 1
1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 1 1 1 0 0 1
0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1
1 0 1 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1
0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1
0 0 0 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 1 1 0
1 1 0 1 1 0 0 1 1 0 1 1 0 1 1 1 1 1 0 1 0
1 0 0 1 1 0 1 1 1 1 1 0 1 0 1 1 0 0 0 0 0
*/
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int const mod =1e9+7;
int n;
int a[21];
int dp[21][(1<<21)];
int solve(int i,int mask){
	if(i == n){
		if(__builtin_popcount(mask)==n)
			return 1;
		else
			return 0 ;
	}
	if(dp[i][mask]!=-1)return dp[i][mask];
	int ans = 0 ;
	for(int j=0;j<n;j++){
		if(mask&(1<<j))continue;
		if(a[i]&(1<<j))
			{ans+=solve(i+1,mask|1<<j);ans%=mod;}
	}
	return dp[i][mask]=ans;
}
signed main() {
	IOS;
	cin>>n;
	// n--;
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++){
		for(int j=n-1;j>=0;j--){
			int x;
			cin>>x;
			if(x){
				a[i]|= (1<<j);
			}
		}
	}
	cout << solve(0,0) <<endl;
return 0;
}


Measured memory_bytes: 344320
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

struct food{
	string f;
	int w;
	int s;
};

int n;
vector<food> foods;
vector<string> res;
pair<int,vector<string> > result;

void f(int b,int w,int k){
	int i;
//cout<<b<<" "<<w<<endl<<" ";
//for(i=0;i<res.size();i++)cout<<res[i]<<endl;
//cout<<endl;
	if(b==(1<<n)-1){
		if(result.first>k){
			result.first=k;
			result.second.clear();
			for(i=0;i<n;i++)result.second.push_back(res[i]);
		}
	}
	for(i=0;i<n;i++){
		if(b&1<<i)continue;
		if(foods[i].s<w)continue;
		res.push_back(foods[i].f);
		f(b|1<<i,w+foods[i].w,k+w+foods[i].w);
		res.pop_back();
	}
}

int main() {
	while(n=in()){
		int i;
		foods.clear();
		food buf;
		result.first=1000000000;
		for(i=0;i<n;i++){
			cin>>buf.f>>buf.w>>buf.s;
			foods.push_back(buf);
		}
		res.clear();
		f(0,0,0);
		for(i=0;i<n;i++){
			cout<<result.second[n-i-1]<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int keta(LL a) {
	LL num = a;
	int ret = 0;
	while (num >= 10) {
		ret++;
		num /= 10;
	}
	ret++;
	return ret;
}

int main() {
	LL n;
	cin >> n;
	vector<int> v;
	for (LL i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)v.emplace_back(i);
	}
	UNIQ(v);
	int ans = HINF;
	for (int i = 0; i < v.size(); i++) {
		LL a = n / v[i];
		ans = min(ans, max(keta(v[i]), keta(a)));
	}
	cout << ans << endl;
}

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

int main(){
    string week[7] = {"MON","TUE","WED","THU","FRI","SAT","SUN"};
    string today;
    cin >> today;
    if(today == "SUN"){
        cout << 7 << endl;
        return 0;
    }

    for(int i = 0; i < 7; i++){
        if(today == week[i]){
            cout << 6 - i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
s = input()
i = len(s)

C_list = []
C_num = []
F_list = []
F_num = []

for x in range(i):
    if s[x] == 'C':
        C_list.append(s[x])
        C_num.append(x)
    elif s[x] == 'F':
        F_list.append(s[x])
        F_num.append(x)


if len(C_list) > 0 and len(F_list) > 0:
    if C_num[0] < F_num[-1]:
        print('Yes')
    else:
        print('No')
else:
    print('No')


Measured memory_bytes: 3064
from bisect import*
e=enumerate
s=input()
p=[i+1for i,(a,b)in e(zip(s,s[1:]))if'RL'==a+b]
a=[0]*len(s)
for i,c in e(s):j=p[bisect(p,i)-(c<'R')];a[j-(j-i)%2]+=1
print(*a)

Measured memory_bytes: 8284
n=int(input())
p=list(map(int,input().split()))
count=0
for i in range(0,n-2):
  ma=max([p[i],p[i+1],p[i+2]])
  mi=min([p[i],p[i+1],p[i+2]])
  if (ma==p[i] and mi==p[i+2]) or (ma==p[i+2] and mi==p[i]):
    count+=1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1e7;
const int MOD = 1000000007;

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

   int k;
   cin >> k;

   ll mod = 0;
   for (int cnt = 1; cnt < INF; cnt++) {
      mod *= 10;
      mod += 7 % k;
      mod %= k;
      if (mod == 0) {
         cout << cnt << endl;
         return 0;
      }
   }
   cout << -1 << endl;
   return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> B(H, vector<char>(W));
    int cnt = 0;
    rep(i, H) rep(j, W) {
        cin >> B[i][j];
        if(B[i][j] == '#')
            cnt++;
    }
    if(cnt > H + W - 1) {
        cout << "Impossible" << endl;
    } else {
        cout << "Possible" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define CONTEST_TYPE 3


//まずは、満足度低下を考えずやってみる

int get_max_satisfuction_of_day(int satisfuctions[]){
	int max = 0;
	int max_index ;
	for (int i = 0; i < CONTEST_TYPE; i++){
		if (max < satisfuctions[i]){
			max = satisfuctions[i];
			max_index = i;
		}
		//printf("satisfuctions[%d] = %d, max = %d\n", i, satisfuctions[i], max);
	}
	return max_index;
}


int main(void) {

	int days;
	int low_of_satisfuction[CONTEST_TYPE];
	int satisfuction[days][CONTEST_TYPE];
	int output_days[days];


	/*入力処理開始*/
	scanf("%d", &days);

	for (int i = 0; i < CONTEST_TYPE; i++ ){
		scanf("%d", low_of_satisfuction + i);
	}

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

		for (int j = 0; j < CONTEST_TYPE; j++ ){
			int w;
			scanf("%d", &w);
			satisfuction [i][j] = w;
		}
	}
	for (int i = 0; i < days; i++){
		for (int j = 0; j < CONTEST_TYPE; j++){
			//printf("%d ", satisfuction[i][j]);
		}
		//printf("\n");
	}
	/*入力処理終了*/


	/*各日の満足度最高のコンテストを抽出*/
	for (int i = 0; i < days; i++){
		printf("%d\n",(i % 26) + 1);
	}


	return 0;
}



Measured memory_bytes: 1748
#include <cstdio>
using namespace std;
const int N=200005;
int n;
int a[N];
int s[N],p[N],t;
int l,r,mid;
bool check(int m)
{
	//printf("check %d\n",m);
	t=0;
	for (int i=1;i<=n;i++)
	{
		if (a[i-1]<a[i])
		{
			t++;
			s[t]=a[i-1]+1;
			p[t]=1;
			if (p[t]>m)
				return 0;
		}
		if (a[i-1]>=a[i])
		{
			while (s[t]>a[i])
				t--;
			if (s[t]!=a[i])
			{
				t++;
				s[t]=a[i];
				p[t]=p[t-1]+1;
				if (p[t]>m)
					return 0;
			}
			else
			{
				p[t+1]=0;
				while (t&&p[t]==m)
					t--;
				if (!t)
					return 0;
				if (s[t]+1==s[t+1]||p[t+1]!=m)
				{
					p[t]++;
					if (p[t]>m)
						return 0;
				}
				else
					if (s[t]+2<s[t+1])
					{
						t++;
						s[t+1]=s[t]-1;
						p[t+1]=2;
						if (p[t+1]>m)
							return 0;
						s[t]=s[t-1]+1;
						p[t]=1;
						t++;
					}
					else
					{
						t++;
						s[t]--;
						p[t]=2;
						if (p[t]>m)
							return 0;
					}
				if (s[t]<a[i])
				{
					t++;
					s[t]=s[t-1]+1;
					p[t]=1;
				}
			}
		}
		s[t+1]=a[i]+1;
		/*for (int j=1;j<=t;j++)
			printf("%d %d\n",s[j],p[j]);
		for (int j=1;j<=t;j++)
			for (int k=s[j];k<s[j+1];k++)
				printf("%c",p[j]-1+'a');
		printf("\n");*/
	}
	return 1;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	l=1;
	r=1e9;
	while (l<r)
	{
		mid=(l+r)>>1;
		if (check(mid))
			r=mid;
		else
			l=mid+1;
	}
	printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 2560
class MyList
  attr_reader :vs

  def initialize
    @vs = []
  end

  def insert x
    @vs.push(x)
  end

  def delete x
    (@vs.length-1).downto(0) do |i|
      if @vs[i] == x
        @vs.delete_at i
        break
      end
    end
  end

  def delete_first
    @vs.pop
  end

  def delete_last
    @vs.shift
  end
end

my_list = MyList.new
n = gets
while l = gets
  command, num = l.chomp.split(' ')
  num = num.to_i
  case command
  when 'insert'
    my_list.insert num
  when 'delete'
    my_list.delete num
  when 'deleteFirst'
    my_list.delete_first
  when 'deleteLast'
    my_list.delete_last
  end
end

puts my_list.vs.reverse.join(' ')


Measured memory_bytes: 21172
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set0(a) memset ((a), 0 , sizeof(a))
#define set1(a) memset((a),-1,sizeof (a))
#define pi pair<int, int>
#define ps pair<string, string>
#define pl pair<long, long>
#define pll pair<long long, long long>
#define vll vector<long long>
#define vl vector<long>
#define vi vector<int>
#define vs vector<string>
#define vps vector< ps >
#define vpi vector< pi >
#define vpl vector< pl >
#define vpll vector< pll >
#define fast1  ios_base::sync_with_stdio(false);
#define fast2 cin.tie(NULL);

bool sortbysec(const pll &a,
              const pll &b)
{
    return (a.second < b.second);
}

void func(void)
{
        freopen("input.txt","r",stdin);
        //freopen("output.c","w",stdout);
}
void sieve(bool *a,ll n){
    for(ll i=0;i<=n;i++ ){
        a[i]=true;
    }
    for(ll i=2;i*i<=n;i++){
        for(ll j=i+i;j<=n;j=j+i){
            a[j]=false;
        }
    }

}
void calculate(bool *p,ll n){
    ll answer=0;
    ll answer2=1;
    for(ll i=2;i<=n;i++){
            answer=0;
        if(p[i]){

                ll m=n;
                while(m){
                    m=m/i;
                    answer=(answer%mod+m%mod)%mod;

                }

        }
        answer2=((answer2%mod)*((answer+1)%mod))%mod;
    }
    cout<<answer2<<endl;
}
int main(){
    ll n;
    cin>>n;
    bool prime[n+1];
    sieve(prime,n);
    calculate(prime,n);
}


Measured memory_bytes: 256