akhauriyash/Code-Regression huggingface dataset:
//                        Bismillahir Rahmanir Rahim
//ALGO:
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define FILL(a, x) memset(a, x, sizeof(a))
#define ll long long
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define INF INT_MAX
#define mx 1000010
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<pair<int, int>, null_type,less<pair<int, int> >, rb_tree_tag,tree_order_statistics_node_update>
*/
const double Pi=acos(-1);
using namespace std;
int debug=0;
int main() {
    int n, k;
    cin>>n>>k;
    int a[n], ans=0;
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    for(int i=0; i<k; i++) ans+=a[i];
    cout<<ans;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<int>> dp(H+1,vector<int>(W+1,0));

  REP(i,H){
    REP(j,W){
      cin >> dp[i+1][j+1];
    }
  }
  int max_square = 0;
  REP(i,H){
    REP(j,W){
      if(dp[i+1][j+1] == 1)
	dp[i+1][j+1] = 0;
      else {
	dp[i+1][j+1] = 1 + min(dp[i][j+1],min(dp[i+1][j],dp[i][j]));
      	max_square = max(dp[i+1][j+1],max_square);
      }
    }
  }
  /*    REP(i,H+1){
    REP(j,W+1){
      cout << dp[i][j];
    }
    cout << endl;
  }*/
  cout << max_square * max_square <<endl;
  return 0;
}

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

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

int main()
{
    string s;
    cin >> s;
    rep(i, s.size()){
        if(s[i] == ','){
            cout << " ";
        }else{
            cout << s[i];
        }
    }

    cout << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $num, $goal);
$ans = 0;
for ($i=0; $i <= $num; $i++) {
    for ($j=0; $j <= $num; $j++) { 
        $k = $goal - $i - $j;
        if ($k >= 0 && $k <= $num) {
            $ans++;
        }
    }
}
echo $ans."\n";

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int l , r , d ;
    cin >> l >> r >> d ;

    int ans = r/d - (l-1)/d ;
    cout << ans ; line ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i = 1 ; i <= t ; i ++ )
    {
        solve ( i ) ;
    }

    return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if(A + B < C + D){
  cout << "Right" << endl;
  }else if(A + B > C + D){
  cout << "Left" << endl;
  }else{
  cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;

map< int64_t, int, greater< int64_t > > D;
int sz[ N ];
int64_t arr[ N ], ans[ N ];
vector< int > G[ N ];
bool vis[ N ];

inline void sosad() {
	cout << -1 << '\n';
	exit( 0 );
}

void dfs1( int u ) {
	if ( vis[ u ] ) sosad();
	vis[ u ] = true;
	for ( int v : G[ u ] ) {
		dfs1( v );
		ans[ u ] += sz[ v ] + ans[ v ];
	}
}

void dfs2( int u, int n, int64_t fa ) {
	fa += n - sz[ u ];
	for ( int v : G[ u ] )
		dfs2( v, n, fa + ans[ u ] - sz[ v ] - ans[ v ] );
	ans[ u ] += fa;
}

int main() {
	ios_base::sync_with_stdio( false );
	cin.tie( nullptr );
	int n; cin >> n;
	for ( int i = 1 ; i <= n ; ++ i ) {
		int64_t x; cin >> x;
		D[ x ] = i; sz[ i ] = 1;
		arr[ i ] = x;
	}
	int rt = -1;
	for ( auto pi : D ) {
		if ( sz[ pi.second ] == n ) {
			rt = pi.second;
			break;
		}
		int64_t fad = pi.first - n + 2 * sz[ pi.second ];
		if ( D.find( fad ) == D.end() ) sosad();
		sz[ D[ fad ] ] += sz[ pi.second ];
		G[ D[ fad ] ].push_back( pi.second );
	}
	if ( rt == -1 ) sosad();
	dfs1( rt ); dfs2( rt, n, 0 );
	for ( int i = 1 ; i <= n ; ++ i )
		if ( arr[ i ] != ans[ i ] or not vis[ i ] )
			sosad();
	for ( int i = 1 ; i <= n ; ++ i )
		for ( int j : G[ i ] )
			cout << i << ' ' << j << '\n';
	return 0;
}

Measured memory_bytes: 17536
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

file = 1





    
def solve():


    
    # for _ in range(ii()):

        
    x = ii()
    if x>=30:
        print('Yes')
    else:
        print('No')











        
if __name__ =="__main__":

    if(file):

        if path.exists('input.txt'):
            sys.stdin=open('input.txt', 'r')
            sys.stdout=open('output.txt','w')
        else:
            input=sys.stdin.readline
    solve()


Measured memory_bytes: 68148
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> A(N); rep(i,N) std::cin >> A[i];

  std::unordered_map<int,int> L;
  rep(i,N) L[ A[i] ]++;

  int ans = 0;
  rep(i,N) {
    if ( L[ A[i] ] >= 2 ) continue;
    if ( A[i] == 1 ) {
      ans++;
      continue;
    }
    bool flag = false;
    for(int x=1; x<=std::sqrt(A[i]); x++) {
      if ( A[i] % x != 0 ) continue;
      if ( L.count(x) == 1 ) flag = true;
      if ( x != 1 && L.count( A[i]/x ) == 1 ) flag = true;
    }
    if( !flag ) ans++;
  }
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 12104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    int S=1;
    cin>>N>>K;
    for(int i = 0;i<N;i++){
        if(S*2>S+K){
            S+=K;
        }else S*=2;
    }
    cout<<S<<endl;
}

