akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 100005

// it's swapnil07 ;)

int dp[MAXN]={0};
vector<int> adj[MAXN];

int getdp(int i){
    if(dp[i]!=0){
        return dp[i];
    }
    for(auto j: adj[i]){
        dp[i] = max(getdp(j), dp[i]);
    }
    dp[i] += 1LL;
    return dp[i];
}

signed main(){
    fast    
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int n, m; cin>>n>>m;
    For(i, 0, m){
        int u, v; cin>>u>>v;
        adj[u].pb(v);
    }
    int ans = 0;
    For(i, 1, n+1){
        dp[i]=getdp(i);
        ans = max(ans, dp[i]);
    }
    cout<<ans-1LL;
    return 0;
}

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

using ll = long long;
using ld = long double;

const int nax = 405;
const  int mod =  1e9+7;
const ll INFL = 1e18L + 5;

//Modular Addition
inline void add_self(int& a, int b){
    a+=b;
    if(a>=mod)
        a-=mod;
}

//Modular Subtraction
inline void sub_self(int& a , int b){
    a -= b;
    if(a < 0)
        a+= mod;
}


ll dp[nax][nax];




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

    int n; cin>>n;

    vector<ll>a(n);
    for(auto& x : a)cin>>x;

    auto sum = [&](int L , int R){
        ll s = 0;
        for(int i = L; i <= R; ++i){
            s += a[i];
        }
        return s;
    };

    for(int gap = 1; gap <= n; gap++){
        for(int l = 0; l < n-gap+1; ++l){
            int r = l + gap;
            dp[l][r] = INFL;
            ll s = sum(l,r);
            for(int i = l; i <= r; i++){
                dp[l][r] = min(dp[l][r], dp[l][i] + dp[i+1][r] + s);
            }
        }
    }

    cout<<dp[0][n-1];


}

Measured memory_bytes: 1664
N=int(input())
S1=input()
S2=input()
l=0
ans=1
flag='a'
if S1[0]==S2[0]:
    l+=1
    ans*=3
    flag='t'
else:
    l+=2
    ans*=6
    flag='y'

for i in range(l,N):
    
    if flag=='t':
        if S1[l]==S2[l]:
            l+=1
            ans*=2
            ans=ans%1000000007
            if l>=N:
                break
        else:
            l+=2
            ans*=2
            ans=ans%1000000007
            flag='y'
            if l>=N:
                break
    else:
        if S1[l]==S2[l]:
            l+=1
            flag='t'
            if l>=N:
                break
        else:
            l+=2
            ans*=3
            ans=ans%1000000007
            if l>=N:
                break

print(ans%1000000007)    

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <numeric>
#include <climits>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int cnt = 0;
int N, M;
int main(){
    int R, G, x;
    cin >> R >> G;
    x = 2 * G - R;
    cout << x << endl;
}

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

using namespace std;

#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define pb push_back

const int N = 301;

ld memo[N][N][N];
int n;

ld dp(int zero, int one, int two, int three) {
	if (one < 0 || two < 0 || three < 0) return 0;
	if (one == 0 && two == 0 && three == 0) return 0;
	ld &ans = memo[one][two][three];
	if (ans > 0) return ans;
	ans = n;
	ans += one * dp(zero + 1, one - 1, two, three);
	ans += two * dp(zero , one + 1, two - 1, three);
	ans += three * dp(zero , one, two + 1, three - 1);
	ans /= (one + two + three);
	return ans;
}

void solve() {
	int i, j, k, m, ans = 0, cnt = 0, sum = 0;
	cin >> n;
	int one = 0, two = 0, three = 0;
	for (i = 0; i < n; i++) {
		cin >> m;
		if (m == 1) one++;
		else if (m == 2) two++;
		else three++;
	}
	memset(memo, (ld) (-1), sizeof(memo));
	cout << setprecision(9) << fixed;
	cout << dp(0, one, two, three);
	return ;
}

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

Measured memory_bytes: 426496
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<pair<int,int> >ab(n);
    for(int i=0;i<n;i++)
    {
        int a,b;
        cin>>a>>b;
        ab.emplace_back(b,a);
    }
    sort(ab.begin(),ab.end());
    int sum=0;
    int cnt=0;
    for(auto v: ab)
    {
        sum+=v.second;
        if(sum>v.first)
        {
            cout<<"No"<<endl;
            cnt++;
            break;
        }
    }
    if(cnt==0)
        cout<<"Yes"<<endl;
    
    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    string S;
    cin >> S;
    int mi=1000;
    rep(i,26){
        char c='a'+i;
        string s=S;
        int x=s.length()-1;
        while(true){
            bool flag=true;
            rep(j,x){
                if(s[j]==c || s[j+1]==c)s[j]=c;
                else flag=false;
            }
          	if(flag)break;
          	else x--;
        }
      	int y=S.length()-x;
        chmin(mi,y);
    }
    bool ans=true;
    rep(i,S.length()){
        if(S[i]!=S[0])ans=false;
    }
    if(ans)cout << 0;
    else cout << mi;


}

