akhauriyash/Code-Regression huggingface dataset:
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: u64 = read();
    println!("{}", dfs(0, n));
}

fn dfs(s: u64, n: u64) -> u64 {
    if s > n {
        0
    } else {
        let mut ret = if is_753(s) { 1 } else { 0 };
        for x in [7, 5, 3].iter() {
            ret += dfs(s * 10 + x, n);
        }
        ret
    }
}

fn is_753(n: u64) -> bool {
    let mut n = n;
    let mut seven = 0;
    let mut five = 0;
    let mut three = 0;

    while n != 0 {
        match n % 10 {
            7 => seven += 1,
            5 => five += 1,
            3 => three += 1,
            _ => return false,
        }
        n /= 10;
    }
    seven > 0 && five > 0 && three > 0
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
/* in the name of Anton */

/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n;
    k=0;
    while(k*(k-1)/2<n)
        k++;
    if(k*(k-1)/2>n)
    {
        cout<<"No"<<endl;
        return 0;
    }

    cout<<"Yes"<<endl;
    vector<vi> a(k);
    u=1;
    fo(i,k)
    repA(j,i+1,k-1)
    {
        a[i].pb(u);
        a[j].pb(u);
        u++;
    }
    cout<<sz(a)<<endl;
    for(auto &v:a)
    {
        cout<<sz(v)<<" ";
        for(auto x:v)
            cout<<x<<" ";
        cout<<endl;
    }
}   aryanc403();
    return 0;
}


Measured memory_bytes: 3200
#include <iostream>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	long long a,b,n;
	cin>>a>>b>>n;
	long long x = min(b-1,n);
	cout<<a*x/b<<endl;
	
	return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;




int main(){
  char a,b;
  cin >> a >>b;
  if(a<b){cout << '<' << endl;}
  else if(a>b){cout << '>' << endl;}else{cout <<'=' << endl;}

}

Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		int aSize1 = input.nextInt();
		int[] arr1 = new int[aSize1];
		
		for (int i = 0; i < aSize1; i++) {
			arr1[i] = input.nextInt();
		}
		
		int aSize2 = input.nextInt();
		int[] arr2 = new int[aSize2];
		
		for (int i = 0; i < aSize2; i++) {
			arr2[i] = input.nextInt();
		}
		
		System.out.println(countIntersection(arr1, arr2));
	}
	
	public static int countIntersection(int[] arr1, int[] arr2) {
		int result = 0;
		
		for (int i = 0; i < arr2.length; i++) {
			for (int j = 0; j < arr1.length; j++) {
				if (arr2[i] == arr1[j]) {
					result++;
					break;
				}
			}
		}
		
		return result;
	}
}



Measured memory_bytes: 40684
x,y,a,b,c=map(int,input().split())
p=list(reversed(sorted(map(int,input().split()))))
q=list(reversed(sorted(map(int,input().split()))))
r=list(reversed(sorted(map(int,input().split()))))
p.append(2**100)
q.append(2**100)
r.append(-2**100)
s=sum(p[:x])+sum(q[:y])
t=0
while True:
  f=p[x-1]<q[y-1]
  m=p[x-1] if f else q[y-1]
  if m<r[t]:
    if f:
      x-=1
      s+=r[t]-p[x]
      t+=1
    else:
      y-=1
      s+=r[t]-q[y]
      t+=1
  else:
    break
print(s)
      


Measured memory_bytes: 106920
#include <iostream>

using namespace std;

int main(void){
	int w;
	while(cin >> w && w != -1){
		if(w<=10){
			cout << 3130 << endl;
		}else if(w <= 20){
			cout << 4280 - (1150+125*(w-10)) << endl;
		}else if(w <= 30){
			cout << 4280 - (1150+1250+140*(w-20)) << endl;
		}else{
			cout << 4280 - (1150+1250+1400+160*(w-30)) << endl;
		}
	}
}

Measured memory_bytes: 0
#!/usr/bin/python3

import sys
# input = sys.stdin.readline
sys.setrecursionlimit(100000)
MOD = 10 ** 9 + 7

#N = int(input())
#A = [int(x) for x in input().split()]
#V = [[0] * 100 for _ in range(100)]

N = int(input())
A = [int(x) for x in input().split()]

T = []
for i,a in enumerate(A):
    T.append((a,i+1))

T.sort()


ans = [str(t[1]) for t in T]

print(" ".join(ans))

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

