akhauriyash/Code-Regression huggingface dataset:
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return;
}

int main()
{
	ll X = 0, i = 0, j = 0;
	scanf("%lld", &X);

	for (i = 100; i < X; ) {
		i = i + (i * 0.01);
		j++;
	}
	printf("%I64d\n", j);
	return 0;
}


Measured memory_bytes: 1728
N=int(input())
A=input().split()
B=input().split()
C=input().split()

ans=0
for i in range(N):
    ans += int(B[int(A[i])-1])
    if i >= 1 and int(A[i-1]) + 1 ==  int(A[i]):
        ans += int(C[int(A[i-1])-1])

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fore(i,a,b) for(int i=int(a); i < int(b); i++)
#define foro(i,a,b) for(int i=int(a); i >= int(b); i--)
#define prnt(a) cout << a << endl

typedef long long int ll;

using namespace std;

int main() {
	int n; cin >> n;
	
	int h[n];
	fore(i,0,n) cin >> h[i];
	
	int ans = 0;
	fore(i,0,n) {
		bool s = true;
		
		fore(j,0,i) if (h[j] > h[i]) {
				s = false;
				break;
			}
		
		if (s == true) ans++;
	}
	
	prnt(ans);

	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException
    {
        Scanner input = new Scanner(System.in);
       
        String whole = input.nextLine();
        
        ArrayList<Integer> lens = new ArrayList<Integer>();
        while (whole.indexOf("A") >= 0 && whole.lastIndexOf("Z") >= whole.indexOf("A"))
        {
            int A = whole.indexOf("A"); // 1
            whole = whole.substring(A); // ABCZ
            int Z = whole.lastIndexOf("Z"); // 3
            lens.add((Z + 1)); // 4
            whole = whole.substring(Z); // Z
        }
        
        int largest = 0;
        for (int i = 0; i < lens.size(); i++)
        {
            if (lens.get(i) > largest)
            {
                largest = lens.get(i);
            }
        }
        
        System.out.println(largest);
    }
}

Measured memory_bytes: 25916
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public void Solve()
	{
		long A = GetLong();
		long B = GetLong();

		var divsA = new List<long>();
		for(long i = 1; i * i <= A; i++)
		{
			if(A % i == 0)
			{
				divsA.Add(i);
				if(i * i < A)
					divsA.Add(A / i);
			}
		}

		var comDivs = new List<long>();
		for(int i = 0; i < divsA.Count; i++)
			if(B % divsA[i] == 0)
				comDivs.Add(divsA[i]);

		comDivs.Sort();
		int ans = 1;
		long current = 1;
		for(int i = 1; i < comDivs.Count; i++)
		{
			if(gcd(current, comDivs[i]) != 1)
				continue;

			current *= comDivs[i];
			ans++;
		}

		Console.WriteLine(ans);
	}

	private static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 13268
import sys
def main():
    input=sys.stdin.readline
    n,m,l=map(int,input().split())
    edge=[[] for i in range(n)]
    for _ in range(m):
        a,b,c=map(int,input().split())
        if c>l:
            continue
        a-=1
        b-=1
        edge[a].append((c,b))
        edge[b].append((c,a))
    def dijkstra(s):
        used=[False for _ in range(n)]
        dist=[(10**18,10**18) for _ in range(n)]
        dist[s]=(0,0)
        for _ in range(n):
            (time,cons),x=min([(dist[i],i) for i in range(n) if not used[i]])
            used[x]=True
            for cost,nx in edge[x]:
                ntime,ncons=dist[nx]
                if l-cons>=cost:
                    if ntime>time:
                        dist[nx]=(time,cons+cost)
                    elif ntime==time:
                        if ncons>cons+cost:
                            dist[nx]=(time,cons+cost)
                else:
                    if ntime>time+1:
                        dist[nx]=(time+1,cost)
                    elif ntime==time+1:
                        if ncons>cost:
                            dist[nx]=(ntime,cost)
        return dist
    ans=[]
    #print(edge)
    for s in range(n):
        ans.append(dijkstra(s))
    q=int(input())
    for _ in range(q):
        s,t=map(int,input().split())
        s-=1
        t-=1
        if ans[s][t][0]==10**18:
            print(-1)
        else:
            print(ans[s][t][0])
if __name__=="__main__":
  main()

Measured memory_bytes: 63324
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']
Yn=['Yes','No']
 
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
#ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

p=deque()

for i in StoI():
    p.append(i)