/*



 */



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> N;
	vector< pii > A(N + 1);
	rep(i, N) {
		cin >> A[i].first;
		A[i].second = i;
	}
	A[N] = pii(0, N);
	sort(A.rbegin(), A.rend());
	int x = N, i = 0, l = LINF;
	vector< int > ans(N + 1, 0);
	while (i <= N) {
		while (i < N && A[i].first == l) {
			chmin(x, A[i].second);
			++i;
		}
		ans[x] += i * (l - A[i].first);
		l = A[i].first;
		chmin(x, A[i].second);
		++i;
	}
	rep(i, N) cout << ans[i] << endl;
	return 0;
}

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

typedef unsigned long long ULL;
typedef long long LL;

const int PI = 3.1415926535;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 100007;


int main() {
	
	ios_base :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	string s, t; cin >> s >> t;
	int ans = inf;
	int ls = (int)s.length();
	int lt = (int)t.length();
	for (int i = 0; i + lt - 1 < ls; i++) {
		int curr = 0;
		for (int j = 0; j < lt; j++) {
			if (s[i + j] != t[j]) curr++;
		}
		ans = min(ans, curr);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3644
n, x, y = map(int, input().split())
x -= 1
y -= 1
ans_l = [0]*n

def min_dist(a,b):
    return min(b-a, abs(x-a)+1+abs(y-b), abs(x-b)+1+abs(y-a))
for i in range(n):
    for j in range(i, n):
        k = min_dist(i,j)
        ans_l[k] += 1
for ans in ans_l[1:]:
    print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string.h>
#include <math.h>
typedef long long ll;
#define MAX(x, y)	(((x) > (y))? (x) : (y))
#define MIN(x, y)	(((x) < (y))? (x) : (y))
#define ABS(x)		(((x) < 0)? (-1*(x)) : (x))
#define REPI(x,y)	for (int i=(x);i<(y);i++)
#define REPJ(x,y)	for (int j=(x);j<(y);j++)
#define MEMCLR(X)	memset((X),0,sizeof((X)))

using namespace std;
typedef pair<int, int> Point;
typedef vector<vector<Point>> Graph;

int i,j,N;
char c;
int main() {
	cin >> N;
	
	REPI(0, N) {
		cin >> c;
		if (c == 'Y') {
			cout << "Four";
			return 0;
		}
	}
	cout << "Three";
	
	return 0;
}


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

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

count = 0
for i in range(N-1):
    if a[i] > x:
        count += (a[i] - x)
        a[i] = x
    if (a[i] + a[i+1]) > x:
        tmp = a[i+1]
        a[i+1] = x - a[i]
        count += tmp - a[i+1]

print(count)

Measured memory_bytes: 14132
#include <stdio.h>

int p[101];
int m[101][101];

void matrixChainOrder(int n){
    int i,l,j,k,q;
    for(l=2;l<=n;l++){
        for(i=1;i<=n-l+1;i++){
        j = i + l - 1;
        m[i][j] = 100000;
            for(k=i;k<j;k++){
                q = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
                if(m[i][j]>q) m[i][j]=q;
            }
        }
    }
}

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

    int i;
    for(i=1; i<=n; i++){
        scanf("%d%d", &p[i-1], &p[i]);
    }

    for(i=1; i<=n; i++){
        m[i][i] = 0;
    }
    matrixChainOrder(n);

    printf("%d\n", m[1][n]);

    return 0;
}



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

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


int main() {
  int n;
  cin >> n;
  if (n < 100 || 999 < n) {
    cout << "No" << endl;
    return 0;
  }
  int a, b, c;
  a = n / 100;
  b = n % 100 / 10;
  c = n % 100 % 10;
  if (a % 7 == 0 || b % 7 == 0 || c % 7 == 0) {
    if (b != 0 && c != 0){
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3588
#include<stdio.h>
int main()
{
    int i;
    char s[3];
  	int ans = 0;
    scanf("%s", &s);
  	for(i=0;i<3;i++){
      if(s[i] == '1'){
          ans++;
      }
    }
	printf("%d",ans);    
    return 0;
}

Measured memory_bytes: 128
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
        for(int i = 0; i < n; i++){
            int d = sc.nextInt();
            if(map.containsKey(d)){
                map.put(d,map.get(d)+1);
            }else{
                map.put(d,1);
            }
        }
        int m = sc.nextInt();
        boolean bool = true;
        for(int i = 0; i < m; i++){
            int t = sc.nextInt();
            if(map.containsKey(t) && map.get(t) > 0){
                map.put(t,map.get(t)-1);
            }else{
                bool = false;
                break;
            }
        }
        System.out.println(bool ? "YES" : "NO");
    }
}


Measured memory_bytes: 134880
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args)
	{
		Scanner s=new Scanner(System.in);
		
		String str=s.next();
		
		if(str.charAt(0)=='7'||str.charAt(1)=='7'||str.charAt(2)=='7')
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
		
	}
	
}

