akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long llong;

llong gcd(llong a, llong b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}

int main() {
    llong n, x;
    scanf("%lld %lld", &n, &x);
    llong g = gcd(x, n);
    llong ans = 3 * n - 3 * g;
    printf("%lld\n", ans);
}


Measured memory_bytes: 128
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <queue>
#include <math.h>
#include <bits/stdc++.h>
#include <queue>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;
// typedef pair<ll,ll> P;

#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)

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

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

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}

// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm( T m, T n ){
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;
    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    ll N; cin >> N;
    ll ans=0LL;

    for(ll i=1; i<sqrt(N); i++){
        if((N-i)%i == 0 && N%((N - i) / i)!=0) {
            ans += (N - i) / i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(300000)
n,k=map(int,input().split())
a=list(map(int,input().split()))

def dfs(index, lx):
  if index < 1:
    return lx
  b=[0]*n
  for i in range(n):
    l=max(0,i-lx[i])
    g=min(n-1,i+lx[i])
    b[l]+=1
    if g+1<n:
      b[g+1]-=1
  for i in range(1,n):
    b[i]+=b[i-1]
  return dfs(index-1,b)
  
    
print(*dfs(min(k,44),a))



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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    int ans=0;

    int n;
    string s;
    cin>>n>>s;

    if(s.length()<3) {
        cout<<0<<endl;
        return 0;
    }

    for(int i=0;i<s.length()-2;i++) {
        string sub=s.substr(i, 3);
        if(sub=="ABC") {
            ans++;
        }
    }

    cout<<ans<<endl;
    return 0;

}




Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int h,w;
char s[60][60];
int a[60][60];
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>s[i][j];
            if(s[i][j]=='.') continue;
            for(int x=-1;x<=1;x++){
                for(int y=-1;y<=1;y++){
                    if(0<=i+x&&i+x<h&&0<=j+y&&j+y<w){
                        a[i+x][j+y]++;
                    }
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(s[i][j]=='#'){
                cout<<'#';
            }else{
                cout<<a[i][j];
            }
        }
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
A,B,C = [int(x) for x in stdin.readline().rstrip().split()]

ans = 0

if A == B == C:
    if A % 2 == 0:
        ans = -1
    else:
        ans = 0
elif A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
     ans = 0
else:
    for _ in range(1000):
        ta = A
        tb = B
        tc = C
        A = (tb/2) + (tc/2)
        B = (ta/2) + (tc/2)
        C = (ta/2) + (tb/2)
        ans += 1
        if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
            break
        
print(ans)

Measured memory_bytes: 3064
n, k, q = map(int, input().split())
point = [k-q for _ in range(n)]
 
for i in range(q):
    a = int(input())
    point[a-1] = point[a-1] + 1
 
ans = '\n'.join('Yes' if i > 0 else 'No' for i in point[0:])
print(ans)

Measured memory_bytes: 8616
<?php
	
function isPrime( $x )
{
	if( 2 == $x ) return true;
	if( 0 == $x%2 ) return false;
	for( $i=3; $i*$i<=$x; $i++ ) {
		if( 0 == $x%$i ) { return false; }
	}
	return true;
}
	$n = trim( fgets( STDIN ) );
	$cnt = 0;
	while( $n-- ) {
		if( isPrime( trim( fgets( STDIN ) ) ) ) { $cnt++; }
	}
	print $cnt;
?>

Measured memory_bytes: 15352
n = gets.to_i
array = gets.split(" ").map(&:to_i)

array_sum = array.sum
sum = 0
previous = 0

mod = 10 ** 9 + 7
(array.length-1).times do |i|
  if i == 0
    previous = array[i]
  else
    previous += array[i]
  end
  sum += array[i] * (array_sum - previous) % mod
end
puts sum % mod

Measured memory_bytes: 33816
#include <iostream>
#include <vector>

using namespace std;

vector<char> tag[2];
vector< vector<int> > e[2];

int v[100][100];
bool f[100][100] = {0};

bool dp(int a, int b, int score) {
	if (tag[0][a] == tag[1][b]) ++score;

	if (score <= v[a][b]) return false;
	if (f[a][b]) return true;
	if (score > 100) return true;
	v[a][b] = score;

	f[a][b] = true;
	if (tag[0][a] != tag[1][b]) {
		for (int i = 0; i < e[0][a].size(); ++i) {
			if ( dp(e[0][a][i], b, score) ) return true;
		}
		for (int i = 0; i < e[1][b].size(); ++i) {
			if ( dp(a, e[1][b][i], score) ) return true;
		}
	}
	else {
	for (int i = 0; i < e[0][a].size(); ++i) {
		for (int j = 0; j < e[1][b].size(); ++j) {
			if ( dp(e[0][a][i], e[1][b][j], score) ) return true;
		}
	}
	}
	f[a][b] = false;
	return false;
}

int main() {
	fill(&v[0][0], &v[0][0]+100*100, -1);

	for (int t = 0; t < 2; ++t) {
		int N, M; cin >> N >> M;
		tag[t].resize(N);
		for (int i = 0; i < N; ++i) {
			cin >> tag[t][i];
		}
		e[t].resize(N);
		for (int i = 0; i < M; ++i) {
			int a, b; cin >> a >> b; --a, --b;
			e[t][a].push_back(b);
		}
	}

	for (int a = 0; a < tag[0].size(); ++a) for (int b = 0; b < tag[1].size(); ++b) {
		if ( dp(a, b, 0) ) {
			cout << -1 << endl;
			return 0;
		}
	}
	int ans = 0;
	for (int a = 0; a < tag[0].size(); ++a) for (int b = 0; b < tag[1].size(); ++b) {
		ans = max(ans, v[a][b]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1456
A, B, H, M = map(int, input().split())

import math
import numpy as np

t = H + M/60
w_A = 2 * math.pi / 12 * t
w_B = 2 * math.pi * t

x_A = A * math.cos(w_A)
y_A = A * math.sin(w_A)

x_B = B * math.cos(w_B)
y_B = B * math.sin(w_B)

xy_A = np.array([x_A, y_A])
xy_B = np.array([x_B, y_B])

u = xy_A - xy_B

print(np.linalg.norm(u))

Measured memory_bytes: 27216
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
//		String[] tmpArray = br.readLine().split(" ");
		
		String command = br.readLine();
		
		String[] tmpArray = br.readLine().split(" ");
		
		int destX = Integer.parseInt(tmpArray[0]);
		int destY = Integer.parseInt(tmpArray[1]);
		
		String f[] = command.split("T", -1);
		int dist[] = new int[f.length];
		
		for(int i = 0; i < f.length; i++){
			dist[i] = f[i].length();
			
			//debug
//			System.out.print(dist[i] + " ");
		}
		
//		System.out.println();
		
//		int currentX = 0;
//		int currentY = 0;
//		int x = destX;
//		int y = Math.abs(destY);

		//座標は8000を原点とする
		boolean dpx[][] = new boolean[dist.length][16001];
		boolean dpy[][] = new boolean[dist.length][16001];

		dpx[0][8000+dist[0]] = true;
		if(dist.length >= 2){
			dpy[1][8000+dist[1]] = true;
			dpy[1][8000-dist[1]] = true;
		}
		int lastX = 0;
		int lastY = 1;

		for(int i = 2; i < dist.length ; i++){
			//横移動
			if(i % 2 == 0){
				lastX = i;
				for(int j = 0; j < dpx[0].length ; j++){
					if(j >= dist[i] && dpx[i - 2][j - dist[i]]){
						dpx[i][j] = true;
//						System.out.println("x "+(j - 8000)+" is ok at i = "+i);
					}
					if(j < dpx[0].length - dist[i] && dpx[i - 2][j + dist[i]]){
						dpx[i][j] = true;
//						System.out.println("x "+(j - 8000)+" is ok at i = "+i);
					}

					//					if(i != 0){
					//						x = Math.abs(x);
					//					}
					//					currentX += dist[i];
					//
					//					if(currentX > x){
					//						x = currentX + (currentX - x);
					//					}
				}

			}
			//縦移動
			else {
				lastY = i;
				for(int j = 0; j < dpx[0].length ; j++){
					if(j >= dist[i] && dpy[i - 2][j - dist[i]]){
						dpy[i][j] = true;
//						System.out.println("y "+(j - 8000)+" is ok at i = "+i);
					}
					if(j < dpx[0].length - dist[i] && dpy[i - 2][j + dist[i]]){
						dpy[i][j] = true;
//						System.out.println("y "+(j - 8000)+" is ok at i = "+i);
					}
				}
//				for(int j = 0; j < dpx[0].length ; j++){
//					currentY += dist[i];
//
//					if(currentY > y){
//						y = currentY + (currentY - y);
//					}
//				}
			}

		
			//debug
//			System.out.println("current; "+currentX+","+currentY);
//			System.out.println("next dest; "+x+","+y);
		}
		
//		if(x == currentX && y == currentY){
		if(dpx[lastX][destX+8000] && ((dist.length <= 1 && destY == 0) || dpy[lastY][destY+8000])){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 295844
n = int(input())
d = []
for i in input().split() :
	d.append(int(i))

def ans() :
	l = len(d)
	if l % 2 == 1 : return 0
	d.sort()
	l = int(l/2)
	if d[l-1] == d[l] : return 0
	return d[l] - d[l-1]

print(ans())


Measured memory_bytes: 14428
#include <iostream>
using namespace std;
 
int main() {
    int n,a,b,c,x,y[102] = {},count,flag,j;
    while(1){
        count = 0;
        flag = 0;
        cin >> n >> a >> b >> c >> x;
        if(n == 0)break;
        for(int i = 0;i < n;i++)cin >> y[i];
        for(int i = 0;i < n && count < 10001;i++){
            while(count < 10001 && y[i] != x){
                x = ((a * x) + b)%c;
                count++;
            }
        if(i < n-1){
            x = ((a * x) + b)%c;
            count++;
        }
        }
        if(count >= 10001)cout << -1 <<endl;
        else cout << count <<endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:String,
    }
    let mut ans:usize=0;
    let mut an:usize=0;
    let a=a.chars().collect_vec();
    for i in 0..a.len() {
        if a[i]=='A'||a[i]=='T'||a[i]=='G'||a[i]=='C' {
            an+=1;
            if ans<an {
                ans=an;
            }
        }
        else { an=0; }
    }
    println!("{}",ans)
}

Measured memory_bytes: 2164
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  ll n;
  scanf("%lld", &n);
  ll t = sqrt(n);
  printf("%lld\n", t * t);
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>

int n,m;
char a[55][55];

signed main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++) std::cin>>a[i][j];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i][j]=='.') continue;
			bool bok=0;
			if(a[i-1][j]=='#') bok=1;
			if(a[i+1][j]=='#') bok=1;
			if(a[i][j-1]=='#') bok=1;
			if(a[i][j+1]=='#') bok=1;
			if(!bok){puts("No");return 0;}
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
using namespace std;
int main()
{
    int n;
    cin >> n;
    string com;
    list<int> L;
    int x;
    for (int i = 0; i < n; i++)
    {
        cin >> com;
        if (com == "insert")
        {
            cin >> x;
            L.push_front(x);
        }
        else if (com == "delete")
        {
            cin >> x;
            for (list<int>::iterator it = L.begin(); it != L.end(); it++)
            {
                if (*it == x)
                {
                    L.erase(it);
                    break;
                }
            }
        }
        else if (com == "deleteFirst")
        {
            L.pop_front();
        }
        else if (com == "deleteLast")
        {
            L.pop_back();
        }
        // cout << com << " : ";
        // int j = 0;
        // for (list<int>::iterator it = L.begin(); it != L.end(); it++)
        // {
        //     if (j++ > 0)
        //         cout << " ";
        //     cout << *it;
        // }
        // cout << endl;
    }
    int i = 0;
    for (list<int>::iterator it = L.begin(); it != L.end(); it++)
    {
        if (i++ > 0)
            cout << " ";
        cout << *it;
    }
    cout << endl;
}


Measured memory_bytes: 34284
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; 
int main()
{
	long long q,h,s,d,n,sum;
    scanf("%lld%lld%lld%lld%lld",&q,&h,&s,&d,&n);
    sum=min(q*4,min(h*2,s));
    if(sum*2<=d) printf("%lld\n",sum*n);
    else printf("%lld\n",((n%2)*sum)+n/2*d);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int ctoi(char c){
	return int(c-'0');
}
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int N;
	string S;
	cin >> N >> S;
	int ans = 0;
	int idx = 2;
	for (int i = 0; i < 1000; i++)
	{
		int tmp = i;
		idx=2;
		for (int j = 0; j < N; j++)
		{
			if(ctoi(S[j])==tmp/int(pow(10,idx))){
				tmp %= int(pow(10,idx));
				idx--;
				if(idx==-1) {
					ans++;
					break;
				}
			}
		}
	}

	cout << ans << endl;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> cnt(n);
    rep(i,n-1){
        int c;
        cin >> c;
        cnt[c-1]++;
    }
    rep(i,n){
        cout << cnt[i] << endl;
    }
}

Measured memory_bytes: 4040
#include <stdio.h>
int main(void){
  int i,j,x,l[200],a,tmp;
  scanf("%d",&x);
  scanf("%d",&l[0]);
  for(i=1;i<=x*2-1;i++){
    scanf("%d",&l[i]);
    for(j=i;j>=1;j--){
      if(l[j]<l[j-1]){
	tmp=l[j];
	l[j]=l[j-1];
	l[j-1]=tmp;
      }
      else break; 
    }
  }
  a=0;
  for(i=0;i<2*x;i+=2)
    a+=l[i];
  printf("%d",a);
  return 0;
}
      


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N; cin>>N;
    vector<int> a(N);
    REP(i,N) cin>>a[i];
    sort(ALL(a));

    cout<<a[N-1]-a[0]<<endl;
}


Measured memory_bytes: 256
x=[]
y=[]
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    else:
        x=[int(input()) for i in range(n)]
        if len(x)<k:
            pass
        else:
            s=sum(x[0:k])
            y.append(s)
            for i in range(0,n-k):
                s=s-x[i]+x[i+k]
                y.append(s)
            print(max(y))


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

int main(){
	ios::sync_with_stdio(0);
	long long n,m,ans=0,summ=0;
	cin>>n>>m;
	vector<long long> a1,a2,b1,b2,c1,c2,sum;
	for(long long i=0;i<n;i++){
		long long a,b,c;
		cin>>a>>b>>c;
		a1.push_back(a);
		b1.push_back(b);
		c1.push_back(c);
		a2.push_back(-a);
		b2.push_back(-b);
		c2.push_back(-c);
		sum.push_back(0);
	}
	for(int i=0;i<2;i++){
		vector<long long> a;
		if(i)a=a2;
		else a=a1;
		for(int j=0;j<2;j++){
			vector<long long> b;
			if(j) b=b2;
			else b=b1;
			for(int k=0;k<2;k++){
				vector<long long>c;
				if(k)c=c2;
				else c=c1;
				for(int l=0;l<n;++l){
					sum[l]=a[l]+b[l]+c[l];
				}
				sort(sum.begin(),sum.end());
				summ=0;
				for(int i=0;i<m;i++)summ+=sum[n-1-i];
				ans=max(ans,summ);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>

int main()
{
    int N, K;
    std::cin >> N >> K;

    double p = 0;
    for (int dice = 1; dice <= N; dice++)
    {
        int64_t point = dice;
        double prob = 1;
        while (point < K)
        {
            point <<= 1;
            prob *= 0.5;
        }
        p += prob;
    }
    p /= N;

    std::cout << std::setprecision(12) << p << std::endl;
    return 0;
}


Measured memory_bytes: 384
N = gets.to_i
a = gets.split.map(&:to_i)

(0..(N-1)).each do |i|
  if a[i].even?
    if a[i] % 3 != 0 && a[i] % 5 != 0
      puts "DENIED"
      exit
    end
  end
end
puts "APPROVED"


Measured memory_bytes: 1788
import math

num = [] #５個の料理の必要時間

n=input()
n=int(n)

for i in range(5): #入力
    a = input()
    a = int(a)
    num.append(a)



mini=min(num)
i=max(0,int(math.ceil(n/mini)))

print(4+i)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int main(void) {
	int a, b, c;
	char x, y;
	cin >> a >> x >> b >> y >> c;
	if (a > 2018 && b > 4)cout << "TBD" << endl;
	else cout << "Heisei" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(ll i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
int main(void){
  string s;
  cin >> s;
  int size=s.size();
  vector<int> sn(size);
  rep(i,size){
    sn[i]=s[i]-'a';
  }
  ll k;
  cin>>k;
  ll tmp;
  rep(i,size){
    if((26-sn[i])%26>k){
      //そのままにしておいた方がいい場合
      continue;
    }else{
      k-=(26-sn[i])%26;
      sn[i]=0;
    }
  }
  sn[size-1]+=k%26;
  rep(i,size){
    cout<<(char)(sn[i]+'a');
  }
  cout<<endl;
  return 0;
}

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

int main(void) {
	int j = 0;
	char s[200001], t[200001];
	scanf("%s", &s);
	scanf("%s", &t);

	for (int i = 0; i <= strlen(s); i++) {
		if (s[i] != t[i]) {
			j++;
		}
	}
	printf("%d", j);
	return 0;
}

Measured memory_bytes: 2100
(n, m) = map(int, input().split())
graph = {}
for _ in range(m):
    (a, b) = map(int, input().split())
    if not a in graph:
        graph[a] = []
    graph[a].append(b)
    if not b in graph:
        graph[b] = []
    graph[b].append(a)
is_visited = [False for _ in range(len(graph.keys()))]


def dfs(count, graph, is_visited, v_id):
    if all(is_visited):
        return 1
    sum = 0
    for neighbor in graph[v_id]:
        if is_visited[neighbor - 1]:
            continue
        is_visited[neighbor - 1] = True
        sum += dfs(count, graph, is_visited, neighbor)
        is_visited[neighbor - 1] = False
    return count + sum


count = 0
is_visited[0] = True
print(dfs(count, graph, is_visited, 1))


Measured memory_bytes: 3064
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a, b = map(int, input().split())
    flag = False
    for i in range(a,b+1):
        if i % n == 0:
            flag = True
            break

    if flag:
        print('OK')
    else:
        print('NG')

if __name__ == '__main__':
    main()


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

const int mod=1000000007;

string s;
int n;
int dp[100005][15];

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>s;
    int n=s.size();
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        if(s[i]=='?'){
            for(int j=0;j<13;j++){
                for(int k=0;k<10;k++){
                    dp[i+1][(j*10+k)%13]+=dp[i][j];
                    if(dp[i+1][(j*10+k)%13]>=mod)dp[i+1][(j*10+k)%13]-=mod;
                }
            }
        }else{
            for(int j=0;j<13;j++){
                dp[i+1][(j*10+s[i]-'0')%13]+=dp[i][j];
                if(dp[i+1][(j*10+s[i]-'0')%13]>=mod)dp[i+1][(j*10+s[i]-'0')%13]-=mod;
            }
        }
    }
    cout<<dp[n][5]<<endl;

    return 0;
}

Measured memory_bytes: 6352
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <string>
using namespace std;

int main()
{
    char ch[7][4]= {"SUN","MON","TUE","WED","THU","FRI","SAT"};

    char A[4];
    int a=0;
    scanf("%s",A);
    for(int x=0; x<7; x++)
    {
        if(strcmp(ch[x],A) == 0)
        {
            a=x;
            break;
        }
    }

    if(a == 0)
        printf("7\n");
    else
        printf("%d",7-a);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
lst = list(map(int,input().split()))

cnt = 0
le = len(lst)
for i, _ in enumerate(lst,1):
    if (i+1) == le:
        break
    
    if ( lst[i-1] < lst[i] < lst[i+1] ) or ( lst[i+1] < lst[i] < lst[i-1] ):
        cnt += 1

print ( cnt )



Measured memory_bytes: 3060
a, b, k = map(int, input().split())

for i in range(k):
    if i % 2 == 0:
        if a % 2 == 1:
            a -= 1
        a //= 2
        b += a
    else:
        if b % 2 == 1:
            b -= 1
        b //= 2
        a += b

print(a, b)
        

Measured memory_bytes: 9068
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;

  vector<int> a(N + 1, 200);
  for (int i = 1; i < N + 1; i++) {
    cin >> a[i];
  }

  sort(a.begin(), a.end(), greater<int>());

  int half = N % 2 == 0 ? N / 2 : (N - 1) / 2;
  int ans = N % 2 == 0 ? 0 : a[N];
  for (int i = 1; i <= half; i++) {
    ans += a[2 * i - 1] - a[2 * i];
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
char s[100005],t[100005];
vector<int> a[35];
int main()
{
 cin>>(s+1);
 cin>>(t+1);
 int lens=strlen(s+1),lent=strlen(t+1);
 for(int i=1;i<=lens;i++)
  a[s[i]-'a'].push_back(i);
 for(int i=1;i<=lent;i++)
  if(a[t[i]-'a'].empty())
  {
   cout<<-1<<endl;
   return 0;
  }
 int cur=0,cnt=0;
 for(int i=1;i<=lent;i++)
 {
  int num=t[i]-'a';
  auto tmp=upper_bound(a[num].begin(),a[num].end(),cur);
  if(tmp==a[num].end())
  {
   cnt++;
   cur=*a[num].begin();
  }
  else cur=*tmp;
 }
 cout<<1ll*cnt*lens+cur<<endl;
 return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  int cnt=0;
  for(int i=0;i<N;i++){
    cin>>a[i];
    if((i+1)%2==1 && a[i]%2==1){
      cnt++;
    }
  }
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
 
#define se second
#define fi first
 
typedef long long ll;
 
int main() {
	
	ll n,k;
	cin >> n >> k;
	vector<pair<ll,ll> >sk;
	ll ska,b;
	for(int i = 0;i<n;i++){
		cin >> ska >> b;
		sk.push_back(make_pair(ska,b));
	}
	sort(sk.begin(),sk.end());
	ll sum = 0;
	for(int i = 0;i<n;i++){
		sum += sk[i].se;
		if(sum >= k){
			cout << sk[i].fi;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 2420
package main

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

var sc = bufio.NewScanner(os.Stdin)
var wtr = bufio.NewWriter(os.Stdout)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type Card struct {
	mark   string
	number int
}

func nextCard() Card {
	sc.Scan()
	text := sc.Text()
	mark := text[0:1]
	number, e := strconv.Atoi(text[1:])
	if e != nil {
		panic(e)
	}
	return Card{mark, number}
}

func main() {
	sc.Split(bufio.ScanWords)
	var n int = nextInt()
	var A []Card

	for i := 0; i < n; i++ {
		A = append(A, nextCard())
	}



	bubble_A := make([]Card, n)

	copy(bubble_A, A)

	var flag = true
	for flag {
		flag = false
		for i := n - 1; i >= 1; i-- {

			if bubble_A[i].number < bubble_A[i-1].number {
				bubble_A[i], bubble_A[i-1] = bubble_A[i-1], bubble_A[i]
				flag = true
			}
		}
	}
	
	//fprintCardArray(A)
	for i := 0; i < n; i++ {
		var minj = i
		for j := i; j < n; j++ {
			if A[j].number < A[minj].number {
				minj = j
			}
		}
		if A[i].number != A[minj].number {
			A[i], A[minj] = A[minj], A[i]
		}

	}

	fprintCardArray(bubble_A)
	fmt.Fprintln(wtr,"Stable")
	fprintCardArray(A)
	if reflect.DeepEqual(A,bubble_A){
		fmt.Fprintln(wtr,"Stable")
	}else {
		fmt.Fprintln(wtr,"Not stable")
	}
	_ = wtr.Flush()

}

func fprintCardArray(arr []Card) {
	for i := 0; i < len(arr); i++ {
		if i == 0 {
			fmt.Fprintf(wtr, "%s%d", arr[i].mark, arr[i].number)
		} else {
			fmt.Fprintf(wtr, " %s%d", arr[i].mark, arr[i].number)
		}
	}
	fmt.Fprintln(wtr)
}



Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






string S;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> S;

    int ans = 0;
    rep(i, 0, 4) {
        if(S[i] == '+') ans++;
        else ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli k,s;
    cin>>k>>s;
    lli ans=0;
    rep(i,k+1){
        rep(j,min(s-i,k)+1){
            if(s-i-j<=k&&0<=s-i-j) ans++;
        }
    }
    out(ans);
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

template<class T>
struct SegmentTree {
	using F = function<T(T, T)>;
	const T init;
	const F f;
	int sz;
	vector<T> seg;
	SegmentTree(int n, const T init, const F f) :
		init(init),
		f(f)
		{
			sz = 1;
			while(sz < n) sz <<= 1;
			seg.resize(sz << 1, init);
		}
	void update(int id) {
		while(id >>= 1) {
			seg[id] = f(seg[2 * id], seg[2 * id + 1]);
		}
	}
	void replace(int id, T x){
		id += sz;
		seg[id] = x;
		update(id);
	}
	// [l,r)
	T get(int l, int r){
		T L = init, R = init;
		for(l += sz, r += sz; l < r; l >>= 1, r>>= 1) {
			if(l & 1) L = f(L, seg[l++]);
			if(r & 1) R = f(seg[--r], R);
		}
		return f(L, R);
	}
	void debug(){
		int i = 1;
		for(int r = 2; r <= 2 * sz; r <<= 1) {
			while(i < r) {
				cout << seg[i++] << " ";
			}
			cout << "\n";
		}
	}
};

int pre[100010];
int main() {
	rep(i,100010) pre[i] = -1;
	int n, m; cin >> n >> m;
	n++;
	string s; cin >> s;
	SegmentTree<pair<int, int>> seg(n, {INF, -1}, [](pair<int, int> a, pair<int, int> b){if(a.first <= b.first) return a; else return b;});
	seg.replace(0, {0, 0});
	for(int i = 1; i < n; ++i) {
		if(s[i] == '0') {
			pair<int, int> aa = seg.get(max(0, i - m), i);
			cerr << i << " " << aa.first << " " << aa.second << endl;
			seg.replace(i, {aa.first + 1, i});
			pre[i] = aa.second;
		}
	}
	vector<int> ans;
	int now = n - 1;
	while(now != -1) {
		if(pre[now] == -1) {
			if(now == 0) break;
			cout << -1 << endl;
			return 0;
		}
		ans.push_back(now - pre[now]);
		now = pre[now];
	}
	reverse(all(ans));
	int nn = ans.size();
	for(int i = 0; i < nn; ++i) {
		cout << ans[i] << (i == nn - 1 ? "\n" : " ");
	}
	return 0;
}

Measured memory_bytes: 3576
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N + 1];
		long[] B = new long[N];
		long sum = 0;
		for (int i = 0; i < N + 1; ++i) {
			A[i] = sc.nextLong();
			sum += A[i];
		}
		for (int i = 0; i < N; ++i) {
			B[i] = sc.nextLong();
		}
		for (int i = N - 1; i >= 0; --i) {
			long sub = Math.min(A[i + 1], B[i]);
			A[i + 1] -= sub;
			B[i] -= sub;
			A[i] -= Math.min(A[i], B[i]);
		}
		for (int i = 0; i < N + 1; ++i) {
			sum -= A[i];
		}
		System.out.println(sum);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}

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

#define ll long long
#define ld long double
#define ff first
#define ss second
#define eps 1e-9
#define pi acos(-1.0)
#define all(v) v.begin(),v.end()

#define MAX 500005

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

    ll n, x, t;
    cin >> n >> x >> t;

    ll m = n/x;

    if(n%x) m++;

    cout << m*t << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
using namespace std;
int main(void){
  int N,x;
  cin >> N;
  for(int i = 1; N >= i; i++){
    if(i % 3 == 0){
      cout << " " << i;
      continue;
    }
    if(i % 10 == 3){
      cout << " " << i;
      continue;
    }
    x = i;
    while(x / 10 != 0){
      x /= 10;
      if(x % 10 == 3){
        cout << " " << i;
        break;
      }
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    long long int n;
    cin>>n;
    DEFOR(i,sqrt(n)+1,1){
        if(n%i==0){
            cout<<abs(i-1)+abs((n/i)-1)<<endl;
            return 0;
        }
    }

    return 0;
}


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

int n, a[10000];

int main() {
	cin >> n;
	int count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		while (a[i] % 2 == 0) {
			count++;
			a[i] /= 2;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<max(a,max(b,c))*9+a+b+c;
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int q;
    cin >> q;
    deque<char> d;
    rep(i,s.size()) d.push_back(s[i]);
    int flag = 0; //0は通常、1は反対
    rep(i,q){
        int t;
        cin >> t;
        if(t == 1) flag ^= 1;
        else{
            int f;
            cin >> f;
            char c;
            cin >> c;
            if(flag == 0){
                if(f == 1) d.push_front(c);
                if(f == 2) d.push_back(c);
            }
            if(flag == 1){
                if(f == 1) d.push_back(c);
                if(f == 2) d.push_front(c);
            }
        }
    }
    if(flag == 0){
        while(!d.empty()){
            cout << d.front();
            d.pop_front();
        }
    }
    if(flag == 1){
        while(!d.empty()){
            cout << d.back();
            d.pop_back();
        }
    }
}

Measured memory_bytes: 3996
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    char a[n+5];
    long long sum=0;
    scanf("%s",a);
    int r=0,g=0,b=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]=='R')
            r++;
        else if(a[i]=='G')
            g++;
        else if(a[i]=='B')
            b++;
    }
    sum=(long long)r*g*b;
    for(int i=1;i<=n-2;i++)
    {
        if(i<n/2)
        {
            for(int j=1; j<=i; j++)
            {
                if(a[i]!=a[i-j]&&a[i]!=a[i+j]&&a[i-j]!=a[i+j])
                    sum--;
            }
        }
        else
        {
            for(int j=1; j<=n-i-1; j++)
            {
                if(a[i]!=a[i-j]&&a[i]!=a[i+j]&&a[i-j]!=a[i+j])
                    sum--;
            }
        }
    }
    printf("%lld\n",sum);
    return 0;
}



Measured memory_bytes: 3816
#include <iostream>
#include <cstdio>

using namespace std;

int co[1010],n;
long long mod=1e9+7;

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
    {
        int j=2,tmp=i;
        while (tmp>1)
        {
            while (tmp%j==0) co[j]++,tmp/=j;
            j++;
        }
    }
    long long x=1;
    for (int i=1;i<=n;i++)
        x*=1LL*(co[i]+1),x%=mod;
    printf("%lld\n",x);
}


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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    int a, b;
    cin >> a >> b;

    if (a>=10 || b>=10) {
        cout << -1 << endl;
        return;
    }

    cout << a*b << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
        solve();
}


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

using namespace std;

#define ll long long
#define mx 0
#define mn 1e9
#define v(dt) vector<dt>
#define pr(x, y) pair<x,y>
#define loop(x, s, n) for(int x = s; x < n; ++x)
#define in_arr(n) loop(i,0,n){cin>>a[i];}
#define out_arr(n) loop(i,0,n){cout<<a[i];}

const int N = 1e5 + 7;

inline void boost() {
    cin.tie(0), cout.tie(0), cin.sync_with_stdio(0), cout.sync_with_stdio(0);
}

int main() {
    boost();
    ll n;
    cin>>n;
    v(ll) a(n);
    in_arr(n);
    bool cond = true;
    for (int i=n-2;i>=0;--i)
    {
        if (a[i]==a[i+1] + 1)
        {
            --a[i];
        }
        else if (a[i]>a[i+1] + 1)
        {
            cond = false;
            break;
        }

    }

    if (!cond) cout<<"No";
    else cout <<"Yes";


}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        double r = (Math.floor(n/2.0)+(n%2==0?0:1)) / n;
        System.out.println(r);
    }
}


Measured memory_bytes: 21844
N = int(input())

def trial_division(n):
    a = []  
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2   
    if n != 1: a.append(n)
    #Only odd number is possible
    return a

D = {}

for i in range(1,N+1) :
    for d in trial_division(i) :
        if d not in D :
            D[d] = 1
        else :
            D[d] += 1

ans = 1

for d in D :
    ans *= (D[d]+1)
    ans %= 10**9+7

print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll x, a;
  cin >> x >> a;
  if (x < a) cout << 0 << endl;
  else cout << 10 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int max(long long int a, long long int b);
const int MAX_N = 100010;
vector<int> A(MAX_N,-1);
vector<int> B(MAX_N,-1);
vector<int> C(MAX_N,0);
vector<int> D(MAX_N,0);

int main(void)
{
    long long int ans;
    int N;
    int count = 0;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    sort(A.begin(), A.end(),greater<int>());
    for(int i = 0; i < N - 1 && count < 2; i++){
        if(A[i] == A[i+1]){
            B[count] = A[i];
            C[count] += 2;
            if(C[count] == 6) D[count] = B[count];
        }else if(A[i] != A[i+1] && B[count] != -1){
            count++;
        }
        //printf("B[%d] = %d\n",count,B[count]);
        //printf("C[%d] = %d\n",count,C[count]);
        //printf("D[%d] = %d\n",count,D[count]);
    }

    if(B[1] == -1 && C[0] < 6){
        ans = 0;
    }else if(D[0] == 0){
        ans = (long long int)B[0] * (long long int)B[1];
    }else if(D[0] != 0){
        ans = max( (long long int)B[0] * (long long int)B[1] , (long long int)D[0]*(long long int)D[0] );
    }

    cout << ans;
    return 0;
}

long long int max(long long int a, long long int b){
    if(a > b) return a;
    if(b > a) return b;
}

Measured memory_bytes: 1792
n=int(input())
keta=len(str(n))
def f(x,y):
  if keta==1:
    if x==y and x<=n:
      return 1
    else:
      return 0
  elif keta==2:
    if x==y and x*10+y<=n:
      return 2
    elif x==y:
      return 1
    elif x*10+y<=n:
      return 1
    else:
      return 0
  else:
    if x==y:
      ret=2
    else:
      ret=1
    for i in range(1,keta-2):
      ret+=10**i
    if x<int(str(n)[0]):
      ret+=10**(keta-2)
    elif x==int(str(n)[0]):
      if y<=int(str(n)[-1]):
        ret+=int(str(n)[1:keta-1])+1
      else:
        ret+=int(str(n)[1:keta-1])
    return ret

ans=0
for i in range(1,10):
  for j in range(1,10):
    ans+=f(i,j)*f(j,i)
print(ans)


Measured memory_bytes: 3188
n = int(input())
a = list(map(int,input().split()))
x = [0]*9
for i in a:
    x[min(i//400,8)]+=1
if x[8]==0:
    print(9-x.count(0),9-x.count(0))
else:
    print(max(1,8-x.count(0)),8-x.count(0)+x[8])


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define MAX 128
#define fst first
#define sec second
#define pb push_back
#define mp make_pair
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'
#define bit(n) (1LL << (n))
#define int long long
const double PI = 3.141593;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double EPS = 1e-9;
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;}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }     //最小公倍数
ll combination(ll n, ll r){if (r * 2 > n)r = n - r;ll dividend = 1;ll divisor = 1;for (ll i = 1; i <= r; ++i){dividend *= (n - i + 1);divisor *= i;}return dividend / divisor;}


signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, m;
  cin >> n >> m;
  int wa[106000];

  bool ac[105000];
  rep2(i,1,n+1){
    ac[i] = false;
    wa[i] = 0;
  }

  int w=0;
  int a = 0;

  int p;
  string s;
  
  rep(i,m){
    cin >> p >> s;
    if(ac[p])
      continue;
    if (s== "AC")
    {
      ac[p] = true;
      a++;
      w += wa[p];
    }
    else if(s=="WA"){
      wa[p]++;
      //w++;
    }
  }
  cout << a << " " << w << endl;

  return 0;
}

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

unsigned long long f(long long n){
    if(n<=0){
      return 1;
    }else if(n==1 || n==2){
      return n;
    }else{
    long long f[n]={0};
    f[0]=1;
    f[1]=2;
    for(long long i=0;i<n-2;i++){
        f[i+2]=(f[i+1]+f[i])%1000000007;
    }
    return f[n-1];
    }
}
    

int main() {
    long long n,m;
    cin>>n>>m;
    bool flag=true;
    if(m==0){
      cout<<f(n)<<endl;
    }else{
    long long a[m+2]={0};
    for(int i=1;i<m+1;i++){
        cin>>a[i];
        if(i>=2){
            if(a[i]-a[i-1]==1){
                flag=false;
                break;
            }
        }
    }
    if(!(flag)){
        cout<<0<<endl;
    }else{
        unsigned long long ans=f(a[1]-1);
        for(long long j=1;j<m;j++){
           ans = (ans*f(a[j+1]-a[j]-2))%1000000007;
          }
        ans *= f(n-a[m]-1);
        cout<<ans%1000000007<<endl;
    }
    }
}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N,M;
    cin >> N >> M;
    int A[N];
    for(int i=0;i<N;i++) cin >> A[i];
   
    long double sum_vote = 0;
    for(int i=0;i<N;i++) sum_vote += A[i]; 
    
    double limit = sum_vote / (4*M);
    int count = 0;
    for(int i=0;i<N;i++){
        if(limit<=A[i]) count++;
    }
    
    if(count>=M) cout << "Yes";
    else cout << "No";
    
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define r0 return 0;
#define f(k,i,n,j) for(ll k=i;k<=n;k=k+j)
#define cin(a) cin>>a;
#define loop while(t--)
#define vi vector<int>
#define vii vector<long long int>
#define crap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define SORT(v) sort(v.begin(),v.end());
int main()
{
    ll n,m;
    cin>>n>>m;

    bool ac[n+1]={false};
    int wa[n+1]={0};
    ll idx,pen=0,c=0;
    string s;
    for(ll i=0;i<m;i++)
    {
        cin>>idx>>s;
        if(s=="AC"){
            if(ac[idx]!=true){
            ac[idx]=true;
            c++;
            }
        }
        else if(s=="WA")
        {
            if(!ac[idx]){
            wa[idx]++;
            }
        }
    }
    for(int i=0;i<=n;i++)
    if(ac[i]) pen+=wa[i];
    
    cout<<c<<" "<<pen<<endl;
    
    
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(int i = (int)(a); i <= (int)(b); i++)
#define rf(i,a,b)    for(int i = (int)(a); i >= (int)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    ll n; rd(n);
    ll  ans = 0;
    fo(i,1,n){
        ans+=i*(n-i+1);
    }   
    fo(i,1,n-1){
        ll a,b; rd(a,b);
        if(a>b)swap(a,b);
        ans-=a*(n-b+1);
    }
    pp(ans);
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    cout<<"\n";
    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
int main(void)
{
    int n,i;
    int x[100];
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&x[i]);
    }
    for(i=n-1;i>0;i--)
    {
        printf("%d ",x[i]);
    }
    printf("%d\n",x[0]);

    return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int MAXN = 1e6 + 100;
int a[MAXN], n, sol,k;

bool check(long long mid)
{	


	long long sol = 0;
	for (int i= 1;i<=n;i++)
	{
		long long pp = a[i] / mid;
		if (a[i] % mid != 0)pp++;

		sol += pp - 1;
	}

	//cout<<mid<<" "<<sol<<endl;

	if (sol <= k)return 1;
	return 0;
}

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

	long long r = 1e9 + 10;
	long long l = 0;


	while ( r - l > 1)
	{
		long long mid = (r + l) /2;

		if (check(mid)){
			r = mid;
		}else l = mid;
	}

	printf("%lld\n",r);

	return 0;
}

Measured memory_bytes: 4464