int main() {
  int W,H,x,y,r;
  cin >> W >> H >> x >> y >> r;
  if (x>=r && y>=r && x+r<=W && y+r<=H) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3120
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<int, int>pi;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second


struct Union_Find_Tree {
private:
	vector<ll>par;
	vector<ll>Rank;
	int N;
public:
	void init(int n) {
		N = n;
		par.resize(N + 1);
		Rank.resize(N + 1);
		for (int i = 0;i <= N;i++)par[i] = i, Rank[i] = 0;
	}
	int find(int x) {
		if (par[x] == x)return x;
		else return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)return;
		if (Rank[x] < Rank[y])par[x] = y;
		else {
			par[y] = x;
			if (Rank[x] == Rank[y])Rank[x]++;
		}
	}
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

vector<ll>v[100010];
ll n, m, a, b;


int main() {
	cin >> n >> m;
	Union_Find_Tree uf;
	uf.init(2 * n);
	for (int i = 0;i < m;i++) {
		cin >> a >> b;
		a--, b--;
		uf.unite(a, b + n);
		uf.unite(b, a + n);
	}
	if (uf.same(0, n))cout << n * (n - 1) / 2 - m << endl;
	else {
		int cnt = 0;
		for (int i = 0;i < n;i++)if (uf.same(0, i))cnt++;
		cout << cnt * (n - cnt) - m << endl;
	}
	return 0;
}


Measured memory_bytes: 5760
#include <cstdio>
#include <cstring>
#include <cmath>
#include <sstream>
#include <algorithm>
#define INF 0x3f3f3f3f
#define ll long long

using namespace std;

ll quickpow(ll a,ll b,ll m)
{
    ll ans=1;
    while(b){
        if(b&1){
            ans=(ans*a)%m;
        }
        b/=2;
        a=a*a%m;
    }
    return ans%m;
}

int main() {
    ll n,a,b,tot=0,mod=1e9+7;
    scanf("%lld%lld%lld",&n,&a,&b);
    a=min(a,n-a);
    b=min(b,n-b);
    tot=quickpow(2,n,mod)-1;
    ll x=1,y=1;
    for (int i = n; i > n - a; i--)
		x = (x*i) % mod;
	for (int i = 1; i <= a; i++)
		y = (y*i) % mod;
    tot=(tot+mod-quickpow(y,mod-2,mod)*x%mod)%mod;
    x=1,y=1;
    for (int i = n; i > n - b; i--)
		x = (x*i) % mod;
	for (int i = 1; i <= b; i++)
		y = (y*i) % mod;
    tot=(tot+mod-quickpow(y,mod-2,mod)*x%mod)%mod;
    printf("%d\n",tot);
}


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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long

void solve(){
	ll num;
	cin >> num;
	string ans = "";
	while(num > 0) {
		num--;
		ans += ('a' + (num % 26));
		num /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
}

int main(){
	IOS;
	int t = 1; 
	// cin >> t;
	while(t--) solve();
	return 0;
}

Measured memory_bytes: 3636
<?php
fscanf(STDIN, "%d", $n);
$sum = 0;
for($i = 1; $i <= $n; $i++){
  if($i % 3 == 0){
  } else {
    if($i % 5 == 0){
    } else {
      $sum += $i;
    }
  }
}
echo $sum;
?>

Measured memory_bytes: 15940
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
long long v[200005];
int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&v[i]);
        v[i]-=i;
    }
    sort(v+1,v+1+n);
    long long m_sum=0;
    for(int i=1;i<=n;i++)
        m_sum+=abs(v[i]-v[n/2+1]);
    printf("%lld\n",m_sum);
    return 0;
}

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

