akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll long long

int cost[200005];
int harr[200005];
ll int dp[200005];
ll int seg[800005];


void build(int node, int start, int end)
{
  if(start == end)
    seg[node] = 0;
  else
  {
    int mid = (start + end) / 2;
    build(node*2, start, mid);
    build(node*2 + 1, mid+1, end);
    seg[node] = max(seg[node*2], seg[node*2 + 1]);
  }
  return;
}

void update(int node, int start, int end, int l, int r, ll int val)
{
  if(end < l || start > r)
    return;

  if(start == end)
    seg[node] = val;
  else
  {
    int mid = (start + end) / 2;
    update(node*2, start, mid, l, r, val);
    update(node*2 + 1, mid+1, end, l, r, val);
    seg[node] = max(seg[node*2], seg[node*2+1]);
  }
  return;
}

ll int query(int node, int start, int end, int l, int r)
{
  if(end < l || start > r)
    return 0;

  if(start >= l && end <= r)
    return seg[node];

  ll int q1, q2;
  int mid = (start + end) / 2;
  q1 = query(node*2, start, mid, l, r);
  q2 = query(node*2+1, mid+1, end, l, r);

  return max(q1, q2);
}


int main()
{
  int n;
  ll int y;
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>harr[i];
  for(int i=0;i<n;i++)
    cin>>cost[i];

  for(int i=0;i<n;i++)
  {
    y = query(1, 0, n, 0, harr[i]);
    dp[harr[i]] = y + cost[i];
    update(1, 0, n, harr[i], harr[i], dp[harr[i]]);
  }

  for(int i=0;i<=n;i++)
    y = max(y, dp[i]);

  cout<<y<<endl;
  return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int maxn=1e5+10;
ll heal[maxn];
ll A,B;
int N;
bool check(ll x)
{
    ll cnt=0;
    ll gap;
    //cout<<x<<"!"<<endl;
    for(int i=N-1;i>=0;i--)
    {
        //cout<<heal[i]<<' '<<cnt<<endl;
        if(x*B>=heal[i])return true;
        gap=heal[i]-x*B;
       //cout<<"g"<<gap<<endl;
        cnt+=gap/A;
        if(gap%A)cnt++;
        //cout<<cnt<<endl;
        if(cnt>x)return false;
    }
    return true;
}
int main()
{
    cin>>N>>A>>B;
    A-=B;
    for(int i=0;i<N;i++)cin>>heal[i];
    sort(heal,heal+N);
    ll l,r,mid;
    l=1;r=N*heal[N-1]/B+1;
    while(l<r)
    {
        mid=(l+r)>>1;
        if(check(mid))r=mid;
        else l=mid+1;
    }
    cout<<l<<endl;
    return 0;
}


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

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

int main(void){
    
    int a;
    cin>>a;
    if(a==3||a==5||a==7)cout<<"YES";
    else cout<<"NO";
    
    return 0;
}


Measured memory_bytes: 764
n,m = map(int, input().split())
p,s = [0] * m, [0] * m
for i in range(m):
    p[i], s[i] = map(str, input().split())
    p[i] = int(p[i])

ac = 0
wa = 0
que = [False] * (n + 1)
wan = [0] * (n + 1)

for i in range(m):
    if que[p[i]] == False:
        if s[i] == "WA":
            wan[p[i]] += 1
        else:
            que[p[i]] = True

for i in range(len(que)):
    if que[i] == True:
        ac += 1
        wa += wan[i]

print(ac,wa)    

Measured memory_bytes: 14800
import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
def fact(n,mod):
    f = 1
    for m in range(1,n + 1):
        f *= m
        f %= mod
    return f

mod = 10**9+7
N = i()
print(fact(N,mod))

Measured memory_bytes: 59116
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	#a = int(input())
	n, a, b = tin()
	#s = input()	
	al=lin()
	pos=al[0]
	ret=0
	for np in al[1:]:
		ret += min(b, (np-pos)*a)
		pos = np
	return ret
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

int N;
ll L[110];

int main(){
  cin >> N;
  rep(i, N) cin >> L[i];

  sort(L, L+N);

  int ans = 0;

  rep(i, N-2){
    repi(j, i+1, N-1){
      repi(k, j+1, N){
        if ((L[i]!=L[j]) && (L[j]!=L[k]) && (L[k] < L[i] + L[j])) ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3620
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            out.println((in.nextInt() - 1) * (in.nextInt() - 1));
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	int dx = abs(tx - sx);
	int dy = abs(ty - sy);
	string U(dy, 'U');
	string D(dy, 'D');
	string R(dx, 'R');
	string L(dx, 'L');

	cout << U << R <<  'R' << D << 'D' << L << 'L' << 'U';
	cout << R << U << 'U' << L << 'L' << D << 'D' << 'R' << endl;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var firstLine = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            var n = firstLine[0];
            var m = firstLine[1];

            var matrix = CreateMatrix(n, m);
            var vector = CreateVector(m);

            var result = Calc(matrix, vector);

            Output(result);

        }

        static int[][] CreateMatrix(int n, int m)
        {
            var mArray = new int[n][];
            for (var i = 0; i < n; i++)
            {
                mArray[i] = Console.ReadLine().Split().Select(s => int.Parse(s)).ToArray();
            }

            return mArray;
        }

        static int[] CreateVector(int m)
        {
            var vArray = new int[m];
            for (var i = 0; i < m; i++)
            {
                vArray[i] = int.Parse(Console.ReadLine());
            }

            return vArray;
        }

        static int[] Calc(int[][] matrix, int[] vector)
        {

            var result = new int[matrix.Length];

            for (var i = 0; i < matrix.Length; i++)
            {
                var sum = 0;
                for (var j = 0; j < matrix[i].Length; j++)
                {
                    sum += matrix[i][j] * vector[j];
                }
                result[i] = sum;
            }

            return result;
        }

        static void Output(int[] result)
        {
            for (var i = 0; i < result.Length; i++)
            {
                Console.WriteLine(result[i]);
            }
        }
    }

}



Measured memory_bytes: 18444
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a[3];
    for(int i=0;i<3;i++)cin>>a[i];
    sort(a,a+3);
    ll cnt=0;
    ll x=a[0];
    ll y=a[1];
    ll z=a[2];
    x=z-x;
    y=z-y;
    cnt+=x/2;
    cnt+=y/2;
    x%=2;
    y%=2;
    if(x && y)cnt+=1;
    else if(x!=y)cnt+=2;
    cout<<cnt<<endl;
}


Measured memory_bytes: 3624
t = [0] * 3
x = [0] * 3
y = [0] * 3
a=[]
for i in range(3):
    t[i], x[i], y[i] = map(int, input().split())
a.append(t)
a.append(x)
a.append(y)#二重のリストへ
n=int(input())
li=[input() for i in range(n)]
#メインコード
ctr=[[0,0,0],[0,0,0],[0,0,0]]
for i in range(3):
    for j in range(3):
        for k in range(n):#それぞれのリストを探索
            if int(a[i][j])==int(li[k]):#intとintの比較なので注意
                ctr[i][j]+=1
if ctr[0][0]==ctr[0][1]==ctr[0][2]==1:
    print('Yes')
elif ctr[1][0]==ctr[1][1]==ctr[1][2]==1:
    print('Yes')
elif ctr[2][0]==ctr[2][1]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][0]==ctr[1][0]==ctr[2][0]==1:
    print('Yes')
