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

typedef long long ll;

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define tt int t; cin>>t; while(t--)
#define nl cout<<"\n";
#define sp cout<<" ";
#define rep(i, a, b) for(long long i=a; i<b; i++)

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
double PI = 4*atan(1);

int main()
{
    optimize();

    int a[5], sum= 0, h= 0, c;

    for(int i=0; i<5; i++)
    {
        cin>> a[i];
        c= ((a[i]+ 9)/10)* 10;
        sum += c;

        h= max ( h, c- a[i]);
    }

    cout << sum- h;
    nl;

    return 0;
}




Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
typedef vector<pii> vp;
typedef vector<tiii> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//cout << fixed << setprecision(10);
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 main () {
  int a, b;
  cin >> a >> b;
  int i = b - a;
  int ans = i*(i+1)/2 - b;
  cout << ans << endl;
  return 0;
}

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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  int a;
  LL ans = 0;
  REP (i, n) {
    scanf("%d", &a);
    while (a % 2 == 0) {
      a /= 2;
      ans++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}

int main(void){

  int a,b;

  while(cin >> a >> b){
    int res=gcd(a,b);
    cout << gcd(a,b) << " " << a/res*b << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import math

time = [int(input()) for _ in range(5)]

uptime = [0 for _ in range(5)]
for i in range(5):
    uptime[i] = math.ceil(time[i]/10)*10 # 1の位切り上げ

sa = [0 for _ in range(5)]
for i in range(5):
    sa[i] = uptime[i] - time[i]

ans = sum(uptime) - max(sa)

print(ans)





Measured memory_bytes: 3060
import sys
import copy
input = sys.stdin.readline


def main():
    N = int(input())
    P = list(input().split())
    bubbleSortted = bubbleSort(N, copy.copy(P))
    print(' '.join(map(str, bubbleSortted)))
    print("Stable")
    selectionSorted = selectionSort(N, copy.copy(P))
    print(' '.join(map(str, selectionSorted)))
    print(isStable(bubbleSortted, selectionSorted))


def selectionSort(N, P):
    change_count = 0
    for i in range(0, N):
        minj = i

        # print(P[i:N])
        # print(min(P[i:N]))

        for j in range(i, N):
            if P[j][1] < P[minj][1]:
                minj = j

        if i != minj:
            tmp = P[i]
            P[i] = P[minj]
            P[minj] = tmp
            change_count += 1

        # print(' '.join(map(str, P)))

    return P


def bubbleSort(N, P):
    change_count = 0
    i = 0
    while True:
        for j in range(N - 1, i, -1):
            if P[j][1] < P[j - 1][1]:
                tmp = P[j]
                P[j] = P[j - 1]
                P[j - 1] = tmp
                change_count += 1
        i += 1
        # print("i:{}".format(i))
        if i == N:
            break

    return P


def isStable(P1, P2):
    for i in range(len(P1)):
        # print("P1:{0},P2:{1}".format(P1[i], P2[i]))
        if P1[i] != P2[i]:
            return "Not stable"
    return "Stable"


if __name__ == '__main__':
    main()



Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  int B=0;
  for(int a=1;a<=A;a++){
    for(int b=1;b<=A;b++){
      for(int c=1;c<=A;c++){
    	B += gcd(gcd(a,b),c);
      }
    }
  }
  cout << B << endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s.back() == s.front())
        cout << "Yes";
    else
        cout << "No";
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  string S; cin >> S;
  if(S == "RRR") {
    cout << 3 << endl;
  } else if(S == "RRS" || S == "SRR") {
    cout << 2 << endl;
  } else if(S == "RSR" || S == "SRS" || S == "RSS" || S == "SSR") {
    cout << 1 << endl;
  } else if(S == "SSS") {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 3628
/******************************************
* AHAM BRAHMASHMI ;) *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vll vector<ll>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007


void print_vec(vll a)
{
	cout << "start printing the vector\n";
	for (ll i = 0; i < a.size(); i++)
		cout << a[i] << " ";
	cout << "\n";
}
void print_mat(vector<vll> a)
{
	cout << "start printing the matrix\n";
	for (ll i = 0; i < a.size(); i++)
	{
		for (ll j = 0; j < a[i].size(); j++)
		{
			cout << a[i][j] << " ";
		}
		cout << "\n";
	}
}

/******************************************
* NUMBER THEORY ;) *
******************************************/



ll powermod(ll x, ll y)
{
	ll res = 1;
	x = x % mod;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x) % mod;
		y = y >> 1;
		x = (x * x) % mod;
	}
	res %= mod;
	return res;
}
ll factmod(ll n)
{
	ll res = 1;
	while (n > 1)
	{
		res = (res * ((n / mod) % 2 ?  mod - 1 : 1)) % mod;
		for (ll i = 2; i <= n % mod; ++i)
			res = (res * i) % mod;
		n /= mod;
	}
	res %= mod;
	return res;
}



void solve()
{
	ll n;
	cin >> n;
	ll count = 0, temp;
	for (ll i = 1; i <= n; i++)
	{
		cin >> temp;
		if (i % 2 == 1 and temp % 2 == 1)
			count++;
	}

	cout << count << "\n";
}

int main()
{

#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	// ll t;
	// cin>>t;
	// while(t--)
	// {
	solve();
	// }

	return 0;
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using namespace std; 

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";} 
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

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

    if(n >= 400 && n < 600) {
        cout << 8 << endl;
    }  
    if(n >= 600 && n < 800) {
        cout << 7 << endl;
    }  
    if(n >= 800 && n < 1000) {
        cout << 6 << endl;
    }  
    if(n >= 1000 && n < 1200) {
        cout << 5 << endl;
    }
    if(n >= 1200 && n < 1400) {
        cout << 4 << endl;
    }
    if(n >= 1400 && n < 1600) {
        cout << 3 << endl;
    }
    if(n >= 1600 && n < 1800) {
        cout << 2 << endl;
    }
    if(n >= 1800 && n < 2000) {
        cout << 1 << endl;
    }
    return 0;
}

/*atcoder*/



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

int main() {
    long long N, K;
    cin >> N >> K;

    if (K == 0) {
        cout << N * N << endl;
        return 0;
    }

    long long res = 0;
    for (long long b = 1; b <= N; b++) {
        res += max(0LL, b - K) * (N / b);
        res += max(0LL, N % b - K + 1);
    }

    cout << res << endl;
    return 0;
}

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

int main(){
  ll a, b, x;  cin >> a >> b >> x;
  ll mi = (a / x) * x + (a%x?x:0);
  ll ma = (b / x) * x;
  cout << (ma - mi) / x + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
    char buffer[20];
    int  a,b;
    if (fgets(buffer, 20, stdin)) {
        a = atoi(strtok(buffer, " "));
        b = atoi(strtok(NULL, " "));
    }
    int b_length = 0;
    for (int i = 1; i <= b-a; i++) {
        b_length += i;
    }
    printf("%d",b_length-b);
    return 0;
}

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

using namespace std;

int cost[10][10];
int A[200][200];

int main()
{
    int H, W;

    cin >> H >> W;
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            cin >> cost[i][j];
        }
    }
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> A[i][j];
        }
    }

    for (int k = 0; k < 10; k++)
    {
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    int s = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (A[i][j] == -1)
            {
                continue;
            }
            s += cost[A[i][j]][1];
        }
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 384
import numpy as np