Measured memory_bytes: 35696
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
 
int main() {
    long long n, cp;
    cin >> n;
    if(n == 1)
    {
         cout << 1;
      return 0;
    }
    cp = n;
    n = 2*n;
    vector<long long> r, m;
    long long i;
    for(i=2;i*i <= n;i++)
    {
        if(n%i == 0)
        {
            long long prod = 1;
            while(n%i == 0)
            {
                n = n/i;
                prod = prod*i;
            }
            r.push_back(prod-1);
            m.push_back(prod);
        }
    }
    if(n > 1)
    {
        r.push_back(n-1);
        m.push_back(n);
    }
    int sz = m.size();
    long long ans = -1;
    for(i=0;i<(1 << sz);i++)
    {
         int j;
         vector<long long> nr;
         for(j=0;j<sz;j++)
         {
             if((i >> j)&1)
               	nr.push_back(r[j]);
             else
               	nr.push_back(0);
         }
         pair<long long, long long> fin = atcoder::crt(nr, m);
         if(ans == -1)
         {
             if(fin.first%(2*cp) != 0)
             	ans = fin.first%(2*cp);
         }
         else
         {
           if(fin.first%(2*cp) != 0)
             ans = min(ans, fin.first%(2*cp));
         }
    }
    cout << ans;
    
}

Measured memory_bytes: 3668
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll A,P;
  cin >> A >>P;
  print(int(A*3+P)/2);
  

 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>

int main(int argc, const char * argv[]) {
    int n;
    scanf("%d", &n);
    
    int m;
    scanf("%d", &m);
    
    std::map<int, std::set<int>> map;
   
    for (int i = 0; i < m; i++) {
        int k;
        scanf("%d", &k);
        
        std::set<int> set;
        
        for (int j = 0; j < k; j++) {
            int x;
            scanf("%d", &x);
            
            set.insert(x - 1);
        }
        
        map[i] = set;
    }
    
    std::vector<bool> p;
    
    for (int i = 0; i < m; i++) {
        int x;
        scanf("%d", &x);
        
        p.push_back(x);
    }
    
    int count = 0;
    
    for (int i = 0; i < std::pow(2, n); i++) {
        bool on = true;
        
        for (int j = 0; j < m; j++) {
            bool sw = false;
            
            for (int k : map.at(j)) {
                sw ^= (i & (int) std::pow(2, k)) != 0;
            }
            
            if (sw != p.at(j)) {
                on = false;
                break;
            }
        }
        
        if (on) count++;
    }
    
    printf("%d\n", count);
    
    return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 205

int n,m,A,B;
int d[maxn][maxn],f[maxn][maxn];

inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	A=read(),B=read();
	for (int i=1;i<=A;i++)
		for (int j=1;j<=B;j++)
			d[i][j]=read();
	for (int i=0;i<=100;i++)
		for (int j=0;j<=100;j++)
			for (int a=1;a<=A;a++)
				for (int b=1;b<=B;b++)
					f[i][j]=max(f[i][j],d[a][b]-i*a-j*b);
	for (int a=1;a<=A;a++)
		for (int b=1;b<=B;b++){
			int res=1e9;
			for (int i=0;i<=100;i++)
				for (int j=0;j<=100;j++)
					res=min(res,f[i][j]+i*a+j*b);
			if (res!=d[a][b]){puts("Impossible"); return 0;}
		}
	puts("Possible");
	n=202,m=10401; printf("%d %d\n",n,m);
	for (int i=1;i<(n>>1);i++) printf("%d %d X\n",i,i+1);
	for (int i=(n>>1)+1;i<n;i++) printf("%d %d Y\n",i,i+1);
	for (int i=1;i<=(n>>1);i++)
		for (int j=(n>>1)+1;j<=n;j++)
			printf("%d %d %d\n",i,j,f[i-1][n-j]);
	printf("%d %d\n",1,n);
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int before[3001][3001], after[3001][3001],cost[3000],kati[3000];//i???????????§j?????§????????§?????¶?????§???
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	for (int d = 0; d < a; d++) {
		int e, f;
		scanf("%d%d", &e, &f);
		for (int g = 0;g<=c; g++) {
			if (g < f)before[g][d+1] = before[g][d];
			else before[g][d + 1] = max(before[g][d], before[g - f][d] + e);
		}
		kati[d] = e; cost[d] = f;
	}
	for (int h = a - 1; h != -1; h--) {
		for (int g = 0; g <= b - c; g++) {
			if (g < cost[h])after[g][a - h] = after[g][a - h - 1];
			else after[g][a - h] = max(after[g][a - h - 1],after[g-cost[h]][a-h-1]+kati[h]);
		}
	}
	int MAX = 0;
	for (int i = 0; i <= b; i++) {
		MAX = max(MAX, before[c][i] + after[b - c][a - i]);
	}
	cout << MAX << endl;
}