Measured memory_bytes: 256
N = int(input())
res = []
dic = {}

for _ in range(N):
    S, P = input().split()
    res.append([S, int(P)])
    if S in dic:
        dic[S].append(int(P))
    else:
        dic[S] = [int(P)]
res_keys = set(list(list(zip(*res))[0]))

for i in sorted(res_keys):
    for j in sorted(dic[i])[::-1]:
        ans = res.index([i, j])
        print(ans + 1)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int,input().split()))
c = 0
for i in range(n-1):
    min = a[i]
    ch = i
    for j in range(i+1,n):
        if min > a[j]:
            min = a[j]
            ch = j
    if i != ch:
        a[i], a[ch] = a[ch], a[i]
        c += 1
print(" ".join(map(str,a)))
print(c)


Measured memory_bytes: 5600
import java.util.Scanner;
import java.util.Arrays;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int array[]=new int[n];
        for(int i=0; i<n; i++){
            array[i]=sc.nextInt();
        }

        Arrays.sort(array);

        for(int j=0; j<n-1; j++){
            if(array[j]-array[j+1]==0){
                System.out.println("NO");
                break;
            }
            if(j==n-2){
                System.out.println("YES");
            }    
        }
        sc.close();
    }
}	

Measured memory_bytes: 82472
X, K, D = gets.split.map(&:to_i)

pos = X.abs
if K * D < pos then
  puts pos - K * D
else
  a = pos / D
  pos = pos - D * a
  i = (K - a) % 2
  if i == 0
    puts pos
  else
    puts (pos - D).abs
  end
end


Measured memory_bytes: 14316
import java.util.Scanner;
 
public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new DPB().doIt();
	}
	class DPB{
		int DP(int v[],int w[],int N,int W,int all[]){
			int result = 0;
			all[0] = 1;
			for(int i = 0;i < N;i++){
				for(int j = W-1;j >= 0;j--){
					if(j + w[i] <= W){
						if(all[j] > 0){
							if(all[0] == 1)all[0] = 0;
							all[j+w[i]]=Math.max(all[j+w[i]], all[j] + v[i]);
							all[0] = 1;
						}
						if(result < all[j+w[i]])result = all[j+w[i]];
					}
				}
			}
			return result;
		}
		void doIt() {
			int N = sc.nextInt();
			int W = sc.nextInt();
			int v[] = new int [N];
			int w[] = new int [N];
			int all[] = new int [W+1];
			for(int i = 0;i < N;i++){
				v[i] = sc.nextInt();
				w[i] = sc.nextInt();
			}
			System.out.println(DP(v,w,N,W,all));
		}
	}
}

Measured memory_bytes: 20704
#9 B - Choose Integers AC(hint)
A,B,C = map(int,input().split())

result = 'NO'

num = 0
#(k+B)A%B = (kA + AB)%B = kB
for i in range(1,B+1):
    num = (A*i)%B
    if num == C:
        result = 'YES'
        break
print(result)    

Measured memory_bytes: 9152
#include "bits/stdc++.h"
using namespace std;

void push(int A);
int pop(void);

vector<int> S(1000);
int Top;

int main(void) {

	string str;
	int a, b;
	Top = 0;
	while (cin >> str) {

		if (str == "+") {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (str == "-") {
			b = pop();
			a = pop();
			push(a - b);
		}
		else if (str == "*") {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(str.c_str()));
		}
	}
	cout << pop() << endl;

	return 0;
}

void push(int A) {
	S.at(++Top) = A;
}