n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    res = 0
    for j in range(m):
        res += a[i][j] * b[j]
    if res + c > 0:
        ans += 1

print(ans)


Measured memory_bytes: 12428
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <set>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
#define MIN(a, b) (((a) < (b)) ? (a) : (b))

using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;
const ll inf = (1LL << 60);
const ll mod = 1000000007;
ll max(ll a, ll b) {
	if (a < b)
		return b;
	else
		return a;

}
ll min(ll a, ll b) {
	if (a < b)
		return a;
	else
		return b;

}





int main() {

	ll N, D;

	cin >> N >> D;

	if (N < 2 * D) {
		cout << 1 << endl;
	}
	else {
		ll ans = N / (2 * D + 1);
		cout << ans + (N % (2*D+1) != 0) << endl;
	}




	return 0;
}

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

using namespace std;

#define ll long long
#define fi first
#define se second

void test_case(){
	double l;
	cin>>l;
	double a=l/3;
	l-=a;
	double b=l/2;
	double c=l-b;
	cout<<setprecision(8)<<a*b*c<<"\n";
}

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


Measured memory_bytes: 256
//	package Dynamic;
import java.io.*;
import java.util.*;
class Main
{
    static public void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//        int t=Integer.parseInt(br.readLine());
//        while(t-->0)
//        {
//        	int n=Integer.parseInt(br.readLine());
//        	int ar[]=new int[n];
        	StringTokenizer st=new StringTokenizer(br.readLine());
        	int a=Integer.parseInt(st.nextToken());
        	int b=Integer.parseInt(st.nextToken());
        	//int c=Integer.parseInt(st.nextToken());
//        	for(int x=0;x<n;x++)
//        	{
//        		ar[x]=Integer.parseInt(st.nextToken());
//        	}
        	System.out.println((int)Math.ceil(a/((b*2.0)+1)));
        //}
    }
}

