akhauriyash/Code-Regression huggingface dataset:
/*
 *
 ********************************************************************************************
 * AUTHOR : Vijju123                                                                        *
 * Language: C++14                                                                          *
 * Purpose: -                                                                               *
 * IDE used: Codechef IDE.                                                                  *
 ********************************************************************************************
 *
 Comments will be included in practice problems if it helps ^^
 */



#include <iostream>
#include<bits/stdc++.h>
using namespace std;

int mod=pow(10,9)+7;
int fastExpo(long long a,long long n, int mod)
{
    a%=mod;
    if(n==2)return a*a%mod;
    if(n==1)return a;
    if(n&1)return a*fastExpo(fastExpo(a,n>>1,mod),2,mod)%mod;
    else return fastExpo(fastExpo(a,n>>1,mod),2,mod);
}
inline void add(vector<vector<int> > &a,vector<vector<int> > &b,int mod)
{
    for(int i=0;i<a.size();i++)for(int j=0;j<a[0].size();j++)b[i][j]=(b[i][j]+a[i][j])%mod;
}

void multiply(vector<vector<int> > &a, vector<vector<int> > &b,int mod,vector<vector<int> > &temp)
{
    assert(a[0].size()==b.size());
    int i,j;
    for(i=0;i<a.size();i++)
    {
        for(j=0;j<b[0].size();j++)
        {
            temp[i][j]=0;
            for(int p=0;p<a[0].size();p++)
            {
                temp[i][j]=(temp[i][j]+1LL*a[i][p]*b[p][j])%mod;
            }
        }
    }
}

void MatExpo(vector<vector<int> > &arr,int power,int mod)
{
    int i,j,k;
    vector<vector<int> >temp,temp2,temp3;
    vector<int> init(arr[0].size());
    for(i=0;i<arr.size();i++){temp.push_back(init);}
    temp3=temp;
    temp2=temp;
    for(i=0;i<arr.size();i++)temp3[i][i]=1;
    while(power>0)
    {
        if(power&1)
        {
            multiply(arr,temp3,mod,temp);
            swap(temp3,temp);
        }
        multiply(arr,arr,mod,temp2);
        swap(arr,temp2);
        power>>=1;
    }
    swap(arr,temp3);
}

vector<int> primes;
int isComposite[1000001]={1,1};
void sieve()
{
    int i,j;
    for(i=2;i<=1000000;i++)
    {
        if(!isComposite[i])
        {
            primes.push_back(i);
            isComposite[i]=i;
        }
        for(j=0;j<primes.size() and i*primes[j]<=1000000;j++)
        {
            isComposite[primes[j]*i]=i;
            if(i%primes[j]==0)break;
        }
    }
}