int pop(void) {
	Top--;
	return S.at(Top + 1);
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+10;
char str[N];
int a[30];
int main() {
    cin >> str;
    for(int i = 0; str[i]; i ++) a[str[i]-'a']++;
    for(int i = 0; i < 26; i ++) {
        if(a[i] == 0) return 0*printf("%c\n",i+'a');
    }
   printf("None");
    return 0;
}


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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define endl '\n'

using namespace std;

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

int n;
bool ok = true;
vector<vector<ii>> v;
vector<int> vb;
bitset<30> vis;

void dfs(int x){
	if(vis[x])
		return;
	vis[x]=true;
	for(auto &u:v[x]){
		if(u.ss==1 && vb[u.ff]==0){
			vb[u.ff]=1;
			dfs(u.ff-1);
		}
		else if(u.ss==1 && vb[u.ff]==2)
			ok=false;
		else if(u.ss==0 && vb[u.ff]==0)
			vb[u.ff]=2;
		else if(u.ss==0 && vb[u.ff]==1)
			ok=false;
	}
}

int count(int x){
	int res=0;
	while(x){
		res++;
		x-=x&-x;
	}
	return res;
}

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	//#endif
	int ans=0;
	cin>>n;
	v = vector<vector<ii>>(n,vector<ii>());
	for(int i=0;i<n;++i){
		int a;
		cin>>a;
		v[i].resize(a);
		for(int j=0;j<a;++j){
			cin>>v[i][j].ff>>v[i][j].ss;
		}
	}
	for(int i=0;i<(1<<n);++i){
		vb = vector<int>(n+1,0);
		ok = true;
		vis.reset();
		for(int j=0;j<n;++j){
			if((i&(1<<j))!=0){
				vb[j+1]=1;
				for(int k=0;k<sz(v[j]);++k){
					if(v[j][k].ss==1 && vb[v[j][k].ff]==0)
						vb[v[j][k].ff]=1;
					else if(v[j][k].ss==0 && vb[v[j][k].ff]==0)
						vb[v[j][k].ff]=2;
				}
			}
		}
		for(int j=0;j<n;++j){
			if(vb[j+1]==1){
				dfs(j);
			}
		}
		if(ok && count(i) > count(ans))
			ans=i;
	}
	cout<<count(ans)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<ctype.h>
using namespace std;
int main(){
  string a;
  int b=0,c=0,d=0;
  cin>>a;
  for(int i=0;i<a.size();i++){
    if(a[i]-'0'>=0&&a[i]-'0'<=9)b++;
    if(isupper(a[i]))c++;
    if(islower(a[i]))d++;
  }
  if(b==0||c==0||d==0||a.size()<6)printf("IN");
  printf("VALID\n");
  return 0;
}

Measured memory_bytes: 3344
/*痛みを受け取れ，痛みを知れ*/
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1000007;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 6e5 + 5;
int a[N];
void xx()
{	
	a[1] = a[2] = 1;
	f(i, 3, 30)
	{
		a[i] = a[i - 2] * i;
	}
	f(i, 1, 20)debug(a[i]);
}
int main()
{
	//freopen("in.txt", "r", stdin);
	//xx();
	ull n;
	while (cin >> n)
	{
		if (n & 1)puts("0");
		else
		{
			ull ans = 0;
			ull tmp = 10;
			while (1)
			{
				ull now = n / tmp;
				if (now == 0)break;
				ans += now;
				tmp *= 5;
			}
			cout << ans << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3624
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

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

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5;
const int INF = INT_MAX;
const db PI = acos(-1);

namespace ModFunctions {
	inline void add(int &a, int b) {
		a += b;
		if (a >= MOD) {
			a -= MOD;
		}
	}

	inline void sub(int &a, int b) {
		a -= b;
		if (a < 0) {
			a += MOD;
		}
	}

	inline int mul(int a, int b) {
		return int((1ll * a * b) % MOD);
	}

	inline int power(int a, ll b) {
		int res = 1;
		while (b > 0) {
			if (b & 1) {
				res = mul(res, a);
			}
			a = mul(a, a);
			b >>= 1;
		}
		return res;
	}

	inline int inv(int a) {
		a %= MOD;
		if (a < 0) {
			a += MOD;
		}
		int b = MOD, u = 0, v = 1;
		while (a) {
			int t = b / a;
			b -= t * a;
			swap(a, b);
			u -= t * v;
			swap(u, v);
		}
		assert(b == 1);
		if (u < 0) {
			u += MOD;
		}
		return u;
	}
}

using namespace ModFunctions;

string s;
int n, dp[N][2];
bool seen[N][2];
int solve(int i, bool ok);

void test();

int main() {
    fast_io();
    test();
    return 0;
}

void test() {
    cin >> s;
    n = s.size();
    cout << solve(0, 0) << "\n";
}

int solve(int i, bool ok) {
    if (i == n) {
        return 1;
    }
    int &ans = dp[i][ok];
    bool &vis = seen[i][ok];
    if (!vis) {
        vis = true;
        if (ok) {
            ans = mul(3, solve(i + 1, 1));
        } else {
            if (s[i] == '1') {
                ans = solve(i + 1, 1); // 0 0
                add(ans, mul(2, solve(i + 1, 0))); // 0 1, 1 0
            } else {
                ans = solve(i + 1, 0); // 0 0
            }
        }
    }
    return ans;
}


Measured memory_bytes: 6096
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

int kek[10][10];
signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int n; cin >> n;
	for (int x = 1; x <= n; x++) {
		int fst = (to_string(x))[0] - '0';
		int lst = x % 10;
		if (!fst || !lst) continue;
		else kek[fst][lst]++;
	}
	ll ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			ans += 1LL * kek[i][j] * kek[j][i];
		}
	}
	cout << ans << endl;

	return 0;	
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    if((N * A) >= B) System.out.println(B);
    else System.out.println(N*A);
  }
}