elif ctr[0][1]==ctr[1][1]==ctr[2][1]==1:
    print('Yes')
elif ctr[0][2]==ctr[1][2]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][0]==ctr[1][1]==ctr[2][2]==1:
    print('Yes')
elif ctr[0][2]==ctr[1][1]==ctr[2][0]==1:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
#include<stdio.h>

int main()
{
  int N;
  long long int total = 0;
  int i;
  int A_top, A_tail, B, B_min, B_max;
  int ret;

  ret = scanf("%d", &N);
  
  for ( i=1;i<=N;i++ ) {
    if ( i < 10) {
      A_top = A_tail = i;
    }
    else if ( i >= 10 && i < 100 ) {
      A_top = i / 10;
      A_tail = i % 10;
    }
    else if ( i >= 100 && i < 1000 ) {
      A_top = i / 100;
      A_tail = i % 10;
    }
    else if ( i >= 1000 && i < 10000 ) {
      A_top = i / 1000;
      A_tail = i % 10;
    }
    else if ( i >= 10000 && i < 100000 ) {
      A_top = i / 10000;
      A_tail = i % 10;
    }
    else if ( i >= 100000 ) {
      A_top = i / 100000;
      A_tail = i % 10;
    }

    // 1-9
    if ( A_top == A_tail ) {
      if ( A_tail <= N )
	total++;
    }
    // 10-99
    B = A_tail * 10 + A_top;
    if ( A_tail != 0 && B <= N )
      total++;
    // 100-999
    B_min = A_tail * 100 + A_top;
    B_max = B_min + 90;
    if ( A_tail != 0 && B_min <= N ) {
      if ( B_max <= N )
	total += 10;
      else if ( N < B_max )
	total += (N - B_min) / 10 + 1;
    }
    // 1000-9999
    B_min = A_tail * 1000 + A_top;
    B_max = B_min + 990;
    if ( A_tail != 0 && B_min <= N ) {
      if ( B_max <= N )
	total += 100;
      else if ( N < B_max )
	total += (N - B_min) / 10 + 1;
    }
    // 10000-99999
    B_min = A_tail * 10000 + A_top;
    B_max = B_min + 9990;
    if ( A_tail != 0 && B_min <= N ) {
      if ( B_max <= N )
	total += 1000;
      else if ( N < B_max )
	total += (N - B_min) / 10 + 1;
    }
    // 100000-999999
    B_min = A_tail * 100000 + A_top;
    B_max = B_min + 99990;
    if ( A_tail != 0 && B_min <= N ) {
      if ( B_max <= N )
	total += 10000;
      else if ( N < B_max )
	total += (N - B_min) / 10 + 1;
    }
  }
  printf("%lld\n", total);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC055_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            const long Divide = 1000000007;
            long power = 1;
            for (int i = 1; i <= N; i++)
            {
                power *= i;
                power %= Divide;
            }
            Console.WriteLine(power);
        }
    }
}


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