Measured memory_bytes: 23124
#include <stdio.h>

int parent[100001];
int root(int x)
{
  if (parent[x] != x) parent[x] = root(parent[x]);
  return parent[x];
}

int main()
{
  int N, M, x, y;
  int j;
  int p[100001];
  int count = 0;

  scanf("%d %d", &N, &M);
  for (j = 1; j <= N; j++) {
    scanf("%d", &p[j]);
    parent[j] = j;
  }

  while (M--) {
    scanf("%d %d", &x, &y);
    parent[root(y)] = root(x);
  }

  for (j = 1; j <= N; j++) {
    if (root(j) == root(p[j])) count++;
  }

  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
#include<ctype.h>

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	long long N,K;
	scanf("%lld %lld",&N,&K);
	
	long long A[N];
	for( int i=0; i<N; i++){
		scanf("%lld",&A[i]);
	}
	
	qsort(A, N, sizeof(long long), compare_int);
	
	if( K == 0){
		printf("%lld", A[N-1]);
		return 0;
	}
	
	long long left = 0; long long right = A[N-1]; long long mid;
	long long sum = 0;
	while(right > left+1){
		mid = (right+left) / 2;
		sum = 0;
		for( long long i=0; i<N ; i++ ){
			if(A[i] > mid){
				sum += A[i] / mid;
			}
		}
		if( sum > K ) {
			left = mid;
		}
		else {
			right = mid;
		}
	}
	printf("%lld",right);
}



Measured memory_bytes: 4576
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

i64 m,d;

cin>>m>>d;

map<i64,i64>mp;
i64 ans=0;
for1(i,d)
{
  if(i%10>1&&i/10>1)
  {
    mp[(i/10)*(i%10)]++;
  }
}
for1(i,m)ans+=mp[i];

cout<<ans;
    return 0;
  }


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
while(1){
	int x,y;
	scanf("%d %d\n",&x,&y);
	if(x == 0 && y == 0){
		break;
	}
	if(y < x){
		int tmp = x;
		x = y;
		y = tmp;
	}
	printf("%d %d\n",x,y);
}
return 0;
}

Measured memory_bytes: 604
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
 

fn main() {
    input! {
        n: usize,
        m: usize,
        mat: [[usize; 2];m],   
    }

    let mut g= [[false; 9]; 9];

    for i in 0..m {
        g[mat[i][0]][mat[i][1]] = true;
        g[mat[i][1]][mat[i][0]] = true;
    }

    let mut visited = [false; 9];

    visited[1] = true;
    let ans = search(g, 1, &mut visited, n);

    println!("{}", ans);
}

fn search(mat: [[bool; 9];9], node: usize, visited: &mut [bool; 9], n: usize) -> usize {
    let mut count = 0;
    for c in visited.iter() {
        if *c == true {
            count = count + 1;
        }
    }
    if count == n {
        return 1;
    }
    
    let mut sum = 0;
    for (i, ch) in mat[node].iter().enumerate() {
        if *ch && visited[i] == false {
            visited[i] = true;
            sum = sum + search(mat, i, visited, n);
            visited[i] = false;
        }
    }
    sum
}

// TODP: bitDPで解く

Measured memory_bytes: 4352
house = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for x in range(n):
    b, f, r, v = map(int,input().split())
    house[b-1][f-1][r-1] += v
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {house[i][j][k]}',end="")
        print()
    if int(i)<3: print("#"*20)




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