int main() {
	// your code goes here
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	srand(time(NULL));
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n,i,j,k;
	cin>>n;
	int dp[n],arr[n];
	memset(dp,0,sizeof(dp));
	for(i=0;i<n;i++)cin>>arr[i];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(i=2;i<n;i++)
	{
	    dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i-2]-arr[i]));
	}
	cout<<dp[n-1]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{
    int N;
    cin >> N;
    string S,T;
    cin >> S>> T;
    rep(i,N) {
        cout << S[i] << T[i];
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 * @author kep
 * @date 2019-10-17
 */
public class Main {

    private static int[] vis = new int[100005];
    private static long[] sum = new long[100005];
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n = scanner.nextLong();
        long x = scanner.nextLong();
        long mod = scanner.nextLong();
        long ans = 0;
        int index = 1;
        int startIndex = -1;
        for(;index<=n;index++){
            if(vis[(int)x] != 0){
                startIndex = vis[(int)x];
                break;
            }
            vis[(int)x] = index;
            sum[index] = sum[index-1]+x;
            ans += x;
            x = (x*x)%mod;
        }
        if(n >= index){
            n = n - index + 1;
            ans = ans + (n/(index-startIndex))*(sum[index-1]-sum[startIndex-1]);
            if(n%(index-startIndex) != 0){
                int xx = (int)(n%(index-startIndex));
                ans = ans + sum[startIndex+xx-1] -sum[startIndex-1];
            }
        }
        System.out.println(ans);
    }



}


Measured memory_bytes: 36988
#include <cstdio>
#include <queue>
#include <map>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;

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

int r,w1,w2,h1,h2,x1,x2,y1,y2;


int k1[503][503];

int k2[503][503];

bool f1[503][503];

bool f2[503][503];



int main(){

  while(1){

  scanf("%d",&r);

  if(r == 0) break;
scanf("%d%d%d%d",&w1,&h1,&x1,&y1);

  for(int i = 1;i <= h1;i++){
    for(int j = 1;j <= w1;j++){
      scanf("%d",&k1[i][j]);
      f1[i][j] = true;
    }
  }

  scanf("%d%d%d%d",&w2,&h2,&x2,&y2);

  for(int i = 1;i <= h2;i++){
    for(int j = 1;j <= w2;j++){
      scanf("%d",&k2[i][j]);
      f2[i][j] = true;
    }
  }



  priority_queue< P, vector<P> , greater<P> > que;

  que.push(P(1,w1*(y1-1)+x1));

  f1[y1][x1] = false;

  map<int,int> m;

  int nl = 0,ko = 0;

  vector<int> hea;

  vector<int>::iterator it;



  while(!que.empty()){


    P tmp = que.top();
    que.pop();

    int fir = tmp.first;
    int sec = tmp.second;

    int xx = sec % w1;
    if(xx == 0) xx = w1;
    int yy = (sec / w1) + 1;
    f1 [yy][xx] = false; 

    for(int i = 0;i < 4;i++){
      int nx = dx[i] + xx;
      int ny = dy[i] + yy;

      if(nx >= 1 && nx <= w1 && ny >= 1 && ny <= h1 && f1[ny][nx] == true){
	que.push(P(k1[ny][nx],w1*(ny-1)+nx));
	f1[ny][nx] = false;
      }
    }

    if(nl < fir){
      hea.push_back(ko);
      m[ko] = nl;


      nl =max(nl,fir);
    }
    ko++;

  }
  hea.push_back(ko);
  m[ko] = nl;
 sort(hea.begin(),hea.end());



 que.push(P(1,w2*(y2-1)+x2));

 it = lower_bound(hea.begin(),hea.end(),r);


 int tuka = *it;

 int ans = m[tuka];
 if(ans == 0) ans = 1000000;


 f2[y2][x2] = false;

 int nau = 0;

 nl = 0;

 while(!que.empty()){

   P  tmp = que.top(); que.pop();

   int   fir = tmp.first;
   int  sec = tmp.second;

   int   xx = sec % w2;
    if(xx == 0) xx = w2;
    int   yy = (sec / w2);
    if(sec % w2 != 0) yy++;
    f2[yy][xx] = false; 

    for(int i = 0;i < 4;i++){
      int nx = dx[i] + xx;
      int ny = dy[i] + yy;

      if(nx >= 1 && nx <= w2 && ny >= 1 && ny <= h2 && f2[ny][nx] == true){
	que.push(P(k2[ny][nx],w2*(ny-1)+nx));
	f2[ny][nx] = false;
      }

    }




   if(nau >= r){
     ans = min(ans,nl);

     break;

   }
   if(nl != fir){
   int ttt = r - nau;

   it = lower_bound(hea.begin(),hea.end(),ttt);

   int sea = *it;

   int kari = m[sea];

   if(kari != 0){

   ans = min(ans,kari+nl);

   }

   nl = max(fir,nl);

   }

   nau++;
 
 }

 printf("%d\n",ans);

  }
 return 0;

}


Measured memory_bytes: 9340
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node { int p, l, r;} ;

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i, c;
  cout << "node " << u << ": ";
  cout << "parent = " << T[u].p << ", ";
  cout << "depth = " << D[u] << ", ";

  if ( T[u].p == NIL ) cout << "root, ";
  else if ( T[u].l == NIL ) cout << "leaf, ";
  else cout << "internal node, ";

  cout << "[";

  for ( i = 0, c = T[u].l; c != NIL; i++, c = T[c].r ) {
    if (i) cout << ", ";
    cout << c;
  }
  cout << "]" << endl;
}

int rec(int u, int p) {
  D[u] = p;
  if ( T[u].r != NIL ) rec(T[u].r, p);
  if ( T[u].l != NIL ) rec(T[u].l, p + 1);
}

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  for ( i = 0; i < n; i++ ) T[i].p = T[i].l = T[i].r = NIL;

  for ( i = 0; i < n ; i++ ) {
    cin >> v >> d;
    for ( j = 0; j < d; j++ ) {
      cin >> c;
      if ( j == 0 ) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for ( i = 0; i < n; i++ ){
    if ( T[i].p == NIL) r = i;
  }

  rec(r, 0);

  for ( i = 0; i < n; i++ ) print(i);

  return 0;
}


Measured memory_bytes: 7764
N = int(input())
a_list = map(int, input().split())

B = dict()
B[0] = 1
ans = 0
s = 0

for a in a_list:
    s += a
    ans += B.get(s, 0)
    B[s] = B.get(s, 0) + 1

print(ans)

Measured memory_bytes: 45036
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(li i=0;i<n;i++)
#define li long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s1 second
const ll INF=(1LL<<60)-1;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}
li pow(li a,li b,li mo)
{
    if(a==0)
    return 1;
    li u=pow(a,b/2,mo);
    u=(u%mod*u%mod)%mo;
    if(b%2==1)
    u=(u%mod*a%mod)%mod;
    return u;
}
ll power(ll a,ll b)
{
    ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const char &i, char &j)
{
    
    return i > j;
    
}

void solve()
{
  li n;
  cin>>n;
  li a[n+1];
  rep(i,n+1)
  a[i]=1;
  for(li i=2;i<=n;i++)
  {
      for(li j=i;j<=n;j+=i)
      {
          a[j]+=1;
      }
  }
  li sum=0;
  for( li i=1;i<=n;i++)
  {
      sum+=i*a[i];
  }
    cout<<sum;
    
}
int main()
{
    FAST_IO;
    li t;
    t=1;
    while(t--)
    solve(),cout<<endl;
    
}


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

using namespace std;