Measured memory_bytes: 38436
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))


def memoize(f):
    cache = {}

    def helper(x, y):
        if (x, y) not in cache:
            cache[(x, y)] = f(x, y)
        return cache[(x, y)]
    return helper


def main():
    for number in m:
        if solve(0, number):
            print('yes')
        else:
            print('no')


@memoize
def solve(i, m):
    if m == 0:
        return True

    if i >= n:
        return False

    res = solve(i + 1, m) or solve(i + 1, m - a[i])
    return res


if __name__ == '__main__':
    main()



Measured memory_bytes: 9604
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int ans2 = sc.nextInt();
        Set<String> set = new HashSet<>();

        for (int i = 0; i < str.length(); i++) {
            set.add(String.valueOf(str.charAt(i)));

            if(set.size() == 26){
                break;
            }
        }

        List<String> list = new ArrayList<>(set);
        Collections.sort(list);

        Set<String> ans = new HashSet<>();
        int pos = 0;
        for (int i = 0; i < set.size(); i++) {
            while(true){
                pos = str.indexOf(list.get(i), pos);
                if(pos == -1){
                    break;
                }

                int count = 0;
                for (int k = pos; k < str.length(); k++) {
                    ans.add(str.substring(pos, k + 1));

                    if(count++ == 10){
                        break;
                    }
                }
                pos++;
            }

            if(ans.size() > ans2){
                break;
            }
        }

        list = new ArrayList<>(ans);
        Collections.sort(list);
        System.out.println(list.get(ans2 - 1));
    }

}


Measured memory_bytes: 24528
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding


	ll n;
	cin>>n;
	string s[n];
	unordered_map<string ,ll>m;
	for(ll i=0;i<n;i++){
		cin>>s[i];
		sort(all(s[i]));
		m[s[i]]++;
	}

	ll cnt = 0;
	for(auto i: m){
		cnt+=((i.S)*(i.S-1))/2;
	}

	cout<<cnt<<endl;


	
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

Measured memory_bytes: 17700
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
 
#define fi first
#define se second
#define endl '\n'
#define MOD(n,k) ( (n % k) + k ) % k
#define isOn(S, j) (S & (1 << j) )
#define setBit(S, j) (S | (1 << j ) )
#define LSB(S) (S & (-S))

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

    ll q, h, s, d, n, res = 0;

    cin >> q >> h >> s >> d >> n;

    res = (n / 2) * d + (n % 2 ? s : 0);
    res = min(res, (n / 2) * d + (n % 2 ? h*2 : 0) );
    res = min(res, (n / 2) * d + (n % 2 ? q*4 : 0) );
    res = min(res, n * s );
    res = min(res, n * h * 2 );
    res = min(res, n * q * 4 );

    cout << res << endl;

    return 0;
}  


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

struct student {
    int no;
    int rank;
};

bool cmp(const student &a, const student &b) {
    return a.rank < b.rank;
}

int main() {
    cin >> n;
    vector<student> a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a.at(i).rank;
        a.at(i).no = i+1;
    }

    sort(a.begin(), a.end(), cmp);

    for(int i = 0; i < n; ++i) {
        cout << a.at(i).no << " ";
    }
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 55;

template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
T hungarian(Matrix< T > &A) {
  const T infty = numeric_limits< T >::max();
  const int N = (int) A.size();
  const int M = (int) A[0].size();
  vector< int > P(M), way(M);
  vector< T > U(N, 0), V(M, 0), minV;
  vector< bool > used;

  for(int i = 1; i < N; i++) {
    P[0] = i;
    minV.assign(M, infty);
    used.assign(M, false);
    int j0 = 0;
    while(P[j0] != 0) {
      int i0 = P[j0], j1 = 0;
      used[j0] = true;
      T delta = infty;
      for(int j = 1; j < M; j++) {
        if(used[j]) continue;
        T curr = A[i0][j] - U[i0] - V[j];
        if(curr < minV[j]) minV[j] = curr, way[j] = j0;
        if(minV[j] < delta) delta = minV[j], j1 = j;
      }
      for(int j = 0; j < M; j++) {
        if(used[j]) U[P[j]] += delta, V[j] -= delta;
        else minV[j] -= delta;
      }
      j0 = j1;
    }
    do {
      P[j0] = P[way[j0]];
      j0 = way[j0];
    } while(j0 != 0);
  }
  return (-V[0]);
}

