akhauriyash/Code-Regression huggingface dataset:
//
// Created by Tetsuya Shiota on 2019-01-27.
//

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include<cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include<bitset>

#define REP(i,b,n) for(int i=b;i<(int)n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define FOR(it,o)  for(__typeof((o).begin()) it=(o).begin(); it!=(o).end(); ++it)
#define dbg(x) cout << __LINE__ << ' ' << #x << " = " << (x) << endl


typedef long long ll;

using namespace std;

//ハマったらチェックリスト見ろ!!

int main(){
    int N;
    string A, B, C;
    cin >> N >> A >> B >> C;
    int cost = 0;
    rep(i, N){
        set<char> S;
        S.insert(A[i]);
        S.insert(B[i]);
        S.insert(C[i]);
        if(S.size() == 1)continue;
        if(S.size() == 2)cost += 1;
        if(S.size() == 3)cost += 2;
    }
    cout << cost <<endl;

    return 0;
}

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

using namespace std;

int main() {
  int n, min = INT_MAX, max = INT_MIN;
  long long sum = 0;
  cin >> n;
  while (n) {
    n--;
    int x;
    cin >> x;
    min = (min > x) ? x : min;
    max = (max < x) ? x : max;
    sum += x;
  }
  cout << min << " " << max << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int k, a, b;
	cin >> k >> a >> b;
	int i = 1;
	while(k*i <= b) {
		if(a <= k*i && k*i <= b) {
			cout << "OK" << endl;
			return 0;
		}
		i++;
	}
	cout << "NG" << endl;
	return 0;
}



Measured memory_bytes: 3624
N = int(input())
B = list(map(int, input().split()))

A=[10**6]*N

for i in range(N-1):
    if A[i] >= B[i]:
        A[i] = B[i]
    if A[i+1] >= B[i]:
        A[i+1] = B[i]

print(sum(A))

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

using namespace std;

int n;
int a[201000];
int ans[201000];
int dis[201000];
vector<int> e[210000];

void dfs(int x,int y,int l)
{   int pos = 210000,tmp;
	if(a[x] > dis[l]) dis[++l] = a[x];
	else{
		pos = lower_bound(dis+1,dis+l+1,a[x])-dis;
		tmp = dis[pos];
		dis[pos] = a[x];
	}
	ans[x] = max(ans[x],l);
    for(int i = 0;i < e[x].size();i++)
    {
    	if(e[x][i] != y)
    	{
    		dfs(e[x][i],x,l);
		}
	}
    if(pos != 210000)	
	dis[pos] = tmp;
}
int main(){
   cin>>n;
   
   for(int i = 1;i <= n;i++)
     cin>>a[i];
   for(int i = 1;i <= n-1;i++)
   {
   	int u,v;
   	scanf("%d%d",&u,&v);
    e[u].push_back(v);
    e[v].push_back(u);
   }
   dis[1] = a[1];
   dfs(1,0,1);
   for(int i = 1;i <=n;i++)
    cout<<ans[i]<<endl;
}

Measured memory_bytes: 30776
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1e5+5;
const int INF = 0x3f3f3f3f;
int dp[MAXN],a[MAXN];