int main(){
  int n,k;
  string s;
  scanf("%d%d", &n,&k);
  cin >> s;
  
  s.at(k-1) -= 'A'-'a';
  printf("%s", s.c_str());
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A; REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << (ans) << endl
#define rsort(p, q) sort(p, q, greater<int>());

#define DEBUGV(V) REP(i, V.size() - 1) cout << V.at(i) << " "; cout << endl 

int
main()
{
  CIN(N);
  CIN(K);
  CINVEC(X, N);

  sort(X.begin(), X.end());
  ull ans = 0;
  REP(i, X.size()) {
    if (X.at(i) < K - X.at(i)) ans += X.at(i) * 2;
    else ans += (K - X.at(i)) * 2;
  }

  ANS(ans);

  return 0;
}


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

int main(){

    long long int N,M;
    cin>>N>>M;
    vector<pair<long long int,long long int>> S(N);
    for(int i=0;i<N;i++){
        cin>>S.at(i).first>>S.at(i).second;
    }
    sort(S.begin(),S.end());
    long long int cnt=0;
    int i=0;
    while(M>0){
        if(S.at(i).second>=M){
            cnt=cnt+M*S.at(i).first;
            M=0;
        }
        else{
            cnt=cnt+S.at(i).first*S.at(i).second;
            M-=S.at(i).second;
        }
        i++;
    }
    cout<<cnt<<endl;
}
    


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

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

template <typename T>
vector<T> divisor(T &n) {
    vector<T> res;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

signed main() {
    INIT;
    cin >> N;
    auto v = divisor(N);
    ans = LLINF;
    REP(i, v.size()) {
        A = v[i];
        B = N / v[i];
        ll tmp = max(to_string(A).size(), to_string(B).size());
        chmin(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3712
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b,a%b)

def lcm(a,b):
  d = (a*b) / gcd(a,b)
  print d
while True:
  try:
   x = map(int,raw_input().split(" "))
   a,b = x[0],x[1]
   print gcd(a,b),(a*b)/gcd(a,b)

  except EOFError:
    break

Measured memory_bytes: 4228
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    K, X = MAP()
    minv = max(X - K + 1, -1000000)
    maxv = min(X + K - 1, 1000000)
    Y = list(range(minv, maxv+1))
    print(*Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
from collections import deque 
n = int(input())
es = [[] for i in range(n)]
for i in range(n - 1):
    a, b = map(int, input().split())
    es[a - 1].append(b - 1)
    es[b - 1].append(a - 1)

c = list(map(int, input().split()))
c.sort()
print(sum(c) - c[-1])

d = [0] * n

q = deque([0])
d[0] = c.pop()

while q:
    v = q.popleft()
    for e in es[v]:
        if d[e]==0:
            d[e] = c.pop()
            q.append(e)
print(*d)

Measured memory_bytes: 77100
s = input()
a = [0]
answer = [0 for i in range(len(s)) ]
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        a.append(i+1)

for i in range(1,len(a),2):
    if i ==len(a)-1:
        a.append(len(s))
    if (a[i+1]-a[i-1])%2==0:
        answer[a[i]-1] = int((a[i+1]-a[i-1])//2)
        answer[a[i]] = int((a[i+1]-a[i-1])//2)
    else:
        if (a[i+1]-a[i])%2==1:
            answer[a[i]-1] = int((a[i+1]-a[i-1])//2)
            answer[a[i]] = int((a[i+1]-a[i-1])//2)+1
        else:
            answer[a[i]-1] = int((a[i+1]-a[i-1])//2)+1
            answer[a[i]] = int((a[i+1]-a[i-1])//2)

for i in range(len(answer)):
    print(answer[i])

Measured memory_bytes: 8816
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define p1d(a,n)                for(int ix=0;ix<n;ix++) out<<a[ix]<<" "; out<<endl
#define p2d(a,n,m)              for(int ix=0;ix<n;ix++){ for(int jx=0;jx<m;jx++) out<<a[ix][jx]<<" "; out<<endl;}
#define range(v)                v.begin(),v.end()
#define w(x)                    while(x--)
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

class DDiceInLine {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int n,k;
	    s2(n,k);
	    vi a(n);
	    f(i,0,n) s(a[i]);
	    f(i,1,n) a[i]+=a[i-1];
	    int m = -1;
	    f(i,k-1, n){
	        m = max(m, a[i] - (i-k >= 0 ? a[i-k]:0));
	    }
	    out<<(m+k)/2<<((m+k)%2 == 1 ? ".5":"")<<endl;

	}
};


integer main() {
	DDiceInLine solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
}


Measured memory_bytes: 1792
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n,k;
  cin >> n >> k;
  ll a[n];
  for(int i=0;i<n;i++) cin >> a[i];
  ll ans = 0;
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(a[i] > a[j]) ans++;
    }
  }
  ans *= k;
  ans %= MOD;
  ll ans_e = 0;
  sort(a,a+n);
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(a[i] < a[j]) ans_e++;
    }
  }
  ans_e *= (k*(k-1)/2)%MOD;
  ans_e %= MOD;

  cout << (ans+ans_e)%MOD << endl;  
  return 0;
}


Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_E main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif

void z_algorithm(vi& pre, const string S) {
    int N = S.size();
    pre = vi(N);

    pre[0] = N;
    int i = 1, len = 0;
    while (i < N) {
        while (i + len < N && S[len] == S[i + len]) len++;
        pre[i] = len;

        if (len == 0) {
            i++;
            continue;
        }

        assert(len > 0);
        int j = 1;
        while (i + j < N && j + pre[j] < len) {
            pre[i + j] = pre[j];
            j++;
        }

        i += j;
        len -= j;
    }
}


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

    int N; cin >> N;
    string S; cin >> S;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        vi pre;
        z_algorithm(pre, S.substr(i));

        for (int j = 1; j < pre.size(); j++) {
            ans = max(ans, min(j, pre[j]));
        }
    }

    cout << ans << endl;


    return 0;
}


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

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

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

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

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

int n,m;
ll a[100005],b[100005],siz[100005],ans[100005],f[100005];
pll p[100005];
vector<int> adj[100005];

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

int main(){
	n=readint(); m=readint();
	for(int i=1;i<=n;i++) a[i]=readint(),b[i]=readint(),chkmax(a[i],b[i]);
	int x,y;
	for(int i=1;i<=m;i++){
		x=readint(); y=readint();
		if(x>y) swap(x,y);
		if(a[x]-b[x]>a[y]-b[y]) adj[x].push_back(y);
		else adj[y].push_back(x);
	}
	for(int i=1;i<=n;i++) p[i]=mp(a[i]-b[i],i);
	for(int i=1;i<=n;i++) f[i]=i,siz[i]=b[i],ans[i]=a[i]-b[i];
	sort(p+1,p+n+1);
	for(int i=1;i<=n;i++){
		int u=p[i].se;
		for(auto x:adj[u]){
			int fx=getf(x);
			if(fx==u) continue;
			chkmin(ans[u],max(a[u]-b[u]-siz[fx],ans[fx]));
			siz[u]+=siz[fx];
			f[fx]=u;
		}
	}
	printf("%lld\n",ans[getf(1)]+siz[getf(1)]);
	return 0;
}

Measured memory_bytes: 10240
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<int, int> qii;
typedef pair<int, int> pii;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n) {
	int digits = 0;
	while (n != 0) {
		n /= 10;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


int main() {
	float n, t, a, temp_h, temp_t, ans_n = 1000, ans_t = 1000;
	cin >> n >> t >> a;
	for (int i = 0; i < n; i++) {
		cin >> temp_h;
		temp_t = t - (temp_h * 0.006);
		if (abs(a - temp_t) < abs(a - ans_t)) {
			ans_t = temp_t;
			ans_n = i + 1;
		}
	}

	cout << ans_n << endl;

	system("pause");
	return 0;
}


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

using vll = std::vector<long long>;
constexpr long long mod{1000000007};

int main()
{
	int h, w;
	scanf("%d%d", &h, &w);
	std::vector<vll> way(h + 1, vll(w + 1));
	way[1][1] = 1;
	for (int r{1}; r <= h; r++)
	{
		for (int c{1}; c <= w; c++)
		{
			char a;
			scanf(" %c", &a);
			if (a == '#') continue;
			way[r][c] += (way[r - 1][c] + way[r][c - 1]) % mod;
		}
	}
	printf("%lld\n", way[h][w]);

	return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a==1 && b==2) cout << 3;
    else if(a==1 && b==3) cout << 2;
    else if(a==2 && b==1) cout << 3;
    else if(a==2 && b==3) cout << 1;
    else if(a==3 && b==1) cout << 2;
    else{cout << 1;}
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
bool f , ff;
int main()
{
	string s;
	cin>>s;
	for (int i=0 ; i<s.length() ; i++)
	{
		if ( s[i]=='C' ) f=true;
		if ( f && s[i]=='F' ) ff=true;
		if ( ff ) {cout<<"Yes"; return 0;}
	}
	cout<<"No";
	return 0;
}

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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const int N=55;
s64 dp[N][2];

int main()
{
	//freopen("1.in","r",stdin);
	int n,p;
	cin>>n>>p;
	dp[0][0]=1;
	rep(i,1,n)
	{
		int a;
		cin>>a;
		a%=2;
		rep(j,0,1)dp[i][j]=dp[i-1][j]+dp[i-1][j^a];		
	}
	cout<<dp[n][p];
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NX = Sarray();
            var N = NX[0];
            var X = NX[1];
            var xi = Slist();
            xi.Add(X);
            xi.Sort();
            var min = xi.Min();
            xi = xi.Select(x => x - min).ToList();
            var ans = xi[0];
            for (var i = 1; i < xi.Count; ++i)
                ans = gcd(ans, xi[i]);
            WriteLine(ans);
            //Out.Flush();
        }
        static long gcd(long x, long y) => y == 0 ? x : gcd(y, x % y);
    }
}

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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;

PL operator+(const PL& lp, const PL& rp) { 
    return PL(lp.first + rp.first, lp.second + rp.second);
}

int di[] = {1, 0, -1, 0};
int dj[] = {0, 1, 0, -1};

int h, w;
bool visited[400][400] = {};
PL dfs(int i, int j, vector<string>& s) {  // b, w
    if(visited[i][j]) return P(0, 0);
    visited[i][j] = true;
    PL bw_sum(0, 0);
    bool is_ok = false;
    REP(k, 4) {
        int next_i = i + di[k];
        int next_j = j + dj[k];
        if(next_i < 0 or next_i >= h) continue;
        if(next_j < 0 or next_j >= w) continue;
        if(s[i][j] != s[next_i][next_j]) {
            bw_sum = bw_sum + dfs(next_i, next_j, s);
            is_ok = true;
        }
    }
    if(is_ok) bw_sum = bw_sum + (s[i][j] == '#' ? P(1, 0) : P(0, 1));
    return bw_sum;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> h >> w;
    vector<string> s(h);
    REP(i, h) cin >> s[i];
    
    ll ans = 0;
    REP(i, h)REP(j, w)if(!visited[i][j] and s[i][j] == '#') {
        PL bw_sum = dfs(i, j, s);
        ans += bw_sum.first * bw_sum.second;
    }
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 23040
import java.util.Scanner

fun main(args: Array<String>){
	val sc = Scanner(System.`in`)
	val S = sc.nextLine()
	val K = sc.nextLine().toLong()
	val N = S.length
	val A = IntArray(N)
	for(i in 0..N-1){
		A[i] = Integer.parseInt(Character.toString(S[i]))
	}
	
	var f = N+1
	var n = 1

	for(i in 0..N-1){
		if(A[i] != 1){
			n = A[i]
			f = i+1
			break
		}
	}

	if(K<f) println(1)
	else println(n)

}

Measured memory_bytes: 31392
from itertools import combinations as comb
from itertools import permutations as perm
from copy import copy


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


A = [0, 0, 0]
N, A[0], A[1], A[2] = inpl()
bamboo = [int(input()) for _ in range(N)]

ans = 10000 * 3
for tmp_a in perm(A, 3):
    tmp_bamboo = copy(bamboo)
    junjo_ans = 0
    for num, a in enumerate(tmp_a):
        tmp_ans = 1000 * 3
        for i in range(1, len(tmp_bamboo) - (2 - num) + 1):
            for Comb in comb(tmp_bamboo, i):
                if tmp_ans > abs(sum(Comb) - a) + 10 * (i - 1):
                    tmp_ans = abs(sum(Comb) - a) + 10 * (i - 1)
                    tmp_comb = copy(Comb)
        junjo_ans += tmp_ans
        for c in tmp_comb:
            tmp_bamboo.remove(c)
    ans = min(ans, junjo_ans)
print(ans)


Measured memory_bytes: 3436
//ITP1_8_C
#include<iostream>
#include<stdio.h>
#include<ctype.h>
using namespace std;

int main(){
	char ch,ch1;
	int i,num,counter[26];

	for(i=0;i<26;i++){
			counter[i]=0;
	}

	while(cin>>ch){
		ch1=tolower(ch);
		num=ch1-'a';
		if(num >= 0&&num<=25){
			counter[num]++;

		}else if(ch ==EOF){
			break;
		}
	}

	for(i=0;i<26;i++){
		printf("%c : %d\n",i+'a',counter[i]);
	}
	return 0;
}

Measured memory_bytes: 1124
n = int(input())
list_A = list(map(int, input().split()))
list_B = list(map(int, input().split()))
list_C = list(map(int, input().split()))
list_A.sort()
list_B.sort()
list_C.sort()
b = 0
list_UP = []
for i in range(n):
    while True:
        if b > n-1 or list_A[i] < list_B[b]:
            break
        b += 1
    list_UP.append(n-b)


c = 0
list_DOWN = []
for i in range(n):
    while True:
        if c > n-1 or list_B[i] < list_C[c]:
            break
        c += 1
    list_DOWN.append(n-c)


ans = 0
num = 0
sum_value = sum(list_DOWN)
for i in list_UP:
    while True:
        if num == n-i:
            break
        sum_value -= list_DOWN[num]
        num += 1
    ans += sum_value

print(ans)


Measured memory_bytes: 24052
#include <bits/stdc++.h>
#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)
#define sp(n) setprecision(n)
#define mp make_pair
#define mt make_tuple
#define pi 3.14159265358979323846264
#define MOD 1000000007

using namespace std;
int primeFactors(ll n)  
{  ll f=0;
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        f++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            f++; 
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2)  
        f++;
        
 return f;        
}  
  
bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}
 
ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++){
            if (j == 0 || j == i){C[i][j] = 1;}
            else{C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}}
    return C[n][k];
 }
 