Measured memory_bytes: 22868
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,A,B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int pa,pb;
    pa = pb = 0;
    for(int i = 0;i < N;i++){
        if(S[i] == 'a'){
            pa++;
            if(pa+pb <= A+B)cout << "Yes" << endl;
            else cout << "No" << endl;
        }else if(S[i] == 'b'){
            pb++;
            if(pa+pb <= A+B && pb <= B)cout << "Yes" << endl;
            else{
            cout << "No" << endl;
            pb--;
            }
        }else{
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
#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++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

long long int Euclid(long long int a,long long int b)
{
 
  long long int r;
 
  if(a<b){
    swap(a,b);
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  return b;
}

int main() {
  long long int K;
  cin>> K;
  long long int ans=0;
  rep(i, K){
  rep(j,K){
  rep(k ,K){
    if(i!=j)
    ans+=Euclid(Euclid(i+1, j+1), k+1);
    else
    ans+=Euclid(j+1, k+1);}}}
  cout << ans << endl;
}

Measured memory_bytes: 3632
xs,ys,xt,yt=list(map(int,input().split()))
N=int(input())
a=[]
for i in range(N):
	a.append(list(map(int,input().split())))

# xs,ys,xt,yt=[-1000000000, -1000000000, 1000000000, 1000000000]
# N=1
# a=[[-1000000000, 1000000000, 1]]

class Dijkstra(object):
	"""
	ダイクストラ法,(N^2)
	ステータス:distance(list),prev(list),size(int)
	distancemap[i][j]->Distance of edge i to j
	"""
	def __init__(self, distancemap, start):
		self.start=start
		self.size=len(distancemap)
		self.distance=[float("inf") for x in range(self.size)]
		self.distance[start]=0
		self.prev=[0 for x in range(self.size)]
		self.prev[start]=-1
		yet=list(range(self.size))
		yet.remove(start)
		now=start
		while(yet!=[]):
			nearest_num=0
			nearest_dis=float("inf")
			for i in yet:
				total_dis=distancemap[now][i]+self.distance[now]
				self.distance[i]=min(total_dis, self.distance[i])
				if self.distance[i]<=nearest_dis:
					nearest_dis=self.distance[i]
					nearest_num=i
			yet.remove(nearest_num)
			self.prev[nearest_num]=now
			now=nearest_num

	def route(self,goal):
		route=[]
		while(True):
			route.append(self.prev[goal])
			goal=self.prev[goal]
			if goal==self.start:
				break
		route.reverse()
		return(route)

import math
def solve(xs,ys,xt,yt,N,a):
	a.insert(0,[xs,ys,0])
	a.append([xt,yt,0])
	def distance(i,j):
		x1=a[i][0]
		y1=a[i][1]
		r1=a[i][2]
		x2=a[j][0]
		y2=a[j][1]
		r2=a[j][2]
		d=math.sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))-r1-r2
		if d<0:
			d=0
		return(d)
	distancemap=[[0 for x in range(N+2)] for x in range(N+2)]
	for i in range(N+2):
		for j in range(N+2):
			if i>j:
				distancemap[i][j]=distancemap[j][i]
			else:
				distancemap[i][j]=distance(i,j)

	d=Dijkstra(distancemap, 0)
	return(d.distance.pop())

print(solve(xs, ys, xt, yt, N, a))


Measured memory_bytes: 24308
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, M = read_ints()
    A, B = [], []
    for _ in range(N):
        A.append(input())
    for _ in range(M):
        B.append(input())
    for i in range(N-M+1):
        for j in range(N-M+1):
            matches = True
            for i0 in range(i, i+M):
                for j0 in range(j, j+M):
                    if A[i0][j0] != B[i-i0][j-j0]:
                        matches = False
                        break
                if not matches:
                    break
            if matches:
                return 'Yes'
    return 'No'


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 63680
#include <stdio.h>

#define INF 1000000000

int n,m,c,s,g;
int map[100][100];
int temp_map[100][100];

typedef struct {
	int x,y,d,c;
} rosen_t;

rosen_t rosen[10000];

int p[20];
int q[20][50];
int r[20][50];

int calc_untin(int c,int dist) {
	int untin=0;
	int nowdist=0;
	int nowkukan=0;
	while(1) {
		if(nowkukan>=p[c]-1 || dist<=q[c][nowkukan]) {
			return untin+(dist-nowdist)*r[c][nowkukan];
		} else {
			untin+=(q[c][nowkukan]-nowdist)*r[c][nowkukan];
			nowdist=q[c][nowkukan];
			nowkukan++;
		}
	}
}

int main(void) {
	while(scanf("%d%d%d%d%d",&n,&m,&c,&s,&g)==5 && (n|m|c|s|g)!=0) {
		int i,j,k,rs;
		s--;g--;
		for(i=0;i<m;i++) {
			scanf("%d%d%d%d",
				&rosen[i].x,&rosen[i].y,&rosen[i].d,&rosen[i].c);
			rosen[i].x--;rosen[i].y--;rosen[i].c--;
		}
		for(i=0;i<c;i++)scanf("%d",&p[i]);
		for(i=0;i<c;i++) {
			for(j=0;j<p[i]-1;j++)scanf("%d",&q[i][j]);
			for(j=0;j<p[i];j++)scanf("%d",&r[i][j]);
		}
		for(i=0;i<n;i++) {
			for(j=0;j<n;j++)map[i][j]=(i==j?0:INF);
		}
		for(rs=0;rs<c;rs++) {
			for(i=0;i<n;i++) {
				for(j=0;j<n;j++)temp_map[i][j]=(i==j?0:INF);
			}
			for(i=0;i<m;i++) {
				if(rosen[i].c==rs && temp_map[rosen[i].x][rosen[i].y]>rosen[i].d) {
					temp_map[rosen[i].x][rosen[i].y]=rosen[i].d;
					temp_map[rosen[i].y][rosen[i].x]=rosen[i].d;
				}
			}
			for(k=0;k<n;k++) {
				for(i=0;i<n;i++) {
					for(j=0;j<n;j++) {
						if(temp_map[i][j]>temp_map[i][k]+temp_map[k][j]) {
							temp_map[i][j]=temp_map[i][k]+temp_map[k][j];
						}
					}
				}
			}
			for(i=0;i<n;i++) {
				for(j=0;j<n;j++) {
					if(temp_map[i][j]<INF) {
						int now_untin=calc_untin(rs,temp_map[i][j]);
						if(map[i][j]>now_untin)map[i][j]=now_untin;
					}
				}
			}
		}
		for(k=0;k<n;k++) {
			for(i=0;i<n;i++) {
				for(j=0;j<n;j++) {
					if(map[i][j]>map[i][k]+map[k][j]) {
						map[i][j]=map[i][k]+map[k][j];
					}
				}
			}
		}
		printf("%d\n",map[s][g]<INF?map[s][g]:-1);
	}
	return 0;
}

Measured memory_bytes: 836
seq = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'
seq = list(map(int, seq.split(',')))
k = int(input())
print(seq[k - 1])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()

const int inf=2e9;


int main(){
    int n,c; cin>>n>>c;
    vector<vector<int>> d(c,vector<int>(c,0)), pp(n,vector<int>(n,0));
    rep(i,c){
        rep(j,c) cin>>d[i][j];
    }
    rep(i,n){
        rep(j,n) cin>>pp[i][j];
    }
    vector<map<int,int>> p(3);
    rep(i,n){
        rep(j,n){
            p[(i+j)%3][pp[i][j]]++;
        }
    }
    int ans=inf, kari;
    rep(i,c){
        rep(j,c){
            if(i==j) continue;
            rep(k,c){
                if(k==i || k==j) continue;
                kari=0;
                for(auto &v: p[0]){
                    kari+=d[v.first-1][i]*v.second;
                }
                for(auto &v: p[1]){
                    kari+=d[v.first-1][j]*v.second;
                }
                for(auto &v: p[2]){
                    kari+=d[v.first-1][k]*v.second;
                }
                ans=min(ans,kari);
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4612
#include <bits/stdc++.h>
using namespace std;
int main() {
  
  int N;
  cin >> N;
  int n = N;
  int x = 0;
  
  for(int i = 0; i < 9; i++) {
    x += n % 10;
    n /= 10;
  }
  
  if(N % x == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

using namespace std;

int qpow(int x, int n)
{
    int res = 1;
    while (n)
    {
        if (n & 1)        // 等价于 if (n % 2 != 0)
        {
            res *= x;
        }

        n >>= 1;
        x *= x;
    }

    return res;
}


int main()
{
    int d, n;
    cin >> d >> n;
    int ans = (n != 100) ? qpow(100, d) * n : qpow(100, d) * (n + 1) ;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

	ll a, b, n;cin >> a >> b >> n;
	ll ans = 0;
	ll tmp = min(b-1, n);
	cout << (a * tmp) / b << endl;

	return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<pll> a(n);
  REP(i,n) {
    ll ai;
    cin >> ai;
    a[i] = make_pair(ai,i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  REP(i,n){
    if(i==a[0].second){
      cout << a[1].first << endl;
    }else{
      cout << a[0].first << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 4736
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
 
int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	
	lli d = a%b, e = a%b, f = 0;
	while(true){
		if(d == c){
			cout << "YES" << endl;
			break;
		}else if(f++ != 0  && d == e){
			cout << "NO" << endl;
			break;
		}else{
			d = (d+a)%b;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
n,m=map(int, input().split())
l=[0]*m
r=[0]*m
for i in range(m):
    x,y=map(int, input().split())
    l[i]=x
    r[i]=y
x=max(l)
y=min(r)
if x>n or y<x:
    print(0)
else:
    print(min(y-x+1,n-x+1))


Measured memory_bytes: 10868
<>;map{push@$_,$_[--$|]for@_=glob}<>;sub f{my($x,$b,$w)=($_,1,1);$c=$_-"@_"and($w*=f($x))%=$==1e9+7,$b=$b*$c%$=for@$x;($b+($c=$w))%$=}print f$_=1

Measured memory_bytes: 189056
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int H,N,P,M,K,h[500];
double dp[501][101][100];
int main(){
	cin>>H>>N>>P>>M>>K;
	P--;
	rep(i,H) h[i]=-1;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		h[H-a]=b-1;
	}
	dp[0][0][P]=1;
	double fr=H-M;
	rep(i,H){
		int a=h[i];
		rep(j,K+1){
			rep(k,N){
				if(a>=0){
					if(a==k) dp[i+1][j][k+1]+=dp[i][j][k];
					else if(a+1==k) dp[i+1][j][k-1]+=dp[i][j][k];
					else dp[i+1][j][k]+=dp[i][j][k];
				}else{
					double s=(K-j)/fr;
					if(s>1) continue;
					double p=s/(N-1);
					double lef=s;
					if(k>0&&j<K) dp[i+1][j+1][k-1]+=dp[i][j][k]*p,lef-=p;
					if(k<N-1&&j<K) dp[i+1][j+1][k+1]+=dp[i][j][k]*p,lef-=p;
					dp[i+1][j+1][k]+=dp[i][j][k]*lef;
					dp[i+1][j][k]+=dp[i][j][k]*(1-s);
				}
			}
		}
		if(a<0) fr--;
	}
	double ans=0;
	rep(i,N) chmax(ans,dp[H][K][i]);
	printf("%.12f\n",ans);
}

Measured memory_bytes: 40208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003,INF=1<<30;

int main(){
    
    double A,B,X;cin>>A>>B>>X;
    double S=X/A;
  
  if(A*A*B==X){
    cout<<"1.130863886742583809729988e-14"<<endl;
    return 0;
  }
    
    double left=0.0,right=M_PI/2.0;
    
    for(int i=0;i<300;i++){
        double mid=(left+right)/2.0;
        double l=A*sin(mid),h=B*sin(M_PI/2.0-mid);
        double size;
        
        if(l<=h){
            size=A*B-A*A*tan(mid)/2.0;
        }else{
            size=B*B*tan(M_PI/2.0-mid)/2.0;
        }
        
        if(size>=S) left=mid;
        else right=mid;
    }
    
    printf("%.12lf\n",left*90.0/(M_PI/2.0));
    //cout<<setprecision(25)<<left*90.0/(M_PI/2.0)<<endl;
}




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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);

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

  vector<int> a(N);
  vector<int> b;
  REP(i,N)cin >> a[i];

  if(N%2==0){
    REP(i,N/2){
      b.push_back(a[N-1-i*2]);      
    }
    REP(i,N/2){
      b.push_back(a[i*2]);      
    }
  }else{
    REP(i,N/2+1){
      b.push_back(a[N-1-i*2]);      
    }
    REP(i,N/2){
      b.push_back(a[1+i*2]);      
    }
  }

  cout << b[0];
  FOR(i,1,N){
    cout << " " << b[i];
  }
  cout << endl;

}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
int d(int n,int d){
    return (n/(int)pow(10,d-1))%10;
}
int main(){
    int A,B;
    cin>>A>>B;
    int between=B/100-A/100+1;
    if(d(A,4)*10+d(A,5)<A%100)--between;
    if(d(B,4)*10+d(B,5)>B%100)--between;
    cout<<between<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int time=0,NumTask=0;
	scanf("%d %d",&time,&NumTask);
	int temp=0;
	for(int i=0;i<NumTask;i++){
		scanf("%d",&temp);
		time-=temp;
	}
	if(time>=0)printf("%d",time);
	else printf("-1");
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 f ? x : -x;
}
int main() {
	int r, g, b, n;
	cin >> r >> g >> b >> n;
	int ans = 0;
	for (int i = 0; i * r <= n; ++ i) {
		for (int j = 0; j * g + i * r <= n; ++ j) {
			if ((n - j * g - i * r) % b == 0) ++ ans;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if (S.at(0) == S.at(1) && S.at(1) == S.at(2)){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,m,sum[33333],lim,dp[17][33333],s,a[17][17],cnt[33333],ss[17][33333];
int main()
{
    scanf("%d%d",&n,&m);
    rap(i,0,n) rap(j,0,n) a[i][j]=-inf;
    rep(i,1,m) {
        int t1,t2,t3;
        scanf("%d%d%d",&t1,&t2,&t3);
        t1--;t2--;
        s+=t3;a[t1][t2]=a[t2][t1]=t3;
    }
    lim=1<<n;
    rap(i,0,lim){
        rap(j,0,n) rap(k,0,n) if(((1<<j)&i) && ((1<<k)&i) && a[j][k]!=-inf) sum[i]+=a[j][k];
        rap(j,0,n) rap(k,0,n) if(((1<<k)&i) && a[j][k]!=-inf) ss[j][i]+=a[j][k];
        sum[i]/=2;
    }
    rap(i,0,lim) cnt[i]=__builtin_popcount(i);
    rap(i,0,n) rap(j,0,lim) dp[i][j]=-inf;
    rap(i,0,lim) if(i&1) dp[0][i]=sum[i];
    rep(siz,2,n) rap(i,0,lim) if(cnt[i]==siz){
        rap(j,0,n) {
            rap(k,0,n) if(a[j][k]!=-inf&& ((1<<j)&i) && ((1<<k)&i)){
            // j:current k:last
                dp[j][i]=max(dp[j][i],dp[k][i^(1<<j)]+a[j][k]);
            }
            for(int ii=i;ii;ii=i&(ii-1))
            if(((1<<j)&ii) && (sum[i^ii]==0||ss[j][ii^i]))dp[j][i]=max(dp[j][i],dp[j][ii]+sum[i^ii^(1<<j)]);
        }
    }
    
    printf("%d\n",s-dp[n-1][lim-1]);
    return 0;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, 1, -1, 0};
const int dy[] = {1, 0, 0, -1};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

bool IsPrime(int num)  //素数判定
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;  // 偶数はあらかじめ除く

  double sqrtNum = sqrt(num);
  for (int i = 3; i <= sqrtNum; i += 2) {
    if (num % i == 0) {
      // 素数ではない
      return false;
    }
  }
  // 素数である
  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  vector<ll> s(100005 + 1, 0), a(100005);
  for (int i = 1; i < 100005; i += 2) {
    if (IsPrime(i) && IsPrime((i + 1) / 2)) a[i]++;
  }
  rep(i, 100005) s[i + 1] = s[i] + a[i + 1];
  ll q;
  cin >> q;
  rep(i, q) {
    int l, r;
    cin >> l >> r;
    cout << s[r] - s[l - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 4788
import copy
S = list(map(str, input().rstrip()))

vari = set(S)

ans = float("inf")

for v in vari:
    s = copy.deepcopy(S)
    while len(s) != s.count(v):
        for i in range(1, len(s)):
            if s[i] == v:
                s[i - 1] = v
        s = s[:-1]
    ans = min(ans, len(S) - len(s))

print(ans)

Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<numeric>
#include<bitset>
#include<cmath>
#include<string>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main() {
  string s, t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);
  vector<vector<int>> iss(26); // 文字列存在判定
  rep(i, n) iss[s[i] - 'a'].push_back(i); // s[i] - 'a'で0~25に出来る
  rep(i, n) iss[s[i] - 'a'].push_back(i+n);
  ll ans = 0;
  int p = 0; // after p
  rep(i, m) {
    int c = t[i] - 'a'; // 今の文字のid
    if (sz(iss[c]) == 0) { // if there exists no character matching this
      puts("-1");
      return 0;
    }
    p = *lower_bound(iss[c].begin(), iss[c].end(), p) + 1; // pに一致する場所の最小の添字のiteratorを返す
    if ( p >= n ) {
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;
}


Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=51;
int n;
ll a[max_n];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%lld",a+i);
    ll ans=0;
    while(1){
        ll res=0;
        for(int i=1;i<=n;i++){
            ll x=(a[i]+res)/n;
            res+=x;
            a[i]-=x*(n+1);
        }
        for(int i=1;i<=n;i++)a[i]+=res;
        if(res==0)break;
        ans+=res;
    }
    printf("%lld\n",ans);
    return 0;
}

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

typedef long long ll;

int main()
{
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n;
    cin>>n;
    long double x = 2*(22.0/7.0)*n;
    cout<<x<<endl;
    
    return 0;
}

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

inline int gcd(int a,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}

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

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

typedef long long ll;
typedef long double lg;

using namespace std;

int main(){

 long long n,a,b;
 cin>>n>>a>>b;

  long long result =0 ;

  if(n == 1){
    if(a == b)
        result = 1;
    else
        result = 0;
  }
 else {
    if(a>b)
        result = 0;
    else
        result = (b-a)*(n-2)+1;
// may anyone explain why are we talking the value as this
 }

 cout<<result<<endl;

return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll n,a[200100];
map<ll,int>m;
int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    cin>>n;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    }
    ll ans=0;
    for(int i=1;i<n;i++){
    	if(a[i]<a[i-1]){
    		ans+=a[i-1]-a[i];
    		a[i]=a[i-1];
    	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5164
int main()
{
  int n;
  scanf("%d", &n);
  double a[n], sum = 0;
  int i;
  for (i = 0; i < n; i++)
  {
    scanf("%lf", &a[i]);
    sum += 1 / a[i];
  }
  printf("%lf", 1 / sum);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
int main(){
	int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int x;
	scanf("%d",&x);
	printf("%d",a[x-1]);
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000


int main(){
	
	int K,N;
	cin>>N>>K;
	
	map<int,int> mp;
	for(int i=0;i<N;i++){
		int a;
		cin>>a;
		mp[a]++;
	}
	
	vector<int> V;
	for(auto a:mp){
		V.push_back(a.second);
	}
	
	sort(V.begin(),V.end());
	
	int ans = 0;
	for(int i=0;i<max(0,(int)V.size()-K);i++){
		ans += V[i];
	}
	
	cout<<ans<<endl;
	
    return 0;
}


Measured memory_bytes: 10748
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#include<stack>
#include<iomanip>
#include<map>
#define rep(i,n) for(int i=0;i<((int)n);i++)
#define drep(i,n) for(int i=((int)n)-1;i>-1;i--)
#define Rep(i,n0,n) for(int i=n0;i<((int)n);i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<((int)n);j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
#define INF2 (long long)8*(long long)INF*(long long)INF
#define mod 1000000007

typedef long long ll;

using namespace std;


int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){if(y>x)return y;else return x;}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
int mfact(int x){int i=1;rep(j,x){i*=(j+1);} return i%mod;}
int modulo(int x){return x%mod;}
long long fact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i;}
long long mfact(long long x){long long i=1;rep(j,x){i*=(j+1);} return i%mod;}
long long modulo(long long x){return x%mod;}
int gcd(int x, int y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
ll gcd(ll x, ll y){if(x%y==0)return y;else if(y%x==0)return x;else return gcd(x%y,y%x);}
void say(bool x){if(x){cout<<"Yes"<<endl;}else {cout<<"No"<<endl;}return;}

int dd[500][500],PP[2][100000];
int main()
{
    int a,b,c,d;
    cin >> a>>b>>c>>d;
    say(abs(a-c)<++d||(abs(a-b)<d&&abs(c-b)<d));
    return 0;
}


Measured memory_bytes: 256
N = int(input())
T = 1
A = 1
for i in range(N):
    t, a = (int(i) for i in input().split())
    #n*t <= T かつ n*a <= Aであることが条件
    n = max((T-1+t)//t, (A-1+a)//a)
    T = n * t
    A = n * a
print(T+A)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <climits>

using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

typedef long long LL;
typedef vector<int> VI;

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int month = sc.nextInt();
            int day = sc.nextInt();
            if(month == 0 && day == 0){
                break;
            }else{
                weekCheck(month, day);
            }
        }
    }
    public static void weekCheck(int month, int day){
        int numberOfDays[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
        int weekDifference = 0;
        if(month == 1){
            weekDifference = day;
        }else{
            for(int i = 0; i < month -1 ; i++){
                weekDifference += numberOfDays[i];
            }
            weekDifference += day;
        }
        switch((weekDifference) % 7){
            case 1:
                System.out.println("Thursday");
                break;
            case 2:
                System.out.println("Friday");
                break;
            case 3:
                System.out.println("Saturday");
                break;
            case 4:
                System.out.println("Sunday");
                break;
            case 5:
                System.out.println("Monday");
                break;
            case 6:
                System.out.println("Tuesday");
                break;
            case 0:
                System.out.println("Wednesday");
                break;
        }
    }
}


Measured memory_bytes: 26344
#include <bits/stdc++.h>
 
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define lol        1000000007
#define endl        '\n'
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define SIZE        1000005
#define debug(x)        cerr << #x << " = " << x << endl;

using namespace std;

void MOD(ll &x)
{
	if (x >= lol) x -= lol;
	if (x < 0) x += lol;
}


void solve()
{
	string a, b, c;
	cin>>a>>b>>c;
	cout<<a[0]<<b[1]<<c[2]<<endl;
	
}


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

Measured memory_bytes: 256