int main(){
//    cout<<INF<<endl;
	int N;
	memset(dp,INF,sizeof(dp));
	cin>>N;
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	dp[0]=0;
	for(int i=0;i<N-1;++i){
		dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
		if(i+1==N-1);
		else dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
	}
//	for(int i=0;i<N;++i)
//	    cout<<dp[i]<<endl;
	cout<<dp[N-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
#include <math.h>

#define N_MAX 100

int main(void)
{
    int N, m, d,a[N_MAX];
    int i, j,cnt,ans;

    scanf("%d",  &N);
    for (i=0;i<N;i++) {
        scanf("%d", &a[i]);
    }
    for (i=0;i<N-1;i++) {
        if (a[i]==a[i+1]) {
            cnt++;
        }
    }
    i=0;
    cnt=1;
    ans=0;
    while (i<N-1) {
        if (a[i]==a[i+1]) {
            cnt++;
        } else {
            ans=ans+cnt/2;
            cnt=1;
        }
        i++;
    }
    if (cnt!=1) ans=ans+cnt/2; 
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
using namespace std;

int main() {
    
    string S;
    cin >> S;

    cout << count(S.begin(),S.end(),'1') << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

    for(int i=1;i<=n;i++){
        int x=i;
        if(i%3==0)
            cout<<' '<<i;
        else{
            for(int j=0;;j++){
                
                if(x%10==3){
                     cout<<' '<<i;
                     break;
                }else    x/=10;
                if(x==0)  break;
                
            }
        }
    }
    cout<<'\n';
}


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

int main() {
  char c;
  cin >> c;
  if (isupper(c)) {
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }
  return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>

using namespace std;

#define Whats(x) cout<<#x<<" is "<<(x)<<endl
#define Divhim() cout<<">>>>>>>>>"<<endl
#define Divher() cout<<"<<<<<<<<<"<<endl
#define Oops() cout<<"!!!!!!!!!!"<<endl

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

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

#define Pir pair<int,int>
#define fir first
#define sec second
const int N=55;

int n,ki,sm,a[N];
vector<int> ans;

void GG()
{
	puts("-1");
	exit(0);
}

int main()
{
	scanf("%d%d",&n,&ki);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	++ki;
	for(int pre=-1;ki;--ki)
	{
		int mn=233,p;
		for(int i=1;i<=n;++i)if(i!=pre&&Getmin(mn,a[i]))
			p=i;
		if(a[p]==0)
			GG();
		for(int i=1;i<=n;++i)if(i!=pre&&i!=p)
		{
			ans.push_back(i);
			--a[i];
		}
		ans.push_back(p);
		--a[pre=p];
	}
	printf("%d\n",(int)ans.size());
	for(int i=0;i<(int)ans.size();++i)
		printf("%d ",ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;
using Graph = vector<vector<int>>;


vector<bool> seen;

int main() {
    ll N,M;
    cin >> N >> M;
        // グラフ入力受取 (ここでは無向グラフを想定)
    Graph G(N);
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        a--;
        b--; //0始まりに
        G[a].push_back(b);
        G[b].push_back(a);
    }
    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    vector<int> ans(N, -1); //道しるべ

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    ans[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {  //nv = next v
            if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            ans[nv] = v; //nvはvに行くのが最短
            que.push(nv);
        }
    }
    bool ok = true;
    for (ll i = 0;i<N;i++) {
        if (dist[i] == -1) ok = false;
    }
    if (ok) {
        cout << "Yes" << endl;
        for (ll i = 1;i<N;i++) cout << ans[i] + 1 << endl;
    }
    else cout << "No" << endl;



}

Measured memory_bytes: 10572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using static kyoupuro.Input;
using static kyoupuro.MyMath;

namespace kyoupuro {

    class MainClass {

        public static void Main() {
            var S = Line();

            if (S[0] == S[1] && S[1] == S[2]) {
                Console.WriteLine("Yes");
            } else if (S[3] == S[2] && S[2] == S[1]) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }

    class MyMath {
        static long Gcd(long a, long b) {
            return b == 0 ? a : Gcd(b, a % b);
        }
    }

    class Input {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line() {
            return Console.ReadLine();
        }

        public static int NextInt() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return int.Parse(enumerator.Current);
        }

        public static long NextLong() {
            while (!enumerator.MoveNext()) {
                enumerator = StrArr().AsEnumerable().GetEnumerator();
            }
            return long.Parse(enumerator.Current);
        }

        public static string[] StrArr() {
            return Line().Split(' ');
        }

        public static List<int> IntList() {
            return StrArr().Select(int.Parse).ToList();
        }

        public static List<long> LongList() {
            return StrArr().Select(long.Parse).ToList();
        }

        public static void Skip(int line = 1) {
            enumerator.Reset();
            for (int i = 0; i < line; i++) Console.ReadLine();
        }

        public static void Reset() {
            enumerator.Reset();
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#pragma GCC optimize(2)
using namespace std;
typedef long long ll;
bool isprime(ll num)
{
    if(num==1)
        return false;
    if(num==2)
        return true;
    if(num%2==0)
        return false;
    ll sqnum=sqrt(num)+1;
    for(int i=3;i<=sqnum;i+=2)
    {
        if(num%i==0)
            return false;
    }
    return true;
}
vector<ll> vc;
int main ()
{
    ll a,b;
    cin>>a>>b;
    ll x=min(a,b);
    ll y=max(a,b);
    ll ans=0;
    for(ll i=1;i*i<=x;i++)
    {
        if(x%i==0){
            vc.push_back(i);
            if(i*i!=x)
                vc.push_back(x/i);
        }
    }
    for(ll i=0;i<vc.size();i++)
    {
        if(y%vc[i]==0&&isprime(vc[i]))
            ans++;
    }
    cout<<ans+1<<endl;
    return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

template <class t, class u>
void chmax(t &a, u b)
{
  if (a < b)
    a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
  if (b < a)
    a = b;
}

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;

int fact(int n)
{
  if (n == 0)
    return 1;
  return fact(n - 1);
}
int main()
{
  int x,y;
  cin >> x>>y;
  int ans=0;
  if(x == 3){
    ans += 100000;
  }
  else if(x == 2){ 
    ans += 200000;
  }else if(x == 1){
    ans += 300000;
  }  
  if(y == 3){
    ans += 100000;
  }
  else if(y == 2) {ans += 200000;}
  else if(y == 1) {ans += 300000;}
  if(x == 1&& y==1){ans += 400000;}
  cout << ans <<endl;
}

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

typedef long long LL;

const int N=15;

char s[N+9];
int n;

void into(){
  scanf("%s",s+1);
  n=strlen(s+1);
}

int ans;

void Get_ans(){
  ans+=15-n;
  for (int i=1;i<=n;++i) ans+=s[i]=='o';
}

void work(){
  Get_ans();
}

void outo(){
  puts(ans>=8?"YES":"NO");
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3684
require 'pp'
# IS_DEBUG = true
IS_DEBUG = false
def dputs str
	if(IS_DEBUG)
		puts str
	end
end
def dpp str
	if(IS_DEBUG)
		pp str
	end
end

require 'pp'

INT_MAX = 999999999999999999999999

# use union find

# array and variables are all 0 indexed
class UnionFind
	def initialize(n)
		@parent = Array.new(n){|i| i}
		@rank = Array.new(n){1}
	end
	def find(x)
		par = @parent[x]
		if(par == x)
			return x
		else
			return @parent[x] = find(par)
		end
	end
	def union(x,y)
		root_x = find(x)
		root_y = find(y)
		if(root_x == root_y)
			#ok
			return
		end
		if(@rank[root_x] < @rank[root_y])
			@parent[root_x] = root_y
		elsif(@rank[root_x] == @rank[root_y])
			@parent[root_y] = root_x
			@rank[root_x] += 1
		else
			@parent[root_y] = root_x
		end
	end
	def same_root?(x,y)
		return find(x)==find(y)
	end
end

N,M=gets.chomp.split(' ').map{|n| n.to_i}
P=gets.chomp.split(' ').map{|n| n.to_i - 1}
dpp P

G=UnionFind.new(N)
0.upto(M-1){|d|
	tmp = gets.chomp.split(' ').map{|n| n.to_i - 1}
	G.union(tmp[0],tmp[1])
}

sum = 0
0.upto(N-1){|i|
	if(G.same_root?(i,P[i]))
		sum += 1
	end
}
puts sum


Measured memory_bytes: 13180
#include<bits/stdc++.h>
using namespace std;
int l[2020][2020];
int cnt[2020];
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
//    cout<<n<<endl;
    for(int i=1;i<n;i++)
      for(int j=i+1;j<=n;j++)
      {
      	l[i][j]=min((j-i),(abs(i-x)+abs(j-y)+1));
      	cnt[l[i][j]]++;
      	//cout<<i<<"    "<<j<<"   "<<l[i][j]<<endl;
	  }
	for(int i=1;i<n;i++)
	{
		cout<<cnt[i]<<endl; 
	}
    return 0;
}

Measured memory_bytes: 17440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
int n,m;
int a[105];
int sum=0;
int yes=0;
double summ;
scanf("%d %d",&n,&m);

for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    sum=sum+a[i];
}

summ=(double)sum/(4*m);

for(int i=0;i<n;i++){
    if((double)a[i]>=summ){yes++;}
}

if(yes>=m){printf("Yes\n");}
else{printf("No");}

}


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

int main(){
    string S,T;
    cin >> S;
    cin >> T;

    int cnt=0;
    if (S.at(0)==T.at(0)) cnt++;
    if (S.at(1)==T.at(1)) cnt++;
    if (S.at(2)==T.at(2)) cnt++;
    cout << cnt << endl;
    return 0;
}

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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,t, aa=0, ans =0;
    cin >> a >> b >> t;
    aa = a;
    while(aa < t+0.5){
        aa += a;
        ans += b;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
N, M = map(int, input().split())
k = []
for _ in range(M):
    k.append(list(map(int, input().split())))

p = list(map(int, input().split()))

candidate = [[0], [1]]
while True:
    temp = []
    for c in candidate:
        for v in [0, 1]:
            temp.append(c + [v])
    candidate = temp
    if len(temp[0]) == N:
        break

ans = 0
for c in candidate:
    flag = True
    for i, switch in enumerate(k):
        hoge = 0
        for s in switch[1:]:
            hoge += c[s-1]
        flag = flag and (hoge % 2 == p[i])
    if flag:
        ans += 1


print(ans)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX_N = 201010;

//組み合わせの余りを求める
ll fac[MAX_N], finv[MAX_N], inv[MAX_N];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX_N; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(ll n, ll k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
char notes[110][10];
ll treasure[3030][3030];
ll dp[3030][3030][4];

//long longしか使わない
//素数は1より大きい
//lower_boundは指定したkey以上の要素の一番左のイテレータをかえす
//upper_boundは指定したkeyより大きい要素の一番左のイテレータをかえす
int main() {
	string s;
	cin >> s;
	ll k;
	cin >> k;
	ll n = s.length();
	rep(i, n - 1) {
		ll amari = 'z' - s[i] + 1;
		if (amari <= k&&s[i]!='a') {
			s[i] = 'a';
			k -= amari;
		}
	}
	ll nokori = k % 26;
	rep(i, nokori) {
		if (s[n - 1] == 'z')s[n - 1] = 'a';
		else {
			s[n - 1] = s[n - 1] + 1;
		}
	}
	cout << s << endl;
	return 0;
}


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

int main() {

    int h,w;cin>>h>>w;
    string s[h];
    for (int i=0;i<h;i++)
        cin>>s[i];
    int l[h][w]{},r[h][w]{},u[h][w]{},d[h][w]{};
    for (int i=0;i<h;i++)
        for (int j=1;j<w;j++)
            if (s[i][j-1]=='.'&&s[i][j]=='.')
                l[i][j]=l[i][j-1]+1;
    for (int i=0;i<h;i++)
        for (int j=w-2;j>=0;j--)
            if (s[i][j+1]=='.'&&s[i][j]=='.')
                r[i][j]=r[i][j+1]+1;
    for (int i=0;i<w;i++)
        for (int j=1;j<h;j++)
            if (s[j-1][i]=='.'&&s[j][i]=='.')
                u[j][i]=u[j-1][i]+1;
    for (int i=0;i<w;i++)
        for (int j=h-2;j>=0;j--)
            if (s[j+1][i]=='.'&&s[j][i]=='.')
                d[j][i]=d[j+1][i]+1;
    int mx=0;
    for (int i=0;i<h;i++)
        for (int j=0;j<w;j++)
            if (s[i][j]=='.')
                mx=max(mx,l[i][j]+r[i][j]+u[i][j]+d[i][j]+1);
    cout<<mx<<endl;
    return 0;
}

Measured memory_bytes: 66816
#include<iostream>
using namespace std;
int main(){
    int a, b, c, s;
    cin >> a >> b >> c;
    if ( a > b ) { s = a; a = b; b = s; }
    if ( b > c ) { s = b; b = c; c = s; }
    if ( a > b ) { s = a; a = b; b = s; }
    cout << a << " " << b << " " << c << endl;
    return 0;
}

Measured memory_bytes: 3092
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var n,k int
    fmt.Scan(&n,&k)
    a := make([]int,n)
    for i:=0;i<n;i++{
        fmt.Scan(&a[i])
    }
    ans := 0
    for i:=0;i<n;i++{
        ans += min32(a[i],abs32(k-a[i]))*2
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n, a, b; cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
#include <iostream>

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

int main(){
	double a, b;
	std::cin >> a >> b;
	std::cout << a / b << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
#define F first
#define int long long int
#define S second
#define boost ios_base::sync_with_stdio(false),cin.tie(NULL);
const int MOD = 998244353;
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp>  
//using namespace __gnu_pbds; 
//stringstream ss; string temp; ss<<str(original string) ss>>temp;

int32_t main()
{   
    boost
  //open("output.txt", "w", stdout);
    //#endif
    int n; cin>>n;
    int a[n];
    int h[10005]={0};
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        h[a[i]]++;
    }
    for(int i=1;i<=10000;i++)
    {
        h[i]+=h[i-1];
    }
    sort(a,a+n);
    int ans = 0;

    for(int i=n-1;i>=1;i--)
    {
        int l = 0, r = i-1; 
        while( l < r){ 
            if( a[l] + a[r] > a[i]){ 
  
                // If it is possible with a[l], a[r] 
                // and a[i] then it is also possible 
                // with a[l+1]..a[r-1],a[r] and a[i] 
                ans += r - l ;  
  
                //checking for more possible solutions 
                r--;   
            } 
            else 
  
                // if not possible check for  
                // higher values of arr[l] 
                l++;   
        } 
    }
    cout<<ans<<endl;
    return 0;
} 


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<cmath>
#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(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int n,d;
    cin>>n>>d;
    vector<double>x(n);
    vector<double>y(n);
    int ans = 0;
    rep(i,n) {
        cin>>x[i]>>y[i];
        if(sqrt(x[i]*x[i]+y[i]*y[i])<=d) ans++;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 1000000000; //10^9

int f(int n){
    if(n%2 == 0){
        return n / 2;
    }
    else
    {
        return 3 * n + 1;
    }
}

int main(){
    int s;
    cin >> s;
    vector<int> a(1000001, 0);
    int i = 1;
    a.at(s) += 1;
    do{
        i = i + 1;
        s = f(s);
        a.at(s) += 1;
    } while (a.at(s) != 2);
    cout << i << endl;
}


Measured memory_bytes: 4096
#include <iostream>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int b[k+1]={0};
    for(int i=1;i<k+1;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(a[j]<=i)
            {
                if(b[i-a[j]]==0)
                {
                    b[i]=1;
                    break;
                }
            }
        }
    }
    if(b[k])
    cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c;
    char op;
    cin>>a>>op>>b;
    while (op!='?'){
        if (op=='+') c=a+b;
        if (op=='-') c=a-b;
        if (op=='*') c=a*b;
        if (op=='/') c=a/b;
        cout<<c<<endl;
        cin>>a>>op>>b;
    }
    return 0;
}


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

int main(){
  int h,a;
  cin >> h >> a;
  
  cout << ( (a+h-1)/a ) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int ans=0;
  char a;
  string S,T;
  cin>>S>>T;
  if(S==T){
    cout<<"Yes"<<endl;
    return 0;
  }
  int N=S.size();
  for(int i=0;i<N;i++){
    a=S.at(N-1);
    for(int j=N-1;j>0;j--){
      S.at(j)=S.at(j-1);
    }
    S.at(0)=a;
    if(S==T){
      ans=1;
      break;
    }
  }
  if(ans==1)	cout<<"Yes"<<endl;
  else	cout<<"No"<<endl;
}

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

map<char, int> suits{
    {'S', 0},
    {'H', 1},
    {'C', 2},
    {'D', 3},
};

int main() {
  set<int> cards[4];
  for (int i{}; i < 4; ++i) {
    for (int j{1}; j <= 13; ++j) {
      cards[i].insert(j);
    }
  }
  int n;
  cin >> n;
  for (int i{}; i < n; ++i) {
    char s;
    int r;
    cin >> s >> r;
    cards[suits[s]].erase(r);
  }
  map<int, char> flipped;
  for (const auto &p : suits) {
    flipped[p.second] = p.first;
  }
  for (int i{}; i < 4; ++i) {
    for (const auto &e : cards[i]) {
      cout << flipped[i] << ' ' << e << endl;
    }
  }

  return 0;
}



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

int main(){
  int a;
  double ans;
  cin>>a;
  
  if(a==1){
    cout<<"1"<<endl;
  }else if(a%2==0){
    cout<<"0.5"<<endl;
  }else{
    ans=(double)(a+1)/(2*a);
    cout<<ans<<endl;
  }
  return 0;
}


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

int main() {
  int x,y;
  cin >> x >> y;
  int X,Y;
  
  while (x != 0 || y != 0) {
    if (x > y){
        X = x;
        Y = y;
        x = Y;
        y = X;
    }
    cout << x << ' ' << y << endl;
    cin >> x >> y;
  }
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

int N, M;
int A[100010];
int cum[20][100010];
int cnt[20];
int memo[1 << 20];

int rec(int sum, int bit) {
    if (sum == N && !bit) return 0;
    if (~memo[bit]) return memo[bit];
    int res = 1 << 30;
    REP(i, M) if (bit >> i & 1) {
        res = min(res, cnt[i] - (cum[i][sum + cnt[i]] - cum[i][sum]) + rec(sum + cnt[i], bit - (1 << i)));
    }
    return memo[bit] = res;
}

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

    cin >> N >> M;
    REP(i, N) {
        cin >> A[i];
        --A[i];
        ++cum[A[i]][i + 1];
        ++cnt[A[i]];
    }
    REP(i, 20) REP(j, N) cum[i][j + 1] += cum[i][j];
    memset(memo, 0xff, sizeof(memo));
    cout << rec(0, (1 << M) - 1) << endl;
}


Measured memory_bytes: 27712
/*~~~~~~~~~~~~~~~~~~~~~~~~*
 *  Jeevan ek rahasya hai *
 *     slow_processor     *
 * Author-maskman_lucifer *
 *~~~~~~~~~~~~~~~~~~~~~~~~*/
#include <bits/stdc++.h>                                        
#define ll long long 
#define mpr make_pair
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define PI 3.141592653589793
#define lc '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double r;
    cin>>r;
    cout<<2.0*r*PI<<lc;
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end() 
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define forn(i, n) for(int i=0;i<(n);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;

bool ispal(string s) {
	string rs = s; reverse(all(rs));
	return s == rs;
}
int main() {
	string s; cin >> s;
	int n = s.size();
	if(ispal(s) && ispal(s.substr(0, n/2)) && ispal(s.substr(n-n/2, n/2))) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}

Measured memory_bytes: 256
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)*}
    };
}

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

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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        p: [u32; n],
    }
    let iter = (1u32..).zip(p.iter());
    let mut c = 0;
    for (idx, value) in iter {
        if idx != *value {
            c += 1;
        }
    }
    if c > 2 {
        println!("NO");
    } else {
        println!("YES");
    }
}


Measured memory_bytes: 4352
#include<cstdio>
 using namespace std;
typedef struct{
    char name[30];
    int ten;
}team;
 
int main(){
    int n,i,j,k,m,h,f;
    team soccer[10],t;
    f=1;
    while(~scanf("%d",&m)){
        if(m==0)break;
        if(f!=1)printf("\n");
        f=2;
        for(i=0;i<m;i++){
            scanf(" %s %d %d %d ",soccer[i].name,&k,&n,&h);
            soccer[i].ten=3*k+h;
        }
         
        for(i=0;i<m;i++){
            for(j=0;j<m-1;j++){
                if(soccer[j].ten<soccer[j+1].ten){
                    t=soccer[j];
                    soccer[j]=soccer[j+1];
                    soccer[j+1]=t;
                }
            }
        }
        for(i=0;i<m;i++){
            printf("%s,%d\n",soccer[i].name,soccer[i].ten);
        }
    }
    return 0;
}

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

int main(){
	int n,a;
	long long int dp[100][21];
	scanf("%d",&n);
	scanf("%d",&a);
	for(int i=0;i<21;i++)dp[0][i]=0;
	dp[0][a]=1;
	for(int i=1;i<n-1;i++){
		scanf("%d",&a);
		for(int j=0;j<21;j++){
			dp[i][j]=0;
			if(j>=a)dp[i][j]+=dp[i-1][j-a];
			if(j+a<=20)dp[i][j]+=dp[i-1][j+a];
		}
	}
	scanf("%d",&a);
	printf("%lld\n",dp[n-2][a]);
}

Measured memory_bytes: 1188
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <tuple>
#include <functional>
#include <cstring>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i <= n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i <= n; i++)

typedef long long ll;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;

using namespace std;

int main(void)
{
    int h, n;
    cin >> h >> n;
    v_int a(n);
    ll sum = 0;
    
    irep(i, n) {
        int tmp;
        cin >> tmp;
        sum += tmp;
    }

    if(h > sum) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
	return 0;
}
/** atcodr **/


Measured memory_bytes: 768
X,K,D = map(int,input().split())

if X==0:
    if K%2==0:
        print(0)
        exit()
    else:
        print(D)
        exit()

if X>0:
    if (X-K*D)>=0:
        print(X-D*K)
    else:
        cnt = X//D
        val = X%D
        if (K-cnt)%2==0:
            print(val)
        else:
            print(abs(D-val))
else:
    if (K*D+X)<=0:
        print(abs(X+K*D))
    else:
        cnt = abs(X)//D
        val = abs(X)%D
        if (K-cnt)%2==0:
            print(abs(-val))
        else:
            print(abs(-val+D))

Measured memory_bytes: 9220
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long,long long> pll;
const int maxn=100005;
int n,m,f[maxn];
struct point {
    int x,y,id;
} p[maxn];
bool cmp1(point p1,point p2) {
    return p1.x<p2.x;
}
bool cmp2(point p1,point p2) {
    return p1.y<p2.y;
}
inline void init() {
    for (int i=0;i<n;++i)
        f[i]=i;
}
int F(int x) {
    return x==f[x]?x:f[x]=F(f[x]);
}
inline void U(int a,int b) {
    f[F(a)]=F(b);
}
struct edge {
    int u,v,w;
    edge(){}
    edge(int u,int v,int w):u(u),v(v),w(w){}
    bool operator<(const edge &rhs)const{
        return w<rhs.w;
    }
} e[maxn<<1];
int main()
{
    scanf("%d",&n);
    init();
    for (int i=0;i<n;++i) {
        scanf("%d%d",&p[i].x,&p[i].y);
        p[i].id=i;
    }
    sort(p,p+n,cmp1);
    for (int i=0;i<n-1;++i)
        e[i]=edge(p[i].id,p[i+1].id,min(abs(p[i].x-p[i+1].x),abs(p[i].y-p[i+1].y)));
    sort(p,p+n,cmp2);
    for (int i=0;i<n-1;++i)
        e[i+n-1]=edge(p[i].id,p[i+1].id,min(abs(p[i].x-p[i+1].x),abs(p[i].y-p[i+1].y)));
    m=2*n-2;
    sort(e,e+m);
    long long res=0;
    for (int i=0;i<m;++i)
        if (F(e[i].u)!=F(e[i].v)) {
            U(e[i].u,e[i].v);
            res+=1LL*e[i].w;
        }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 4224
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int H = sc.nextInt();
        int N = sc.nextInt();
        int[] A  = new int[N];
        int[] B  = new int[N];

        for(int i=0;i<N;i++){
            A[i] = sc.nextInt();
            B[i] = sc.nextInt();
        }
        int[] dp = new int[H+1];


        for(int i=0;i<H+1;i++){
                dp[i] = Integer.MAX_VALUE;
        }

        dp[0] = 0;
        for(int i=0;i<H+1;i++){
            for(int j=0;j<N;j++){
                if(A[j] >= i ){
                    dp[i] = Math.min(dp[i],B[j]);
                } else {
                    dp[i] = Math.min(dp[i-A[j]]+B[j],dp[i]);
                }
            }
        }
        System.out.println(dp[H]);

    }

}






Measured memory_bytes: 26044
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 1000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

char g[maxn+5][maxn+5];
int dis[maxn+5][maxn+5];
bool vis[maxn+5][maxn+5];

const int mov[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int main()
{
    int h,w; scanf("%d%d",&h,&w);
    int sx,sy,dx,dy; scanf("%d%d%d%d",&sx,&sy,&dx,&dy);
    rep(i,1,h) scanf("%s",g[i]+1);
    
    memset(dis,63,sizeof dis);

    deque<pii> q;
    q.pb(mp(sx,sy));
    dis[sx][sy]=0;
    while(q.size())
    {
        int x=q.front().FI;
        int y=q.front().SE;
        q.pop_front();
        if(vis[x][y]) continue;
        vis[x][y]=1;
        //printf("?? %d %d\n",x,y);
        rep(i,0,3) 
        {
            int nx=x+mov[i][0];
            int ny=y+mov[i][1];
            if(nx>=1 && nx<=h && ny>=1 && ny<=w && dis[nx][ny]>dis[x][y] && g[nx][ny]=='.')
            {
                dis[nx][ny]=dis[x][y];
                q.push_front(mp(nx,ny));
            }
        }
        rep(i,-2,2) rep(j,-2,2)
        {
            int nx=x+i;
            int ny=y+j;
            if(nx>=1 && nx<=h && ny>=1 && ny<=w && dis[nx][ny]>dis[x][y]+1 && g[nx][ny]=='.')
            {
                dis[nx][ny]=dis[x][y]+1;
                q.push_back(mp(nx,ny));
            }
        }
    }
    if(dis[dx][dy]==inf) puts("-1");
    else printf("%d\n",dis[dx][dy]);
    return 0;
}

Measured memory_bytes: 9764
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--)
using namespace std;
int hehe;
int n,mat[21][21],dp[21][3000001];
int rec(int cur,int mask){
	if(cur == n){
		if(mask != hehe){
			return 0;
		}
		return 1;
	}
	if(dp[cur][mask]!=-1)
		return dp[cur][mask];
	int ways = 0;
	for(int i=0;i<n;i++){
		// Check if the ith bit is set and its compatible
		if(!(mask & (1<<i)) && mat[cur][i]){
			//cout << cur << ' ' << i << ' ' << 1<<i << endl; 
			ways += rec(cur+1,mask+(1<<i));
			ways %= MOD;
		}
	}
	dp[cur][mask] = ways;
	return ways;
}
int32_t main(){

	
	FASTIO;
	mem(dp,-1);
	cin >> n;
	hehe = pow(2,n)-1;
	REP(i,0,n){
		REP(j,0,n){
			cin >> mat[i][j];
		}
	}
	cout << rec(0,0) << endl;
    return 0;

}

Measured memory_bytes: 492416
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long[] a = new long[7];
        for(int i=0;i<7;i++) a[i]=sc.nextLong();
        long ans = 0;
        ans += a[1];
        if(a[0]==0||a[3]==0||a[4]==0){
            System.out.println(ans+(a[0]/2+a[3]/2+a[4]/2)*2);
            System.exit(0);
        }
        long res1 = (a[0]/2+a[3]/2+a[4]/2)*2;
        long temp = Math.min(Math.min(a[0],a[3]),a[4]);
        long res2 = temp*3+((a[0]-temp)/2+(a[3]-temp)/2+(a[4]-temp)/2)*2;
        long res3 = a[0]+a[3]+a[4]-1;
        ans += Math.max(Math.max(res1,res2),res3);
        System.out.println(ans);
    }
}


Measured memory_bytes: 25172
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n = int(ipt())
    i = 1
    mi = -1
    while i**2 <= n:
        if n%i == 0:
            a = str(i)
            b = str(n//i)
            mi = max(len(a),len(b))
        i += 1
    print(mi)


    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template<typename T>
vector<T> BFS(vector<vector<int>> &G, int s) {
    vector<T> ret(G.size(),-1);
    ret[s] = 0;
    queue<int> que;
    que.emplace(s);
    while (!que.empty()) {
        int v = que.front(); que.pop();
        for (auto nv : G[v]) {
            if (ret[nv] != -1) continue;
            ret[nv] = ret[v] + 1;
            que.emplace(nv);
        }
    }

    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    vector<vector<int>> G(N);
    rep(i,N-1) {
        int u,v; cin >> u >> v;
        --u; --v;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
    }

    int ans = N;
    rep(i,N) {
        auto dist = BFS<int>(G,i);
        int k = -1;
        rep(j,N) {
            if (dist[j]==K) k = j;
        }
        if (k==-1) {
            k = max_element(all(dist)) - dist.begin();
        }
        auto dist2 = BFS<int>(G,k);
        int cnt = 0;
        rep(j,N) {
            if (dist[j] > K || dist2[j] > K) cnt++;
        }
        chmin(ans,cnt);
    }

    cout << ans << ln;
}

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

using namespace std;

int main() {
	double l;
	cin >> l;

	double ans = pow(l / 3.0, 3);
	printf("%.12f\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}



int main(){

  string s;
  cin >> s;
  if(s[1] == 'B'){
    cout << "ARC" << endl;
  }else{
    cout << "ABC" << endl;
  }
}


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

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

    int n; cin >> n;
    ll r_up_min = 2e9, r_up_max = 0LL, l_up_min = 2e9, l_up_max = 0LL;

    rep(i,n){
        ll x, y; cin >> x >> y;
        r_up_min = min(x+y, r_up_min);
        r_up_max = max(x+y, r_up_max);
        l_up_min = min(1000000000-x + y, l_up_min);
        l_up_max = max(1000000000-x + y, l_up_max);
    }

    cout << max(r_up_max - r_up_min, l_up_max - l_up_min) << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	int n;cin >> n;
	int a[n];
	rep(i,n)cin >> a[i];
	sort(a,a+n);
	double ret = a[0];
	for(int i = 1;i < n ;i++){
		ret = (ret+a[i])/2;
	}
	printf("%12lf\n",ret);
	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007

using namespace std;

int n, ans = 1;

int main() {
	cin >> n;
	int mx = 0;
	for (int i = 1; i <= n; i++) {
		int c = 0;
		int x = i;
		while(x % 2 == 0) {
			c++;
			x /= 2;
		}
		if (c > mx) mx = c, ans = i;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
using namespace std;

long long digits(long long n){
  long long ans = 1;
  while(n > 0){
    n /= 10; 
    if(n > 0) ans++;
  }//while
  return ans;
}//digts


int main(){

  long long N;
  cin >> N;

  long long dig = digits(N);
  for(long long int i=2; i*i <= N; i++){
    if(N % i == 0){
      dig = min(dig , digits(N/i));
      //cout << i << "\n";
    }//if
  }//for
  
  cout << dig << "\n";
  return 0;
}//main 


Measured memory_bytes: 3604