int main(){
	int kosuu = 0, kosa = 0;
	int x, y, sizuku;
	int masu[20][20];
	char trash1, trash2;
	for(int i = 0; i < 20; i++){
		for(int j = 0; j < 20; j++){
			masu[i][j] = 0;
		}
	}
	while(cin >> x >> trash1 >> y >> trash2 >> sizuku){
		if(sizuku == 1){
			masu[x+4][y+5]++;
			for(int i = 0; i < 3; i++){
				masu[x+5][y+4+i]++;
			}
			masu[x+6][y+5]++;
		}
		else if(sizuku == 2){
			for(int i = 0; i < 3; i++){
				for(int j = 0; j < 3; j++){
					masu[x+4+i][y+4+j]++;
				}
			}
		}
		else{
			masu[x+3][y+5]++;
			masu[x+7][y+5]++;
			for(int i = 0; i < 3; i++){
				masu[x+4][y+4+i]++;
				masu[x+6][y+4+i]++;
			}
			for(int i = 0; i < 5; i++){
				masu[x+5][y+3+i]++;
			}
		}
	}
	for(int i = 5; i < 15; i++){
		for(int j = 5; j < 15; j++){
			if(kosa < masu[i][j]){
				kosa = masu[i][j];
			}
			if(masu[i][j] == 0){
				kosuu++;
			}
		}
	}
	cout << kosuu << endl << kosa << endl;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h> 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
int main(){
	char s[3];
	scanf("%s",&s);
	int a=0;
	ifor(3){
		if(s[i]=='A')a++;
	}
	if(a==0||a==3)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++){
      int n;
      cin >> n;
      long double ans = 0.0;
      for(int i = 0; i < n; i++){
        long double x;
        string s;
        cin >> x >> s;
        if(s == "BTC"){
            ans += (380000.0 * x);
        }
        else ans += x;
      }
      cout << fixed << setprecision(8) << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
#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=200005;
int n,k,l;
int f1[maxn],f2[maxn],ans[maxn];
map<pii,vector<int> >mp;


int Find(int f[],int x){
	return f[x]==x?x:f[x]=Find(f,f[x]);
}

void Union(int f[],int x,int y){
	x=Find(f,x);y=Find(f,y);
	if(x!=y)f[x]=y;
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k>>l;
	REP(i,n)f1[i]=f2[i]=i;
	while(k--){
		int u,v;
		cin>>u>>v;
		Union(f1,u,v);
	}
	while(l--){
		int u,v;
		cin>>u>>v;
		Union(f2,u,v);
	}
	REP(i,n)mp[mk(Find(f1,i),Find(f2,i))].push_back(i);
	for(map<pii,vector<int> >::iterator it=mp.begin();it!=mp.end();it++){
		rep(j,it->se.size())ans[it->se[j]]=it->se.size();
	}
	REP(i,n)cout<<ans[i]<<" ";
	return 0;
}

Measured memory_bytes: 23040
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int main(void) {
  int a, b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}


Measured memory_bytes: 3192
function main(input) {
  const n = parseInt(input[0]);
  const a = input[1].trim().split(" ").map(i => BigInt(i));
  let ans = 1n;
  const judge = a.includes(0n);
  if(!judge){
    for(i of a){
      if(ans>10**18){
        break;
      }
      ans = ans * i;
    }
    console.log((ans>10**18)?(-1):(ans+""));
  }else{
    console.log(0);
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));

Measured memory_bytes: 44192
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
#include <stack>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;
using Graph = Vvec<int>;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    
    cout << (h2*60+m2) - (h1*60+m1) - k << endl;
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

bool solve(const vector<int>& v)
{
    int n = v.size();

    int x = n - 1;
    while(v[x] == 0)
        -- x;
    if(x == 1)
        return n == 2;

    int i;
    for(i=x; i>(x+1)/2; --i){
        if(v[i] < 2)
            return false;
    }
    if(x % 2 == 0){
        if(v[i] != 1)
            return false;
    }
    else{
        if(v[i] != 2)
            return false;
    }
    -- i;

    for(; i>0; --i){
        if(v[i] > 0)
            return false;
    }
    return true;
}

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i=0; i<n; ++i){
        int a;
        cin >> a;
        ++ v[a];
    }

    if(solve(v))
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;

    return 0;
}

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

using namespace std;