int main() {
  int M, N, B[500], R[500];
  while(cin >> M >> N, M) {
    for(int i = 0; i < M; i++) {
      cin >> B[i];
    }
    for(int i = 0; i < N; i++) {
      cin >> R[i];
    }
    if(M > N) swap(M, N), swap(B, R);
    Matrix< int > mat(M + 1, vector< int >(N + 1));
    for(int i = 0; i < M; i++) {
      for(int j = 0; j < N; j++) {
        if(__gcd(B[i], R[j]) > 1) mat[i + 1][j + 1] = -1;
      }
    }
    cout << -hungarian(mat) << endl;
  }
};


Measured memory_bytes: 3872
#!/usr/bin/python
# AOJ
# 0016

import math

degree = 90
x = 0
y = 0

while True:
    a, b = map(int, input().split(','))
    if a is 0 and b is 0: break
    x += a * math.cos(math.radians(degree))
    y += a * math.sin(math.radians(degree))
    degree -= b
    if degree > 360:
        degree -= 360
    elif degree < 0:
        degree += 360
print(int(x))
print(int(y))

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

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    string S;
    cin >> S;
    for(int i = S.length() - 1; i >= 0; i-- ){
        if(i%2 == 1) continue;
        string s1 = S.substr(0, i/2);
        string s2 = S.substr(i/2, i/2);
        if(s1 == s2){
            cout << i << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int dp[4][2]={{1,0},{-1,0},{0,1},{0,-1}};
	int H,W,K;
	char A[802][802];
	int dismin[802][802];
	int nearest=INF;
	fill(dismin[0],dismin[802],INF);
	pint st;
	scan(H);scan(W);scan(K);
	rep1(i,H){
		scanf("%s",A[i]+1);
		rep(j,W+2){
			if(A[i][j]=='S'){
				st=mp(i,j);
				A[i][j]='.';
			}
		}
	}
	rep(i,H+2){
		A[i][0]=A[i][W+1]='#';
	}
	rep(j,W+2){
		A[0][j]=A[H+1][j]='#';
	}
	pint inizahyo;
	inizahyo=st;
	dismin[st.first][st.second]=0;
	nearest=min(nearest,min(min(st.first-1,st.second-1),min(H-st.first,W-st.second)));
	vector<pint> zahyorecord;
	zahyorecord.push_back(inizahyo);
	for(int count=1;count<=K;count++){
		if(zahyorecord.empty()) break;
		vector<pint> zahyobefore=zahyorecord;
		zahyorecord.clear();
		rep(i,zahyobefore.size()){
			rep(j,4){
				pint zahyoto=zahyobefore[i];
				int y=zahyoto.first+dp[j][1];
				int x=zahyoto.second+dp[j][0];
				if(A[y][x]=='.'&&count<dismin[y][x]){
					zahyorecord.push_back(mp(y,x));
					dismin[y][x]=count;
					nearest=min(nearest,min(min(y-1,x-1),min(H-y,W-x)));
				}
			}
		}
	}
	prin(nearest/K+(nearest%K!=0)+1);
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	static int pt, ph;
	for (int i = 0; i < n; ++i) {
		string st,sh;
		cin >> st >> sh;
		if (st > sh)
			pt += 3;
		else if (st < sh)
			ph += 3;
		else {
			++pt;
			++ph;
		}
	}
	cout << pt << " " << ph << endl;
	return 0;
}



Measured memory_bytes: 3128
import sys
input = sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int,input().split()))
def LF(): return list(map(float,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode()

#import numpy as np

def main():
	n,a,b,c,d=MI()

	n-=1
	x=abs(b-a)

	ans="NO"

	for i in range(n):
		r=(n-i)*d-c*i
		l=(n-i)*c-d*i
		#print(l,x,r)
		if l<=x<=r:
			ans="YES"
			#print(l,x,r)
			break
		elif l<0:
			break

	print(ans)





if __name__ == "__main__":
	main()


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

int Dis[100005];

int main(){
	long long n,x1,x2,a,b,ans=0;
	cin>>n>>a>>b;
	cin>>x2;
	for(int i=1;i<n;i++){
		x1=x2;
		cin>>x2;
		Dis[i-1]=x2-x1;
	}
	for(int i=0;i<n-1;i++){
		ans+=min(Dis[i]*a,b);
	}
	cout<<ans<<endl;
	return 0;
}

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

#define INF 1000000010
#define INFLL ((1LL<<62)-5)
#define FO(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define sz(v) int(v.size())

using namespace std;
//PAIRS:
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pii;
typedef long long ll;

/*~~~~TEMPLATE END~~~~*/

ll N, X;
ll ans;



int main() {
    scanf ("%lld %lld", &N, &X);
    ans += N;
    ll a = X;
    ll b = N-X;
    while (true) {
        if (a < b) swap (a,b);
        if (b == 0) break;
        ll m = a/b;
        ans += m*b*2;
        ll c = a%b;
        if (c == 0) ans -= b;
        a = b;
        b = c;
    }
    printf ("%lld\n", ans);
    return 0;
}


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

int main(){
  string S,T;
  int c=0;
  cin >> S >> T;
  
  rep(i,3){
    if(S.at(i)==T.at(i))
    c++;
  }
  
  cout << c << endl;
}

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

using namespace std;
using ll =long long;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	string a , b , c;	
	cin >> a >> b >> c;	
	cout << 'A' << b[0] <<'C'<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<vector>
#include<cstring>
#include<sstream>
#include<algorithm>
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;

#define MOD 1000000007

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

    int n, k;
    cin >> n >> k;

    long long a[n];
    vector<long long> pos, neg;

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

        if (a[i] >= 0) pos.push_back(a[i]);
        else neg.push_back(a[i]);
    }

    sort(pos.rbegin(), pos.rend());
    sort(neg.begin(), neg.end());

    long long res = 1ll;

    if (n == k) {
        for (int i = 0; i < k; i++) {
            res *= a[i];
            while (res < 0ll) res += MOD;
            res %= MOD;
        }

        cout << res << endl;

        return 0;
    } else if (pos.size() == 0) {

        if (k%2 != 0) sort(neg.rbegin(), neg.rend());

        for (int i = 0; i < k; i++) {
            res *= neg[i];
            while (res < 0ll) res += MOD;
            res %= MOD;
        }

        cout << res << endl;

        return 0;
    }

    int i = 0, j = 0;
    while (k) {
        if (k == 1) {
            if (i < pos.size()) {
                res *= pos[i++];
                res %= MOD;
            } else {
                res *= neg[j++];
                while (res < 0) res += MOD;
                res %= MOD;
            }

            --k;
        } else if (i < pos.size() && j < neg.size()) {
            long long x1 = pos[i], x2 = (i+1) < pos.size() ? pos[i+1] : 1ll;
            long long y1 = neg[j], y2 = (j+1) < neg.size() ? neg[j+1] : 1ll;

            if ((x1*x2) > (y1*y2)) {
                res *= x1;
                res %= MOD;
                ++ i;
                k --;
            } else {
                long long tmp = (y1*y2)%MOD;
                res *= tmp;
                res %= MOD;

                if (y2 != 1ll) {
                    j += 2;
                    k -= 2;
                }
                else {
                    ++ j;
                    -- k;
                }
            }
        } else {
            while (i < pos.size() && k) {
                res *= pos[i++];
                res %= MOD;
                k --;
            }

            while (j < neg.size() && k) {
                res *= neg[j++];
                while (res < 0ll) res += MOD;
                res %= MOD;
                k --; 
            }
        }
    }

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


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

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

    string c = "0123456789";
    for(int i=0; i<n; i++) {
        string in1, in2;
        cin >> in1 >> in2;
        if(in1.size() > 80 || in2.size() > 80) {
            cout << "overflow" << endl;
            continue;
        }

        string ans = "";
        int k = 0;
        for(int j=0; j<80; j++) {
            int x = in1.size() - 1 - j;
            if(x >= 0) {
                k += in1[x] - '0';
            }
            int y = in2.size() - 1 - j;
            if(y >= 0) {
                k += in2[y] - '0';
            }
            ans = c[k%10] + ans;
            k /= 10;
        }

        if(k!=0) {
            cout << "overflow" << endl;
        } else {
            bool flag = true;
            for(int i=0; i<ans.size(); i++) {
                if(ans[i] == '0' && flag) continue;
                flag = false;
                cout << ans[i];
            }
            if(flag) cout << "0";
            cout << endl;
        }
    }
    return 0;
}

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