q=I()
m=0
for i in range(q):
    si=input()
    if len(si)==1:
        m=1-m
    else:
        t,f,c=si.split()
        c=ord(c)-97
        f=int(f)
        if f==1:
            M=1-m
        else:
            M=m

        if M==0:
            p.append(c)
        else:
            p.appendleft(c)
show(LtoS(p)[::1-2*m])

Measured memory_bytes: 76992
#include <cstdio>
#include <cstring>
#define MAXN 100010
#define LL long long

const LL P=1000000007;

struct Mat{
	struct Data{
		LL a[3][3];
	}*data;

	Mat(){
		data=new Data;
		memset(data->a,0,sizeof data->a);
	}

	void release(){ delete data; }

	friend void mul(Mat &x,Mat y){
		static Mat res;
		for(int i=0;i<3;i++) 
			for(int j=0;j<3;j++){
				res.data->a[i][j]=0;
				for(int k=0;k<3;k++)
					res.data->a[i][j]+=x.data->a[i][k]*y.data->a[k][j];
				res.data->a[i][j]%=P;
			}
		for(int i=0;i<3;i++)
			for(int j=0;j<3;j++)
				x.data->a[i][j]=res.data->a[i][j];
	}
}trans;

Mat getPow(Mat _x,int y){
	Mat res;
	for(int i=0;i<3;i++) res.data->a[i][i]=1;
	static Mat x;
	for(int i=0;i<3;i++) for(int j=0;j<3;j++) x.data->a[i][j]=_x.data->a[i][j];
	while(y){
		if(y&1) mul(res,x);
		mul(x,x);
		y>>=1;
	}
	return res;
}

void init(){
	trans.data->a[0][0]=1; trans.data->a[0][1]=1; trans.data->a[0][2]=1;
	trans.data->a[1][0]=0; trans.data->a[1][1]=1; trans.data->a[1][2]=2;
	trans.data->a[2][0]=1; trans.data->a[2][1]=1; trans.data->a[2][2]=2;
}

LL getG(int x){
	Mat temp=getPow(trans,x);
	return temp.data->a[0][2];
}

int n,m;
int p[MAXN];
LL f[MAXN];

void gao(){
	Mat temp;
	f[1]=getG(p[1]);
	temp.data->a[0][0]=f[1];
	for(int i=2;i<=m;i++){
		mul(temp,getPow(trans,p[i]-p[i-1]));
		f[i]=(getG(p[i])-temp.data->a[0][2]+P)%P;
		temp.data->a[0][0]=(temp.data->a[0][0]+f[i])%P;
	}
}

int main(){
#ifdef DEBUG
	freopen("E.in","r",stdin);
#endif
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++) scanf("%d",p+i);
	p[++m]=n;
	init();
	gao();
	printf("%lld\n",f[m]);
	return 0;
}


Measured memory_bytes: 17024
h, w = gets.split.map(&:to_i)
ss = h.times.map { gets.chomp }

h.times do |i|
  ans = Array.new(w, 0)

  w.times do |j|
    if ss[i][j] == "#"
      print ss[i][j]
      next
    end

    count = 0
    l = j - 1 < 0 ? j : j - 1
    r = j + 1 > w ? j : j + 1

    if i - 1 >= 0
      count += ss[i - 1][l..r].count("#")
    end

    count += ss[i][l..r].count("#")

    if i + 1 <= h - 1
      count += ss[i + 1][l..r].count("#")
    end

    print count
  end

  puts
end


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vl;

string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> s;
	int cur = 0;
	ll ans = 0;
	for (int i = (int)s.size() - 1; i >= 0; i--) {
		if (s[i] == 'B') {
			ans += cur;
		}	else {
			cur++;
		}
	}
	cout << ans;
}


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

