akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

struct rest{
	string name;
	int point;
	int num;
};

bool operator < (rest a, rest b){
	if(a.name != b.name) return a.name < b.name;
	return a.point > b.point;
}

int main(){
	int n;cin>>n;
	rest r[100];
	for(int i=0;i<n;i++){
		cin>>r[i].name;
		cin>>r[i].point;
		r[i].num = i+1;
	}
	sort(r,r+n);
	for(int i=0;i<n;i++){
		cout<<r[i].num<<endl;
	}
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

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



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

if(s=="RRR")
cout<<3<<endl;
else if(s=="SSS")
    cout<<0<<endl;
else if(s=="RRS"||s=="SRR")
    cout<<2<<endl;
else
    cout<<1<<endl;
 return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void){
  char a='a',i='i',u='u',e='e',o='o',s;
  scanf("%c",&s);
  if(a==s ||i==s || u==s || e==s || o==s){
    printf("vowel");
  }else{
    printf("consonant");
  }
  return 0;
}
    



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int maxn=100100;
const double pi=acos(-1.0);
double Ans[maxn];
struct node{
	int x,y,id;
	void print(){
		printf("x=%d y=%d\n",x,y);
	}
}a[maxn];
long long cross(const node &A,const node &B){
	return A.x*(long long)B.y-A.y*(long long)B.x;
}
long long operator * (const node &A,const node &B){
	return A.x*(long long)B.x+A.y*(long long)B.y;
}
node operator - (const node &A,const node &B){
	return (node){A.x-B.x,A.y-B.y,A.id};
}
bool cmp1(const node &A,const node &B){
	return A.x==B.x?A.y<B.y:A.x<B.x;
}
long long pf(const node &A){
	return A.x*(long long)A.x+A.y*(long long)A.y;
}
bool cmp2(const node &A,const node &B){
	return cross(A,B)>0;
}
double getdis(const node &A){
	return sqrt(A.x*(long long)A.x+A.y*(long long)A.y);
}
int main(){
//		freopen("B.in","r",stdin);
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].id=i;
	}
	sort(a+1,a+n+1,cmp1);
	for(int i=n;i>=1;i--)
		a[i]=a[i]-a[1];
	stable_sort(a+2,a+n+1,cmp2);
	static node stk[maxn];
	int top=1;
	stk[1]=a[1];
	for(int i=2;i<=n;i++){
		while(top>1&&cross(a[i]-stk[top-1],stk[top]-stk[top-1])>=0)
			top--;
		stk[++top]=a[i];
	}
	if(top==1){
		for(int i=1;i<=top;i++)
			Ans[stk[i].id]=1.0;
	}
	else if(top==2){
		for(int i=1;i<=top;i++)
			Ans[stk[i].id]=0.5;
	}
	else{
		double x;
		for(int i=1;i<=top;i++){
			x=(stk[i%top+1]-stk[i])*(stk[(i+top-2)%top+1]-stk[i]);
			x=x/(getdis(stk[i%top+1]-stk[i])*getdis(stk[(i+top-2)%top+1]-stk[i]));
			Ans[stk[i].id]=(pi-acos(x))/(pi*2);
		}
	}
	for(int i=1;i<=n;i++)
		printf("%.10f\n",Ans[i]);
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <set>
using namespace std;
long long n, a, s, l, r, b[200005];
set<int> st;
int main() {
	int i;
	scanf("%d", &n);
	for(i=1; i<=n; i++) scanf("%d", &a), b[a] = i;;
	st.insert(0);
	st.insert(n+1);
	for(i=1; i<=n; i++) {
		l = *(--st.lower_bound(b[i]));
		r = *st.lower_bound(b[i]);
		s += i * (b[i]-l) * (r-b[i]);
		st.insert(b[i]);
	}
	printf("%lld", s);
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
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 = 1000000007;

int main(){
  int d,t,s; cin >> d >> t >> s;
  if(s*t < d) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string Int2Str(int);
int Str2Int(string);
int main(){
  int l,s,cal;
  string str,L,S;
  while(1){
    cin >> str;
    if(str=="0000") break;
    int cnt=0,flag=0;
    if(str=="6174") cnt--;
    while(1){
      cnt++;
      sort(str.begin(),str.end());
      S=str;
      reverse(str.begin(),str.end());
      L=str;
      l=Str2Int(L);
      s=Str2Int(S);
      cal=l-s;
      if(cal==6174){
	flag=1;
	break;
      }
      if(cal==0||cal==1111||cal==2222||cal==3333||cal==4444||cal==5555||cal==6666||cal==7777||cal==8888||cal==9999){
	break;
      }
      str=Int2Str(cal);
    }
    if(flag==1) cout << cnt << endl;
    else cout << "NA" << endl;
  }
  return 0;
}
string Int2Str(int n){
  int p;
  string ret;
  while(n){
    p=n%10;
    ret=(char)(p+'0')+ret;
    n/=10;
  }
  if(ret.size()!=4){
    while(ret.size()!=4){
      ret+='0';
    }
  }
  return ret;
}
int Str2Int(string str){
  int ret=0,i=0,x=1,len=4;
  while(len){
    ret=ret*x+(str[i]-'0');
    i++;
    x=10;
    len--;
  }
  return ret;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    vector<ll> B(N);
    rep(i, N) cin >> B.at(i);
    reverse(all(B));
    ll cnt = 0;
    vector<ll> freq(N+1, 0);
    rep(i, N){
      freq.at(A.at(i))++;
      freq.at(B.at(i))++;
    }
    rep(i, N+1){
      if(freq.at(i) > N){
        cout << "No" << endl;
        return 0;
      }
    }
    ll p = 0;
    rep(i, N){
      if(A.at(i) == B.at(i)){
        rep2(j, p, N){
          if(A.at(j) != B.at(i) && B.at(j) != B.at(i)){
            swap(B.at(i), B.at(j));
            p = j+1;
            break;
          }
        }
      }
    }
    cout << "Yes" << endl;
    rep(i, N-1){
      cout << B.at(i) << " ";
    }
    cout << B.at(N-1) << endl;
}

Measured memory_bytes: 7984
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;

void main() {
  auto s = readln.strip;
  auto cl = s.count!"a == 'x'";
  writeln (cl <= 7 ? "YES" : "NO");
}



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

int main() {
	int N;
	while (cin >> N) {
		if (N == 0) break;
		int A, COUNT = 0, MAX = 0, MIN = 10000;
		for (int i = 0; i < N; i++) {
			cin >> A;
			COUNT += A;
			MAX = max(MAX, A);
			MIN = min(MIN, A);
		}
		cout << (COUNT - MAX - MIN) / (N - 2) << endl;
	}
}


Measured memory_bytes: 3108
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define int ll

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

int a[200005];
int cnt[200005];
int ans[200005];
signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		cnt[a[i]]++;
	}
	ll s=0;
	for(int i=1;i<=200000;i++)  
		s+=(cnt[i]*cnt[i]-cnt[i])/2;
	for (int i=1;i<=200000;i++)  
		ans[i]=s-(cnt[i]-1);
	for(int i=0;i<n;i++)
	{
		cout<<ans[a[i]]<<endl;
	}
	return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    
    double fa, fb;
    fa = a;
    fb = b;
    
    int d, r;
    double f;
    d = a / b;
    r = a % b;
    f = fa / fb;
    
    // cout << d << " " << r << " " << f << endl;
    printf("%d %d %.8f\n", d, r, f);
    
    return 0;
}