ll gcd(ll a, ll b){if (b == 0)
        return a;return gcd(b, a % b);}
 
ll expmod(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}
//define temp-functions below
 
 
//some definitions and global variables
vector<ll> primes;
void storePrime(ll n){
    fori(n){
        if(isPrime(i+1)&&(n%(i+1)==0)){primes.push_back(i+1);}
    }
}
 
int main(){ //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);cout.tie(NULL);

 
      ll n,k;cin>>n>>k;
       ll l=0;
    while(n!=0){
        n=n/k;l++;
    }

      cout<<l;
      
      
      
      
      
      
      
      
      
    

return 0;}

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

int x[2000000];
long long p;
int a, b, sum;

int main() {
	for (int i = 0; i < 20; i++) {
		for (int j = 0; j < 13; j++) {
			for (int k = 0; k < 9; k++) {
				p = (long long)pow(2, i)*(long long)pow(3, j)*(long long)pow(5, k);
				if (p < 2000000) {
					x[p] = 1;
				}
			}
		}
	}
	while (true) {
		sum = 0;
		cin >> a;
		if (a == 0) { break; }
		cin >> b;
		for (int i = a; i <= b; i++){
			sum += x[i];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 6236
a = list(map(int,input().split()))
p = list(map(int,input().split()))
n = a[0]
k = a[1]

E = [0]*(n+1)

sum_E = 0
max_E = 0

for i in range(1,n+1):
  sum_E += (p[i-1]+1)/2
  E[i] = sum_E

for i in range(n-k+1):
  #print(E[i+k] - E[i])
  if max_E < E[i+k] - E[i]:
    max_E = E[i+k] - E[i]
#print(E)
print(max_E)

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

int main()
{
	ll n,a,b;
	cin>>n>>a>>b;
	ll p=a+b;
	ll q=n/p;
	ll d=n-(q*p);
	ll c=(q*a);
	if(d>a)
		d=a;
	c+=d;
	cout<<c;
}

Measured memory_bytes: 256
#include <stdio.h>

struct DICE {
int d1,d2,d3,d4,d5,d6;
};

void MoveDice(struct DICE *p,char c){
    int tmp;
    tmp=p->d1;
    switch(c){
        case 'W':
            p->d1=p->d3;p->d3=p->d6;p->d6=p->d4;p->d4=tmp;
            break;
        case 'E':
            p->d1=p->d4;p->d4=p->d6;p->d6=p->d3;p->d3=tmp;
            break;
        case 'N':
            p->d1=p->d2;p->d2=p->d6;p->d6=p->d5;p->d5=tmp;
            break;
        case 'S':
            p->d1=p->d5;p->d5=p->d6;p->d6=p->d2;p->d2=tmp;
            break;
    }
}
int main(){
    struct DICE p;
    int q,i;
    int n1,n2;
    scanf("%d %d %d %d %d %d\n",&p.d1,&p.d2,&p.d3,&p.d4,&p.d5,&p.d6);
    scanf("%d", &q);
    for(i=0;i<q;i++){
        scanf("%d %d", &n1,&n2);
        if(n2 == p.d4){
            MoveDice(&p,'E');
            MoveDice(&p,'S');
        }
        else if(n2 == p.d3){
            MoveDice(&p,'W');
            MoveDice(&p,'S');
        }
        else if(n2 == p.d5){
            MoveDice(&p,'S');
            MoveDice(&p,'S');
        }
        else if(n2 == p.d1) MoveDice(&p,'S');
        else if(n2 == p.d6) MoveDice(&p,'N');
        else{
            ;
        }
        while(n1 != p.d1){
            MoveDice(&p,'W');
        }
        printf("%d\n",p.d3);
    }
    return (0);
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    getline(cin, s);
    for(int i = 0; i < s.size(); i++)
    {
        if(s.substr(i, 5) == "apple")
        {
            cout << "peach";
            i += 4;
        }
        else if(s.substr(i, 5) == "peach")
        {
            cout << "apple";
            i += 4;
        }
        else cout << s[i];
    }
    cout << endl;
    return 0;
}




Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}

void solve(){
  ll A, B; cin >> A >> B;
 char C; cin >> C;
 int D; cin >> D;
 B *= 100; B += D;
 ll X = A*B; X /= 100;
 cout << X << endl;
}
int main(){
    optimizeIO();
    // tc
    {
      solve();
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define N 200004
#define pp pair<int,int>
#define mp make_pair
#define pb push_back
#define ff first
#define dd second


using namespace std;
int n;
int maxi = 1;
int tab[N];
map<int,int> no;

main() {
    ios_base::sync_with_stdio(false);
    cin >> n; int ans = 0;
    for(int i = 0; i < n; ++i) cin >> tab[i];
    sort(tab, tab+n);
    for(int i = 0; i < n; ++i) no[tab[i]]++;

    for(int i = n-1; i >= 0; --i) {
        if (no[tab[i]] == 0) continue;
        no[tab[i]]--;
        for(int p = 30; p >= 0; --p) {
            int col = (1 << p) - tab[i];
            if (no[col] > 0) {
                no[col]--;
                ans++; break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 302208
n, m, x = map(int, input().split())
a = [list(map(int,input().split())) for i in range(n)]
A = []
for i in range(n):
  A.append(i)
sum =10**9+7
for i in range(1 << len(A)):
    output = []
    for j in range(len(A)):
        if ((i >> j) & 1) == 1:
            output.append(A[j])
    ans = [0]*(m+1)
    for i in output:
      ans = [x + y for (x, y) in zip(ans, a[i])]
    for j in ans[1:]:
      if j >= x:
        continue
      else: break
    else: sum = min(sum, ans[0])
if sum == 10**9+7:
  print(-1)
else:
  print(sum)

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
	char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
	vector<char*> v({token});
	while(token = strtok(NULL,", ")) v.push_back(token);
	return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
	debug() << " [" << args.back() << ": " << H << "] ";
	args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=1e9+7;
const int MX=0x3f3f3f3f;

int main(){
	IOS;
	int n,i,j,k;
	cin>>n;
	string s;
	cin>>s;
	int a[n];
	REP(i,0,n-1) a[i]=(s[i]=='R')?1:(s[i]=='G')?2:3;
	int suf[4][n+1];
	memset(suf,0,sizeof(suf));
	RAP(i,n-1,0){
		suf[a[i]][i]++;
		REP(j,1,3) suf[j][i]+=suf[j][i+1];
	}
	ll ans=0;
	REP(i,0,n-3){
		REP(j,i+1,n-2){
			if(a[i]!=a[j])
				ans+=suf[a[i]^a[j]][j+1]-(2*j-i<n&&a[2*j-i]==(a[i]^a[j]));
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3680
import numpy as np

a, b, h, m = map(int, input().split())
theta = np.pi / 6 * (h + m / 60)
phi = np.pi / 30 * m
ans = np.sqrt((a * np.sin(theta) - b * np.sin(phi))**2 + (a * np.cos(theta) - b * np.cos(phi))**2)
print(ans)

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


ll optimal_strategy(ll start , ll end , vector<vector<ll>>& dp , vector<ll>& arr)
{   //  cout<<start<<" "<<end<<endl;
    if(start < 0  || end >= arr.size()) return 0;
   // cout<<start<<" "<<end<<" "<<arr[start]<<" "<<arr[end]<<" "<<dp[start][end]<<endl;
    if(start == end)
    {
        dp[start][end] = arr[start];
        return dp[start][end];
    }
    if(end == (start + 1))
    {
        dp[start][end]  = max(arr[start],arr[end]);
        return dp[start][end];
    }
   //  cout<<start<<" "<<end<<" "<<arr[start]<<" "<<arr[end]<<" "<<dp[start][end]<<endl;
    if(dp[start][end] != INT_MIN) return dp[start][end];
    dp[start][end] = max ( arr[start] + min( optimal_strategy(start+2,end,dp,arr) , optimal_strategy(start+1,end-1,dp,arr) ) , arr[end] + min( optimal_strategy(start+1,end-1,dp,arr) , optimal_strategy(start,end-2,dp,arr) ) ); 
    return dp[start][end];
}
int main()
{  
    
    int n;
    cin>>n;
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,INT_MIN));
    vector<ll> arr(n);
    ll total_sum = 0;
    for(ll i = 0 ; i< n;i++)
    {
        cin>>arr[i];
        total_sum += arr[i];
    }
    ll ans = optimal_strategy(0,n-1,dp,arr) ; 
    cout<< 2*ans - total_sum <<endl;
    return 0;
    
        
}



Measured memory_bytes: 70912
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  string s;
  cin>>n>>s;
  if(n%2==1) cout<<"No"<<endl;
  else if(n%2==0){
    for(i=0;i<n/2;i++) if(s.at(i)!=s.at(i+n/2)) break;
    if(i==n/2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h> //Ithea Myse Valgulious
namespace chtholly{
typedef long long ll;
#define re0 register int
#define rec register char
#define rel register ll
#define gc getchar
#define pc putchar
#define p32 pc(' ')
#define pl puts("")
/*By Citrus*/
inline int read(){
  int x=0,f=1;char c=gc();
  for (;!isdigit(c);c=gc()) f^=c=='-';
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return f?x:-x;
  }
template <typename mitsuha>
inline bool read(mitsuha &x){
  x=0;int f=1;char c=gc();
  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';
  if (!~c) return 0;
  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');
  return x=f?x:-x,1;
  }
template <typename mitsuha>
inline int write(mitsuha x){
  if (!x) return 0&pc(48);
  if (x<0) x=-x,pc('-');
  int bit[20],i,p=0;
  for (;x;x/=10) bit[++p]=x%10;
  for (i=p;i;--i) pc(bit[i]+48);
  return 0;
  }
inline char fuhao(){
  char c=gc();
  for (;isspace(c);c=gc());
  return c;
  }
}using namespace chtholly;
using namespace std;

int main(){
int a=read(),b=read(),c=read();
if (a>b) swap(a,b);
if (b>c) swap(b,c);
if (a>b) swap(a,b);
write(a+b+c*10);
}

Measured memory_bytes: 256
import collections
n = int(input())
v = list(map(int, input().split()))
o = [v[i] for i in range(n) if i % 2 == 0]
e = [v[i] for i in range(n) if i % 2 == 1]
odd = collections.Counter(o)
even = collections.Counter(e)
odd_num = odd.most_common(2)
even_num = even.most_common(2)
odd_num.append(('', 0))
even_num.append(('', 0))
if odd_num[0][0] == even_num[0][0]:
    print(n - max(odd_num[0][1] + even_num[1][1], odd_num[1][1] + even_num[0][1]))
else:
    print(n - odd_num[0][1] - even_num[0][1])


Measured memory_bytes: 19040
def dp(array)
  max = 0
  for i in 1...array.size
    for j in 1...array[0].size
      array[i][j] = [array[i - 1][j - 1], array[i - 1][j], array[i][j - 1]].min + 1 if array[i][j] != 0
      max = array[i][j] if max < array[i][j]
    end
  end
  return max
end
def main
  while (n = gets.to_i) != 0
    array = Array.new(1, Array.new(n + 1, 0))
    n.times do
      array << ([0] + gets.chomp.split(//).map{|c|
        if c == "."
          1
        else
          0
        end
        })
    end
    puts dp(array)
  end
end
main

Measured memory_bytes: 27104
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val hList = readLine()!!.split(' ').map(String::toLong).reversed().toMutableList()

    for (i in 0 until n - 1) {
        if (hList[i] + 1 < hList[i + 1]) {
            println("No")
            return
        } else if (hList[i] < hList[i + 1]) {
            hList[i + 1] = hList[i + 1] - 1
        }
    }
    println("Yes")
}

Measured memory_bytes: 59680
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <cmath>
# include <functional>
# include <utility>
#include<iomanip>
# define MOD 1000000000+7
# define INF 2000000000
#define rep(i,rept)	for(int i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
int main() {
	//new
	double N,a,b,ans=0;
	double x[8],y[8];
	cin >> N;
	rep(i, N) {
		cin >> x[i] >> y[i];
	}
	for (int i = 0; i < N - 1; i++) {
		for (int j = i + 1; j < N; j++) {

			ans += sqrt(pow(x[j]-x[i],2)+pow(y[j]-y[i],2));
		}
	}
	cout <<setprecision(10)<< ans * 2/N << endl;
}



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

struct edge{
    long long from,to,cost;
    edge(){}
    edge(long long f,long long t,long long c) : from(f),to(t),cost(c){}
};

vector<long long> bellmanford(int s,const vector<edge>& es,int V){
    constexpr long long inf = 1ll << 60;
    vector<long long> d(V,inf);
    d[s] = 0;
    for(int i=0;i<V;i++){
        for(const edge& e : es){
            if(d[e.from]!=inf && d[e.to]>d[e.from]+e.cost){
                d[e.to] = d[e.from] + e.cost;
            }
        }
    }
    return d;
}

signed main(){
    int n;cin>>n;
    vector<edge> es;
    for(int i=0;i<n;i++){
        int u,k;
        cin >> u >> k;
        for(int j=0;j<k;j++){
            int c,v;
            cin >> v >> c;
            es.emplace_back(edge(u,v,c));
        }
    }
    auto d = bellmanford(0,es,n);
    for(int i=0;i<n;i++){
        cout << i <<  " " << d[i] << endl;
    }
}

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

int main()
{
	int N;
	vector<int> a;
	cin >> N;
	a.resize(N);
	for (int i = 0; i < N; i++)
	{
		cin >> a[i];
	}

	int light = 1,count = 0;
	while(light != 2)
	{
		light = a[light-1];
		count++;
		if (count > 2 * N)
			break;
	}

	if (count > 2 * N)
		cout << -1;
	else
		cout << count;
	
	return 0;
}




Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
int main()
{ 
    cool;
    long long int n,k,q,x,i;
    cin>>n>>k>>q;
    long long int a[n+1];
    for(i=1;i<=n;i++)
    a[i]=(k-q);
    while(q--)
    {
    	cin>>x;
    	a[x]+=1;
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]>0)
		cout<<"Yes\n";
		else
		cout<<"No\n";
	}
    return 0;
}

Measured memory_bytes: 1408