int N, R[2][101], t;
int main(void){
	scanf("%d", &N);
	for(int i = 0;i < 2;++i){
		for(int j = 0;j < N;++j){
			scanf("%d", &t);
			if(i == 0){
				if(j != N-1){
					R[0][j+1] = max(R[0][j+1], R[0][j] + t);
				}
				R[1][j] = max(R[1][j], R[0][j] + t);
			}else{
				if(j != N-1){
					R[1][j+1] = max(R[1][j+1], R[1][j] + t);
				}
			}
		}
	}

	printf("%d\n", R[1][N-1] + t);
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        try {
            String[] str = br.readLine().split(" ");
            int a = Integer.parseInt(str[0]);
            int b = Integer.parseInt(str[1]);
            int c = Integer.parseInt(str[2]);
            if(a < b && b < c) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } catch(IOException e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 17048
#include<bits/stdc++.h>
using namespace std;
int ans,a,b,c,d[10001];
int main(){
    cin>>a>>b>>c;
    for(int i=1;i<=a;++i){
        cin>>d[i];
        if(d[i]<b||d[i]>=c){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int x; cin >> x;
  int ans = 1;
  for (int i = 2; i * i <= x; ++i) {
    int j = i;
    while (true) {
      if (j * i <= x) j = j * i;
      else break;
      ans = max(ans, j);
    }
  }
  cout << ans << '\n';
  return 0;
}

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

int main(){
    int n , k , q;
    cin >> n >> k >> q;
    int a;
    vector<int> v(n);
    for(int i = 0; i < q; ++i){
        cin >> a;
        v[a - 1]++;
    }

    for(int i = 0; i < n; ++i){
        if(v[i] + k - q > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1024
n=int(input())
P=list(map(int,input().split()))
ans=0
for i in range(1,n-1):
  if P[i]<P[i-1] and P[i]>=P[i+1]:
    ans+=1
  elif P[i]<P[i+1] and P[i]>=P[i-1]:
    ans+=1
  else:
    continue

print(ans)


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

void solve(){
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> a(n, k);
    REP(i, n){
        a[i] -= q;
    }
    REP(i, q){
        ll ind;
        cin >> ind;
        a[ind-1]++;
    }
    REP(i, n){
        if(a[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

}

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

Measured memory_bytes: 1408
#include <iostream>
#include <complex>
#include <vector>

using namespace std;


class Circle {
public:
	complex<double> p;
	double r;
	Circle (complex<double> p0, double r0) {
		p = p0;
		r = r0;
	}
};

vector<complex<double> > intersectCC(Circle a, Circle b) {
	vector<complex<double> > res(2);

	auto d = abs(a.p - b.p);
	auto c = (d*d + a.r*a.r - b.r*b.r) / (2*d);
	auto s = sqrt(a.r*a.r - c*c);
	auto diff = (b.p - a.p) / d;

	res[0] = a.p + diff * complex<double>(c, s);
	res[1] = a.p + diff * complex<double>(c, -s);

	return res;
}


bool containsCP(Circle c, complex<double> p) {
	const double EPS = 10e-7;
	auto d = abs(c.p - p);
	return d <= c.r + EPS;
}


int main()
{
	int n;

	while (cin >> n, n) {
		vector<complex<double> > ps(n);

		for (int i = 0; i < n; i++) {
			double x[2];
			cin >> x[0] >> x[1];
			ps[i] = complex<double>(x[0], x[1]);
		}

		auto res = 1;

		for (int i = 0; i < n; i++) {
			for (int j = i+1; j < n; j++) {
				if (abs(ps[i]-ps[j]) > 2) continue;
				auto cp = intersectCC(Circle(ps[i], 1.0), Circle(ps[j], 1.0));
				int cnt = 0;
				
				for (int k = 0; k < n; k++) {
					if (containsCP(Circle(cp[0], 1.0), ps[k])) cnt++;
				}

				res = max(cnt, res);
				cnt = 0;

				for (int k = 0; k < n; k++) {
					if (containsCP(Circle(cp[1], 1.0), ps[k])) cnt++;
				}
				res = max(cnt, res);
			}
		}
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1272
#include <stdio.h>
#include <string.h>

int
main(int argc, char *argv[])
{
  int n; char s[100][100];
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%s", s[i]);
  }

  int l; int flag[100];

  for(int i = 0; i < strlen(s[0]); i++){
    l = 0;
    for(int j = 1; j < n; j++){
      for(int x = 0; x < strlen(s[j]); x++){
	if(s[j][x] == s[0][i]){
	  s[j][x] = '.';
	  l++;
	  break;
	}
      }
    }
    if(l == n - 1) flag[i] = 1;
    else flag[i] = 0;
  }

   char ss[100]; int h = 0;

   for(int i = 0; i < strlen(s[0]); i++){
    if(flag[i] == 1){
      ss[h] = s[0][i];
      h++;
    }
  }

  ss[h] = '\0';

  char d;

  for(int i = 0; i < h - 1; i++){
    for(int j = i + 1; j < h; j++){
      if(ss[i] > ss[j]){
	d = ss[i];
	ss[i] = ss[j];
	ss[j] = d;
      }
    }
  }

  printf("%s\n", ss);

  return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	ll res = 0;
	int tmp = 0, l = 0;
	for (int r = 0; r < N; r++) {
		while (tmp & A[r]) tmp -= A[l++];
		tmp |= A[r];
		res += r - l + 1;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	sort.Ints(ar)
	if n == 1 {
		fmt.Println(0)
		return
	}
	fmt.Println(ar[n-1] - ar[0])
}


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

int main() {
  int n;
  cin >> n;
  if(n%2 != 0) cout << 2*n << endl;
  else cout << n << endl;
}
  


Measured memory_bytes: 256
'''
n = int(input())
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [int(input()) for i in range n]
p = [list(map(int, input().split()))]

a = input()
a, b = input().split()
a = [input() for i in range n]
'''

n = int(input())
a = list(map(int, input().split()))

ans = "APPROVED"
#DENIED
for i in a:
    if i%2 == 1:
        continue
    elif i%3 == 0:
        continue
    elif i%5 == 0:
        continue
    else:
        ans = "DENIED"

print(ans)


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main() {

  const vector<string> vec = {"dreamer", "dream", "eraser", "erase"};
  
  string S;
  cin >> S;

  vector<int> dp(S.size()+1);
  dp[0] = 1;
  
  for(int i=0;i<S.size();++i) {
    for(int j=0;j<4;++j)
      if(S.substr(i, vec[j].size()) == vec[j])
	dp[i+vec[j].size()] |= dp[i];
  }
  
  if(dp[S.size()] == 1)
    cout << "YES" <<endl;
  else
    cout << "NO" <<endl;    
  
  return 0;
}


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

int main(){
	int A,B,C,x;
	cin >> A >> B >> C >> x;
	int count = 0;
	rep(i, A+1)rep(j,B+1)rep(k,C+1) if(500*i + 100*j + 50*k == x) count++;
	cout << count << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
const long long INF = 1e18;

int main() {
    int n;
    cin >> n;
    bool is_z = false;
    bool is_r = false;
    long long a = 1;
    for (int i=0; i<n; ++i) {
        if (is_z) continue;
        long long num; cin >> num;
        if (num == 0) is_z = true;
        if (is_r) continue;
        if (num > INF / a) is_r = true;
        a *= num;
    }
    if (is_z) cout << 0 << endl;
    else if (is_r) cout << -1 << endl;
    else cout << a << endl;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k) {
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= MOD;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    return x * modinv(y, MOD) % MOD;
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n;
    map<int, int>fact;
    int cnt74 = 0, cnt24 = 0, cnt14 = 0, cnt4 = 0, cnt2 = 0;
    int ans = 0;

    //入力
    cin >> n;

    //素因数分解
    for (int i = 2; i <= n; i++) {
        int now = i;
        int a = 2;
        while (a * a <= now) {
            if (now % a == 0) {
                fact[a]++;
                now /= a;
            }
            else a++;
        }
        fact[now]++;
    }

    for (auto x : fact) {
       // cout << x.first << ":" << x.second << endl;
        if (x.second >= 2) cnt2++;
        if (x.second >= 4) cnt4++;
        if (x.second >= 14) cnt14++;
        if (x.second >= 24) cnt24++;
        if (x.second >= 74) cnt74++;
    }

    ans += cnt74;
    ans += cnt24 * (cnt2 - 1);
    ans += cnt14 * (cnt4 - 1);
    ans += cnt4 * (cnt4 - 1) / 2 * (cnt2 - 2);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*g++ file.cpp -o file.out*/
/*./file.out*/

#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define LL long long
#define Mod 1000000007
#define L_Mod 17100000013

LL sov[100005],tmp[100005];
int main()
{
    int n,A,B;
    scanf("%d%d%d",&n,&A,&B);
    for(int i=1;i<=n;i++)
    {
        scanf("%lld",&tmp[i]);
    }
    tmp[0]=0;
    sov[1]=0;
    for(int i=2;i<=n;i++)
    {
        sov[i]=min(sov[i-1]+(tmp[i]-tmp[i-1])*A,sov[i-1]+B);
    }
    printf("%lld\n",sov[n]);
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int l,r;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='A'){
      l=i;
      break;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s.at(i)=='Z'){
      r=i;
      break;
    }
  }
  cout<<r-l+1<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,a,b;
	cin>>n>>a>>b;
	map<ll,ll>c;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		x*=-1;
		c[x]++;
	}
	ll ans=0;
	auto itr=c.begin();
	if(a<=itr->second){
		ll ans1=(itr->first)*(-1)*a;
		double A=a;
		printf("%.9f\n",ans1/A);
		ll lim=min(itr->second,b);
		//cout << lim<<endl;
		ll val=itr->second;
		ll now=itr->second;
		for(ll i=2;i<=a;i++){
			now*=(val-i+1);
			now/=i;
		}
		a++;
		ans=now;
		while(a<=lim){
			now*=(val-a+1);
			now/=a;
			ans+=now;
			a++;
		}
		cout <<ans;
		return 0;
	}
	ll sum=0;
	double num=a;
	while(a>itr->second){
		a-=itr->second;
		sum+=(itr->first)*(-1)*(itr->second);
		itr++;
		//cout <<sum;
	}
	sum+=(itr->first)*(-1)*a;
	printf("%.9f\n",sum/num);
	ll now=1;
		for(ll i=1;i<=a;i++){
			now*=(itr->second-i+1);
			now/=i;
		}	
		cout<<now;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

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

	int tmp=n;
	int dsum=0;

	while(tmp>0)
	{
		dsum+=tmp%10;
		 tmp/=10;
	}
	
	cout << (n%dsum==0 ? "Yes" : "No") << endl;
}

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

typedef long long ll;

const int Maxn = 2005;

int n;
int L[Maxn];
ll res;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%d", &L[i]);
    sort(L, L + n);
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++) {
            int ind = lower_bound(L, L + n, L[i] + L[j]) - L;
            res += ind - j - 1;
        }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

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

int main() {
    ll N;
    cin >> N;
    vector<pair<string,ll>> ts;
    rep(i,N){
        string x;
        cin >> x;
        ts.push_back(make_pair(x,1));
    }

    ll M;
    cin >> M;
    rep(i,M){
        string x;
        cin >> x;
        ts.push_back(make_pair(x,-1));
    }

    sort(ts.begin(),ts.end());


    ll ans = 0;
    ll result = 0;
    rep(i,N+M){
        result += ts[i].second;

        if(i != 0 && ts[i].first != ts[i-1].first){
            result = ts[i].second;
        }

        // cout << result << endl;
        
        ans = max(ans, result);
    }

    // rep(i,N+M){
    //     cout << ts[i].first << " : " << ts[i].second << endl;
    // }

    cout << ans << endl;


}


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

int main(){
    int n;
    while(1){
        cin >> n;
        if(n==0) break;
        int left = 0, right = 0;
        int state = 0;
        int cnt=0;
        for(int i=0; i<n; i++){
            string f;
            cin >> f;
            if(f == "lu"){
                left = 1;
            }
            if(f == "ld"){
                left = 0;
            }
            if(f == "ru"){
                right = 1;
            }
            if(f == "rd"){
                right = 0;
            }
            if(state == 0 && left == 1 & right == 1){
                cnt++;
                state = 1;
            }
            if(state == 1 && left == 0 & right == 0){
                cnt++;
                state = 0;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3160
def main():
    N = int(input())
    S = input()
    west_counts = [0 for _ in range(N)]
    east_counts = [0 for _ in range(N)]
    for i, c in enumerate(S):
        if c == 'W':
            west_counts[i] = 1
        else:
            east_counts[i] = 1
    for i in range(1, N):
        west_counts[i] += west_counts[i - 1]  # cumsum from leftside
        east_counts[N - 1 - i] += east_counts[N - i]  # cumsum from rightside
    ans = N
    for i in range(N):
        d = 0
        if i < N - 1:
            d += east_counts[i + 1]  # rightside
        if i > 0:
            d += west_counts[i - 1]  # leftside
        ans = min([ans, d])
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 27384
N, D = map(int, input().split())
XY = [map(int, input().split())for _ in range(N)]
X, Y = [list(i) for i in zip(*XY)]
i = 0
c = 0
for i in range(N):
  if X[i] ** 2 + Y[i] ** 2 <= D ** 2:
    c += 1
print(c)

Measured memory_bytes: 116732
N = int(input())
ans = 0
for i in range(1, N + 1):
    n = N // i  # 項数n
    cnt = (n * (2 * i + (n - 1) * i)) // 2  # 初項i, 項数n の等差数列の和の公式
    ans += cnt
print(ans)

Measured memory_bytes: 9104
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;

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

    int res = 0;
    for (int i = 0; i < N-2; i++) {
        if (S[i] == 'A') {
            if (S[i+1] == 'B' && S[i+2] == 'C') res++;
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
K,X = map(int,input().split())

K -= 1 
if  -1000000 <= X-K:
	start = X-K 
else:
	start = -1000000

if X+K <= 1000000:
	goal = X+K
else:
	goal = 1000000


ans = list(range(start,goal+1,1))
print(' '.join(map(str,ans))) 


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

int main() {
	int a[5];
	int k;
	for (int i = 0; i < 5; i++)
		cin >> a[i];
	cin >> k;
	int max = 0, min = 123;
	for (int i = 0; i < 5; i++) {
		if (max < a[i])
			max = a[i];
		if (min > a[i])
			min = a[i];
	}
	if (max - min > k)
		cout << ":(" << endl;
	else
		cout << "Yay!" << endl;
	return 0;
}

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

using namespace std;
using ll = long long int;
using ull = unsigned long long int;
#define vll vector<ll>

#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define REV(v) reverse((v).begin(), (v).end())
#define IN(v) cin >> (v);
#define VIN(v, n) REP(i, n) cin >> v[i];
#define OUT(v) cout << (v) << endl;
#define YN(b) OUT((b) ? "YES" : "NO")
#define Yn(b) OUT((b) ? "Yes" : "No")
#define yn(b) OUT((b) ? "yes" : "no")

const ll MOD = 1000000007;

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

  string s;
  cin >> s;

  if (s == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;

  return 0;
}

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

long long dp[3001][3001][3];

void solve(string s, string t){
	for (int i=0; i<=s.size(); i++) {
		for (int j=0; j<=t.size(); j++) {
			if (i == 0 || j == 0) {
				dp[i][j][0] = 0;
				dp[i][j][1] = -1;
				dp[i][j][2] = -1;
			}	else if (s[i-1] == t[j-1]) {
				dp[i][j][0] = dp[i-1][j-1][0]+1;
				dp[i][j][1] = i-1;
				dp[i][j][2] = j-1;
			} else {
				if (dp[i-1][j][0] >= dp[i][j-1][0]) {
					dp[i][j][0] = dp[i-1][j][0];
					dp[i][j][1] = dp[i-1][j][1];
					dp[i][j][2] = dp[i-1][j][2];
				} else {
					dp[i][j][0] = dp[i][j-1][0];
					dp[i][j][1] = dp[i][j-1][1];
					dp[i][j][2] = dp[i][j-1][2];
				}
			}
		}
	}
	long long dpi = s.size(), dpj = t.size();
	bool dps[s.size()];
	for (int i=0; i< s.size(); i++) dps[i] = false;
	while (dpi != -1 && dpj != -1) {
		long long befi = dp[dpi][dpj][1], befj = dp[dpi][dpj][2];
		if (dpi != -1) dps[befi] = true;
		dpi = befi;
		dpj = befj;
	}
	for (int i=0; i< s.size(); i++) if(dps[i]) cout << s[i];
	cout << "\n";
}

int main(){
	string s;
	string t;
	cin >> s;
	cin >> t;
	solve(s, t);
	return 0;
}


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

struct RGB {
    int r;
    int g;
    int b;
};

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<RGB> vec(N);
    vec[N-1].r = vec[N-1].g = vec[N-1].b = 0;
    if (S[N-1] == 'R') vec[N-1].r++;
    else if (S[N-1] == 'G') vec[N-1].g++;
    else vec[N-1].b++;
    for (int i = N-2; i >= 0; i--) {
        vec[i] = vec[i+1];
        if (S[i] == 'R') vec[i].r++;
        else if (S[i] == 'G') vec[i].g++;
        else vec[i].b++;
    }
    ll ans = 0;
    for (int i = 0; i < N-2; i++) {
        for (int j = i+1; j < N-1; j++) {
            if (S[i] == S[j]) continue;
            if (S[i] == 'R' && S[j] == 'G') {
                ans += vec[j+1].b;
                if (j*2 - i < N && S[j*2 - i] == 'B') ans--;
            }
            else if (S[i] == 'G' && S[j] == 'B') {
                ans += vec[j+1].r;
                if (j*2 - i < N && S[j*2 - i] == 'R') ans--;
            }
            else if (S[i] == 'R' && S[j] == 'B') {
                ans += vec[j+1].g;
                if (j*2 - i < N && S[j*2 - i] == 'G') ans--;
            }
            else if (S[i] == 'G' && S[j] == 'R') {
                ans += vec[j+1].b;
                if (j*2 - i < N && S[j*2 - i] == 'B') ans--;
            }
            else if (S[i] == 'B' && S[j] == 'G') {
                ans += vec[j+1].r;
                if (j*2 - i < N && S[j*2 - i] == 'R') ans--;
            }
            else if (S[i] == 'B' && S[j] == 'R') {
                ans += vec[j+1].g;
                if (j*2 - i < N && S[j*2 - i] == 'G') ans--;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

#define FOR(i,n) for(int i = 0; i < n; i++)
#define FORa(i,a,b) for(int i = a; i < b; i++)
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
#define SORT(a,n) sort(begin(a), begin(a) + n)
#define VSORT(v) sort(v.begin(), v.end())
#define MAX 1000000
#define ll long long
#define LOW(s) transform(s.begin(),s.end(),s.begin(),::tolower)
#define UP(s) transform(s.begin(),s.end(),s.begin(),::toupper)

//-------------------------------------------------------//

int main() {
	int k;
	cin >> k;
	
	if(k % 2 == 0 || k % 5 == 0) cout << "-1" << endl;
	else {
		int a = 1, b = 7%k;
		while(b != 0) {
			b = (b * 10 + 7)%k;
			a++;
		}
		
		cout << a << endl;
	}
  
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  vector<string>s;
  cin >> N;
  for(int i = 0; i < N; i++){
    string str;
    cin >> str;
    s.push_back(str);
  }
  int M;
  vector<string>t;
  cin >> M;
  for(int i = 0; i < M; i++){
    string str;
    cin >> str;
    t.push_back(str);
  }
  int ans = 0;
  for(int i = 0; i < s.size(); i++){
    int cnt = 0;
    //青いカード内に何枚あるか調べる
	for(int j = 0; j < s.size(); j++){
      if(s[i] == s[j])cnt++;
    }
    //赤いカードに同じの見つけたら-1
    for(int j = 0; j < t.size(); j++){
      if(s[i] == t[j])cnt--;
    }
    ans = max(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}
    

Measured memory_bytes: 256
from collections import deque
import numpy as np

S=deque(input())
Q=int(input())
count = 0
L=np.array([input().split() for _ in range(Q)])

for i in range(Q):
  l=L[i]
  if len(l)==1:
    count+=1
    continue
  elif len(l)==3:
    F=int(l[1])
    C=l[2]
    if count%2==0:
      if F==1:
        S.appendleft(C)
      else:
        S.append(C)
    else:
      if F==2:
        S.appendleft(C)
      else:
        S.append(C)

if count%2==1:
  S.reverse()
print(''.join(S))


Measured memory_bytes: 64676
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

class KMP {
public:
    string pattern;
    int plen;
    vector<int> table;

    // tからsを探す(探すものを引数に)
    KMP(const string& s) : pattern(s), plen((int)pattern.size()), table(plen + 1) {
        table[0] = -1;
        int j = -1;
        for (int i = 0; i < plen; i++) {
            while (j >= 0 && pattern[i] != pattern[j]) j = table[j];
            if (pattern[i + 1] == pattern[++j]) table[i + 1] = table[j];
            else table[i + 1] = j;
        }
    }

    // マッチする左端の箇所
    vector<int> search(const string& text) {
        vector<int> res;
        int head = 0, j = 0, tlen = (int)text.size();
        while (head + j < tlen) {
            if (pattern[j] == text[head + j]) {
                if (++j != plen) continue;
                res.push_back(head);
            }
            head += j - table[j], j = max(table[j], 0);
        }
        return res;
    }
};

struct DAG {
private:
    struct Edge {
        int to;
    };
    std::vector<std::vector<Edge>> graph;
    bool is_dag = false;
    std::vector<int> sorted; // トポロジカルソート
    int V; // 頂点数
public:

    DAG(int v) {
        assert(v > 0);
        V = v;
        graph.resize(v);
    }

    // from から to への有向辺を張る
    void add_edge(int from, int to) {
        graph[from].push_back({to});
    }

    // トポロジカルソート O(V + E)
    // DAG じゃないなら size 0 の vectorを返す
    std::vector<int> topological_sort(int &ret) {
        ret = 0;
        std::stack<int> sta;
        std::vector<int> dist(V, 0);//その頂点までの最長路
        std::vector<int> in(V, 0);// 入次数
        int used_cnt = 0;//使用した頂点の数
        for (int i = 0; i < V; i++) {
            for (Edge e : graph[i]) {
                in[e.to]++;
            }
        }
        for (int i = 0; i < V; i++) if (in[i] == 0) {
            sta.push(i);
            used_cnt++;
        }
        while (!sta.empty()) {
            int p = sta.top(); sta.pop();
            sorted.push_back(p);
            for (Edge e : graph[p]) {
                int v = e.to;
                in[v]--;
                dist[v] = std::max(dist[v], dist[p] + 1);
                ret = max(ret, dist[v]);
                if (in[v] == 0) {
                    sta.push(v);
                    used_cnt++;
                }
            }
        }
        if (used_cnt == V) {
            return sorted;
        }
        else {
            return std::vector<int>(0);
        }
    }

    vector<Edge>& operator[](int x) {
        return graph[x];
    }
};

int main() {
    string s, t; cin >> s >> t;
    string s2 = s;
    int n = s.size();
    DAG g(n);
    while (n + t.size() - 1 > s.size()) {
        s += s2;
    }
    KMP kmp(t);
    //cout << "s : " << s << endl;
    for (int v : kmp.search(s)) {
        if (v >= n) break;
        g.add_edge(v, (v + t.size()) % n);
        //cout << v << " " << (v + t.size()) % n << endl;
    }
    int ans;
    if (g.topological_sort(ans).size() == 0) {
        cout << -1 << endl;
    }
    else {
        //cout << g.topological_sort(ans).size() << endl;;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 36052
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT)
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((minus nil)
           (result (loop (let ((byte (%read-byte)))
                           (cond ((<= 48 byte 57)
                                  (return (- byte 48)))
                                 ((zerop byte) ; #\Nul
                                  (error "Read EOF or #\Nul."))
                                 ((= byte #.(char-code #\-))
                                  (setf minus t)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte 57)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return (if minus (- result) result))))))))

(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (trial (read))
         (as (make-array n :element-type 'uint32))
         (table (make-hash-table :test #'eq :size n)))
    (dotimes (i n)
      (setf (aref as i) (read-fixnum)))
    (let ((gain 0)
          (prevmin #xffffffff)
          (res 0))
      (declare (uint32 gain res prevmin))
      (sb-int:dovector (a as)
        (setf gain (max gain (- a prevmin))
              prevmin (min prevmin a)))
      (sb-int:dovector (a as)
        (when (gethash (- a gain) table)
          (incf res))
        (setf (gethash a table) t))
      (println res))))

#-swank (main)


Measured memory_bytes: 26080
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <complex>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處
int n, k, c;

char s[200005];

int before[200005];
int after[200005];

int bef(int i) {
    if (i <= n && i >= 1) {
        return before[i];
    }
    return 0;
}

int af(int i) {
    if (i <= n && i >= 1) {
        return after[i];
    }
    return 0;
}

int main() {
    scanf("%d%d%d", &n, &k, &c);
    scanf("%s", s + 1);
    int constraint = 0;
    int x = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i] == 'o' && i > constraint) {
            x++;
            before[i] = x;
            constraint = i + c;
        } else {
            before[i] = x;
        }
    }
    for (int i = n; i >= 1; i--) {
        if (s[i] == 'o') {
            after[i] = max(1 + af(i + c + 1), af(i + 1));
        } else {
            after[i] = af(i + 1);
        }
    }
    vector<int> ans;
    for (int i = 1; i <= n; i++) {
        if (bef(i - 1) + af(i + 1) < k) {
            ans.push_back(i);
        }
    }
    for (int a: ans) {
        printf("%d\n", a);
    }
}


Measured memory_bytes: 4212
n=int(input())
point=[0]*(n+1)
for i in range(int(n*(n-1)/2)):
    a,b,c,d=map(int,input().split())
    if c>d:
        point[a]+=3
    elif d>c:
        point[b]+=3
    elif c==d:
        point[a]+=1
        point[b]+=1
point_s=point[:]
point_s.sort(reverse=True)
for i in point[1:]:
    print(point_s.index(i)+1)


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

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

int main(int argc, char const *argv[]) {
  /* code */
  int m,d;
  cin >> m >> d;

  if (m<4 || d<22) {
    printf("0\n");
  }
  else{
    int ans=0;
    int ten,one;
    ten = d / 10;
    one = d % 10;

    for (int i = 4; i < m+1; i++) {
      for (int j = 2; j <= ten; j++) {
        for (int k = 2; k <= 9; k++) {
          if (j==ten && k==one) {
            if(j*k==i){
              ans++;
              break;
            }
            break;
          }
          if(k*j == i && (10*j+k) <= d){
            ans++;
          }
        }
      }
    }

    printf("%d\n", ans);
  }
  return 0;
}


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

const int nm = 1e5;
int n, a[nm], b[nm], c[nm];
long long d[nm];

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> b[i];
	for (int i = 0; i < n; i++)
		cin >> c[i];
	sort(a, a + n), sort(b, b + n), sort(c, c + n);
	for (int i = 0, j = 0; i < n; i++) {
		while (j < n && a[j] < b[i])
			j++;
		d[i] = j + (i > 0 ? d[i - 1] : 0);
	}
	long long rv = 0;
	for (int i = 0, j = 0; i < n; i++) {
		while (j < n && b[j] < c[i])
			j++;
		rv += d[j - 1];
	}
	cout << rv << endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <climits>

using namespace std;

int main()
{
    int n, m;
    while (cin >> n >> m, n | m)
    {
        vector<int> taro_cards(n);
        vector<int> hanako_cards(m);
        for (auto &card : taro_cards)
        {
            cin >> card;
        }
        for (auto &card : hanako_cards)
        {
            cin >> card;
        }

        auto taro_sum = accumulate(taro_cards.begin(), taro_cards.end(), 0);
        auto hanako_sum = accumulate(hanako_cards.begin(), hanako_cards.end(), 0);
        int min_swapped_score_taro = 101;
        int min_swapped_score_hanako = 101;
        for (int i = 0; i < taro_cards.size(); ++i)
        {
            for (int j = 0; j < hanako_cards.size(); ++j)
            {
                auto taro_sum_swapped = taro_sum - taro_cards[i] + hanako_cards[j];
                auto hanako_sum_swapped = hanako_sum - hanako_cards[j] + taro_cards[i];
                if (taro_sum_swapped == hanako_sum_swapped)
                {
                    auto sum_swapped = taro_cards[i] + hanako_cards[j];
                    if (sum_swapped < min_swapped_score_taro + min_swapped_score_hanako)
                    {
                        min_swapped_score_taro = taro_cards[i];
                        min_swapped_score_hanako = hanako_cards[j];
                    }
                }
            }
        }

        if (min_swapped_score_taro == 101)
        {
            cout << -1 << endl;
        }
        else
        {
            cout << min_swapped_score_taro << " " << min_swapped_score_hanako << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1196
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

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

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

	string S;
	cin >> S;

	deque<char> dq(all(S));

	int cntL = 0;

	rep(i, N)
	{
		if (S[i] == '(')
		{
			cntL++;
		}
		else
		{
			cntL--;
			if (cntL < 0)
			{
				dq.push_front('(');
				cntL = 0;
			}
		}
	}

	rep(i, cntL)
	{
		dq.push_back(')');
	}

	for (auto c : dq)
	{
		cout << c;
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int search(int A[], int n, int key) {
  int i = 0;  A[n] = key;
  while(A[i] != key) i++;
  return i != n;
}

int main(void) {
  int i, n, A[10000+1], q, key, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) scanf("%d", &A[i]);
  scanf("%d",&q);
  for(i=0; i<q; i++) {
    scanf("%d", &key);
    if(search(A, n, key)) sum++;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 2148
dish = [int(input()) for i in range(5)]

import itertools

dish_list = list(itertools.permutations(dish))

time = 0
time_list = []

for i in range(len(dish_list)):
    for j in range(5):
        time += dish_list[i][j]
        if time%10 != 0 and j != 4:
            time += 10-(time%10)
            
    time_list.append(time)
    time = 0
    
print(min(time_list))
        

Measured memory_bytes: 3060