int gcd(int a,int b) {
  if (a > b) {
    a = a+b;
    b = a-b;
    a = a-b;
  }
  for (;;) {
    if (b%a == 0) {
      return a;
    }
    return gcd(b%a,a);
  }
}

int main() {
  int N,X;
  cin >> N >> X;
  vector<int> dx(N);
  int a;
  for (int i=0; i<N; i++) {
    cin >> a;
    dx[i] = abs(a-X);
  }
  int ans = dx[0];
  for (int i=1; i<N; i++) {
    ans = gcd(ans,dx[i]);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 640
import math

N = int(input())
X = list(map(int, input().split()))


def summ(ii):
    xxx = 0
    for x in X:
        xxx += (x - ii) ** 2
    return xxx


i1 = math.ceil(sum(X) / N)
i2 = math.floor(sum(X) / N)

if i1 == i2:
    print(summ(i1))
else:
    print(min(summ(i1), summ(i2)))

Measured memory_bytes: 3064
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin,stdout
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math
import math
import time
from queue import Queue
# PradeepGhosh_2017076

def seive(n):
	l=[True]
	l=l*(n+1)
	for i in range(2,int(sqrt(n))+1):
		if(l[i]==True):
			val=i*i
			while(val<len(l)):
				l[val]=False
				val+=i
	prime=[]
	for i in range(2,len(l)):
		if(l[i]==True):
			prime.append(i)
	return prime

def dp(l,i,n,val,ans):
	if(i>=n or val<0):
		return 1000000
	elif(val==0):
		return 0
	else:
		if(ans[i]==1000000):
			ans[i]=min(min(1+dp(l,i+1,n,val-l[i],ans),1+dp(l,i,n,val-l[i],ans)),dp(l,i+1,n,val,ans))
		return ans[i]
from queue import Queue
def factors(n):
	l=[]
	for i in range(1,int(sqrt(n))+1):
		if(n%i==0):
			if(n//i==i):
				l.append(i)
			else:
				l.append(i)
				l.append(n//i)
	return l
def check1(s,v,x):
	while(True):
		if(v not in s):
			return v
		else:
			v-=1
def check2(s,v,x):
	while(True):
		if(v not in s):
			return v
		else:
			v+=1

def up(n):
	j=n-1
	while(j>0):
		if(n%j==0):
			break
		j-=1
	return j		
def fac(n):
	c=1
	i=1
	while(i<=n):
		c*=i
		i+=1
	return c
def check_happy(n):
	ss=set()
	print(n)
	while(n!=1):
		val=n
		s=0
		print(val)
		while(val!=0):
			s+=(val%10)**2
			val=val//10
		print(val)
		print("hi")
		if(val in ss):
			return False
		else:
			n=val
			ss.add(n)
	return True
def update(a,b):
	c=1
	val=a
	while(a<b):
		print(c,a)
		c+=c
		a+=a
	print(1)
	while(a>b):
		print()
		a-=val
		c-=1
	return c
import random as rand
def gcd(a,b): 
    if a == 0: 
        return b 
    return gcd(b % a, a) 
# nakdna
from itertools import permutations
def insertion_sort(arr):
	for i in range(len(arr)):
		j=i
		while(j>0):
			if(arr[j]<arr[j-1]):
				temp=arr[j]
				arr[j]=arr[j-1]
				arr[j-1]=temp
			j-=1
	return arr
def quick_sort(arr,low,high):
	i=low
	j=high
	
	while(i<j):
		if(arr[i]>arr[low] and arr[j]<arr[low]):
			temp=arr[i]
			arr[i]=arr[j]
			arr[j]=arr[i]
			i+=1
			j-=1
		elif(arr[i]<=arr[low]):
			i+=1
		elif(arr[j]>=arr[low]):
			j-=1
	print(i,j)
	toto=arr[j]
	arr[j]=arr[low]
	arr[low]=toto
	return j
def dodo(arr,low,high):
	if(low<high):
		val=quick_sort(arr,low,high)
		dodo(arr,low,val-1)
		dodo(arr,val+1,high)
def dp(arr,c,n,k,z,ans):
	if(k==0):
		return ans
	else:
		if(c==0):
			return dp(arr,c+1,n,k-1,z,ans+arr[c+1])
		elif(c==n-1):
			if(z==0):
				return 0
			else:
				return dp(arr,c-1,n,k-1,z-1,ans+arr[c-1])
		else:
			if(z==0):
				return dp(arr,c+1,n,k-1,z,ans+arr[c+1])
			else:
				return max(dp(arr,c+1,n,k-1,z,ans+arr[c+1]),dp(arr,c-1,n,k-1,z-1,ans+arr[c-1]))
if __name__ == '__main__':
	n,d=map(int,input().split(" "))
	c=0
	for i in range(n):
		x,y=map(int,input().split(" "))
		val=sqrt((x)**2+(y)**2)
		if(val<=d):
			c+=1
	print(c)

Measured memory_bytes: 10628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		int min = 10;
		int sum = 0;
		for (int i=0;i<5;i++) {
			a[i] = sc.nextInt();
			if (a[i]%10!=0) {
				sum +=(a[i]/10+1)*10;
			} else {
				sum +=a[i];
			}
			if (a[i]%10!=0&&a[i]%10<min) {
				min = a[i]%10;
			}
		}
		if (min <10) {
			sum-=10-min;
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 21844
import           Control.Applicative
import           Control.Monad
import           Data.List
import           Data.Maybe

main = do
    n <- readLn :: IO Int
    a <- map read . words <$> getLine :: IO [Int]
    mapM_ (putStrLn . unwords . map show) $ scanl insSort' a [1..n-1]
  where
    insSort' :: Ord a => [a] -> Int -> [a]
    insSort' a i =
        let (l, r) = splitAt i a
            v = head r
            i' = fromMaybe (length l) $ findIndex (v<) l
            l' = insertAt i' v l
            r' = tail r
        in l' ++ r'

    insertAt :: Int -> a -> [a] -> [a]
    insertAt i v a = take i a ++ [v] ++ drop i a



Measured memory_bytes: 4080
import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	A, V = getlist()
	B, W = getlist()
	T = int(input())
	dist = abs(A - B)
	if W > V:
		print("NO")
		return

	if dist <= T * (V - W):
		print("YES")
	else:
		print("NO")

if __name__ == '__main__':
	main()

Measured memory_bytes: 64708
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if (1 <= a && a <= 9 && 1 <= b && b <= 9) cout << a*b << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 256
import math

A = input()
B = input()
C = input()
D = input()
E = input()

num = 10
for i in [int(A[-1]), int(B[-1]), int(C[-1]), int(D[-1]), int(E[-1])]:
    if i != 0:
        num = min(num, i)

result = (math.ceil(int(A)/10) + math.ceil(int(B)/10) + math.ceil(int(C)/10) + math.ceil(int(D)/10) + math.ceil(int(E)/10)) * 10
if num != 10:
    result = result - 10 + num

print(result)

Measured memory_bytes: 9128
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
#define all(x) (x).begin(),(x).end()
#define V vector<int>
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int k, s; cin >> k >> s;
	int ans = 0;
	rep(i, k+1) {
		rep(j, k+1) {
			int tmp = s - i - j;
			if (0 <= tmp && tmp<=k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<stdio.h>
#include<utility>
#include<algorithm>

int main() {
	int n = 1;
	while (n <= 10000) {
		int a = 0;
		scanf("%d", &a);///////////////
		printf("Case %d: %d\n", n, a);
		n++;
	}
}

Measured memory_bytes: 2612
# ある位置のゴーレムが
# 左端にたどりつくか、右端にたどりつくか、生きているか、を
# 判別する関数
# 戻り値 -1:左端、0:生存、1:右端
def isDead(pos):
    nPos = pos
    if (nPos < 0):
        return -1
    elif (nPos > N-1):
        return 1

    for magic in td:        
        if S[nPos] == magic[0]:
            if magic[1] == 'L':
                nPos -= 1
            else:
                nPos += 1

        if (nPos < 0):
            return -1
        elif (nPos > N-1):
            return 1

        pass # end for
    return 0

N, Q = map(int, input().split())
S = input()
td = [input().split() for _ in range(Q)]

# 二分法で左側の解を求める
lAns = -1
if isDead(0) > -1:
    # 解なし
    lAns = -1
    pass
else:
    tmpMin = -1
    tmpMax = N
    tmp = N // 2
    while( (tmpMax - tmpMin) > 1):
        tmp = (tmpMin + tmpMax) // 2
        if(isDead(tmp) == -1):
            tmpMin = tmp
        else:
            tmpMax = tmp
        pass

    lAns = tmpMin
    # 左側死んだ数 = lAns + 1



# 二分法で右側の解を求める
rAns = N-1
if isDead(N-1) < 1:
    # 解なし
    rAns = N-1
    pass
else:
    tmpMin = -1
    tmpMax = N
    tmp = N // 2
    while( (tmpMax - tmpMin) > 1):
        tmp = (tmpMin + tmpMax) // 2
        if(isDead(tmp) == 1):
            tmpMax = tmp
        else:
            tmpMin = tmp
        pass

    rAns = tmpMin
    # 右側死んだ数 = N - (rAns+1)


alive = rAns - lAns

print(alive)


Measured memory_bytes: 41392
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Scanner;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        BigDecimal A = new BigDecimal(scanner.next());
        BigDecimal B = new BigDecimal(scanner.next());

        BigDecimal ans = A.multiply(B);
        BigDecimal bd1 = ans.setScale(0, RoundingMode.DOWN);


        System.out.println(bd1.toString());
    }
}


Measured memory_bytes: 35956
#include<stdio.h>
int p[300000];
int main(){
	int a;
	p[0]=p[1]=-1;
	for(int i=2;i<300000;i++){
		if(!p[i]){
			p[i]=1;
			for(int j=i+i;j<300000;j+=i)p[j]=-1;
		}
	}
	while(scanf("%d",&a),a){
		int ret=0;
		for(int i=a+1;i<=a+a;i++){
			if(p[i]==1)ret++;
		}printf("%d\n",ret);
	}
}

Measured memory_bytes: 2200
import itertools
Q = int(input())
LR = [[int(x) for x in input().split()] for _ in range(Q)]

MAX = 10**5
is_prime = [True] * MAX
is_prime[0] = is_prime[1] = False
for i in range(2, int(MAX**.5)+1):
    if is_prime[i]:
        for j in range(i*i, MAX, i):
            is_prime[j] = False

NUM = [0] * MAX
for p in range(MAX):
    if is_prime[p] and is_prime[(p+1)//2]:
        NUM[p] += 1
NUMcum = [0] + list(itertools.accumulate(NUM))
for l, r in LR:
    print(int(NUMcum[r+1] - NUMcum[l]))

Measured memory_bytes: 26656