int main(){
    long long int n,a,b;
    cin >> n >> a >> b;
    long long int p = n/(a+b)*a;
    long long int q = n % (a+b);
    if(q <= a){
        cout << p + q << endl;
    }else{
        cout << p + a << endl;
    }
    return 0;
}



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



typedef long long ll;
ll gcd(ll a, ll b) { while (b) a %= b, swap(a, b); return a; }
int N;
int A[101010];
//-----------------------------------------------------------------
bool sol() {
	if (N == 1) return A[0] % 2 == 0;

	int even = 0;
	rep(i, 0, N) if (A[i] % 2 == 0) even++;

	if (even % 2 == 1) return true;
	if (2 <= N - even) return false;

	int sit;
	rep(i, 0, N) if (A[i] % 2 == 1) sit = i;
	if (A[sit] == 1) return false;
	A[sit]--;

	ll g = A[0];
	rep(i, 0, N) g = gcd(g, A[i]);
	rep(i, 0, N) A[i] = A[i] / g;

	return !sol();
}
//-----------------------------------------------------------------
int main() {
	cin >> N;
	rep(i, 0, N) scanf("%d", &A[i]);

	if (sol())
		printf("First\n");
	else
		printf("Second\n");
}

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

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

  int k;
  cin >> k;
  long long sum = 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < k; j++) {
      for (int l = 0; l < k; l++) {
        sum += gcd(i+1,gcd(j+1,l+1));
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,sum=0;
	cin>>a>>b;
	if(a>=b)
	{
		sum+=a;
		a-=1;
	}
	else
	{
		sum+=b;
		b-=1;
	}
	if(a>=b)
	{
		sum+=a;
		a-=1;
	}
	else
	{
		sum+=b;
		b-=1;
	}
	cout<<sum<<endl;
	return 0;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=0; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;

int main()
{
  string s, t ;
  cin >> s >> t ;
  int n = s.size() ;
  vector<string> vec(n) ;
  
  REP(i,n){
    for(int j=i; j<n; j++){
      vec.at(i).push_back(s.at(j)) ; 
    }
    for(int j=0; j<i; j++){
      vec.at(i).push_back(s.at(j)) ;
    }
   // cout << vec.at(i)<<endl ;
  }
  
  int i = 0 ;
  while(true){
    if(vec.at(i)==t){
      cout <<"Yes"<<endl ;
      break ;
    }
    else{
      i++ ;
    }
    if(i==n){
      cout <<"No"<<endl ;
      break ;
    }
  }

  return 0 ;
}




Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] S = br.readLine().split(" ");
		int N = Integer.parseInt(S[0]);
		int K = Integer.parseInt(S[1]);
		int[] H = new int[N+1];
		
		S = br.readLine().split(" ");
		for(int i = 0; i < N ; i++) {
			H[i+1] = Integer.parseInt(S[i]);
		}
		System.out.println(minCostJump(N, K, H));
	}
	
	public static int minCostJump(int N, int K, int[] H) {
		int[] cache = new int[N+1];
		
		for(int i = 2; i <= N; i++) {
			cache[i] = cache[i-1] + Math.abs(H[i-1] - H[i]);
			for(int j = i-2; j >= i-K && j > 0; j--) {
				cache[i] = Math.min(cache[i], cache[j] + Math.abs(H[j]-H[i]));
			}
		}
		
		return cache[N];
	}
}


Measured memory_bytes: 41220
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    s = s.substr(0, s.size() - 8);
    cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(){

    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int k;
    string s;

    cin>>k;
    cin>>s;
    if(s.length()<=k){
        cout<<s;
    }
    else{
        for(int i=0;i<k;i++){
            cout<<s[i];
        }
        cout<<"..."<<endl; 
    }

//    cout<<endl;


}



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

typedef long long ll;

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

ll lcm(ll a, ll b){
    ll g = gcd(a,b);
    return a/g * b;
}