int main(){
	int n;
	cin>>n;
	string s1,s2;
	cin>>s1>>s2;
	
	int i=1;
	
	long long int ans=1;
	long long int mod=1e9+7;
	
	int flag;
	if(s1[0]==s2[0]){
		flag=0;
	}else{
		flag=1;
		i=2;
		if(n!=1)ans=2;
	}
	
	for(;i<n;i++){
		if(flag==0){
			if(s1[i]==s2[i]){
				ans*=2;
				ans%=mod;
			}else{
				ans*=2;
				ans%=mod;
				flag=1;
				i++;
			}
		}else{
			if(s1[i]==s2[i]){
				flag=0;
			}else{
				ans*=3;
				ans%=mod;
				i++;
			}
		}
	}
	
	ans*=3;
	ans%=mod;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	map<int, ll> mp;
	rep(i, n) {
		cin >> a[i];
		mp[a[i]]++;
	}
	ll ans = 0;
	for (auto& c : mp) {
		if (c.second >= 2) {
			ans += ll(c.second * (c.second - 1) / 2);
		}
	}
	rep(i, n) {
		if (mp[a[i]] < 2) {
			dunk(ans);
			continue;
		}
		ll j_ans = ans;
		j_ans -= (mp[a[i]] - 1);
		dunk(j_ans);
	}

	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int a,b,c;
  cin >> a >> b >> c;
  int t=a;
  bool f=1;
  REP(i,1,60*60+c+1) {
    c--;t--;
    if(c==0&&f) {
      pr(i);
      return;
    }
    if(!c) c=60;
    if(!t) {
      if(f) {
        f=0;
        t=b;
      } else {
        f=1;
        t=a;
      }
    }
  }
  pr(-1);
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


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

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[10011], B[10011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    REP (i, N) scanf("%d", B+i);

    LL sa = 0, sb = 0;
    REP (i, N) {
	if (A[i] > B[i]) {
	    sb += A[i] - B[i];
	} else if (A[i] < B[i]) {
	    sa += (B[i] - A[i] + 1) / 2;
	    sb += (B[i] - A[i]) % 2;
	}
    }

    LL ta = 0, tb = 0;
    ta += max(sa, sb) * 2;
    tb += max(sa, sb);
    REP (i, N) {
	ta += A[i];
	tb += B[i];
    }
    if (ta <= tb) puts("Yes");
    else puts("No");
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 384
S=str(input())
P=S
for i in range(len(P)//2):
  if P[i]!=P[len(P)-1-i]:
    print('No')
    exit()
    
for i in range(len(P)//2):
  if P[i]!=P[len(P)-1-i]:
    print('No')
    exit()

P=S[(len(S)+3)//2-1:len(S)]
for i in range(len(P)//2):
  if P[i]!=P[len(P)-1-i]:
    print('No')
    exit()
    
print('Yes')

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	num, _ := strconv.Atoi(a + b)

	for i := 4; i*i <= num; i++ {
		if i*i == num {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<62;





int main(void) {

    ll n,m;
    cin>>n>>m;
    vll v(n);
    rep(i,n)cin>>v[i];
    vll csum(n+1,0);
    for(int i=1;i<n+1;i++){
        csum[i]=csum[i-1]+v[i-1];
    }
    map<ll,ll> ma;
    ll  ans=0;
    for(int i=0;i<=n;i++){
        ans+=ma[csum[i]%m];
        ma[csum[i]%m]++;
    }
    
    
    fin(ans);
}


Measured memory_bytes: 5760
#include<stdio.h>
bool b[1000000];

int main(void)
{
    int a,n,i;
    int count=0;
    int f=1;

    for(i=3;i<1000000;i+=2){
        f=1;
        for(a=2;a*a<=i;a++){
            if(i%a == 0){
                f=0;
                break;

            }
        }
        if(f==1){
            b[i]=1;
        }
    }
    b[2]=1;

    while(scanf("%d",&n)!=EOF){
        for(i = 0; i <= n; i++){
            if(b[i]==1)count++;
        }

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

Measured memory_bytes: 1732
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c= sc.nextInt();
		int [] haiku = {a,b,c};
		int temp = 0;
		
		for(int i = 0; i<3 ; i++ ) {
			for(int j=0 ; j<3 ; j++) {
				if(haiku[i]<haiku[j]) {
					temp=haiku[i];
					haiku[i]=haiku[j];
					haiku[j]=temp;
				}
			}
		}
		if(haiku[0]==5 && haiku[1]==5 && haiku[2]==7) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		sc.close();


	}

}


Measured memory_bytes: 21844
N = int(input())
x = [i for i in range(1,N+1) if i%2!=0]
z = []
for i in x:
  y = 0
  for j in range(1,N+1):
    if i % j == 0:
      y += 1
  if y == 8:
    z.append(i)
print(len(z))

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		long W = GetLong();
		List<long>[] v = new List<long>[4];
		for(int i = 0; i < 4; i++)
			v[i] = new List<long>(N);

		long w1 = GetLong();
		v[0].Add(GetLong());
		for(int i = 1; i < N; i++)
			v[GetLong() - w1].Add(GetLong());

		for(int i = 0; i < 4; i++)
		{
			v[i].Sort();
			v[i].Reverse();
		}

		long[,] csum = new long[4, N+1];
		for(int i = 0; i < 4; i++)
		{
			for(int j = 1; j <= v[i].Count; j++)
			{
				csum[i,j] = csum[i,j-1] + (v[i])[j-1];
			}
		}

		long ans = 0;
		for(int i = 0; i <= v[3].Count; i++)
		{
			for(int j = 0; j <= v[2].Count; j++)
			{
				for(int k = 0; k <= v[1].Count; k++)
				{
					long tmpW = (w1 + 3) * i + (w1 + 2) * j + (w1 + 1) * k;
					
					if(tmpW > W)
						continue;
					
					long value = 
						csum[3,i] + 
						csum[2,j] + 
						csum[1,k] + 
						csum[0, Math.Min(v[0].Count, (W - tmpW)/w1)];
					ans = Math.Max(ans, value);
				}
			}
		}

		Console.WriteLine(ans);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13524
import math

def main():
    H = {int(input()): 1}
    ans = 0
    while True:
        new_H = {}
        for h, freq in H.items():
            ans += freq
            if h > 1:
                new_H[h // 2] = 2 * freq
        if len(new_H) == 0:
            break
        else:
            H = new_H
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62044
from sys import stdin

def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

def main():
    N, K = [int (x) for x in stdin.readline().rstrip().split()]
    result = len(str(N)) if K == 10 else len(Base_10_to_n(N, K)) 
    print(result)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
namespace io{
    #define re register
    #define ll long long
    #define inf 0x3f3f3f3f
    #define il inline 
    #define in1(a) read(a)
    #define in2(a,b) in1(a),in1(b)
    #define in3(a,b,c) in2(a,b),in1(c)
    #define in4(a,b,c,d) in2(a,b),in2(c,d)
    il void readl(ll &x){
        x=0;ll f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
    il void read(int &x){
        x=0;int f=1;char c=getchar();
        while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
        while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
        x*=f;
    }
}using namespace io;
int main(){
	int a,b;
	in2(a,b);
	printf("%d",max(a+b,max(a-b,a*b)));
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LLINF 1<<63-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007
#define NUM 100001
void swap(int* x,int* y){
  int tmp=*x;*x=*y;*y=tmp;
}
int cmp(const void *x,const void *y){
  return *(int*)x-*(int*)y;
}

int main() {
  int i,A,P,ans=0;
  scanf("%d%d",&A,&P);
  ans=(A*3+P)/2;
  printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define vi vector<int>
#define vl vector<ll>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define mm map<ii>
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

    int n;
    cin>>n;

    vi v(n);
    
    forn(i,0,n) cin>>v[i];

    int count = 0;

    forn(i,1,n-1)
    {
        int maxi = max(v[i-1],max(v[i],v[i+1]));
        int mini = min(v[i-1],min(v[i],v[i+1]));
        if(mini < v[i] && v[i] < maxi) count++;
    }

    cout<<count;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>

using namespace std;

int N;
map<int, int> m;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		m[a]++;
	}
	int ans = 0;
	int ct = 0;
	for (auto i = m.begin(); i != m.end(); i++) {
		if (i->second > 1) {
			if (i->second % 2 == 0) {
				ct++;
			}
		}
		ans++;
	}
	if (ct % 2 == 1) {
		cout << ans - 1 << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4992
#include<stdio.h> 
#define MAX 200000
  
int Partition(int D[],int p,int r){
 
  int i=p-1,j;
  int x = D[r];
  for(j=p;j<=r-1;j++){
    if(D[j]<=x){
      i=i+1;
      swap(&D[i],&D[j]);
    }
  }
  swap(&D[i+1],&D[r]);
  return i+1;
}
int A[MAX];
int main(){
  int n,temp;
  int i,x;
  int result;
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&A[i]);
    x=Partition(A,0,n-1);
    i=0;
    while(i<n){
    if(i)printf(" ");
    if(i==x)printf("[");
    result=A[i];
	printf("%d",result);
    if(i==x)printf("]");
    i=i+1;
  }
  printf("\n");
  return 0;
}
void swap(int* c,int* k){
  int temp;
  temp=*c;
  *c=*k;
  *k=temp;
}


Measured memory_bytes: 2124
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <algorithm>
using namespace std;

typedef long long ll;

int main()
{
    int n, m;
    while(cin >> n && n) {

        map<char, char> conv;
        char a, b;
        for(int i = 0; i < n; i++) {
            cin >> a >> b;
            conv[a] = b;
        }
    
        cin >> m;
    
        char c;
        map<char, char>::iterator it;
        for(int i = 0; i < m; i++) {
            cin >> c;
            putchar(conv[c] ? conv[c] : c);
        }

        putchar('\n');
    }
}

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

using namespace std;

const int N = 1e5 + 5;

int n, m, dp[N], deg[N];
vector <int> g[N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        ++deg[v];
    }

    vector <int> topo;
    queue <int> q;
    memset(dp, -0x3f, sizeof(dp));
    for (int i = 1; i <= n; i++) {
        if (!deg[i]) {
            dp[i] = 0;
            q.push(i);
            topo.push_back(i);
        }
    }

    while (!q.empty()) {
        int u = q.front(); q.pop(); 
        for (auto v: g[u]) {
            if (--deg[v] == 0) {
              q.push(v);
              topo.push_back(v);
            }
        }
    }

    for (auto i: topo) {
        for (auto j: g[i]) {
            dp[j] = max(dp[j], dp[i] + 1);
        }
    }

    cout << *max_element(dp + 1, dp + n + 1);
    return 0;
}


Measured memory_bytes: 7164
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long INF = 1LL << 60;
template <class T> bool chmin(T& a, T b){if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b){if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  vector<char> s(12);
  for (int i = 0; i < 12; i++) cin >> s.at(i);
  
  for (int i = 0; i < 4; i++) cout << s.at(i);
  cout << " ";
  for (int i = 4; i < 12; i++) cout << s.at(i);
  cout << endl;
}

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

using namespace std;
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } 
template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int c=0;
	if(s[0]=='o') c++;
	if(s[1]=='o') c++;
	if(s[2]=='o') c++;
	cout << (700 + 100*c) <<"\n";
	return 0;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
int n;
int A[660];
bool usd[660],mst[660];
int dp[2][330][330];
inline void add(int &a,int b)
{
	a+=b;
	if(a>=MOD)a-=MOD;
}
int main()
{
	scanf("%d",&n);
	int two=0,one=0,usea=0,useb=0;
	int m=n;
	for(int i=0;i<n;i++)
	{
	//	cout<<i<<endl;
		scanf("%d%d",&A[i*2],&A[i*2+1]);
		if(A[i*2]==-1&&A[i*2+1]==-1)
		{
			two++;
		}
		else if(A[i*2]==-1)
		{
			one++;
		//	use++;
			mst[A[i*2+1]]=1;
		}
		else if(A[i*2+1]==-1)
		{
			one++;
		//	use++;
			mst[A[i*2]]=1;
		}
		else
		{
		//	use+=2;
			m--;
			usd[A[i*2]]=usd[A[i*2+1]]=1;
		}
	}
	int p=0,q=1;
	dp[p][two][0]=1;
//	cout<<p<<" "<<two<<" "<<one<<endl;
	for(int i=n*2;i>=1;i--)
	{
		if(usd[i])continue;
		memset(dp[q],0,sizeof(dp[q]));
	//	cout<<i<<endl;
		for(int curtwo=0;curtwo<=two;curtwo++)
		{
		//	if((m-two)*2<use)break;
		//	cout<<i<<" "<<two<<endl;
			for(int curone=0;curone<=one;curone++)
			{
			//	if((m-two-one)*2+one<use)break;
				if(!dp[p][curtwo][curone])continue;
				int spt=(two-curtwo)*2+(useb-curone);
			//	cout<<i<<" "<<curone<<" "<<curtwo<<" "<<usea<<" "<<useb<<" "<<spt<<endl;
			//	cout<<i<<" "<<two<<" "<<one<<" "<<p<<" "<<dp[p][two][one]<<endl;
			/*	if(two)
				{
					if(!mst[i])add(dp[q][two-1][one+1],dp[p][two][one]*1ll*two%MOD);
					else add(dp[q][two-1][one+1],dp[p][two][one]);
					cout<<i<<" "<<q<<" "<<two-1<<" "<<one+1<<" "<<dp[q][two-1][one+1]<<endl; 
				}
				if(!mst[i]&&one)
				{
					add(dp[q][two][one-1],dp[p][two][one]);
					cout<<i<<" "<<q<<" "<<two<<" "<<one-1<<" "<<dp[q][two][one-1]<<endl;
				}*/
				if(mst[i])
				{
					add(dp[q][curtwo][curone+1],dp[p][curtwo][curone]);
					if(spt<usea)
					{
						add(dp[q][curtwo][curone],dp[p][curtwo][curone]);
					}
				}
				else
				{
					add(dp[q][curtwo][curone],dp[p][curtwo][curone]);
					if(curtwo&&spt<usea)
					{
						add(dp[q][curtwo-1][curone],dp[p][curtwo][curone]*1ll*(curtwo)%MOD);
					}
					if(curone)
					{
						add(dp[q][curtwo][curone-1],dp[p][curtwo][curone]*1ll*(curone)%MOD);
					}
				}
			}
		}
		if(mst[i])useb++;
		else usea++;
		swap(p,q);
	}
	printf("%d\n",dp[p][0][0]);
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int a[MAX];

ll f(bool plus) {
  ll res = 0;

  ll sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
    if (plus) {
      if (sum <= 0) {
        res += 1 - sum;
        sum = 1;
      }
    } else {
      if (sum >= 0) {
        res += 1 + sum;
        sum = -1;
      }
    }
    plus = !plus;
  }

  return res;
}

int main() {
  // 入力
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];

  // プラスから始まるか、マイナスから始まるかの2パターン試して小さい方を出力
  cout << min(f(true), f(false)) << endl;

  return 0;
}


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

int main(){
    long long X,Y,ans;
    cin >> X >> Y;
    if(X%Y==0){
        cout << -1 << "\n";
    }
    else{
        for(long long i=1;i<1000000000000000000;i++){
            X*=i;
            if(X%Y!=0){
                cout << X << "\n";
                break;
            }
        }
    }
    return 0;
}

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

using namespace std;

template <typename T>
void print(T vec) { for(auto i : vec) cout<<i<<" ";}
template <typename T>
void print2D(T matrix) {for(auto vec:matrix) {print(vec);cout<<'\n';}}


int main() {
    int n;
    cin>>n;
    vector<double> prob(n + 1, 0);
    for(int i = 1;i <=n;i++) {
        cin>>prob[i];
    }
    vector<vector<double>> dp(n+1,vector<double>(n+1, 0));
    dp[0][0] = 1.0;
    for(int i = 1; i<=n;i++) {
        for(int j = 0;j <= i; j++) {
            if(j == 0) {
                dp[i][j] = dp[i - 1][j] * ((double)1 - prob[i]);
            }
            else dp[i][j] = dp[i - 1][j - 1] * prob[i] +  dp[i - 1][j] * ((double)1 - prob[i]);

        }
    }
    double ans = 0.0;
    for(int i = (n+1)/2;i<=n;i++) {
        ans+=dp[n][i];
    }
    cout<<setprecision (numeric_limits<double>::digits10 + 1)<<ans<<'\n';
    //print2D(dp);

    return 0;
}

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

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

int cumsum[3000][3000];

int rectangleSum(int lx, int rx, int by, int ty) {
    int sum = cumsum[rx][ty];
    if (lx - 1 >= 0) sum -= cumsum[lx - 1][ty];
    if (by - 1 >= 0) sum -= cumsum[rx][by - 1];
    if (lx - 1 >= 0 and by - 1 >= 0) sum += cumsum[lx - 1][by - 1];
    return sum;
}

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

    int n, k;
    cin >> n >> k;

    const int size = 2 * k;

    auto add = [&](int x, int y) {
        cumsum[x][y]++;
        if (x < k) cumsum[x + size][y]++;
        if (y < k) cumsum[x][y + size]++;
        if (x < k and y < k) cumsum[x + size][y + size]++; 
    };

    repeat (i, n) {
        int x, y;
        char c;
        cin >> x >> y >> c;

        if (c == 'B') {
            add(x % size, y % size);
            add((x + k) % size, (y + k) % size);
        } else {
            add((x + k) % size, y % size);
            add(x % size, (y + k) % size);
        }
    }

    repeat (y, 3 * k) {
        for (int x = 1; x < 3 * k; x++) {
            cumsum[x][y] += cumsum[x - 1][y];
        } 
    }

    repeat (x, 3 * k) {
        for (int y = 1; y < 3 * k; y++) {
            cumsum[x][y] += cumsum[x][y - 1];
        }
    }

    int ans = 0;

    repeat (x, size) {
        repeat (y, size) {
            ans = max(ans, rectangleSum(x, x + k - 1, y, y + k - 1));
        }
    }

    cout << ans << endl;

    return 0;
}


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

const ll INF = 1e17;

int main() {
    // input
    int X,Y;
    cin >> X >> Y;

    // resolve
    int ans =0;
    if (X ==3) ans += 100000;
    if (Y ==3) ans += 100000;
    if (X ==2) ans += 200000;
    if (Y ==2) ans += 200000;
    if (X ==1) ans += 300000;
    if (Y ==1) ans += 300000;        
    if (X==1 && Y==1) ans += 400000;
  
    // resolve
    cout << ans << endl;

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

struct UnionFind {
  vi32 par;
  vi32 siz;
  UnionFind(int n) {
    par = vi32(n + 1);
    siz = vi32(n + 1, 1);
    iota(all(par), 0);
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    par[x] = y;
    siz[y] += siz[x];
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return siz[root(x)];
  }
};

void solve() {
  int N, K, L;
  cin >> N >> K >> L;
  auto uf1 = UnionFind(N);
  auto uf2 = UnionFind(N);
  rep(i, K) {
    int p, q;
    cin >> p >> q;
    uf1.unite(p, q);
  }
  rep(i, L) {
    int r, s;
    cin >> r >> s;
    uf2.unite(r, s);
  }
  using P = pair<int, int>;
  map<P, int> ma;
  reps(i, N) {
    ma[P(uf1.root(i), uf2.root(i))]++;
  }
  vi32 ans(N);
  reps(i, N) {
    ans[i - 1] = ma[P(uf1.root(i), uf2.root(i))];
  }
  cout << ans << '\n';
}


Measured memory_bytes: 15872
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef long long ll;
int a[20],b[20],ten[9];
int d;
int i,j,k,l,t,n,m,tot,top;
ll num,sum,wdc,pp,ans;
bool czy;
int main(){
	ten[0]=1;
	fo(i,1,8) ten[i]=ten[i-1]*10;
	scanf("%d",&d);
	pp=1;
	if (d%10==0){
		czy=1;
		while (d%10==0){
			d/=10;
			pp*=10;
		}
		pp=pp/10*9;
	}
	fo(l,1,7)
	fo(i,0,ten[l]-1){
		t=0;
		k=i;
		top=0;
		fo(j,1,l){
			a[++top]=k%10;
			k/=10;
		}
		k=i+d;
		tot=0;
		fo(j,1,top){
			b[++tot]=k%10;
			k/=10;
		}
		if (!czy&&b[1]==0) continue;
		reverse(b+1,b+tot+1);
		fo(j,1,tot) a[++top]=b[j];
		num=0;
		wdc=1;
		fo(j,1,top){
			num+=(ll)a[j]*wdc;
			wdc*=10;
		}
		sum=0;
		wdc=1;
		reverse(a+1,a+top+1);
		fo(j,1,top){
			sum+=(ll)a[j]*wdc;
			wdc*=10;
		}
		if (num+(ll)d==sum){
			ans++;
		}
		//continue;
		reverse(a+1,a+top+1);
		top-=tot;
		a[++top]=0;
		fo(j,1,tot) a[++top]=b[j];
		num=0;
		wdc=1;
		fo(j,1,top){
			num+=(ll)a[j]*wdc;
			wdc*=10;
		}
		sum=0;
		wdc=1;
		reverse(a+1,a+top+1);
		fo(j,1,top){
			sum+=(ll)a[j]*wdc;
			wdc*=10;
		}
		if (num+(ll)d==sum){
			ans+=10;
		}
	}
	/*fo(l,1,7)
	fo(i,0,ten[l]-1){
		t=0;
		k=i;
		top=0;
		fo(j,1,l){
			a[++top]=k%10;
			k/=10;
		}
		k=i+d;
		tot=0;
		fo(j,1,top){
			b[++tot]=k%10;
			k/=10;
		}
		if (!czy&&b[1]==0) continue;
		reverse(b+1,b+tot+1);
		fo(j,2,tot) a[++top]=b[j];
		num=0;
		wdc=1;
		fo(j,1,top){
			num+=(ll)a[j]*wdc;
			wdc*=10;
		}
		sum=0;
		wdc=1;
		reverse(a+1,a+top+1);
		fo(j,1,top){
			sum+=(ll)a[j]*wdc;
			wdc*=10;
		}
		if (num+(ll)d==sum){
			ans++;
		}
	}*/
	ans*=pp;
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
from collections import deque

def dfs():
    que = deque()
    for i in range(1,10):
        que.append([i,i])

    counter = 9

    if k <= 9:
        print(k)
        exit()

    temp = [0]*2

    while True:
        x = que.popleft()
        for j in [-1,0,1]:
            if x[0]+j < 0 or x[0]+j >= 10:
                continue
            temp[0] = x[0] + j
            temp[1] = x[1]*10 + x[0] + j
            counter += 1
            if counter == k:
                print(temp[1])
                exit()
            que.append(temp)
            temp = [0] * 2
                



k = int(input())
dfs()
#幅優先探索で良いとのこと



Measured memory_bytes: 71776
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N, K;
    cin >> N >> K;

    ll ans = 0;

    for (int i = 0; i < K; i++) {
        if ((i * 2) % K != 0) {
            continue;
        }

        ll acc = 0;

        // TODO: how to calculate a
        ll a = N / K;
        if (i != 0 && i <= N % K) {
            a++;
        }

        acc = a * a;

        ll b = N / K;
        if (K - i != 0 && K - i <= N % K) {
            b++;
        }

        acc *= b;

        // printf("i: %d, a: %lld, b: %lld, acc: %lld\n", i, a, b, acc);

        ans += acc;
    }

    cout << ans << endl;

    return 0;
}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const string t = "AKIHABARA";

bool good(string &s) {
    int i = 0, j = 0, rep = 0;
    int n = si(s), m = si(t);
    while (i < n && j < m && rep < 100) {
        if (s[i] == t[j]) { i++; j++; }
        else if (t[j] == 'A') j++;
        rep++;
    }
    return i == n && j >= m-1;
}

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

    string s; cin >> s;
    cout << (good(s) ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong(),d=sc.nextLong();
        long ans=0;
        ans+=b/c-(a-1)/c;
        ans+=b/d-(a-1)/d;
        ans-=b/(c*d/Euclid(c,d))-(a-1)/(c*d/Euclid(c,d));
        System.out.println(b-a+1-ans);

    }
    private static long Euclid(long n, long m) {
        long tmp;
        while (true) {
            if (n == 0) {
                return m;
            } else if (m == 0) {
                return n;
            }
            tmp = n;
            n = m;
            m = tmp;
            n = n % m;

        }

    }

}


Measured memory_bytes: 22996
n = int(input())
n_list = [input() for _ in range(n)]

print("AC x "+str(n_list.count('AC')))
print("WA x "+str(n_list.count('WA')))
print("TLE x "+str(n_list.count('TLE')))
print("RE x "+str(n_list.count('RE')))


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

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> p(n);
    string s;
    cin >> s;
    int a = 0, i = 0;
    for (const auto& e : s) {
      if (e == 'M') {
        p[i % n]++;
      } else if (e == 'S') {
        a += p[i % n] + 1;
        p[i % n] = 0;
      } else {
        p[i % n] += a + 1;
        a = 0;
      }
      i++;
    }
    sort(p.begin(), p.end());
    for (int i = 0; i < n; i++) {
      cout << p[i] << " ";
    }
    cout << a << "\n";
  }
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int n,k,x;
double a[200010],f[200010],ans=-1e9;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>x;
		a[i]=(x+1.0)/2;
	}
	f[1]=a[1];
	for(int i=2;i<=n;i++)
		f[i]=f[i-1]+a[i];
	for(int i=k;i<=n;i++)
		ans=max(ans,f[i]-f[i-k]);
	printf("%.10lf",ans);
	return 0;
}

Measured memory_bytes: 3328
import collections
n=int(input())
a=list(map(int,input().split()))
q=int(input())
bc=[list(map(int,input().split())) for i in range(q)]
ac=collections.Counter(a)
#print(ac)
ans=sum(a)
for i in range(q):
    if ac[bc[i][0]]!=None:
        if ac[bc[i][1]]!=None:
            ans-=bc[i][0]*ac[bc[i][0]]
            ans+=bc[i][1]*ac[bc[i][0]]
            ac[bc[i][1]]+=ac[bc[i][0]]
            ac[bc[i][0]]=0
        else:
            ans-=bc[i][0]*ac[bc[i][0]]
            ans+=bc[i][1]*ac[bc[i][0]]
            ac[bc[i][1]] = ac[bc[i][0]]
            ac[bc[i][0]]=0

    print(ans)


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

int main() {
  int n,m,x,y;
  cin >>n>>m>>x>>y;
  vector<int>a(n),b(m);
  for(int i=0;i<n;i++)cin>>a[i];
  sort(a.begin(),a.end());
  for(int i=0;i<m;i++)cin>>b[i];
  sort(b.begin(),b.end());
  for(int i=x+1;i<=y;i++){
    if(a[n-1]<i&&i<=b[0]){
      //cout<<a[n-1]<<" "<<i<<" "<<b[0]<<endl;
      cout<<"No War"<<endl;
      return 0;
    }
  }
  cout<<"War"<<endl;
  return 0;
}


Measured memory_bytes: 256