Measured memory_bytes: 3212
function main(input) {
  input = input.split("\n");
  const N = input[1].split(" ");
  let problems = [];
  let problemCount = 0

  for(problemCount = 0; problemCount < N.length; problemCount++){
    problems[problemCount] = parseInt(N[problemCount], 10);
  }
  
  function compareFunc(a, b) {
    return a - b;
  }
  
  problems.sort(compareFunc);
  const ans = problems[N.length/2] - problems[N.length/2 - 1];
  
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 41624
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    int a,b,c;
    int h=0;
    scanf("%d %d %d",&a,&b,&c);
    while(1)
    {
        if(a%2 || b%2 || c%2)
        {
            break;
        }
        if((a==b && b==c) || h>100000)
        {
            puts("-1");
            return 0;
        }
        int f=a/2;
        int g=b/2;
        int o=c/2;
        a=g+o;
        b=f+o;
        c=f+g;
        h++;
    }
    printf("%d\n",h);
    return 0;
}


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



int main(){
	int a,b,c,k;
	cin >> a >> b >> c >> k;
	if(k<a) cout << k << endl;
	else{
		if(a+b >= k) cout << a << endl;
		else{
			cout << 2 * a + b - k << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3668
// 2008ツアツジツアツ地ツ凝ヲツ予ツ選G : Search of Concatenated Strings
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main(){
	int n, m;
	static bool dp[4096][5001];
	static bool occ[12][5000];
	while(cin >> n >> m, n){
		string s, t, p[12];
		for(int i=0;i<n;i++) cin >> p[i];
		for(int i=0;i<m;i++){
			cin >> t; 
			s += t;
		}
		memset(dp, false, sizeof(dp));
		for(int i=0;i<s.size();i++) dp[0][i] = true;
		memset(occ, false, sizeof(occ));
		for(int i=0;i<n;i++){
			int idx = s.find(p[i]);
			while(idx!=-1){
				occ[i][idx] = true;
				idx = s.find(p[i],idx+1);
			}
		}
		for(int i=0;i<s.size();i++){
			for(int S=0;S<(1<<n);S++){
				if(!dp[S][i]) continue;
				for(int k=0;k<n;k++){
					if(!occ[k][i]||(S&(1<<k))) continue;
					dp[S|(1<<k)][i+p[k].size()] = true;
				}
			}
		}
		int ans = 0;
		for(int i=0;i<s.size();i++)
			ans += dp[(1<<n)-1][i+1];
		printf("%d\n", ans);
	}
}

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

typedef long long lint;

int n, m, L, len[12];
string e[12], T;

bool match[12][5050], dp[5050][1<<12];

void solve() {
	memset(dp, 0, sizeof(dp));
	
	for (int i=0; i<n; ++i) {
		for (int j=0; j<=L-len[i]; ++j) {
			match[i][j] = true;
			for (int x=0; x<len[i]; ++x) match[i][j] &= (e[i][x] == T[j+x]);
			dp[j+len[i]][1<<i] = match[i][j];
		}
	}
	
	for (int i=0; i<L; ++i) for (int S=0; S<(1<<n); ++S) {
		if (!dp[i][S]) continue;
		for (int j=0; j<n; ++j) {
			if ((S>>j) & 1) continue;
			if (match[j][i]) dp[i+len[j]][S | (1<<j)] = true;
		}
	}
	
	int ans = 0;
	for (int i=0; i<=L; ++i) if (dp[i][(1<<n)-1]) ++ans;
	cout << ans << endl;
}

int main() {
	while (cin >> n >> m, n>0) {
		for (int i=0; i<n; ++i) {
			cin >> e[i];
			len[i] = e[i].size();
		}
		
		T = "";
		string str;
		for (int i=0; i<m; ++i) {
			cin >> str;
			T += str;
		}
		L = T.size();
				
		solve();
	}
}


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

int T;
long long a,b,c,d,x,y;

long long gcd(long long a,long long b)
{
	if(a%b==0)return b;
	return gcd(b,a%b);
}

int main()
{
	cin>>T;
	while(T--)
	{
		cin>>a>>b>>c>>d;
		if(d<b||a<b)
			printf("No\n");
		else
			if(c>=b)
    			printf("Yes\n");
    		else
    		{
    			a=a%b;
    			if(a>c)
    			{
    				printf("No\n");
    				continue;
    			}
    			x=gcd(b,d);
    			a+=(c-a)/x*x;
    			while(a<=c)a+=x;
    			if(a>=b)printf("Yes\n");
    			else printf("No\n");
    		}
    	//cerr<<b<<" "<<d<<" "<<gcd(b,d)<<endl;
		/*if(c>=b)
		{
			printf("Yes\n");
			continue;
		}
		a%=b;*/
		
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>

const int mod = 1e9 + 7;

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> primes(n + 1, true);
    for(int i = 2; i <= n; i++) {
        if(primes[i]) {
            for(int j = i * i; j <= n; j += i) {
                primes[j] = false;
            }
        }
    }
    vector<pii> freq;
    for(int i = 2; i <= n; i++) {
        if(!primes[i]) continue;
        freq.push_back({i, 0});
        int x = n;
        while(x > 0) {
            freq.back().se += x / i;
            x /= i;
        }
    }
    int ans = 1;
    for(auto &el : freq) {
        ans *= el.se + 1;
        ans %= mod;
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

const int MAXN = 105;
int N, T;
int c[MAXN], t[MAXN];
int ans = 9999;

int main()
{
	scanf("%d %d", &N, &T);
	for(int i = 1;i <= N; i++)
	{
		scanf("%d %d", &c[i], &t[i]);
		if(t[i] <= T && c[i] < ans) ans = c[i];
	}
	if(ans == 9999) printf("TLE");
	else printf("%d", ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main{

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter wr = new PrintWriter(System.out);
        String str = br.readLine().trim();
        
        int A = Integer.parseInt(str);
        str = br.readLine().trim();
        int B = Integer.parseInt(str);
        str = br.readLine().trim();
        int C = Integer.parseInt(str);
        str = br.readLine().trim();
        int D = Integer.parseInt(str);
        System.out.println(Math.min(A, B)+Math.min(C,D));

	}

}


Measured memory_bytes: 21332
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	s := r.nextString()
	a := map[string]string{}
	a["Sunny"] = "Cloudy"
	a["Cloudy"] = "Rainy"
	a["Rainy"] = "Sunny"
	fmt.Fprintln(stdout, a[s])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    REP(i, n)cin >> a[i];
    
    sort(ALL(a), greater<int>());
    ll ans = a[0];

    ll i = 1;
    ll remaining = n-2;

    while (remaining > 0){
        if (remaining == 1) {ans += a[i]; break;}
        ans += a[i]*2;
        i++;
        remaining -= 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4836
#include <iostream>
#define INF (1<<21)
using namespace std;

int main(){
  int i,j,k,n,m,s,g1,g2,d[101][101],ans;
  while(1){
    cin >> n >> m >> s >> g1 >> g2;
    if(!n && !m && !s && !g1 && !g2) break;

    for(i=0;i<=n;i++){
      for(j=0;j<=n;j++){
	if(i == j) d[i][j] = 0;
	else d[i][j] = INF;
      }
    }

    for(j=0;j<m;j++){
      int a,b,cost;
      cin >> a >> b >> cost;
      d[a][b] = cost;
    }

    for(k=0;k<=n;k++){
      for(i=0;i<=n;i++){
	for(j=0;j<=n;j++){
	  if(d[i][k] >= INF || d[k][j] >= INF) continue;
	  d[i][j] = min(d[i][j],d[i][k] + d[k][j]);
	}
      }
    }

   int ans = INF;
   for(i=1;i<=n;i++){
       ans = min(ans,d[s][i]+d[i][g1]+d[i][g2]);
   }

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 904
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

const ll MOD = 1e9 + 7;


int main() {

  string S;
  cin >> S;

  int N = S.size();
  vector<vector<ll>> dp(N + 1, vector<ll>(13, 0));
  dp[0][0] = 1;

  REP(i, N){
    if (S[i] == '?')REP(j, 13)REP(tmp, 10){
      dp[i + 1][(j * 10 + tmp) % 13] += dp[i][j];
    }else{
      int tmp = S[i] - '0';
      REP(j, 13){
        dp[i + 1][(j * 10 + tmp) % 13] += dp[i][j];
      }
    }
    REP(j, 13) dp[i + 1][j] %= MOD;
  }

  cout << dp[N][5] << endl;



  return 0;
}


Measured memory_bytes: 13696
n,T=map(int,input().split())
a=list(map(int,input().split()))
b=[0]*n
mn=10**18
for i in range(1,n):
  mn=min(mn,a[i-1])
  b[i]=a[i]-mn
# print(b)
from collections import Counter
c=Counter(b)
ans=0
for k,v in sorted(c.items(),reverse=1):
  ans+=v
  break
print(ans)

Measured memory_bytes: 29828
#include <stdio.h>
#include <stdlib.h>

int main() {
  int a_kun, b_kun, c_kun, distance;
  scanf("%d %d %d %d", &a_kun, &b_kun, &c_kun, &distance);
  if(abs(a_kun - c_kun) <= distance || abs(a_kun - b_kun) <= distance && abs(b_kun - c_kun) <= distance) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 2;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const ld PI = acos(-1.0);
const ld EPS = 1e-11;

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#pragma endregion

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
  ll n;
  cin >> n;
  if (n == 2)
  {
    cout << 1 << endl;
    return 0;
  }
  ll ans = 0;
  for (ll k = 1; k * k <= n; k++)
  {
    if (n % k != 0)
      continue;
    if (k != 1)
    {
      ll t = n;
      while (t % k == 0)
      {
        t /= k;
      }
      if (t % k == 1)
        ans++;
    }
    ll k2 = n / k;
    if (k2 != 1 && k2 * k2 != n)
    {
      ll t = n;
      while (t % k2 == 0)
      {
        t /= k2;
      }
      if (t % k2 == 1)
        ans++;
    }
  }
  for (ll k = 1; k * k <= n - 1; k++)
  {
    if ((n - 1) % k != 0)
      continue;
    if (k != 1)
    {
      if (n % k == 1)
        ans++;
    }
    ll k2 = (n - 1) / k;
    if (k2 != 1 && k2 * k2 != n - 1)
    {
      if (n % k2 == 1)
        ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
require 'prime'
io = STDIN
n=io.gets.to_i
pd=n.prime_division
def calc(j)
  i=1
  cnt=0
  while j-i>=0
    j-=i
    cnt+=1
    i+=1
  end
  cnt
end
p pd.map { |i,j|calc(j)}.sum


Measured memory_bytes: 14488
#include<stdio.h>

int right(int top,int front,int arr[7]){

	int dice[8][3] = { {arr[1],arr[2],arr[3]},{arr[1],arr[5],arr[4]},{arr[1],arr[4],arr[2]},{arr[1],arr[3],arr[5]},{arr[2],arr[4],arr[6]},{arr[3],arr[6],arr[5]},{arr[4],arr[5],arr[6]},{arr[3],arr[2],arr[6]}};


	for(int i=0;i<8;i++){
		if(dice[i][0] == top && dice[i][1] == front)
		return dice[i][2];
		if(dice[i][1] == top && dice[i][2] == front)
		return dice[i][0];
		if(dice[i][2] == top && dice[i][0] == front)
		return dice[i][1];
	}
return 0;
}

int main(){

int dice1[7] = {0};
int dice2[7] = {0};

for(int i=1;i<7;i++){
	scanf("%d",&dice1[i]);
}
for(int i=1;i<7;i++){
	scanf("%d",&dice2[i]);
}

int temp[6][2] = { {dice1[1],dice1[6]},{dice1[6],dice1[1]},{dice1[2],dice1[5]},{dice1[5],dice1[2]},{dice1[3],dice1[4]},{dice1[4],dice1[3]} };

int top = dice2[1];
int front = dice2[2];

int new1[7] = {0};
int right1 = right(top,front,dice1);

for(int i=0;i<6;i++){
	if(dice2[1] == temp[i][0]){
		new1[1] = temp[i][0];
		new1[6] = temp[i][1];
	}
	if(dice2[2] == temp[i][0]){
		new1[2] = temp[i][0];
		new1[5] = temp[i][1];
	}
	if(right1 == temp[i][0]){
		new1[3] = temp[i][0];
		new1[4] = temp[i][1];
	}
}

int count = 0;

for(int i=1;i<7;i++){
	if(new1[i] != dice2[i]){
		count++;
		break;
	}
}

if(count==0)
printf("Yes\n");
else
printf("No\n");





	return 0;
}


Measured memory_bytes: 2112
#include <iostream>

int main()
{
	int n, q;
	std::cin >> n;
	int *A = new int[n];
	for (int i=0; i<n; i++) std::cin >> A[i];
	
	int sum = 0;
	for (int i=0; i<n; i++) sum += A[i];
	
	bool* DP = new bool[sum+1];
	for (int i=0; i<=sum; i++) DP[i] = false;
	
	DP[0] = true;
	for (int i=0; i<n; i++) {
		for (int j=sum; j>=0; j--) {
			if (DP[j]) DP[j+A[i]] = true;
		}
	}
	
	std::cin >> q;
	for (int i=0; i<q; i++) {
		int m;
		std::cin >> m;
		if (m <= sum && DP[m]) std::cout << "yes" << std::endl;
		else std::cout << "no" << std::endl;
	}
	
	
	return 0;
}




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

int b, r, g, c, s, t;

int main()
{
	while (cin >> b >> r >> g >> c >> s >> t, b | r | g | c | s | t){
		int res = 100;
		res += 15 * b + 15 * r + 7 * g + 2 * c;
		res -= 3 * t;
		res += 3 * s;
		res += (15 + 1) * 5 * b;
		res += (15 + 1) * 3 * r;
		cout << res << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,W;
  cin>>N>>W;
  long long int v[N];
  int w[N];
  //map<int,long long int> mp;
  for(int i=0;i<N;i++){
    cin>>w[i]>>v[i];
    //mp[w[i]]=v[i];
  }
  long long int T[N+1][W+1];
  for(int j=0;j<=N;j++){
    T[j][0]=0;
  }
  for(int i=1;i<=W;i++)
    T[0][i]=0;
  //sort(w,w+N);
  for(int i=1;i<=N;i++){
    for(int j=1;j<=W;j++){
    if(j<w[i-1])
       T[i][j]=T[i-1][j];
       else 
       T[i][j]=max(T[i-1][j],(v[i-1]+T[i-1][j-w[i-1]]));
    }
  }
       cout<<T[N][W];
       return 0;
}


Measured memory_bytes: 79104
import math
A, B, H, M = map(int, input().split())
s = H*3600 + M*60

HH = math.pi*s/21600
MM = math.pi*s/1800

degH = math.degrees(HH)
degM = math.degrees(MM)

if degH > degM:
    X = degH - degM
elif degH == degM:
    X = 0
else:
    X = degM - degH
if X > 180:
    X = 360 - X
cos = math.cos(math.radians(X))
ans = (A**2) + (B**2) - (2*A*B*cos)
print(math.sqrt(ans))


Measured memory_bytes: 9392
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
using namespace std; 
#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 {
#ifdef LOCAL
~debug() { cerr << endl; }
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
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int MOD = 1e9 + 7;
bool cmp(const pair<int,int>&a , const pair<int,int>&b){
  if(a.second != b.second) return a.second < b.second;
  return a.first < b.first;
}
signed main(){
  ios::sync_with_stdio(false);cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int,int>>vp;
  for(int i=0;i<n;i++){
    int x, y;
    cin >> x >> y;
    vp.emplace_back(x,y);
  }
  sort(vp.begin() , vp.end() , cmp);

 // for(auto i : vp) cout << i.first <<" "<<i.second<<'\n';

  int sum = 0;
  for(auto i : vp){
    sum += i.first;
    if(sum > i.second){
      cout << "No" << '\n';
      return 0;
    }
  }
  cout <<"Yes" << '\n';
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
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; }
using namespace std;

//ABC136
signed main(void){

    //総和の約数
    int n, k; cin >> n >> k;
    vector<int> a(n);
    int sum = 0;
    rep(i, n){
        cin >> a[i];
        sum += a[i];
    }

    auto can  = [&](int t){
        vector<int> x(n), y(n);
        int cnt = 0;
        rep(i, n){
            x[i] = a[i] % t;
            y[i] = t - x[i];
            cnt += x[i];
        }
        if(cnt % t != 0)return false;
        int num = cnt / t;
        sort(all(y));
        int tmp = 0;
        rep(i, num)tmp += y[i];
        return tmp <= k;
    };

    int ans = 0;
    for(int i = 1; i * i <= sum; i++){
        if(sum % i == 0){
            if(can(i))chmax(ans, i);
            if(can(sum / i))chmax(ans, sum / i);
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import math

a, b, x = map(float, input().split())
x = math.radians(x)
S = 0.5 * a * b * math.sin(x)
h = b * math.sin(x)
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(x))
L = a + b + c
print(S)
print(L)
print(h)

Measured memory_bytes: 7684
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>

using namespace std;

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i<n;i++)
#define fod(i,n) for(i=n-1;i>=0;i--)
#define MAX std::numeric_limits<lld>::max();
#define MIN std::numeric_limits<lld>::min();
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main (){
    FastIO
    lld n, i;
    cin >> n;
    lld q, r;
    lld s;
    q =n/500;
    r =n%500;
    s =r / 5;
    cout << (q*1000)+(s*5) << "\n";
    return 0;
}

Measured memory_bytes: 256
s = gets.to_i
@memo = Hash.new(0)

def func(n,i)
    return i if @memo[n] == 2
    if i == 0
        @memo[n]=1
        return func(n,i+1) 
    end

    if n.even?
        n = n/2
    elsif n.odd?
        n = (3*n)+1
    end
    return func(n,i+1) if @memo[n] += 1
    return @memo[n] = func(n,i+1)
end

puts func(s,0)

Measured memory_bytes: 1916
#include<stdio.h>

int main(void) {
	int a, b;

	scanf("%d %d", &a, &b);

	if (a < b)
		printf("a < b\n");
	else if (a > b)
		printf("a > b\n");
	else
		printf("a == b\n");

	return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<stack>
#include<map>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

bool find_child(int my,vector<int> &child,int tar){
  rep(i,child.size()){
    if (  child[i]==tar)return true;
  }
  return false;
}

bool find_descendant(int my,vector<int> *edge,int tar){
  if ( my == tar)return true;
  rep(i,edge[my].size() ){
    if ( find_descendant(edge[my][i],edge,tar) )return true;
  }

  return false;
}

void solve(int n,int q,map<string,int>&M,vector<int> *edge,vector<int> &p){
  rep(i,q){
    string a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    f.erase(f.size()-1);
    int x = M[a],y=M[f];
    bool flag=false;
    if ( d == "child"){
      flag=find_child(y,edge[y],x);
    }else if ( d == "parent"){
      flag=find_child(x,edge[x],y);
    }else if (d == "sibling"){
      flag = find_child(p[x],edge[p[x]],y);
    }else if ( d == "descendant"){
      flag = find_descendant(y,edge,x);
    }else if ( d == "ancestor"){
      flag = find_descendant(x,edge,y);
    }
    if ( flag)puts("True");
    else puts("False");
  }
  puts("");
  return;
}

#define DUMMYNODE 0

main(){
  int n,q;

  while(cin>>n>>q && n){
    string t;getline(cin,t);
    vector<int> p;p.push_back(-1);
    vector<int> edge[n+1];
    map<string,int>M;
    stack<int> Parent;
    stack<int> Blank;

    getline(cin,t);M[t]=1;Parent.push(M[t]);Blank.push(0);
    p.push_back(0);

    REP(i,2,n+1){
      getline(cin,t);
      int cnt=0;
      rep(j,t.size())if ( t[j]==' ')cnt++;else break;
      string ins=t.substr(cnt);M[ins]=i;

      while(!Blank.empty() && cnt <=Blank.top()){
	Blank.pop();Parent.pop();
      }
      p.push_back(Parent.top());
      edge[Parent.top()].push_back(i);
      
      Parent.push(i);
      Blank.push(cnt);
    }

    /*
    puts("DEBUG");
    for(int i=1;i<=n;i++){
      cout <<i << " parent is " << p[i] << endl;
      cout << "childlen is " ;
      rep(j,edge[i].size())cout << edge[i][j]<< " ";
      cout << endl;
    }
    puts("DEBUGEND");
    */
    solve(n,q,M,edge,p);
  }
  return false;
}

Measured memory_bytes: 1008
s=input()
n=len(s)

iRL=[0]
for i in range(0,n-1):
    if s[i:i+2]=="LR":
        iRL.append(i+1)
iRL.append(n)

sRL=[s[iRL[i]:iRL[i+1]] for i in range(len(iRL)-1)]

ans=[]
for ss in sRL:
    l=len(ss)
    nR=ss.count("R")
    nL=l-nR
    ans0 = [0]*l
    ans0[nR-1] = (nR+1)//2 + nL//2
    ans0[nR]   = (nL+1)//2 + nR//2
    ans.extend(ans0)

print(*ans)

Measured memory_bytes: 52720
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  string s, t;
  int a[30], b[30];
  bool f=true;
  vector<int> v, w;
  cin >> s >> t;
  for(int i=0;i<30;i++){
    a[i]=0;
    b[i]=0;
  }
  for(int i=0;i<s.length();i++)
    a[s[i]-'a']++;
  for(int i=0;i<t.length();i++)
    b[t[i]-'a']++;
  for(int i=0;i<27;i++){
    v.push_back(a[i]);
    w.push_back(b[i]);
  }
  sort(v.begin(),v.end());
  sort(w.begin(),w.end());
  for(int i=0;i<27;i++){
    if(v[i]!=w[i]){
      f=false;
      break;
    }
  }
  if(f)puts("Yes");
  else puts("No");
  return 0;
}


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

int main() {
  float A ,B;
  cin >> A >> B;
  B -= 1;
  cout << ceil(B/(A-1));
  return 0;
}


Measured memory_bytes: 256
k = 72
K = 1<<k
nu = lambda L: int("".join([bin(K+a)[-k:] for a in L[::-1]]), 2)
st = lambda n: bin(n)[2:] + "0"
li = lambda s, l: [int(a, 2) if len(a) else 0 for a in [s[-(i+1)*k-1:-i*k-1] for i in range(l)]]

def grow(d, v, h):
    h += [0] * d
    f = [(-1 if (i+d) % 2 else 1) * fainv[i] * fainv[d-i] % P * h[i] % P for i in range(d+1)]
    
    for idx, a in enumerate([d+1, d * fa[v-1] * fainv[v] % P, (d * fa[v-1] * fainv[v] + d + 1) % P]):
        g = [pow(a - d + i - 1, P-2, P) if i else 0 for i in range(2*d+2)]
        fg = li(st(nu(f) * nu(g)), d * 8 - 1)
        p = 1
        for i in range(d+1):
            p = p * (a-i) % P
        for i in range(d+1):
            fg[d+i+1] = fg[d+i+1] * p % P
            p = p * (a+i+1) % P * pow(a-d+i, P-2, P) % P
        if idx == 1:
            for i in range(d+1):
                h[i] = h[i] * fg[d+i+1] % P
        elif idx == 0:
            for i in range(d):
                h[i+d+1] = fg[d+i+1]
        elif idx == 2:
            for i in range(d):
                h[i+d+1] = h[i+d+1] * fg[d+i+1] % P
    return h

# Create a table of the factorial of the first v+2 multiples of v, i.e., [0!, v!, 2v!, ..., (v(v+1))!]
def create_table(v):
    s = 1
    X = [1, v+1]
    while s < v:
        X = grow(s, v, X)
        s *= 2
    table = [1]
    for x in X:
        table.append(table[-1] * x % P)
    return table

def fact(i, table):
    a = table[i//v]
    for j in range(i//v*v+1, i+1):
        a = a * j % P
    return a

P = 10**9+7
v = 1 << 11
fa = [1] * (2*v+2)
fainv = [1] * (2*v+2)
for i in range(2*v+1):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(2*v+1)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P

T = create_table(v)

f = lambda a, b: fact(a+b+2, T) * pow(fact(a+1, T) * fact(b+1, T), P-2, P) % P
r1, c1, r2, c2 = map(int, input().split())
print((f(r2, c2) - f(r2, c1-1) - f(r1-1, c2) + f(r1-1, c1-1)) % P)

Measured memory_bytes: 5004
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	char s, ok[5] = {'a', 'i', 'u', 'e', 'o'};
	cin >> s;
	bool flag = false;
	REP(i, 5){
		if(s == ok[i]){
			flag = true;
		}
	}

	if(flag){
		cout << "vowel" << endl;
	}else{
		cout << "consonant" << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
template<class T, class S> int KMP(T A[], int As, T B[], int Bs, S res[], int mem[]){
  int c=0, *f=(int*)mem, i, k;
  k=f[0]=-1;
  for(i=0;i<Bs;i++){
    while(k>=0&&B[k]!=B[i]){
      k=f[k];
    }
    f[i+1]=++k;
  }
  if(res!=NULL){
    for(i=0;i<As-Bs+1;i++){
      res[i]=0;
    }
  }
  k=0;
  for(i=0;i<As;i++){
    while(k>=0&&B[k]!=A[i]){
      k=f[k];
    }
    if(++k==Bs){
      c++;
      if(res!=NULL){
        res[i-Bs+1]=1;
      }
      k=f[k];
    }
  }
  return c;
}
int As;
int Bs;
char A[5000002];
char B[5000002];
int res[5000001];
int dp[5000001];
int failA[5000001];
int failB[5000001];
int main(){
  int Ap, Bp, i, j, k, mx;
  As = rd(A);
  Bs = rd(B);
  KMP(B, Bs, A, As, res, failA);
  KMP(A, As, B, Bs, res, failB);
  Ap = As - failA[As];
  if(As % Ap){
    Ap = As;
  }
  Bp = Bs - failB[Bs];
  if(Bs % Bp){
    Bp = Bs;
  }
  k = 4000000 / As * As;
  for(i=As;i<k;i++){
    A[i] = A[i-As];
  }
  KMP(A, k, B, Bs, res, failB);
  mx = 0;
  for(i=0;i<k;i++){
    dp[i] = 0;
    if(res[i]){
      dp[i]++;
      if(i-Bs >= 0){
        dp[i] += dp[i-Bs];
      }
    }
    chmax(mx, dp[i]);
  }
  if( (long long)mx * Bs > 2000000 ){
    mx = -1;
  }
  wt_L(mx);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// template<class T, class S> int KMP(T A[], int As, T B[], int Bs, S res[], int mem[]){int i,k,c=0,*f=(int*)mem;k=f[0]=-1;rep(i,Bs){while(k>=0&&B[k]!=B[i])k=f[k];f[i+1]=++k;}if(res!=NULL)rep(i,As-Bs+1)res[i]=0;k=0;rep(i,As){while(k>=0&&B[k]!=A[i])k=f[k];if(++k==Bs){c++;if(res!=NULL)res[i-Bs+1]=1;k=f[k];}}return c;}
// 
// int As, Bs;
// char A[5000002], B[5000002];
// 
// int res[5000001], dp[5000001];
// int failA[5000001], failB[5000001];
// 
// {
//   int i, j, k, mx;
//   int Ap, Bp;
//   
//   rd(A@As, B@Bs);
//   
//   KMP(B, Bs, A, As, res, failA);
//   KMP(A, As, B, Bs, res, failB);
// 
//   Ap = As - failA[As]; if(As % Ap) Ap = As;
//   Bp = Bs - failB[Bs]; if(Bs % Bp) Bp = Bs;
// 
//   k = 4d6 / As * As;
//   rep(i,As,k) A[i] = A[i-As];
//   KMP(A, k, B, Bs, res, failB);
// 
//   mx = 0;
//   rep(i,k){
//     dp[i] = 0;
//     if(res[i]){
//       dp[i]++;
//       if(i-Bs >= 0) dp[i] += dp[i-Bs];
//     }
//     mx >?= dp[i];
//   }
// 
//   if( (ll)mx * Bs > 2d6 ) mx = -1;
//   wt(mx);
// }


Measured memory_bytes: 46208
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int n;cin>>n;
  pr(n*n*n);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> A(n);

    for (int i = 0; i < n; i++)
    {
        cin >> A.at(i);
    }
    vector<int>::iterator uni = unique(A.begin(), A.end());
    for (vector<int>::iterator it = A.begin(); it != uni - 1; it++)
    {
        cout << *it << ' ';
    }
    // A.erase(unique(A.begin(), A.end()), A.end());
    // for (i = 0; i < (A.size() - 1); i++)
    // {
    //     cout << A.at(i) << ' ';
    // }
    cout << A.back() << endl;
}


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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N; cin >> N;
  vector<double> x(N), y(N);
  for (int i = 0; i < N; i++) cin >> x.at(i) >> y.at(i);
  double t = 0.0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      double xd = x.at(i) - x.at(j);
      double yd = y.at(i) - y.at(j);
      double d = sqrt(xd*xd + yd*yd);
      t += d;
    }
  }
  cout << t * 2 / N << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 using namespace std;
#define INF 1000000000
#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
typedef long long LL;
int N;
LL A[200001];
typedef pair<int,int>P;
P p[200001];

bool check(LL x){
	p[0]=P(1,A[0]);
	LL now=0;
	for(int i=1;i<N;i++){
		if(A[i]-A[i-1]>0){
			if(p[now].first==1){
				p[now].second=p[now].second+(A[i]-A[i-1]);
			}else{
				now++;
				p[now]=P(1,A[i]-A[i-1]);
			}
		}else{
			int B=A[i-1]-A[i];
			while(B!=0){
				if(p[now].second==B){
					B-=p[now].second;
					now--;
				}else if(p[now].second<B){
					B-=p[now].second;
					now--;
				}else{
					p[now].second-=B;
					B=0;
				}
			}
			LL AA=0;
			if(p[now].first==x){
				if(now==0)return false;
				AA=p[now].second;
				if((p[now-1].second==1)&&(now!=1)&&(p[now-1].first+1==p[now-2].first)){
					now-=2;
					p[now].second+=1;
				}else{
					if(p[now-1].second==1){
						now-=1;
						p[now].first=p[now].first+1;
					}else{
						now-=1;
						p[now].second-=1;
						now++;
						p[now]=P(p[now-1].first+1,1);
					}
				}
				
				now++;
				p[now]=P(1,AA);
			}else{
				if((p[now].second==1)&&(now!=0)&&(p[now].first+1==p[now-1].first)){
					now-=1;
					p[now].second+=1;
				}else{
					if(p[now].second==1){
						p[now].first=p[now].first+1;
					}else{
						p[now].second-=1;
						now++;
						p[now]=P(p[now-1].first+1,1);
					}
				}
			}
		}
	}
	return true;
}

int main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	LL lb=0;
	LL ub=1e9;
	while(ub-lb>1){
		LL mid=(ub+lb)/2;
		if(check(mid)){
			ub=mid;
		}else{
			lb=mid;
		}
	}
	cout<<ub<<endl;
	
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
all = []
nums = [3,5,7]
for i in range(8):
    tmp = []
    for n in nums:
        tmp.append(n*10+3)
        tmp.append(n*10+5)
        tmp.append(n*10+7)
    all += nums
    nums = tmp
all += nums
all.sort()
ans = 0
for a in all:
    if a > N:
        break
    if '3' in str(a) and '5' in str(a) and '7' in str(a):
        ans += 1
print(ans)

Measured memory_bytes: 39920
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <typeinfo>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(){
    vector< pair<ll, ll> > vp(0);
    ll h, w, n;
    cin >> h >> w;
    cin >> n;

    for(int i=0;i<n;i++) {
        ll ai, bi;
        cin >> ai >> bi;
        for(int k = 0;k<3;k++) {
            for(int l = 0;l<3;l++) {
                if((ai-k) >= 1 && (ai-k) <= h-2 && (bi-l) >= 1 && (bi-l) <= w-2) {
                    vp.push_back(make_pair((ai-k), (bi-l)));
                }
            }
        }
    }

    sort(vp.begin(), vp.end());
    ll tot = 0;
    int cnt = 1;
    vector<ll> ans(10, 0);
    //cout << "type : " << typeid(vp.size()).name() << endl;
    for(int i=0;i<int(vp.size())-1;i++) {
        if(vp[i] == vp[i+1]) {
            cnt++;
        }
        else {
            ans[cnt]++;
            cnt = 1;
            tot++;
        }
        if(i == vp.size()-2) {
            ans[cnt]++;
            tot++;
        }
    }
    ans[0] = (h-2) * (w-2) - tot;
    for(int i=0;i<10;i++) {
        cout << ans[i] << endl;
    }
}


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

const int n = 1000000000;
signed main(void)
{
	long long s, x, y;

	cin >> s;
	y = s / n;
	if (s % n != 0) y++;
	x = n * y - s;
	printf("0 0 1000000000 1 %lld %lld\n", x, y);
	return 0;
}


Measured memory_bytes: 256
import sys
H, W = map(int, input().split())
s = []
s.append('.' * (W + 2))
for i in range(1, H + 1):
    a = input()
    a = '.' + a + '.'
    s.append(a)
s.append('.' * (W + 2))
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if s[i][j] == '#':
            OK = False
            if s[i - 1][j] == '#' or s[i + 1][j] == '#' or s[i][j - 1] == '#' or s[i][j + 1] == '#':
                OK = True
            if OK == False:
                print('No')
                sys.exit()
print('Yes')

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

int main() {
  string s;
  cin>>s;
  int count=700;
  if(s[1]=='o') count+=100;
  if(s[0]=='o') count+=100;
  if(s[2]=='o') count+=100;
  cout<<count<<endl;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    sort(a, a + n);
    ll num_max = a[n - 1];
    bool memo[num_max + 1] = {};
    ll count = 0;
    rep(i, n) {
        ll num = a[i];
        if (memo[num]) {
            continue;
        }
        if (i != n - 1 && num == a[i + 1]) {
            // pass
        } else {
            count++;
        }
        ll index = num;
        while (index < num_max + 1) {
            memo[index] = true;
            index += num;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 5956
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,n,sum=0;
  int a[1000005];
  cin>>h>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  if(sum<h){
    cout<<"No"<<"\n";
  }else{
    cout<<"Yes"<<"\n";
  }
  return(0);
}


Measured memory_bytes: 640