akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def solve(A: int, B: int):
    while A % B:
        tmp = B
        B = A % B
        A = tmp
    if B == 1:
        print(1)
    else:
        ans = factorization(B)
        print(len(ans)+1)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.IllegalArgumentException
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    val b = Array(m) { sc.nextInt() }
    val z = minOf(y, b.min()!!)
    if (x < z && z <= y && a.max()!! < z) {
        println("No War")
    } else {
        println("War")
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

const int sz = 17;
int A[100005];
const int INF = 1 << 30;
const int Backet = 800;
vector< int > v[100005 / Backet];

int main() {
  int D;
  scanf("%d", &D);
  for(int i = 0; i < D; i++) {
    scanf("%d", &A[i]);
    v[i / Backet].push_back(A[i]);
  }
  for(int i = 0; i < D / Backet; i++) {
    sort(v[i].begin(), v[i].end());
  }

  int Q;
  scanf("%d", &Q);
  for(int i = 0; i < Q; i++) {
    int l, r, e;
    scanf("%d %d %d", &l, &r, &e); --l;
    int a = min(A[l], A[r - 1]), b = max(A[l], A[r - 1]);
    int templ = l, tempr = r;
    int cnt = 0;
    while(templ < tempr && templ % Backet) {
      if((A[templ] < a - e) || (A[templ] > b + e)) ++cnt;
      templ++;
    }
    while(templ < tempr && tempr % Backet) {
      --tempr;
      if((A[tempr] < a - e) || (A[tempr] > b + e)) ++cnt;
    }
    while(templ < tempr) {
      int idx = templ / Backet;
      cnt += lower_bound(v[idx].begin(), v[idx].end(), a - e) - v[idx].begin();
      cnt += v[idx].end() - upper_bound(v[idx].begin(), v[idx].end(), b + e);
      templ += Backet;
    }
    printf("%d\n", cnt);
  }
}

Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 205;
const int mod = 1e9 + 7;

int n, m, k, tim, cnt, vis[MAXN], dfn[MAXN], low[MAXN], C[MAXN][MAXN];
vector <pii> q, edg[MAXN];
vector <int> adj[MAXN];

inline int Qow(int x, int y)
{
	int r = 1;
	for (; y; y >>= 1, x = 1LL * x * x % mod)
		if (y & 1)
			r = 1LL * r * x % mod;
	return r;
}

inline void Dfs(int x, int p = 0)
{
	dfn[x] = low[x] = ++ tim;
	for (auto y : adj[x])
		if (!dfn[y])
		{
			q.pb(mp(x, y));
			Dfs(y, x);
			low[x] = min(low[x], low[y]);
			if (low[y] >= dfn[x])
			{
				cnt ++;
				while (!q.empty())
				{
					pii e = q.back(); q.pop_back();
					edg[cnt].pb(e);
					if (e == mp(x, y))
						break;
				}
			}
		}
		else if (y ^ p)
		{
			low[x] = min(low[x], dfn[y]);
			if (dfn[x] > dfn[y])
				q.pb(mp(x, y));
		}
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read(), k = Read();
	for (int i = 0; i <= m + k; i ++)
	{
		C[i][0] = 1;
		for (int j = 1; j <= i; j ++)
			C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % mod;
	}
	for (int i = 1, x, y; i <= m; i ++)
		x = Read(), y = Read(), adj[x].pb(y), adj[y].pb(x);
	for (int i = 1; i <= n; i ++)
		if (!dfn[i])
			Dfs(i);
	int ans = 1;
	for (int i = 1; i <= cnt; i ++)
	{
		tim ++;
		int v = 0, e = edg[i].size();
		m -= e;
		for (auto e : edg[i])
		{
			if (vis[e.xx] ^ tim)
				vis[e.xx] = tim, v ++;
			if (vis[e.yy] ^ tim)
				vis[e.yy] = tim, v ++;
		}
		if (v == e)
		{
			int ways = 0;
			for (int i = 1; i <= v; i ++)
				ways = (ways + Qow(k, __gcd(i, v))) % mod;
			ways = 1LL * ways * Qow(v, mod - 2) % mod;
			ans = 1LL * ans * ways % mod;
		}
		else if (v == 2 && e == 1)
			ans = 1LL * ans * k % mod;
		else
			ans = 1LL * ans * C[e + k - 1][k - 1] % mod;
	}
	return printf("%d\n", ans), 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int n,a,b;
inline int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=!f;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return f?-x:x;
}

int main(){
    n=read(),a=read(),b=read();
    if(a*n<=b) printf("%d\n",a*n);
    else printf("%d\n",b);
    return 0;
}

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

int nGame ;

int AnotherMask[10010][13][13] ;

int dp[10010][13][13] ; // =0 : not confirm , =2 : win , =1 :lose 

int dfs( int mask , int Left , int Right ){
	if( dp[mask][Left][Right] ) return dp[mask][Left][Right] ;
	if( !mask ) return dp[mask][Left][Right] = 2 ;
	int cnt = 0 ;
	if( Left && (mask & (1 << (Left - 1))) ) cnt ++ , dp[mask][Left][Right] = max( dp[mask][Left][Right] , 3 - dfs( AnotherMask[mask][Left][Right] , Left - 1 , Right ) ) ;
	if( Right != 12 && (mask & (1 << (Right + 1))) ) cnt ++ , dp[mask][Left][Right] = max( dp[mask][Left][Right] , 3 - dfs( AnotherMask[mask][Left][Right] , Left , Right + 1 ) ) ;
	if( !cnt ) dp[mask][Left][Right] = max( dp[mask][Left][Right] , 3 - dfs( AnotherMask[mask][Left][Right] , Left , Right ) ) ;
	return dp[mask][Left][Right] ;
}	

int main(){
	
	//freopen( "sevens.inp" , "r" , stdin ) ; freopen( "sevens.out" , "w" , stdout ) ;
	
	cin >> nGame ;
	
	for( int mask = 0 ; mask <= (1 << 13) ; ++ mask ){
		int newmask = (1 << 13) - 1 - mask ;
		for( int Left = 0 ; Left < 13 ; ++ Left ){
			int ansMask = newmask ;
			for( int Right = Left ; Right < 13 ; ++ Right ){
				if( mask & (1 << Right) ) break ;
				ansMask ^= 1 << Right ;
				AnotherMask[mask][Left][Right] = ansMask ;
			}
		}
	}

	for( int mask = 1 ; mask <= (1 << 13) - 1 ; ++ mask ){
		if( mask & (1 << 6) ) continue ;
		if( __builtin_popcount(mask) != 6 ) continue ;
		int zz = dfs(mask , 6 , 6) ;
	}

	while(nGame --){
		int mask = 0 ;
		for( int i = 0 ; i < 6 ; ++ i ){
			int x ; cin >> x ; x -- ; mask |= (1 << x) ;
		}
		if( dp[mask][6][6] == 2 ) cout << "yes" << endl ;
		else cout << "no" << endl ;
	}

	return 0 ;
}


Measured memory_bytes: 10832
import java.util.*;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        Map<Integer, Integer> map = new HashMap<>();
        long sum = 0;
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
            int ll = A[i] + i;
            int rr = i - A[i];
            sum += map.getOrDefault(rr, 0);
            map.put( ll, map.getOrDefault(ll, 0) + 1);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 69240
let rec lower_bound l r p =
  if r <= 1 + l
  then r
  else let m = (l + r) / 2 in
       if p m
       then lower_bound l m p
       else lower_bound m r p

let rec upper_bound l r p =
  if r <= 1 + l
  then l
  else let m = (l + r) / 2 in
       if p m 
       then upper_bound m r p
       else upper_bound l m p

let () = Scanf.scanf "%d\n" @@ fun n ->
  let xs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun x -> x in
  Scanf.scanf "%d\n" @@ fun l ->
  let up = Array.make_matrix 32 n 0 in
  let dn = Array.make_matrix 32 n 0 in
  for i = 0 to n - 1 do
    up.(0).(i) <- upper_bound 0 n (fun j -> xs.(j) - xs.(i) <= l);
    dn.(0).(i) <- lower_bound (-1) (n - 1) (fun j -> xs.(i) - xs.(j) <= l)
  done;
  for i = 1 to 31 do
    for j = 0 to n - 1 do
      up.(i).(j) <- up.(i - 1).(up.(i - 1).(j));
      dn.(i).(j) <- dn.(i - 1).(dn.(i - 1).(j))
    done
  done;
  Scanf.scanf "%d\n" @@ fun q ->
  for i = 0 to q - 1 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      Printf.printf "%d\n" @@ succ @@ snd @@
        Array.fold_left 
        ( if a < b then
            fun (a, acc) i ->
              if b - 1 <= up.(i).(a)
              then (a, acc)
              else (up.(i).(a), acc lor (1 lsl i))
          else 
            fun (a, acc) i ->
              if dn.(i).(a) <= b - 1
              then (a, acc)
              else (dn.(i).(a), acc lor (1 lsl i)) ) (a - 1, 0) @@
        Array.init 32 @@ fun i -> 31 - i
  done


Measured memory_bytes: 57080
/* Aditya0412 */
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
//#define pop pop_back
#define mp make_pair
#define ve vector
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpl vector < pll >
#define fi first
#define sz size 
#define len length 
#define se second 
//const ll mod=998244353;
const ll mod = 1000000000+7;
const ll N=1000000+6;
#define M_PI           3.14159265358979323846 
int main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll n;
    cin>>n;
    ll arr[n];
     map<ll , ll > m;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        m[arr[i]]++;
    }
    ll ans=0;
    for(auto it=m.begin();it!=m.end();it++)
    {
        ll x=it->second;
        ans+=(x*(x-1))/2;
    }
    for(int i=0;i<n;i++)
    {
        ll x=m[arr[i]];
        cout<<ans-(x-1)<<'\n';
    }
     
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
ll lcm(ll a, ll b) {return ((a*b)/gcd(a,b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 1e6 + 10;

long long modpow(long long n, long long k, long long mod)
{
if (k == 0) return 1;
long long r = modpow(n * n % mod, k >> 1, mod);
if (k & 1) r = r * n % mod;
return r;
}

void solve(){
    string s;cin >> s;
    int sum = 0;
    for(int i = 0;i<s.size();i++){
        sum += (s[i]-'0');
    }
    if(sum%9==0) cout <<"Yes";
    else cout <<"No";
}



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}



Measured memory_bytes: 3784
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    // vector<int> a;
    ll ans = 0, k = 0;
    int n = (int)s.size();
    reprev (i, n) {
        if (s[i] == 'A') {
            eprintf("%d ", k);
            ans += k;
        }
        if (s[i] == 'B') {
            if ((i != n - 1 && s[i + 1] == 'C')) k++;
            else k = 0;
        }
        if (s[i] == 'C' && (i == 0 || s[i - 1] != 'B')) k = 0;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 720
S, T = gets.chomp, gets.chomp

A = (0..S.size-T.size).each_with_object([]){|i, a|
    s = S.slice(i...i+T.size)
    t = S.dup
    
    if s.chars.each_with_index.all?{|e, j| e == T[j] || e == "?"} then
        t[i...i+T.size] = T
        a << t.gsub("?", "a")
    end
}

puts A.empty? ? :UNRESTORABLE : A.min

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }



void solve(void)
{
  int N,L;
  cin>>N>>L;
  vector<string> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  sort(ALL(vec));
  for (int i = 0; i < N; i++)
  {
    cout<<vec[i];
  }
  cout<<endl;
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int W, H;
int cost[101][101];
int bfs(vector<string> &s, int ii, int jj){
    int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
    queue<pair<int, int>> que;
    que.push(make_pair(ii, jj));
    cost[ii][jj] = 0;
    int ret = 0;

    while(!que.empty()) {
        pair<int, int> p = que.front();
        que.pop();
        for(int i = 0; i < 4; i++) {
            int ny = p.first + dy[i], nx = p.second + dx[i];
            if(nx < 0 || ny < 0 || nx >= W || ny >= H) continue;
            if(s[ny][nx] == '#') continue;
            if(cost[ny][nx] != -1) continue;

            cost[ny][nx] = cost[p.first][p.second] + 1;
            chmax(ret, cost[ny][nx]);
            que.push(make_pair(ny, nx));
        }
    }
    return ret;
}

 
int main(){
    fastcin();

    cin >> H >> W;
    vector<string> s(H);
    rep(i, H) cin >> s[i];
    int ans = 0;
    rep(i, H)rep(j, W){
        if(s[i][j] == '#') continue;
        memset(cost, -1, sizeof(cost));
        chmax(ans, bfs(s, i, j));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<set>
#include<map>
//#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define all(x) x.begin(),x.end()
using namespace std;
int mp[15][15], sum, n;
bool b1(int x, int y) {
	if (mp[x][y] < 1)return 0;
	if (mp[x - 1][y] < 1)return 0;
	if (mp[x + 1][y] < 1)return 0;
	if (mp[x][y - 1] < 1)return 0;
	if (mp[x][y + 1] < 1)return 0;
	return 1;
}
bool b2(int x, int y) {
	if (!b1(x, y))return 0;
	if (mp[x - 1][y - 1] < 1)return 0;
	if (mp[x - 1][y + 1] < 1)return 0;
	if (mp[x + 1][y - 1] < 1)return 0;
	if (mp[x + 1][y + 1] < 1)return 0;
	return 1;
}
bool b3(int x, int y) {
	if (!b2(x, y))return 0;
	if (x < 2 || x > 7 || y < 2 || y > 7)return 0;
	if (mp[x - 2][y] < 1)return 0;
	if (mp[x + 2][y] < 1)return 0;
	if (mp[x][y - 2] < 1)return 0;
	if (mp[x][y + 2] < 1)return 0;
}
void f1(int x, int y) {
	mp[x][y]--;
	mp[x - 1][y]--;
	mp[x + 1][y]--;
	mp[x][y - 1]--;
	mp[x][y + 1]--;
	sum -= 5;
}
void f1_(int x, int y) {
	mp[x][y]++;
	mp[x - 1][y]++;
	mp[x + 1][y]++;
	mp[x][y - 1]++;
	mp[x][y + 1]++;
	sum += 5;
}
void f2(int x, int y) {
	f1(x, y);
	mp[x - 1][y - 1]--;
	mp[x - 1][y + 1]--;
	mp[x + 1][y - 1]--;
	mp[x + 1][y + 1]--;
	sum -= 4;
}
void f2_(int x, int y) {
	f1_(x, y);
	mp[x - 1][y - 1]++;
	mp[x - 1][y + 1]++;
	mp[x + 1][y - 1]++;
	mp[x + 1][y + 1]++;
	sum += 4;
}
void f3(int x, int y) {
	f2(x, y);
	mp[x - 2][y]--;
	mp[x + 2][y]--;
	mp[x][y - 2]--;
	mp[x][y + 2]--;
	sum -= 4;
}
void f3_(int x, int y) {
	f2_(x, y);
	mp[x - 2][y]++;
	mp[x + 2][y]++;
	mp[x][y - 2]++;
	mp[x][y + 2]++;
	sum += 4;
}
bool f(int i, int j) {
	if (n == 0 && sum > 0)return 0;
	if (n > 0 && sum == 0)return 0;
	if (n == 0 && sum == 0)return 1;
	//cout << i << ' ' << j << ' ' << sum << endl;
	if (i >= 9)return 0;
	int in = i, jn = j + 1;
	if (jn == 9) { in++; jn = 1; }
	if (b3(i, j)) {
		f3(i, j); n--;
		if ((sum == 0 && n == 0) || f(i, j)) {
			cout << j << ' ' << i << ' ' << 3 << endl;
			return 1;
		}
		f3_(i, j); n++;
	}
	if (b2(i, j)) {
		f2(i, j); n--;
		if ((sum == 0 && n == 0) || f(i, j)) {
			cout << j << ' ' << i << ' ' << 2 << endl;
			return 1;
		}
		f2_(i, j); n++;
	}
	if (b1(i, j)) {
		if (b3(i, j + 1)) {
			f3(i, j + 1); n--;
			if ((sum == 0 && n == 0) || f(i, j)) {
				cout << j + 1 << ' ' << i << ' ' << 3 << endl;
				return 1;
			}
			f3_(i, j + 1); n++;
		}
		if (b3(i + 1, j)) {
			f3(i + 1, j); n--;
			if ((sum == 0 && n == 0) || f(i, j)) {
				cout << j << ' ' << i + 1 << ' ' << 3 << endl;
				return 1;
			}
			f3_(i + 1, j); n++;
		}
		f1(i, j); n--;
		if ((sum == 0 && n == 0) || f(i, j)) {
			cout << j << ' ' << i << ' ' << 1 << endl;
			return 1;
		}
		f1_(i, j); n++;
	}
	if (f(in, jn))return 1;
	return 0;
}
signed main() {
	cin >> n;
	for0(i, 10)for0(j, 10) { cin >> mp[i][j]; sum += mp[i][j]; }
	f(1, 1);
}


Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>
#include <iomanip>
#include <tuple>

using namespace std;
long long dp[100005];
const long long mod=1000000007;

int main(){
   int n,m;
   cin>>n>>m;
   vector<int> a(m),flag(n+2);
   for(int i=0;i<m;i++){
      cin>>a[i];
      flag[a[i]]++;
   }
   dp[0]=1;
   if(!flag[1])dp[1]=1;
   for(int i=2;i<=n;i++){
      if(!flag[i])dp[i]=dp[i-1]+dp[i-2];
      else dp[i]=0;
      dp[i]%=mod;
   }
   cout<<dp[n]<<endl;
   
}

   


Measured memory_bytes: 1792
#include<iostream>
#include<string>

using namespace std;

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

  int plus,minus,multi;
  plus = a+b;
  minus = a-b;
  multi = a*b;
  if(plus > minus){
    if(plus > multi){
      cout << plus << endl;
    }else{
      cout << multi <<endl;
    }
  }else{
    if(minus > multi){
      cout << minus << endl;
    }else{
      cout << multi << endl;
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;

int main() {
    fast_io;

    int k;
    cin >> k;
    int cnt = 0;
    int cur = 0;

    while (cnt < 1e8) {
        ++cnt;
        cur = (cur * 10 + 7) % k;
        if (cur == 0)
            break;
    }

    if (cur != 0) cout << "-1\n";
        else cout << cnt << "\n";
}


Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
int main(){
int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  sort(A.begin(),A.end());
  bool x=true;
  for(int i=0;i<N;i++){
  if(N%2==0){
   if(A.at(i)!=2*(i/2)+1){x=false; break;}
  }else{
  if(A.at(i)!=2*((i+1)/2)){x=false; break;}
  }
  
 }if(!x)
    cout<<0<<endl;
  else{
  int ans=1;
    for(int i=0;i<(N/2);i++){
    ans=(ans*2)%1000000007;
    }cout<<ans<<endl;
  
  
  
  }
   return 0;
}

Measured memory_bytes: 640
//I am so vegetable
//#define _LOCAL_
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(ll i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll N = 1e5 + 5;
const int MOD = 998244353;
const double eps = 1e-6;
const double pi = acos(-1);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
priority_queue<int>ma;
priority_queue<int, vector<int>, greater<int> >mi;
ll sma, smi;
void add(int x) {
	if (!ma.empty() && ma.top() >= x) {
		ma.push(x);
		sma += x;
	}
	else {
		mi.push(x);
		smi += x;
	}
	while (mi.size() - ma.size() > 1) {
		int cur = mi.top(); mi.pop(); smi -= cur;
		ma.push(cur); sma += cur;
	}
	while (mi.size() - ma.size() < 1) {
		int cur = ma.top(); ma.pop(); sma -= cur;
		mi.push(cur); smi += cur;
	}
}
int main() {
	FIO;
	int T; cin >> T;
	ll sb = 0;
	while (T--) {
		int q; cin >> q;
		if (q == 1) {
			int x, b;
			cin >> x >> b;
			sb += b;
			add(x);
		}
		else {
			int x = mi.top();
			cout << x << ' ' << (1ll * x *(int)ma.size() - sma) + (smi - 1ll * x * (int)mi.size()) + sb << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 3452
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;


int main(){

	int N;
	scanf("%d",&N);

	printf("%d\n",N*32);

    return 0;
}

Measured memory_bytes: 2692
import sys
input = sys.stdin.readline

import itertools

# 初日以外は何も気にせず動けるとしてよい。初日に到達可能な場所のうち、最もゴールに近いものはどこか

H,W,K = map(int,input().split())
A = '#' * (W+2)
for _ in range(H):
    A += '#' + input().rstrip() + '#'
A += '#' * (W+2)

start = A.find('S')
dxs = (1,-1,(W+2),-(W+2))

visited = set()
q = [start]
visited.add(start)
for _ in range(K):
    qq = []
    for x,dx in itertools.product(q,dxs):
        y = x+dx
        if A[y] == '#':
            continue
        if y in visited:
            continue
        visited.add(y)
        qq.append(y)
    q = qq

nearest = 10**9
for x in visited:
    row,col = divmod(x,W+2)
    d = min(row-1,H-row,col-1,W-col)
    if nearest > d:
        nearest = d

answer = 1 + (nearest+K-1)//K
print(answer)

Measured memory_bytes: 40040
/*
Author: Babin Dutta
*/

#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define endl "\n"
#define inf 1e18

void solve(){
	int n; cin>>n;
	ll a[n], b[n], c[n-1];
	f(i,n) cin>>a[i];
	f(i,n) cin>>b[i];
	f(i,n-1) cin>>c[i];
	ll ans=0;
	ll y;
	f(i,n){
		ll x = a[i]-1;
		ans += b[x];
		if(i>0 && a[i]-a[i-1] == 1){
			ans += c[y];
		}
		y=x;
	}
	cout<<ans<<endl;
}

int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
#include <climits>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

const double PI = acos(-1.0);

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

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter = " ") { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }


int main() {
    char c;
    cin >> c;
    if ('a' <= c && c <= 'z') cout << 'a' << endl;
    else cout << 'A' << endl;
}

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

string s;
int a[105],minx=105,miny;
int main()
{
	getline(cin,s);
	for(int i=0;s[i];i++)
	{
		a[s[i]]++;
		if(s[i]=='C')
			minx=min(minx,i);
		if(s[i]=='F')
			miny=max(miny,i);
	}
		
	if(a['C']!=0&&a['F']!=0&&minx<miny)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(){
  int i, year=0;
  double x, X=100.0;
  scanf("%lf",&x);
  while(X<x){
    X=X*1.01;
    X=floor(X);
    year++;
  }
  printf("%d",year);
  return(0);
}

Measured memory_bytes: 1752
import itertools

H, W, K = map(int, input().split())
S = []
for _ in range(H):
    S.append([int(s) for s in input()])

ans = 2000
#itertoolsproductでビット全探索が簡潔に書ける
for t in itertools.product([0, 1], repeat=H - 1):
    cnt = t.count(1)
    #横方向の分割の回数を数えている
    lst = [[s for s in S[0]]]
    #リストを新たな要素として加えるか、それとも中身を足し合わせるだけか
    for h in range(H - 1):
        if t[h]:
            lst.append(S[h + 1])
        else:
            lst[-1] = [lst[-1][i] + S[h + 1][i] for i in range(W)]
    L = len(lst)
    sum_lst = [0] * L
    for w in range(W):
        if max(lst[i][w] for i in range(L)) > K:
            break
        #横方向の分割を終えた時点で一列にK+1個以上あるとアウト
        tmp = [sum_lst[i] + lst[i][w] for i in range(L)]
        if max(tmp) > K:
            cnt += 1
            sum_lst = [lst[i][w] for i in range(L)]
        else:
            sum_lst = tmp
    else:
        ans = min(ans, cnt)
print(ans)
#このコードはループをうまくリストに入れ込んでるので短く見えてすごい
#5月24日


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;
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; }

// ****************************************CODE***************************************//


ll n;
ll h[100010];
ll dp[100010];

int main() {
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 0; i < 100010; i++) dp[i] = inf;

    dp[0] = 0;

    for(int i = 0; i < n; i++){
        dp[i+1] = min(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
        dp[i+2] = min(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
    }

    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cassert>
#include <limits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <array>
#include <map>
#include <set>
#include <deque>
#include <list>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cstring>
#include <bitset>
#include <stack>
#include <queue>

#define MOD (1e9 + 7);
#define PI (3.14159265358979323846)

using ll = int64_t;
using ull = uint64_t;

using namespace std;

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

    double r;
    cin >> r;
    cout << (2 * PI * r);

    return 0;
}


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

int main()
{
    int n, w;
    cin >> n >> w;
    long long dp[200005];
    for(int i=0; i<n; i++){
        int a,b;
        cin >> a >> b;
        for(int k=w-a+1; k>=0; k--){
            dp[k+a] = max(dp[k+a], dp[k] + b);
        }
    }
    cout << dp[w];
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int n2 = n / 10;
		int n1 = n % 10;
		String message = "No";
		if(n1 == 9 || n2 == 9) {
			message = "Yes";
		}
		System.out.println(message);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cmath>
#include <cstdio>
 
using namespace std;
 
int main(int argc, char *argv[]) {
  int a, b;
  double x, y, angle;
 
  x = y = angle = 0.0;
 
  while (true) {
    scanf("%d,%d", &a, &b);
    if (a == 0 && b == 0)
      break;
    y += a * cos(angle / 180 * M_PI);
    x += a * sin(angle / 180 * M_PI);
    angle += b;
  }
 
  cout << (int)x << endl;
  cout << (int)y << endl;
  return 0;
}

Measured memory_bytes: 1212
use std::io;

fn main() {
    let N=get_int();
    let mut max = 2;
    while N>=max*max {
        max+=1;
    }
    println!("{}",(max-1)*(max-1));
}

fn get_String()->String{
    let mut s =String::new();
    io::stdin().read_line(&mut s).expect("Fail!");        
    s.trim().to_string()
}

fn get_int()->i32{
    let mut input =String::new();
    io::stdin().read_line(&mut input).expect("Fail!");
    input.trim().to_string().parse().unwrap()
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef queue<int> Q;
ll MOD = 1000000007;

int main(){
    int n,m; cin>>n>>m;
    S a;
    for(int i=0; i<m; i++){
        int tmp; cin>>tmp;
        a.insert(tmp);
    }
    ll x1=1, x2 = (a.find(1)==a.end())? 1:0;
    for(int i=2; i<=n; i++){
        ll t = x1+x2;
        x1 = x2%MOD;
        x2 = t%MOD;
        if(a.find(i) != a.end()) x2 = 0;
    }
    OUT(x2);
}

Measured memory_bytes: 4992
import itertools
import math
N = int(input())
P = ''.join(input().split())
Q = ''.join(input().split())
np = sorted(list(map(lambda x: ''.join(x), itertools.permutations([str(i+1) for i in range(N)]))))
print(abs((np.index(P)+1)-(np.index(Q)+1)))

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

//UnionFind
struct UnionFind
{
    vector<ll> par;
    vector<ll> siz;

    UnionFind(ll N) : par(N), siz(N, 1LL)
    {
        for (int i = 0; i < N; i++)
            par[i] = i;
    }
    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        if (siz[rx] < siz[ry])
            swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }
    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    ll size(ll x)
    {
        return siz[root(x)];
    }
};

int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, N) cin >> P[i];
    UnionFind uf(N + 1);
    set<int> se;
    rep(i, N)
    {
        if (se.count(P[i] - 1))
        {
            uf.unite(P[i] - 1, P[i]);
        }
        se.insert(P[i]);
    }
    ll ma = 0;
    FOR(i, 1, N + 1)
    {
        ma = max(uf.size(i), ma);
    }
    cout << N - ma << endl;
    return 0;
}

Measured memory_bytes: 16436
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<numeric>
#include<vector>
#include<tuple>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
typedef long long ll;
const int MOD = 1e9 + 7;
string a;
char st[200000];
int main(void)
{
	cin >> a; int n = a.length(),cnt=0;
		FOR(i, 0, n) {
		if (cnt > 0 && st[cnt - 1] == 'S'&&a[i] == 'T')cnt--;
			else st[cnt++] = a[i];
	}
		ct(cnt);
	return 0;
}

Measured memory_bytes: 772
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int l;
  cin >> l;
  vector<tuple<int, int, int>> edge;
  int c = 1, p = 0;
  for (int i = 0; c*2-1 < l; i++) {
    edge.emplace_back(i+1, i+2, c);
    edge.emplace_back(i+1, i+2, 0);
    c *= 2;
    p++;
  }
  int sum = 1<<p;
  for (int i = p-1; i >= 0; i--) {
    if (l & 1<<i) {
      edge.emplace_back(i+1, p+1, sum);
      sum |= 1<<i;
    }
  }
  cout << p+1 << ' ' << edge.size() << endl;
  rep(i, edge.size()) {
    int a, b, w;
    tie(a, b, w) = edge[i];
    cout << a << ' ' << b << ' ' << w << endl;
  }
  return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
arr = arr[1].split(" ").map(Number);
arr.sort(function(a,b){
   return b-a;
});
var s = [];
arr.reduce(function(a,b){
   s.push([a-b,a,b]); 
   return b;
});
var max = 0;
arr.reduce(function(a,b){
   s.forEach(function(v){
      if(v[1] != a && v[2] != b && v[1] != b && v[2] != a){
         max = Math.max(max, (a+b)/v[0]);
      }
   });
   return b;
});
console.log(max.toFixed(6));

Measured memory_bytes: 17840
N = int(input())
a = list(map(int, input().split()))

a = sorted(a, reverse=True)

Alice = 0
for i in range(0, len(a), 2):
    Alice += a[i]
    
Bob = 0
for i in range(1, len(a), 2):
    Bob += a[i]
    
print(Alice - Bob)

Measured memory_bytes: 3064
#include<stdio.h>

#define INF 1e9
#define MAX 150
#define NIL -1
#define W 1
#define B 0

void initial(void);
void dij(void);
int d[MAX];
int pi[MAX];
int c[MAX];
int str[MAX][MAX];
int n;


int main(){
  int i,j,k;
  int a,b;
  scanf("%d",&n);

  for(i = 1;i <= n;i++){
    for(j = 1; j <= n; j++){
     str[i][j]= NIL;
    }
  }
  
  for(i = 1;i <= n;i++){
    scanf("%d%d", &a,&k);
    for(j = 1;j<=k;j++){
      scanf("%d",&b);
      scanf("%d",&str[a+1][b+1]);
    }
  }
  dij();
  return 0;
}

void initial(void){
  int a;
  for(a = 1;a<=n;a++){
    d[a] = INF;
    pi[a] = NIL;
    c[a] = W;
  }
  d[1] = 0;
}
void dij(void){
  int i,a,b,min;
  initial();
  while(1){
    min = INF;
    for(i = 1; i <= n;i++){
      if(c[i] != B && d[i] < min){
	min = d[i];
	a = i;
      }
    }
    if(min == INF)break;
    c[a] = B;

    for(b = 1;b <= n;b++){
      if(c[b] != B && str[a][b] + d[a] < d[b] && str[a][b] != -1){
	d[b] = str[a][b];
	d[b] += d[a];
      }
    }
  }
  for(i = 1;i<=n;i++){
    printf("%d %d\n",i-1,d[i]);
  }
}
    

Measured memory_bytes: 664
n = int(input())
num_list = list(map(int, input().split()))

flowers = [0 for i in range(n)]
count = 0

def pour(li):
    li.insert(0, 0)
    pour_count = 0
    for i in range(len(li)-1):
        if li[i] == 0 and li[i+1] == 1:
            pour_count += 1
    return pour_count


while flowers != num_list:
    pour_list = [0] * n
    for i in range(n):
        if flowers[i] != num_list[i]:
            pour_list[i] = 1
            flowers[i] += 1
    count += pour(pour_list)

print(count)



Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int N,M,K[30],A[30][30];
    int i,j,cou[30],all=0;
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++){
        scanf("%d",&K[i]);
        for(j=0;j<K[i];j++){
            scanf("%d",&A[i][j]);
        }
    }

    
    
        for(int m=0;m<K[0];m++){
            for(i=1;i<N;i++){
                for(j=0;j<K[i];j++){
                    if(A[0][m]==A[i][j]){
                       cou[m]++; 
                    }
                }
            }
        }
    for(i=0;i<K[0];i++){
        if(cou[i]==N-1){
            all++;
        }
    }
if(N==1){
    printf("%d",K[0]);
}else{
    printf("%d",all);
}
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

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

		String pass1 = scan.nextLine();
		String pass2 = scan.nextLine();
		String passCheck = "0K";

		int length = pass2.length();

		if(length == 2) {
			passCheck = pass2.substring(0 , 1);
		}else {
			passCheck = pass2.substring(0 , length - 1);
		}

		if(pass1.equals(passCheck)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35636
import numpy as np
from math import sqrt
N, D = map(int, input().split())
Xlist = [np.array(list(map(int, input().split()))) for _ in range(N)]
counter = 0
for i in range(N):
    for j in range(i + 1, N):
        dis = sqrt(np.sum((Xlist[i] - Xlist[j])**2))
        if int(dis) == dis:
            counter += 1
print(counter)


Measured memory_bytes: 13236
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main() {
    long long n;
    cin>>n;
    int k=pow(n,0.5);
    int a;
    rrep(i,k+1){
        if(n%i==0){
            a=i;
            break;
        }
    }
    a=(max)((long long)a,n/a);
    int ans=0;
    while(a>0){
        a/=10;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;

  int a, b, c, d;
  a = N / 1000;
  b = (N-1000*a) / 100;
  c = (N-1000*a-100*b) / 10;
  d = N-1000*a-100*b-10*c;

  if ((a==b && b==c) || (b==c && c==d)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char a,b;cin >> a >> b;
	if(a=='H') cout << b << endl;
	else{
		if(b=='H') cout << a << endl;
		else cout << 'H' << endl;
	}
}

Measured memory_bytes: 256
s = input()
i, ans, total = 0, 0, 0

while i < len(s) - 1:
    if s[i: i + 2] == "BC":
        ans += total 
        i += 2
    elif s[i] == "A":
        total += 1
        i += 1
    else:
        total = 0
        i += 1

print(ans)

Measured memory_bytes: 9344
from functools import reduce
from operator import add

def solve():
  N = int(input())
  M = [0] * N
  for i in range(N):
    x, u = input().split()
    if u == 'JPY':
      M[i] = int(x)
    else:
      M[i] = float(x) * 380000.0
  return reduce(add, M)

print(solve())


Measured memory_bytes: 3828
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b,c,d=0;
    scanf("%d%d%d",&a,&b,&c);
    if(d<a*10+b+c) d=a*10+b+c;
    if(d<b*10+a+c) d=b*10+a+c;
    if(d<c*10+b+a) d=c*10+b+a;
    printf("%d\n",d);
    return 0;
}


Measured memory_bytes: 128
//passwordが入って時
//E=asod,O=pswr
#include <iostream>
#include <algorithm>
using namespace std;
string O,E;
int main(void){
  cin >> O >> E;
  int N = O.length() + E.length();
  string ans;
  for (int i=0; i<N; i++){//0から
    if(i%2 == 0){
      ans += O[i/2];
    }
    else{
      ans += E[i/2];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
using namespace std;

//***********************************************************************

// hash struct for unordered_map
struct hash_pair { 
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
};

int MAXNUM = 5e3+5;
vector <int>vis(MAXNUM);
vector<int> pr;
void sieve() {
	pr.push_back(2);
	for(ll i=3;i<MAXNUM;i+=2) if(!vis[i]) {
		pr.push_back(i);
		for(ll j=i*i;j<MAXNUM;j+=2*i) vis[j]=true;
	}
}
//************************************************************************

void solve()
{
    char ch;
    cin >> ch;
    if(ch-'A'<26)
    cout <<  "A" << endl;
    else
    cout << "a" << endl;
}


int main()
{ 
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	ll t;
	//cin >> t;
	t=1;
	while(t--)
	{
		solve();
	}

	return 0;
}

Measured memory_bytes: 3632
def S(n):
    return sum(int(x) for x in str(n))
rest = K = int(input())

ans = list(range(1, 10))

rest -= 9
suffix = 10
i = 0
while rest > 0:
    num = int(str(suffix) + '9' * i)
    if suffix % 10 == 0:
        next_suffix = suffix + 9
        next_num = int(str(next_suffix) + '9' * i)
        if num / S(num) > next_num / S(next_num):
            i += 1
            suffix //= 10
        num = int(str(suffix) + '9' * i)
    ans.append(num)
    rest -= 1
    suffix += 1

for i in range(K):
    print(ans[i])


Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String str[] = new String[n];

        for (int i = 0; i < n; i++) {
            str[i] = "";
            String s = sc.next();
            String tmp[] = new String[10];
            for (int j = 0; j < 10; j++) {
                tmp[j] = s.substring(j, j + 1);
            }
            Arrays.sort(tmp);
            for (int j = 0; j < 10; j++) {
                str[i] = str[i] + tmp[j];
            }
        }
        Arrays.sort(str);
        long ans = 0;
        long tmp = 1;

        for (int i = 0; i < n - 1; i++) {
            while (str[i].equals(str[i + 1])) {
                tmp++;
                i++;
                if (i == n - 1) {
                    break;
                }
            }
            ans += tmp * (tmp - 1) / 2;
            tmp = 1;

        }
        System.out.println(ans);
        sc.close();
    }
}


Measured memory_bytes: 98340
#include<stdio.h>
int main(){
    int a,op,b;
    while(1)
    {
        scanf("%d %c %d",&a,&op,&b);
        if(op == '+'){
                printf("%d\n",a+b);
        }else if(op == '-'){
                printf("%d\n",a-b);
        }else if(op == '*'){
                printf("%d\n",a*b);
        }else if(op == '/'){
                printf("%d\n",a/b);
        }else{
        break;}
    }
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define PI pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)


int32_t main() { 
    boost;
    
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}	

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

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

  int n, d, x;
  cin >> n >> d >> x;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    x += (d-1) / a + 1;
  }
  cout << x << '\n';
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
rl = sys.stdin.buffer.readline

A, B, C = map(int, rl().split())
K = int(rl())

b = 0
for k in range(K):
  if A < (B * (2 ** k)):
    b = k
    break

c = K - b
vb = B * (2 ** b)
vc = C * (2 ** c)

print('Yes' if A < vb and vb < vc else 'No')

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

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i += 2) {
		int divisors = 0;
		for (int j = 1; j <= i; j++) {
			if (i % j == 0) {
				divisors++;
			}
		}
		if (divisors == 8) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256