int main(){
    int N;
    cin >> N;
    vector<ll> T(N);
    ll ans=1;
    for(int i=0; i<N; i++){
        cin >> T[i];
        ans = lcm(ans,T[i]);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

public class Program
{
    static void Main()
    {
        var str = Console.ReadLine();
        var stack = new Stack<char>();
        var count = 0;
        for (int i = 0; i < str.Length; i++)
        {
            stack.Push(str[i]);
            if (stack.Count > 1)
            {
                var a = stack.Pop();
                var b = stack.Pop();
                if (a != b)
                {
                    count += 2;
                }
                else
                {
                    stack.Push(b);
                    stack.Push(a);
                }
            }
        }

        Console.WriteLine(count);
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

bool flg[SIZE];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    for( int i = 0; i <= n; ++i ) flg[i] = true;
    
    for( int i = 0; i < m; ++i ) {
        int a;
        cin >> a;
        flg[a] = false;

    }

    int dp[n + 1];
    dp[0] = dp[1] = 1;
    if( flg[1] == false ) dp[1] = 0;
    for( int i = 2; i <= n; ++i ) {
        if( !flg[i] ) dp[i] = 0;
        else dp[i] = ( dp[i - 1] + dp[i - 2] ) % MOD;
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 768
import std.functional,
       std.algorithm,
       std.container,
       std.typetuple,
       std.typecons,
       std.bigint,
       std.string,
       std.traits,
       std.array,
       std.range,
       std.stdio,
       std.conv;

long f(ulong x) {
  long t = (x + 1) / 2;

  if ((x + 1) % 2 == 0) {
    return t % 2;
  } else {
    return (t % 2) ^ x;
  }
}

void main() {
  long[] AB = readln.chomp.split.to!(long[]);
  long A = AB[0],
      B = AB[1];
  long ans = f(B);

  if (A > 0) {
    ans ^= f(A - 1);
  }

  writeln(ans);
}


Measured memory_bytes: 256
def main():
  from collections import Counter
  n=int(input())
  a,b=tuple(map(int,input().split())),[0]*n
  c=Counter(a)
  x=0
  for i in set(a):
    b[i-1]=c[i]
    x+=(b[i-1]*(b[i-1]-1))//2
  b=tuple(b)
  for i in a:
    y=b[i-1]-1
    print(x-y if x>=y else 0)
if __name__=='__main__':
  main()

Measured memory_bytes: 27036
#include <stdio.h>
#include <stdlib.h>
#define N 100

void visit(int);

int count=1,d[N+1],f[N+1],arr[N+1][N+1],/*stack[N+1],s=1,*/n;

int main(){
  int i,j,m,node,num;

  scanf("%d",&n);
  if(n<1 || n>N) exit(2);
    f[0]=d[0]=0;
  for(i=0;i<n;i++){
    f[i+1]=d[i+1]=0;
    scanf("%d %d",&node,&num);
    for(j=0;j<num;j++){
      scanf("%d",&m);
      arr[node][m]=1;
    }
  }

  visit(1);
  for(i=1;i<=n;i++){
    if(d[i] == 0){
      count++;
      visit(i);
    }
    printf("%d %d %d\n",i,d[i],f[i]);
  }
   
  return 0;
}

void visit(int x){
  int i,j;
  //stack[s]=x;
  //s++;
  d[x]=count;
  for(i=1;i<=n;i++){
    if(arr[x][i]==1 && d[i] == 0){
      count++;
      visit(i);
    }
  }
  //s--;
  //stack[s]=0;
  count++;
  f[x]=count;
}



Measured memory_bytes: 2088
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
	int l;
	double a;
	cin >> l;
	a = (double)l/3;
	cout << setprecision(10) << pow(a,3) <<endl;
	return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n;
    cin >> n;
    map<ll,ll> mp;
    rep(i,n){
        int a;cin >> a;
        mp[a]++;
    }
    vl a,b;
    for(auto t : mp){
        if(t.second>=2) a.push_back(t.first);
        if(t.second>=4) b.push_back(t.first);
    }
    if(a.size()) sort(a.begin(),a.end(),greater<ll>());
    if(b.size()) sort(b.begin(),b.end(),greater<ll>());
    ll A=INF,B=-INF;
    if(b.size()) B = b[0] * b[0];
    if(a.size()>=2) A = a[0] * a[1];
    if(a.size()<2 && b.size()<1) cout << 0 << endl;
    else cout << max(A,B) << endl;
}

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

int main() {
  int x, y;
  cin >> x >> y;

  int a, b;
  if (x >= y) {
    a = x;
    b = y;
  }
  else {
    a = y;
    b = x;
  }

  while (a % b != 0) {
    int tmp;
    tmp = a % b;
    a = b;
    b = tmp;
  }

  cout << b << endl;


}


Measured memory_bytes: 3116
#include <iostream>

using namespace std;

int main()
{
    int n,a,b;
    int k;
    cin >> n >> a >> b;
    int t[1000] = {};
    for(int i = 0; i < n; i++){
        cin >> t[i];
    }
    for(int j = 0; j < n; j++){
        if((t[j] < a)||(t[j] >= b)){
            k++;
        }
    }
    cout << k << endl;
    return 0;
}


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

using namespace std;

#define int long long

signed main(){
    int N;
    int K;
    int BIT = 40;
    cin >> N >> K;
    vector<int> a(N);
    
    int pow2[BIT];
    
    int p2 = 1;
    for(int i = 0; i < BIT; ++i){
        pow2[i] = p2;
        p2 *= 2;
    }
    
    for(int i = 0; i < N; ++i){
        cin >> a[i];
    }
    

    vector<int> list;
    
    for(int l = 0; l < N; ++l){
        for(int r = l; r < N; ++r){
            int sum = 0;
            for(int i = l; i <= r; ++i){
                sum += a[i];
            }
            
            list.push_back(sum);
        }
    }
    
    sort(list.begin(), list.end(), greater<int>());
    
    int range = list.size();
    
    int ans = 0;
    
    for(int i = BIT - 1; i >= 0; --i){
        int cnt = 0;
        
        for(int j = 0; j < range; ++j){
            if((list[j] >> i) & 1){
                ++cnt;
            }
        }
        
        if(cnt >= K){
            range = cnt;
            ans += pow2[i];
        } else {
            for(int j = 0; j < range; ++j){
                if((list[j] >> i) & 1){
                    list[j] -= pow2[i];
                }
            }
            sort(list.begin(), list.end(), greater<int>());
        }
        
    }
    
    cout << ans << endl;
    
    
}


Measured memory_bytes: 6388
# import math
n,m=map(int, raw_input().split())
arr=map(int, raw_input().split())
s=sum(arr)
arr.sort()
k=m
for i in xrange(n-1,-1,-1):
    if arr[i]>=s/(4.0*m) and k>0:
        k-=1
 
if k>0:
    print 'No'
else:
    print 'Yes'

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


//#define int long long 

const int N = 1e5 + 7;


vector <int> adj[N];

int dfs(int u, int p) {
	int x = 0;
	for(int v: adj[u]) if(v ^ p) {
		x ^= (1 + dfs(v, u));
	}
	return x;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	for(int i = 1; i < n; i++) {
		int u, v; cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}

	cout << (dfs(1, 0) ? "Alice" : "Bob") << endl;
}

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

const int MOD = 1e9+7;
const int MAX_N = 1e5+10;
string s;
int N;
ll dp[MAX_N][13];

void solve()
{
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	const int N = s.length();
	for(int i=0;i<N;++i){
		if(s[i] == '?'){
			for(int k=0;k<13;++k)for(int j=0;j<10;++j){
				(dp[i+1][(10*k+j)%13] += dp[i][k])%=MOD;
			}
		}else{
			for(int k=0;k<13;++k){
				(dp[i+1][(10*k+(s[i]-'0'))%13] += dp[i][k])%= MOD;
			}
		}
	}
	int ans = dp[N][5];
	if(ans < 0) ans += MOD;
	cout << ans << endl;
}

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


Measured memory_bytes: 10624
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <algorithm>
using namespace std;

long long int dx[4] ={1,0,-1,0};
long long int dy[4] = {0,1,0,-1};
long long int cntw,cntb;
long long int state[402][402];

long long int dfs(int x,int y){
  if(state[x][y]==0) {
    cntw+=1;
  }
  if(state[x][y]==1){
    cntb+=1;
  }
  long long int tmp=state[x][y];
  state[x][y]=-1;  
  for(long long int i=0;i<4;i++){
    long long int nx=x+dx[i], ny=y+dy[i];
    if(state[nx][ny]+tmp==1) {
      dfs(nx,ny);
    } 
  }
  return cntb*cntw;
}

int main()
{
  long long int H,W;
  cin>>H>>W;
  memset(state,-1,sizeof(state));

  for(int i=1;i<=H;i++){
    string s;
    cin>>s;
    for(int j=1;j<=W;j++){
      if(s[j-1]=='.'){
        state[i][j]=0;
      }else{
        state[i][j]=1;
      }
    }
  }
  
  long long int ans=0;
  for(int i=0;i<402;i++){
    for(int j=0;j<402;j++){
      cntw=0,cntb=0;
      if(state[i][j]>=0){
	ans += dfs(i,j);
      }
    }
  }
  cout<< ans <<endl;
}


Measured memory_bytes: 8960
import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


N, M = map(int, input().split())
S = input()
T = input()
L = lcm(N, M)
G = math.gcd(N, M)
for i in range(G):
    if S[N//G * i] != T[M//G * i]:
        print(-1)
        break
else:
    print(L)


Measured memory_bytes: 9328
#include <bits/stdc++.h>
#define int long long
#define R(i,a,n) for(int i=a;i<n;i++)
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
int ddx[]={0,1,1,1,0,-1,-1,-1};
int ddy[]={-1,-1,0,1,1,1,0,-1};

int n;
int a[200009];

void end(){
	cout<<-1<<endl;
	exit(0);
}

void ER(){
	if(a[0]!=0)end();
}

signed main(){
	cin>>n;
	r(i,n)cin>>a[i];
	ER();
	int sum=0,p=0;
	for(int i=1;i<n;i++){
		if(a[i]==0){
			p=0;
		}
		else if(a[i-1]+1==a[i])sum++;
		else{
			p++;
			int x=i-a[i];
			if(a[i]>p)end();
			//cout<<x<<endl;
			if(x<0)end();
			else sum+=a[i];
		}
		p=a[i];
	}
	cout<<sum<<endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

static int N =100;
int min(int, int);

int main(){
    int n, p[N+1], m[N+1][N+1];
    scanf("%d",&n);
    
    for(int i=1; i<= n; i++){
        scanf("%d%d",&p[i-1], &p[i]);
    }
    
    for(int i=1; i<=n; i++) m[i][i]=0;
    
    for(int l=2; l <= n; l++){
        for(int i=1; i<=n-l+1; i++){
            int j=i+l-1;
            m[i][j]=1000000;
            for(int k=i; k<=j-1; k++){
                m[i][j]=min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    printf("%d\n",m[1][n]);
    return 0;
}

int min(int a, int b)
{
    if(a>b) return b;
    else return a;

}


Measured memory_bytes: 2104
/******************************************
* AUTHOR : SOMU KUMAR *
* INSTITUTION : IIT BHUBANESWAR *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//code here...............//
int n;
cin>>n;
int arr[n][2];
for(int i=0;i<n;i++){
	int a,b;
	cin>>a>>b;
	arr[i][0]=a;
	arr[i][1]=b;
}
int cnt=0;
for(int i=0;i<n;i++){
	if(arr[i][0]==arr[i][1]){
		cnt++;
		if(cnt==3){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	else{
		cnt=0;
	}

}
cout<<"No"<<endl;
return 0;
}

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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;



//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a[1000000],b,c,cmp[10000000],data,m,h,w,x,y,xcmp,ycmp,sum=0;
                                               //1000000000
string s;

vector<int> z;

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

       cin >> n;
       rep(i,n){
           cin >> a[i];
          // cmp[a[i]]++;
       }
       sort(a,a+n);
       rep(i,n){
           if(i==0){
               cmp[cnt]++;
           }
           if(a[i]!=a[i+1]){
               cnt++;
               cmp[cnt]++;
           }
           else{
               cmp[cnt]++;
           }
       }
       //Cout(cmp[0]);
       cnt=0;
       rep(i,n){
           if(a[i]!=cmp[cnt]){
               ans++;
               cmp[cnt]--;
           }
           if(a[i]!=a[i+1]){
               cnt++;
           }
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> S.at(i).at(j);
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)=='#')  cout << '#';
      else{
        int count=0;
        if(i>0&&j>0){if(S.at(i-1).at(j-1)=='#')  count++;}
        if(i>0){if(S.at(i-1).at(j)=='#')  count++;}
        if(i>0&&j<W-1){if(S.at(i-1).at(j+1)=='#')  count++;}
        if(j>0){if(S.at(i).at(j-1)=='#')  count++;}
        if(j<W-1){if(S.at(i).at(j+1)=='#')  count++;}
        if(i<H-1&&j>0){if(S.at(i+1).at(j-1)=='#')  count++;}
        if(i<H-1){if(S.at(i+1).at(j)=='#')  count++;}
        if(i<H-1&&j<W-1){if(S.at(i+1).at(j+1)=='#')  count++;}
        cout << count;
      }
    }
    cout << endl;
  }

  return 0;
}


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

bool used[101010101];

int main()
{
    int n;
    cin >> n;
    int ans = 1;
    while (!used[n])
    {
        used[n] = true;
        if (n % 2)
            n = 3 * n + 1;
        else
            n /= 2;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func lowerBound(a []int, x int) int {
	// (l, r]
	n := len(a)
	l := -1
	r := n
	for r-l > 1 {
		mid := (l + r) / 2
		if x <= a[mid] {
			r = mid
		} else {
			l = mid
		}
	}
	return r
}

func main() {
	var n int
	fmt.Scan(&n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	a := make([]int, n)
	for i := range a {
		sc.Scan()
		a[i], _ = strconv.Atoi(sc.Text())
	}
	sc.Scan()
	q, _ := strconv.Atoi(sc.Text())
	for i := 0; i < q; i++ {
		sc.Scan()
		k, _ := strconv.Atoi(sc.Text())
		x := lowerBound(a, k)
		ans := 0
		if x < n && a[x] == k {
			ans = 1
		}
		fmt.Println(ans)
	}
}



Measured memory_bytes: 5904
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define N 131072
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define MXN 3005
struct CostFlow {
    struct Edge {
        int v, r;
        long long f, c;
        Edge(int a,int b,int _c,int d):v(a),r(b),f(_c),c(d){
		}
    };
    int n, s, t, prv[MXN], prvL[MXN], inq[MXN];
    LL dis[MXN], fl, cost;
    vector<Edge> E[MXN];
    void init(int _n, int _s, int _t) {
        n = _n; s = _s; t = _t;
        for (int i=0; i<n; i++) E[i].clear();
        fl = cost = 0;
    }
    void add_edge(int u, int v, long long f, long long c)
    {
        E[u].pb(Edge(v, E[v].size() , f, c));
        E[v].pb(Edge(u, E[u].size()-1, 0, -c));
    }
    void SPFA(){
        fill(dis,dis+n+1,-1e18);
        fill(inq,inq+n+1,0);
        dis[s] = 0;
        queue<int> q;
        q.push(s);
        while(!q.empty()){
            int x=q.front();
            q.pop();
            inq[x]=0;
            int cnt=0;
            for(auto it:E[x]){
                if(it.f>0&&dis[it.v]<dis[x]+it.c){
                    prv[it.v]=x;prvL[it.v]=cnt;
                    dis[it.v]=dis[x]+it.c;
                    if(!inq[it.v]){
                        inq[it.v]=1;
                        q.push(it.v);
                    }
                }
                cnt++;
            }
        }
    }
    pll flow() {
        while (true) {
            SPFA();
            if (dis[t] == -1e18) break;
            long long tf = 1e18;
            for (int v=t, u, l; v!=s; v=u) {
                u=prv[v]; l=prvL[v];
                tf = min(tf, E[u][l].f);
            }
            for (int v=t, u, l; v!=s; v=u) {
                u=prv[v]; l=prvL[v];
                E[u][l].f -= tf;
                E[v][E[u][l].r].f += tf;
            }
            cost += tf * dis[t];
            fl += tf;
        }
        return {fl, cost};
    }
}flow;


int main(){
    int n;
    scanf("%d",&n);
    flow.init(2*n+10,0,2*n+5);
    pair<pii,int> r[1005],b[1005];
    for(int i=1;i<=n;i++){
        int x,y,c;
        scanf("%d %d %d",&x,&y,&c);
        r[i]=mp(mp(x,y),c);
        flow.add_edge(0,i,c,0);
        flow.add_edge(i,n+1,c,x+y);
        flow.add_edge(i,n+2,c,x-y);
        flow.add_edge(i,n+3,c,y-x);
        flow.add_edge(i,n+4,c,-y-x);
    }
    for(int i = 1;i<=n;i++){
        int x,y,c;
        scanf("%d %d %d",&x,&y,&c);
        b[i]=mp(mp(x,y),c);
        flow.add_edge(n+i+4,2*n+5,c,0);
        flow.add_edge(n+1,n+i+4,c,-x-y);
        flow.add_edge(n+2,n+i+4,c,y-x);
        flow.add_edge(n+3,n+i+4,c,x-y);
        flow.add_edge(n+4,n+i+4,c,y+x);
    }
    printf("%lld\n",flow.flow().y);  
  
}
/*
230
0.5 0.5
0.5 0.25
0.25 0.125
0.25
*/

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

using namespace std;

using ll = long long;

struct Node {
    bool has_visited = false;
    std::deque<ll> to;
    std::deque<ll> from;
};

void Visit(const ll &index, std::deque<Node> &nodes, std::deque<ll> &sorted) {
    if (!nodes[index].has_visited) {
        nodes[index].has_visited = true;
        for (const auto &to_index : nodes[index].to) {
            Visit(to_index, nodes, sorted);
        }
        sorted.emplace_front(index);
    }
}

void TopologicalSort(std::deque<Node> &nodes, std::deque<ll> &sorted) {
    for (ll i = 0; i < nodes.size(); ++i) {
        Visit(i, nodes, sorted);
    }
}

int main() {
    ll N, M;
    cin >> N >> M;

    std::deque<Node> nodes(N);
    {
        ll x, y;
        for (ll i = 0; i < M; ++i) {
            cin >> x >> y;
            nodes[x - 1].to.emplace_back(y - 1);
            nodes[y - 1].from.emplace_back(x - 1);
        }
    }

    std::deque<ll> sorted_index;
    TopologicalSort(nodes, sorted_index);
    
    std::vector<ll> dp(N + 1, 0);
    dp[sorted_index[0]] = 0;

    for (ll i = 1; i < N; ++i) {
        const auto current = sorted_index[i];

        for (const auto &f : nodes[current].from) {
            dp[current] = std::max(dp[current], dp[f] + 1);
        }
    }
    
    cout << *std::max_element(dp.cbegin(), dp.cend()) << endl;

    return 0;
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	cin >> N;

	if (N < 105)
	{
		cout << "0" << endl;
		return 0;
	}

	int ans = 0;

	rep(i, 105, N + 1)
	{
		if (i % 2 == 0)continue;

		int c = 0;
		rep(j, 1, i + 1)
		{
			if (i%j == 0)c ++;
		}
		if (c == 8)ans++;
	}

	cout << ans << endl;

	return 0;
}

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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
#define test cout<<"test"<<endl;
#define fi first
#define se second
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
const ll zero=0;
using P = pair<ll, ll>;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  ll a[n][m];
  for(i=0;i<n;i++)for(j=0;j<m;j++){
    cin>>a[i][j];
    a[i][j]--;
  }
  vector<ll>t(m),k(n);
  for(i=0;i<m;i++){
    vector<ll>h(m);
    ll maxbuf=0;
    buf=0;
    for(j=0;j<n;j++){
      while(t[a[j][k[j]]]==1)k[j]++;
      //cout<<i spa j<<endl;
      h[a[j][k[j]]]++;
      if(h[a[j][k[j]]]>maxbuf){
        buf=a[j][k[j]];
        maxbuf=h[a[j][k[j]]];
      }
    }
    chmin(res1,maxbuf);
    t[buf]=1;
  }
  cout<<res1<<endl;

  return 0;
}

Measured memory_bytes: 896
package main

import "fmt"

func getgcd(a int, b int) int{
	if b == 0 {
		return a;
	}
	return getgcd(b, a % b);
}

func gcd(a int, b int ,c int) int{
	var f, g int
	f = getgcd(a, b);
	g = getgcd(f, c);
	return g
}

func main(){
	var K int;
	fmt.Scan(&K);

	ans := 0;

	for a := 1 ; a <= K ; a++ {
		for b := 1 ; b <= K ; b++ {
			for c := 1 ; c <= K ; c++ {
				ans += gcd(a, b, c)
			}
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1776
function Main(input) {
    input =input.split('\n');
    var size = parseInt(input[0], 10);
    var targetList = input[1].split(' ');
    var minCount = 0;
    for(var index = 0; index < size; index++) {
        var num = parseInt(targetList[index], 10);
        var count = 0;
        while(true) {
            if(num % 2 !== 0) {
                break;
            }
            num = num / 2;
            count++;
        }
        minCount = (count < minCount) || (minCount === 0) ? count : minCount;
        if(minCount === 0){
            console.log(minCount);
            return;
        }
    }
    console.log(minCount);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

signed main() {
	string s;
	priority_queue<int> q;
	int n;
	while (cin >> s and s != "end") {
		if (s == "insert") {
			cin >> n;
			q.push(n);
		}
		else if (s == "extract") {
			cout << q.top() << endl;
			q.pop();
		}	
	}
}




Measured memory_bytes: 7036
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;

const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n),b(n);
    for(int i=0;i<a.size();i++){
		cin >> a[i];
	}
    for(int i=0;i<b.size();i++){
		cin >> b[i];
	}
    vector<int> d(n);
    for(int i=0;i<n;i++){
        d[i]=a[i]-b[i];
    }
    int ans=0;
    sort(d.begin(),d.end());
    int p=0;
    ll sum1=0,sum2=0;
    while(p<n&&d[p]<0){
        ans++;
        sum1-=d[p];
        p++;
    }
    p=n-1;
    while(p>=0&&sum2<sum1){
        if(d[p]<0){
            break;
        }
        sum2+=d[p];
        ans++;
        p--;
    }
    //cout << sum1 << " " << sum2 << endl;
    if(sum2>=sum1){
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



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

	if(b<a){
		printf("%d\n", a-1);
	}else{
		printf("%d\n", a);
	}

	return 0;
}


Measured memory_bytes: 256
N = int(input())
FRI_STRING=input().split()
FRI = [int(s) for s in FRI_STRING]
 
import numpy as np
ARR = np.array(FRI)
ARR = np.sort(ARR)
ARR = ARR[::-1]
 
count = 0
sum = 0
for i in range(len(FRI)-1):
  #print(ARR[count])
  sum = sum + ARR[count]
  if i % 2 == 0:
    count = count + 1
  
    
print(sum)


Measured memory_bytes: 51924
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;


typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

int main(){
    int n,k,d;
    cin>>n>>k;
    vector<int> m(n,0);
    rep(i,k){
        cin >> d;
        rep(l,d){
            int a;
            cin>>a;
            m[a-1]++;
        }
    }
    int ans=0;
    rep(i,n){
        if(m[i]==0)ans++;
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3628