int main(){
	long long int N, K;
	cin >> N >> K;
	long long int ans = 0;
	if( K % 2 == 0 ){
		long long int x = max(( N + K / 2 ) / K, 0LL);
		ans += x * x*x;
	}
	long long int num = N / K;
	cout << ans + num * num*num << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int H, W;
    cin >> H >> W;
    string *grid = new string[H];
    long long **memo = new long long *[H];
    for (int i = 0; i < H; i++) {
        memo[i] = new long long[W];
        for (int j = 0; j < W; j++) {
            memo[i][j] = 0;
        }
    }
    memo[H - 1][W - 1] = 1;
    for (int i = 0; i < H; i++) cin >> grid[i];
    for (int y = H - 1; y >= 0; y--) {
        for (int x = W - 1; x >= 0; x--) {
            if (grid[y][x] == '#')
                continue;
            if (y < H - 1)
                memo[y][x] += memo[y + 1][x];
            if (x < W - 1)
                memo[y][x] += memo[y][x + 1];
            memo[y][x] %= 1000000007L;
        }
    }
    cout << memo[0][0] << endl;

    for (int i = 0; i < H; i++) delete[] memo[i];
    delete[] grid, memo;
    return 0;
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
//typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) <<double値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    string s;
    cin >> s;
    int len = s.size();
    
    string t = s;
    reverse(t.begin(),t.end());

    int ok = 0;
    if(t != s) ok++;

    string u = s.substr(0,len/2);
    string ru = u;
    reverse(ru.begin(),ru.end());
    if(u != ru) ok++;

    if(!ok) cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;
 
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
 
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
map<ll,ll>mp_a,mp_b;
 
map<ll,ll> prime_factors(ll n){
    map<ll,ll> factors;
    for(ll i=2;i*i<=n;i++){
            while(n%i==0){
                factors[i]++;
                n/=i;
            }
    }
    //greatest prime > sqrt()
    if(n>1)factors[n]=1;
    return factors;
}
 
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    ll a,b;
    init();
    scanf("%lld%lld",&a,&b);
    
    for(auto it :prime_factors(a)){
        while(it.second--){
            mp_a[it.first]++;
        }
    }
   
    for(auto it :prime_factors(b)){
        while(it.second--){
            mp_b[it.first]++;
        }
    }
    ll cnt=0;
    for(auto it:mp_a){
        if(mp_b[it.first]>0)cnt++;
    }
    printf("%lld",cnt+1);
    return 0;
}

Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int,input().split()))
ub = collections.defaultdict(int)
ub[8] = 0
lb = set()
for x in a:
    lb.add(min(x,2800)//400)
    ub[min(x,3200)//400] += 1;
print(len(lb),len(ub)+ub[8]-1)


Measured memory_bytes: 3316
Sa = list(input())
Sb = list(input())
Sc = list(input())
c = 0
for _ in range(10**9):
    if c == "a" and not Sa:
        print("A")
        break
    if c == "b" and not Sb:
        print("B")
        break
    if c == "c" and not Sc:
        print("C")
        break
    if _ == 0:
        c = Sa[0]
        del Sa[0]
    elif c == "a":
        c = Sa[0]
        del Sa[0]
    elif c == "b":
        c = Sb[0]
        del Sb[0]
    else:
        c = Sc[0]
        del Sc[0]






Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
//#define rep(i,n) for(int i=0;i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)

typedef long long int lli;
typedef pair<lli,int> mp;

int n,m,st;
vector<mp> vs[100005];//グラフの情報を持つ
lli dist[100005];//距離を持つ

int main(void){
	scanf("%d%d%d",&n,&m,&st);
	rep(i,m){
		int a,b;
		lli c;
		scanf("%d%d%lld",&a,&b,&c);
		vs[a].push_back( mp(c,b) );
	}
	
	memset(dist,-1,sizeof(dist));//最初は、無限大で初期化
	
	priority_queue<mp,vector<mp>,greater<mp> > que;
	
	que.push(mp(0,st));//stには0で行ける
	
	while(!que.empty()){//queが空になるまでやる
		
		mp pa = que.top();
		que.pop();
		//queの先頭要素(一番軽いの)を取り出す。
		
		int no = pa.second;//今の頂点
		lli co = pa.first;//今の距離
		
		if(dist[no]!=-1)continue; //もし、すでに確定していたら、飛ばす
		
		dist[no] = co;//確定させる
		
		rep(i,vs[no].size()){//今の地点から出ているすべての辺の先について、キューに突っ込んでいく
			int to = vs[no][i].second;//次の頂点
			lli tc = co + vs[no][i].first;//次の距離
			
			if(dist[to]!=-1)continue; //もし、すでに確定していたら、飛ばす
			que.push( mp(tc,to) ); //queに追加
		}
	}
	//これで、全ての頂点について、stからの距離が求まった
	
	rep(i,n){
		if(dist[i]==-1)printf("INF\n");//もし-1なら、その頂点には到達不可能
		else printf("%lld\n",dist[i]);//そうでなければ、距離を出力
	}
	
	return 0;
}

/*
ちなみに、上の
「もし-1なら、その頂点には到達不可のう」
のコメントの、
「のう」の字を「能」にしたところ、
まともに動かなくなったことを、ここに付記しておきます。
*/

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

using namespace std;

int main() {
  int n; cin >> n;
  vector <int> b(n - 1);
  for(int i = 0; i < n - 1; i++) {
    cin >> b[i];
  }
  vector <int> a(n);
  a[0] = b[0], a[1] = b[0];
  for(int i = 1; i < n - 1; i++) {
    if(a[i] > b[i]) {
      a[i] = b[i];
      a[i + 1] = b[i];
    } else {
        a[i + 1] = b[i];
    }
  }
  int sum = 0;
  for(int i = 0; i < n; i++) {
    sum += a[i];
  }
  cout << sum << '\n';
}

Measured memory_bytes: 256
n = int(input())
A = [list(map(int, input().split())) for i in range(n)]

isVisited = [False] * n
d = [0] + [2001] * (n - 1)
p = [-1] * n

while True:
    mincost = 2001
    for i in range(n):
        if (not isVisited[i]) and (d[i] < mincost):
            mincost = d[i]
            u = i

    if mincost == 2001:
        break

    isVisited[u] = True

    for v in range(n):
        if (not isVisited[v]) and (A[u][v] != -1): #uと繋がる頂点v
            if A[u][v] < d[v]:
                d[v] = A[u][v]
                p[v] = u

print(sum(d))


Measured memory_bytes: 5884
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    ll a,b,t;
    cin >> a>> b>>t;
    ll sum =0;
    for (size_t i = a; i < t+1;  i +=a) {
      sum += b;
    }
    cout << sum;
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
from bisect import bisect_left, bisect_right
n = int(input())
li_s = list(map(int, input().split()))
q = int(input())
li_t = list(map(int, input().split()))
li_s.sort()
ans = 0
for i in li_t:
    left = bisect_left(li_s, i)
    right = bisect_right(li_s, i)
    k = right - left
    if k >= 1:
        ans += 1
print(ans)


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

int main(){
    int N, A; cin >> N;
    
    int odd = 0, four = 0;
    while(cin >> A){
        if( A % 4 == 0 ) four++;
        if( A % 2 == 1 ) odd++;
    }

    if( four + odd == N && N % 2 == 1 && four + 1 >= odd ){
        cout << "Yes" << endl;
        return 0;
    }

    if( four >= odd ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 384
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

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

int main() {
  ll N, K;

  cin >> N >> K;

  unordered_map<ll, ll> um;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    um[tmp]++;
  }

  ll vars = um.size();
  vector<ll> nums;
  for (auto& kv : um) {
    ll value = kv.second;
    nums.emplace_back(value);
  }

  sort(nums.begin(), nums.end());
  ll ans = 0;

  int index = 0;
  while (vars > K) {
    ans += nums[index];
    index++;
    vars--;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 11592
#include<bits/stdc++.h>
using namespace std;
#define maxn 100005
using ll=long long;
ll a[maxn];

int main(){
    ll n,x;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=0;
    if(a[0]>x){
        ans+=a[0]-x;
        a[0]=x;
    }
    for(int i=1;i<n;i++){
        if(a[i-1]+a[i]<=x)
            continue;
        else{
            ans+=(a[i-1]+a[i]-x);
            a[i]-=(a[i-1]+a[i]-x);
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include<string>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, n) for(i = 0; i < n; i++)]
#define DEBUG
using namespace std;

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

int main(){
	int N, M;
	while(cin>>N, N){
		bool gem[21][21];
		int cx, cy;
		cx = cy = 10;
		rep(i, 21)rep(j, 21)gem[i][j] = 0;
		rep(i, N){
			int x,y;
			cin>>x>>y;
			gem[x][y] = true;
		}
		cin>>M;
		rep(i, M){
			string s;
			int l, d;
			cin>>s>>l;
			if(s == "E")d = 0;
			else if(s == "W")d = 1;
			else if(s == "N")d = 2;
			else d = 3;
			while(l--){
				cx += dx[d]; cy += dy[d];
				gem[cx][cy] = false;
			}
		}
		bool flag = false;
		rep(i, 21)rep(j, 21){
			flag = flag || gem[i][j];
		}
		cout<<(flag?"No":"Yes")<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
N = int(input())

A = []
for i in range(N):
    A.append(list(map(int,input().split())))

B = sorted(A, key = lambda x:x[1])
task = 0
time_1 = 0
flag = 0

for i in range(N):
    task += B[i][0]
    time_1 = B[i][1]

    if task <= time_1:
        pass
    else:
        flag = 1

if flag == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 55188
#include <iostream>

int main(){
    using namespace std;

    int number = 0;
    int count  = 1;
    while( true ){
        cin >> number;
        if( number == 0 ) break;
        cout << "Case " << count << ":" << " " << number << endl;
        ++count;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[105]={0};
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int sum=0;
    for(int i=1;i<=n;i++){
        int check=1;
        for(int j=1;j<=i;j++){
            if(check==0) break;
            if(a[j]>a[i]) check=0;
        }
        if(check) sum++;
    }
    cout<<sum<<endl;
    return 0;
}


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

const int mod = 998244353;

string S;

unordered_map<string, int> mm;
int dp(string &S) {
    if(mm.find(S) != mm.end()) return mm[S];
    int ret = 0;
    if(S.size() == 0) return mm[S] = 1;

    string T = S.substr(1, S.size() - 1);
    ret += (S[0] == '1'? 2 : 1) * dp(T) % mod;
    ret %= mod;

    for(int i = 1; i <= S.size() / 2; i++) {
        T = S.substr(0, i);
        for(int j = 2; j <= (int)S.size() / i; j++) {
            for(int k = 0; k < i; k++) {
                T[k] = (T[k] == '1' && S[i * (j - 1) + k] == '1'? '1' : '0');
            }
            string R = S.substr(i * j, (int)S.size() - i * j);
            ret += 1LL * dp(T) * dp(R) % mod;
            ret %= mod;
        }
    }
    return mm[S] = ret;
}

int main() {
    cin >> S;
    cout << dp(S);
}


Measured memory_bytes: 5388
//C - Lower
//2019/09/09

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

int main(void) {
    int *trout,num,i,ans=0,temp=0;
    scanf("%d",&num);
    trout=malloc(sizeof(int)*(num));
    for (i=0;i<num;i++) {
        scanf("%d",&trout[i]);
    }
    for (i=0;i<num-1;i++) {
        if (trout[i]<trout[i+1]) {
            if (ans<temp) {
                ans=temp;
            }
            temp=0;
        }
        else {
            temp++;
        }
        if (i==num-2) {
            if (ans<temp) {
                ans=temp;
            }
        }
    }
    free(trout);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 512
module UIntegerSort
  implicit none
 
  private
 
  public QuickSortInteger
 
contains
    
  !!
  ! ピボット値の取得
  !
  subroutine GetPivotIntegerValue(array, n, a, b, pivot_value)
    integer(16), intent(inout) :: array(:), pivot_value
    integer(16), intent(in) :: n, a, b
 
    pivot_value = array((a + b) / 2)
  end subroutine
 
  !!
  ! ピボット値に従って値を分離
  !
  subroutine GetPartitionInteger(array, n, a, b, pivot)
    integer(16), intent(inout) :: array(:)
    integer(16), intent(in)  :: n, a, b
    integer(16), intent(out) :: pivot
 
    integer(16) :: buffer, pivot_value
    integer(16) :: l, r
 
    if (a == b) then
      pivot = 0
      return
    end if
 
    call GetPivotIntegerValue(array, n, a, b, pivot_value)
 
    l = a
    r = b
 
    do while(.true.)
      do while(array(l) < pivot_value)
        if (l >= b) exit
        l = l + 1
      end do
 
      do while(pivot_value < array(r))
        if (r <= a) exit
        r = r - 1
      end do
 
      if(r <= l) exit
 
      buffer   = array(l)
      array(l) = array(r)
      array(r) = buffer
 
      l = l + 1
      r = r - 1
    end do
 
    pivot = r
  end subroutine
 
  !!
  ! 配列の一部分をソートする。
  !
  recursive subroutine QuickSortIntegerSubarray(array, n, a, b)
    integer(16), intent(inout) :: array(:)
    integer(16), intent(in)    :: n, a, b
 
    integer(16) :: pivot
 
    call GetPartitionInteger(array, n, a, b, pivot)
    if (pivot /= 0) then
      call QuickSortIntegerSubarray(array, n, a, pivot)
      call QuickSortIntegerSubarray(array, n, pivot + 1, b)
    end if
  end subroutine
 
  !!
  ! 配列全体をソートする
  !
  subroutine QuickSortInteger(array, n)
    integer(16) :: array(:)
    integer(16) :: n
 
    call QuickSortIntegerSubarray(array, n, 1_16, n)
  end subroutine
end module
 
program test 
use UIntegerSort
implicit none
integer(16),allocatable::a(:)
integer(16)::n,i,ans
read*,n
allocate(a(n))
read*,a
call QuickSortInteger(a, N)
ans=1
do i=1, n
	ans=ans*a(i)
    	if(ans==0)then
        	exit
        else if(ans > 10**18_16)then
        	ans = -1
            exit
        else 
         	ans = ans
        end if
end do
print*,ans 
end program test

Measured memory_bytes: 4476
#![allow(unused)]

use std::cmp::{max, min};
use std::io::stdin;
use std::mem::swap;
use std::str::FromStr;

fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim().parse()
}

fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|x| x.parse())
        .collect()
}

fn main() {
    let n: usize = input().unwrap();
    let a: Vec<i32> = input_vec().unwrap();

    let mut ans = std::i32::MAX;
    for base in -100..101 {
        ans = min(ans, a.iter().map(|x| (*x - base) * (*x - base)).sum());
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
	public static void main(String[] args)  {
		Scanner scan =new Scanner(System.in);
		int n=Integer.parseInt(scan.nextLine());
		int[][] a = new int [2][n];
		for (int i = 0;i < n ;++i)a[0][i]=Integer.parseInt(scan.next());
		scan.nextLine();
		for (int i = 0;i < n ;++i)a[1][i]=Integer.parseInt(scan.next());

		long[] cs_upper = new long [n];cs_upper[0]=a[0][0];
		long[] cs_lower = new long [n];cs_lower[n-1]=a[1][n-1];
		for (int i = 1;i < n; ++i){
			cs_upper[i] = cs_upper[i-1]+a[0][i];
			cs_lower[n-i-1] = cs_lower[n-i]+a[1][n-i-1];
		}
		long max=0;
		for (int i = 0;i < n;++i){
			max=Math.max(max, cs_lower[i]+cs_upper[i]);
		}
		System.out.print(max);
	}
}
//end


Measured memory_bytes: 21972
#include <iostream>

using namespace std;
 
    
    
int main(){
  int n,m;
  cin>>n>>m;
  int day[m];
  
  for (int i = 0; i < m; i++)
  {
    cin>>day[i];
  }
  
  int sum=0;

  for (int i = 0; i < m; i++)
  {
    sum=sum+day[i];
  }

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

Measured memory_bytes: 3656
from collections import defaultdict
N=int(input())
L=input()
Hash=defaultdict(lambda:0)
for i in L:
    Hash[i]+=1
ans=Hash['G']*Hash['R']*Hash['B']
for j in range(2*N//3+1):
    diff=j
    for i in range(N-2*diff):
        if L[i+diff]!=L[i] and L[i+2*diff]!=L[i] and L[i+2*diff]!=L[i+diff]:
            ans-=1
print(ans)

Measured memory_bytes: 74188
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000010;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n, c;
	cin >> n >> c;
	vector<vector<int>> d(c, vector<int>(c));
	rep(i, c) rep(j, c) cin >> d[i][j];
	vector<vector<int>> a(n, vector<int>(n));
	rep(i, n) rep(j, n) cin >> a[i][j];
	vector<vector<int>> change(3, vector<int>(c));
	rep(x, n) {
		rep(y, n) {
			rep(z, c) {
				if ((x + y) % 3 == 0) change[0][z] += d[a[x][y] - 1][z];
				else if ((x + y) % 3 == 1) change[1][z] += d[a[x][y] - 1][z];
				else change[2][z] += d[a[x][y] - 1][z];
			}
		}
	}
	int ans = inf;
	rep(i, c) {
		rep(j, c) {
			rep(k, c) {
				if (i == j || j == k || k == i) continue;
				chmin(ans, change[0][i] + change[1][j] + change[2][k]);
			}
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 1280
n, k = gets.split().map(&:to_i)
s = gets.chomp.split("")

#s.chunk(&:itself).each {|key, arr|
#  puts "#{key}: #{arr.inspect}"
#  #puts "#{key}: #{arr.to_s}"
#}

happy = n - s.chunk(&:itself).count
happy += k*2  # +2 happy / 1 switch

puts [n-1, happy].min

Measured memory_bytes: 9980
#include<stdio.h>
int main(){
  int a;
  double b,c,d;
  scanf("%d",&a);
  if(a%2==0){
    d=0.50000;
    }
  else if(a%2==1){
    b=a+1;
    c=b/2;
    d=c/a;
  }
printf("%f",d);
  return 0;}
  

Measured memory_bytes: 128