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

int N,K;
long long a[5000];
int dp[5000][5000];

int rec(int x, int y);
bool need(int i);


int main(){
    int ans;
    int left,right;

    scanf("%d %d", &N,&K);
    for(int i=0;i<N;i++){
        scanf("%lld",&a[i]);
    }

    sort(a,a+N);

    if(need(0)==true){
        ans = 0;
    }else if(need(N-1)==false){
        ans = N;
    }else{
        left = 0;
        right = N-1;

        while(left<right-1){
            int m = (right - left) / 2 + left;
            if(need(m)){
                right = m;
            }else{
                left = m;
            }
        }

        ans = right;
    }
        printf("%d\n",ans);

        return 0;
}


int rec(int x,int y){
    if(dp[x][y]>=0){
        return dp[x][y];
    }
    if(x==0){
        if(a[0]==y) return 1;
        else return 0;
    } else {
        int res = 0;
        if(rec(x-1,y)==1){
            res = 1;
        }
        if(y>=a[x]){
            if(rec(x-1,y-a[x])==1){
                res = 1;
            }
        }
        dp[x][y] = res;
        return res;
    }
}


bool need(int i){
    int temp = a[i];
    a[i] = 0;
    memset(dp,-1,sizeof(dp));
    bool found = false;

    for(int j=max(0,K-temp);j<K;j++){
        if(rec(N-1,j)==1){
            found = true;
            break;
        }
    }
    a[i] = temp;
    return found;
}


Measured memory_bytes: 98176
package main

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

var sc = bufio.NewScanner(os.Stdin)

// H =height/witdh
var H int

// W =height/witdh
var W int

func main() {
	scanInit()

	H = nextInt()
	W = nextInt()
	s := nextGrid(H, W)

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			if s[i][j] == "." {
				s[i][j] = getBombnum(i, j, "#", s)
			}
		}
	}

	DBGprintGrid(s)

}

// DBGprintGrid print the grid
//! DBG
func DBGprintGrid(g [][]string) {
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			fmt.Printf("%s", g[i][j])
		}
		fmt.Printf("\n")
	}
}

// 周りからtargetを探す
func getBombnum(i, j int, target string, s [][]string) string {
	cnt := 0

	//* 検索方向設定
	// 12時から時計回り ８方向
	dx := []int{+0, +1, +1, +1, +0, -1, -1, -1}
	dy := []int{-1, -1, +0, +1, +1, +1, +0, -1}
	// 12時から時計回り ４方向
	//dx := []int{+0, +1, +0, -1}
	//dy := []int{-1, +0, +1, +0}

	dnum := len(dx)
	for d := 0; d < dnum; d++ {
		ni := i + dy[d]
		nj := j + dx[d]

		// 領域外なら探索せずにスルー
		if ni < 0 || H <= ni || nj < 0 || W <= nj {
			continue
		}
		if s[ni][nj] == target {
			// Bomb HIT
			//fmt.Println("DBG HIT") //! DBG
			cnt++
		}

	}

	//return fmt.Sprintf("%d", cnt)
	return "" + string(cnt+'0')
}
func getBombnum2(i, j int, target string, s [][]string) string {
	cnt := 0

	// 上段
	if i > 0 && j > 0 {
		if s[i-1][j-1] == target {
			cnt++
		}
	}
	if i > 0 {
		if s[i-1][j] == target {
			cnt++
		}
	}
	if i > 0 && j < W-1 {
		if s[i-1][j+1] == target {
			cnt++
		}
	}
	// 中段
	if j > 0 {
		if s[i][j-1] == target {
			cnt++
		}
	}
	if j < W-1 {
		if s[i][j+1] == target {
			cnt++
		}
	}
	// 下段
	if i < H-1 && j > 0 {
		if s[i+1][j-1] == target {
			cnt++
		}
	}
	if i < H-1 {
		if s[i+1][j] == target {
			cnt++
		}
	}
	if i < H-1 && j < W-1 {
		if s[i+1][j+1] == target {
			cnt++
		}
	}

	return fmt.Sprintf("%d", cnt)
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
func nextGrid(a int, b int) [][]string {
	mat := make([][]string, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]string, b)
		tmp := nextStr()
		mat[i] = strings.Split(tmp, "")
	}
	return mat
}


Measured memory_bytes: 1872
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 14:49:47 2020

@author: liang
"""

"""
【組み合わせ生成】
    itertools.combinations(iterable, r)
【総積】
    numpy.prod(iterable)
"""
from itertools import combinations
import numpy as np

N = int(input())
d = [0]*5
for i in range(N):
    s = input()
    if s[0] == "M":
        d[0] += 1
    if s[0] == "A":
        d[1] += 1
    if s[0] == "R":
        d[2] += 1
    if s[0] == "C":
        d[3] += 1
    if s[0] == "H":
        d[4] += 1
    
ans = 0
for lis in combinations(d,3):
    ans += np.prod(lis)
print(ans)

Measured memory_bytes: 27116
import re
n=int(input())
s=[ ''.join(map(lambda x : '{0:09d}'.format(int(x)) if '0' <= x[0] <= '9' else x, re.sub(r'\d+', r' \g<0> ',input()).split()))for _ in range(n+1) ]
for i in range(1,n+1):
    print('-' if s[i] < s[0] else '+')



Measured memory_bytes: 6672
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
C.insert(0, 0)
ans = 0
pre = N

for _ in range(N):
  buf = A[_] - 1
  ans += B[buf]
  if buf == pre + 1:
    ans += C[buf]
  pre = buf

print(ans)


Measured memory_bytes: 3060
<?php
fscanf(STDIN, "%d %d", $N, $K);
$x = explode(" ", trim(fgets(STDIN)));

$answer = PHP_INT_MAX;

for ($i = 0; $i < $N - $K + 1; $i++) {
	$tmp = 0;
	if ($x[$i] < 0) {
		$tmp -= $x[$i];
		$tmp += $x[$i + $K - 1] - $x[$i];
	} else {
		$tmp = $x[$i + $K - 1];
	}

	$answer = min($answer, $tmp);

	// 0以上なら抜ける
	if ($x[$i] >= 0) {
		break;
	}
}
for ($i = $N - 1; $i >= $K - 1; $i--) {
	$tmp = 0;
	if ($x[$i] > 0) {
		$tmp += $x[$i];
		// echo $tmp . PHP_EOL;
		$tmp += abs($x[$i] - $x[$i - $K + 1]);
		// echo $tmp . PHP_EOL;
	} else {
		$tmp = -$x[$i - $K + 1];
		// echo $tmp . PHP_EOL;
	}
	// echo $tmp . PHP_EOL;
	// echo PHP_EOL;

	$answer = min($answer, $tmp);

	// 0以上なら抜ける
	if ($x[$i] <= 0) {
		break;
	}
}

echo $answer;

Measured memory_bytes: 12792
n, k = gets.split.map(&:to_i)
vs   = gets.split.map(&:to_i)

# 全探索する.
# 1個取る -> 最大k-1個, マイナスで一番大きい数から返す
#   左から1取る
# 2個取る -> 最大k-2個, マイナスで一番大きい数から返す
#   左から2取る 
#   左から1取る, 右から1取る
#   右から2取る 
# 3個取る -> 最大k-3個, マイナスで一番大きい数から返す
#   左から3取る 
#   左から2取る, 右から1取る
#   左から1取る, 右から2取る
#   右から3取る 
# :
# :
# (n,k).min 個取る -> 最大...

# memo
#   配列の最初の要素を返す: shift
#   配列の末尾の要素を返す: pop

max = 0

1.upto([n, k].min) do | i | # i が取る総数
  # 左から取る数=l, 右から取る数=r を初期化.
  l, r = i, 0
  while l >= 0
    # queue, 取得boxの初期化
    queue, at_hand = vs.clone, []

    # 取得
    l.times{ at_hand << queue.shift }
    r.times{ at_hand << queue.pop }

    # 返却
    at_hand.sort!
    (k-i).times do
      break if at_hand.size == 0
      if at_hand.min < 0
        at_hand.shift
      else
        break
      end
    end

    # 最大値の更新
    sum = 0
    at_hand.each{ |num| sum+= num }
    max = sum if max < sum

    # 左右の数を変える
    l -= 1
    r += 1
  end
end

p max

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

int max(int x,int y){if(x>=y)return x; return y;}

int main(){
	int l,a,b,c,d;
	scanf("%d%d%d%d%d",&l,&a,&b,&c,&d);
	printf("%d\n",l-max((a-1)/c,(b-1)/d)-1);
}

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

#define watch(x) cout << (#x) << " is " << (x) << endl

// const double PI = acos(-1.0); 

void solve();

void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}

long long binpow (long long a, long long b)
{
    long long res = 1;
    
    while (b > 0)
    {
        if (b & 1) res *= a;
        a *= a;
        b >>= 1;
    } 

    return res;
}

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

    // int t; 
    // cin >> t;

    // while (t--) 
    solve(); 

    return 0;
}

void solve()
{
    long long n;
    cin >> n;

    vector<char> ans;
    long long i = 0;


    while(n)
    {
        n--;
        ans.push_back(n % 26 + 97);
        n /= 26; 
    }    

    for (long long i = ans.size() - 1; i >= 0; --i)
    {
        cout << ans[i];
    }
    cout << "\n";

    return;

}

Measured memory_bytes: 3652
n = int(input())
happy = [list(map(int,input().split())) for _ in range(n)]

dp = [[0] * (n+1) for _ in range(3)]
#dp[k][i]:=i日目までの最大の幸福度、ただしkはi日目の選んだ行動

#初期条件 dpテーブルを作るときに０で作っているのでいらない
dp[0][0] = dp[1][0] = dp[2][0] = 0

#漸化式
'''
dp[j][i] = dp[k][i-1] + j *jは幸福度が最大となるようなi+1日目の行動、j ￢= k
'''
for i in range(n):
    for j in range(3):
        for k in range(3):
            if k == j:continue
            dp[k][i+1] = max(dp[k][i+1],dp[j][i] + happy[i][k])

print(max(dp[0][n],max(dp[1][n],dp[2][n])))


Measured memory_bytes: 42392
import itertools

N, K = map(int, input().split())
ans = []
for i in range(2, N + 1):
    ans.append([1, i])

"""
全ての組み合わせは N_C_2
1を中心にスターグラフを作る
2,3,...,Nの中での組み合わせは N-1_C_2、これらの距離は2
2,3,...,Nの中で、(N-1_C_2 - K) 個の辺を張れば、
距離2の組み合わせがK個残る

N-1_C_2 - K < 0 となる時、構築不可
"""

if (N - 1) * (N - 2) // 2 - K < 0:
    print(-1)
    exit()
else:
    comb = list(itertools.combinations(range(2, N + 1), 2))
    for i in range((N - 1) * (N - 2) // 2 - K):
        u = comb[i][0]
        v = comb[i][1]
        ans.append([u, v])
    print(len(ans))
    for i in ans:
        print(*i)


Measured memory_bytes: 75324
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int str_cmp(const void *a, const void *b)
{
	return strcmp(*(char **)a, *(char **)b);
}

int main()
{
	int N;
	scanf("%d", &N);
	char str[N + 1][11];
	char **sort;
	sort = (char**)malloc(sizeof(char*) * N);
	int i = 0;
	int len;
	while (i < N)
	{
		scanf("%s", str[i]);
		len = strlen(str[i]);
		sort[i] = (char*)malloc(sizeof(char) * (len + 1));
		strcpy(sort[i], str[i]);
		i++;
	}
	qsort(sort, N, sizeof *sort, str_cmp);

	i = 0;
	int max[N];
	int top = 0;
	int n = 1;
	while (i < N - 1)
	{
		max[i] = 0;
		if (i != N - 1)
		{
			if (strcmp(sort[i], sort[i + 1]) == 0)
				n++;
			else if (strcmp(sort[i], sort[i + 1]))
			{
				max[i] = n;
				if (max[i] >= top)
					top = max[i];
				n = 1;
			}
		}
		i++;
	}
	max[i] = n;
	if (max[i] >= top)
			top = max[i];
	// printf("--------------\n");
	i = 0;
	while (i < N)
	{
		// printf("%d %s %d\n", i, sort[i], max[i]);
		if (max[i] == top)
			printf("%s\n", sort[i]);
		i++;
	}
	return (0);
}

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

int n, m, a[111], res[111];
vector<map<int, int>> mp(3);

int main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> a[i];
    }
    int p[111];
    for (int i = 0; i < m; i++)
    {
        int ad = 0;
        for (int j = 0; j < n; j++)
        {
            cin >> p[j];
            if (p[j] == a[i])
                res[j]++;
            else
                ad++;
        }
        res[a[i] - 1] += ad;
    }
    for (int i = 0; i < n; i++)
    {
        cout << res[i] << endl;
    }
}


Measured memory_bytes: 3104
n=int(input())
li6=[46656,7776,1296,216,36,6,1]
li9=[59049,6561,729,81,9,1]
dp6=[0]*(n+1)
dp9=[0]*(n+1)
dp6[1]=1
dp9[1]=1
ans=[]
for i in range(2,n+1):
    for j in range(7):
        if i>=li6[j]:
            k=i-li6[j]
            break
    dp6[i]=1+dp6[k] 
for i in range(2,n+1):
    for j in range(6):
        if i>=li9[j]:
            k=i-li9[j]
            break
    dp9[i]=1+dp9[k]  
for i in range(n+1):
    ans.append(dp6[i]+dp9[n-i])                    
print(min(ans))



Measured memory_bytes: 5528
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

# A
"""
s = input()
sum = 700
for i in range(3):
    if s[i] == "o":
        sum += 100
print(sum)
"""
# B
"""
n, x = map(int, input().split(" "))
m = [0 for i in range(n)]
sum = 0
for i in range(n):
    m[i] = int(input())
m.sort()
for i in range(n):
    x -= m[i]
    sum += 1
sum += (x//m[0])
print(sum)
"""
# C
"""
a,b,c,x,y = map(int, input().split(" "))
sum = 0
if a+b >= c*2:
    v = min(x, y)
    for i in range(v):
        sum += 2*c
    x -= v
    y -= v

if a < c*2:
    sum += a*x
if b < c*2:
    sum += b*y
if a >= c*2:
    sum += 2*c*x
if b >= c*2:
    sum += 2*c*y
print(sum)
"""
# D
n,c = LI()
l = [0]
r = []
v = [0]
for i in range(n):
    a,b = LI()
    l.append(a)
    r.append(c-a)
    v.append(b)
r.append(0)
r = r[::-1]
sl = defaultdict(int)
sr = defaultdict(int)
sl[0] = 0
sr[0] = 0
for i in range(n):
    sl[i+1] = sl[i]+v[i+1]-l[i+1]+l[i]
for i in range(n):
    if sl[i+1] < sl[i]:
        sl[i+1] = sl[i]
for i in range(n):
    sr[i+1] = sr[i]+v[-i-1]-r[i+1]+r[i]
for i in range(n):
    if sr[i+1] < sr[i]:
        sr[i+1] = sr[i]
ans = 0
x = 0
for i in range(n+1):
    x += v[i]
    j = n-i
    m = max(x-l[i],x-2*l[i]+sr[j])
    ans = max(ans,m)

x = 0
for i in range(n+1):
    x += v[-i]
    j = n-i
    m = max(x-r[i],x-2*r[i]+sl[j])
    ans = max(ans,m)
print(ans)


Measured memory_bytes: 82776
#include<stdio.h>
int main(){
  int i=0,d=0,n=0;
  char s[10];
  scanf("%s",s);
do{
  d=0;
  if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G'){
    d++;
  for(int f=i+1;f<10;f++){
    if(s[f]=='A'||s[f]=='T'||s[f]=='C'||s[f]=='G')
      d++;
    else
      break;
  }
    if(n<d)
      n=d;
  }
    i++;
  }while(i<10);
  printf("%d",n);
  return 0; 
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int T = scan.nextInt();
        int A = scan.nextInt();

        int[] H = new int[N];
        for(int i=0; i<N; i++){
            H[i] = scan.nextInt();
        }

        int C = (T-A)*1000/6;
        int min = 99999;
        int calc;
        int answer = 0;

        for(int j=0; j<N; j++){
            calc = Math.abs(H[j] - C);
            if (calc < min) {
                min = calc;
                answer = j;
            }
        }

        System.out.println(answer + 1);
    }
}


Measured memory_bytes: 22868
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Text;
using System.Diagnostics;
using static System.Math;
using static System.Array;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static long N, M;
       
        

        public static void Input()
        {
            var cin = new Scanner();
            var input = cin.SplitReaderL();
            Sort(input);
            N = input[0];
            M = input[1];
        }

        static void Main(string[] args)
        {
            Input();

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            long ans = 0;
            if (N == 1)
            {
                if (M == 1) { ans = 1; }
                else
                {
                    ans = M - 2;
                }
            }
            else //N>=2
            {
                ans = (N - 2) * (M - 2);
            }

            Console.WriteLine(ans);


            //Console.Out.Flush();

        }





    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }

    }

    public class Graph
    {
        
    }
}

    



Measured memory_bytes: 13396
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 一行の文字列を読み込む
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 数値（INT）を読み込む
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var a [20]int
	var b [20]int
	var c [20]int
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	for i := 0; i < n; i++ {
		b[i] = nextInt()
	}
	for i := 0; i < n-1; i++ {
		c[i] = nextInt()
	}
	// fmt.Println(a, b, c)
	prev := -1
	ans := 0
	for i := 0; i < n; i++ {
		ai := a[i]
		ans += b[ai-1]
		if prev+1 == ai {
			ans += c[prev-1]
		}
		prev = ai
		// fmt.Println(ans)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  double a,b,x;
  double y,tan;
  double pi=3.141592653979;
  cin >> a >> b>>x;
  if(2*x<a*a*b)
  { 
    tan=(a*b*b)/(2*x);
    y=atan(tan);
  }
  else
  {
    tan=(2*a*a*b-2*x)/(a*a*a);
  //  cout << tan << endl;
      y=atan(tan);
  }
  y=y*180/pi;
  printf("%.8lf",y);
}


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

#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pi 3.14159265
#define oo 1000000007
#define loo 0x7fffffffffffffff

#define prime 1000000007
#define mod 1000000007
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
#define W(x) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << "\n";
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    vector<ll> v {1, 2, 3, 4, 5, 6, 7, 8, 9};
    int k; cin >> k;
    int at = 0;
    while((int)v.size() < k){
        vl aux;
        for(int i = at; i < (int)v.size(); i++){
            ll l = v[i];
            if(l%10LL == 0LL){
                aux.pb(l*10LL);
                if((int)v.size()+(int)aux.size() == k) break;
                aux.pb(l*10LL+1);
                if((int)v.size()+(int)aux.size() == k) break;
            }
            else if(l%10LL == 9){
                aux.pb(l*10LL+8);
                if((int)v.size()+(int)aux.size() == k) break;
                aux.pb(l*10LL+9);
                if((int)v.size()+(int)aux.size() == k) break;
            }
            else{
                aux.pb(l*10LL+(l%10LL-1));
                if((int)v.size()+(int)aux.size() == k) break;
                aux.pb(l*10LL+(l%10LL));
                if((int)v.size()+(int)aux.size() == k) break;
                aux.pb(l*10LL+(l%10LL+1));
                if((int)v.size()+(int)aux.size() == k) break;
            }
        }
        at = (int)v.size();
        for(auto l : aux){
            v.pb(l);
        }
        sort(v.begin(), v.end());
    }

    cout << v[k-1] << "\n";

    return 0;
}

Measured memory_bytes: 4724
import java.util.*;

public class Main{

    Scanner sc = new Scanner(System.in);

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

    void run() {

        long[] arr = new long[3];

        for (int i=0; i<3; i++) arr[i] = sc.nextLong();

        long k = sc.nextLong();

        long sum = 0;

        long[] cnt = new long[3];

        for (int i=0; i<3; i++) {
            if (arr[i] > k) {
                cnt[i] = k;
                k = 0;
            } else {
                cnt[i] = arr[i];
                k -= arr[i];
            }
        }

//        for (int i=0; i<3; i++) System.out.println(cnt[i]);

        System.out.println(cnt[0] - cnt[2]);



    }
}


Measured memory_bytes: 35892
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let n = v[0];
	let mut flag = false;
	for i in 1..10 {
		for j in 1..10 {
			if i*j == n {
				flag = true;
				break;
			}
		}
	} 
	if flag {
		println!("Yes");
	}else{
		println!("No");
	}
}

Measured memory_bytes: 4352
using System;

class Program {
    static void Main(string[] args) {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = a * b;
        if (c % 2 == 0) {
            Console.WriteLine("Even");
        } else {
            Console.WriteLine("Odd");
        }
    }
}


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

int main()
{
	ll T;
	cin >> T;
	ll ans = 0;
	ans += 1000*(T/500);
	T = T%500;
	ans += 5*(T/5);
	T = T%5;
	cout << ans;

}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k, r, s, p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;
  vector<bool> win(t.size(), false);
  rep(i, t.size()) {
    bool w = true;
    if (i >= k) {
      if (t[i] == t[i - k] && win[i - k]) w = false;
    }
    win[i] = w;
  }
  ll ans = 0;
  rep(i, t.size()) {
    // cerr << win[i];
    if (win[i]) {
      if (t[i] == 'r')
        ans += p;
      else if (t[i] == 's')
        ans += r;
      else
        ans += s;
    }
  }
  // cerr << endl;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int k, t;
  cin>>k>>t;
  int a[t], m=0, sum=0;
  REP(i, t){
    cin>>a[i];
    m=max(m, a[i]);
    sum += a[i];
  }

  int ans=max(0, m-(sum-m)-1);
  cout<<ans<<endl;

  return 0;
}


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

int main(){
    while(1){
        ll n;
        cin >> n;
        if(n == 0){ break; }
        vector<double> s(n);
        REP(i, n){
            cin >> s.at(i);
        }
        const double mean = accumulate(s.begin(), s.end(), 0.0f) / n;
        double s2 = 0;
        REP(i, n){
            s2 += (s.at(i) - mean) * (s.at(i) - mean);
        }
        s2 /= n;
        printf("%.10f\n", sqrt(s2));
    }
    return 0;
}



Measured memory_bytes: 3184
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

l = LIST()
comb = list(combinations(l, 2))
m_l = []
for c in comb:
    m_l.append(sum(c))

ans = min(m_l)
print(ans)

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

restaurant_list = [list(input().split()) for i in range(N)]

sorted_list = sorted(sorted(restaurant_list, reverse = True, key=lambda x:int(x[1])), key=lambda x:x[0])

for restaurant in sorted_list:
    for i, original in enumerate(restaurant_list):
        if restaurant == original:
            print(i+1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
#define MOD 1e9+7

vll prime_factrize(ll n){
    vll prime_factrize_ret;
    ll temp=n;
    for(ll i=2;i*i<=n;i++){
        while(temp%i==0){
            prime_factrize_ret.push_back(i);
            temp/=i;
        }
    }
    if(temp!=1) prime_factrize_ret.push_back(temp);
    return prime_factrize_ret;
}

ll fast_pow(ll n,ll a,ll mod){
    ll res=1;
    while(a>0){
        if(a&1) res=res*n%mod;
        n=n*n%mod;
        a>>=1;
    }
    return res;
}

ll mod_inv(ll n, ll mod){
    return fast_pow(n,mod-2,mod);
}

ll comb(ll n, ll r, ll mod){
    ll temp=1;
    for(int i=r+1;i<=n;i++){
        temp=(temp*i)%mod;
    }
    ll temp2=1;
    for(int i=2;i<=n-r;i++){
        temp2=(temp2*i)%mod;
    }
    return temp*mod_inv(temp2,mod)%mod;
}

struct UnionFind {
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }
 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }
 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    bool same(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return true;
        else return false;
    }
 
    int size(int x) {
        return -r[root(x)];
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    vi a(m);
    vi b(m);
    for(int i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
    }

    int ans=0;
    for(int i=0;i<m;i++){
        UnionFind uf(n);
        for(int j=0;j<m;j++){
            if(j==i) continue;
            uf.unite(a[j],b[j]);
        }
        if(uf.size(0)!=n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int n,d;
  cin >> n >> d;

  int ans1=0, ans2=0;
  for(int i=1; i<=n; i+=2*d+1){
//    cout << i << endl;
    ans1++;
  }

//  for(int i=d+1; i<=n; i+=2*d+1){
//    ans2++;
//    if(i+d<n && n<i+2*d+1) ans2++;
//  }

  cout << ans1 << endl;
//  cout << ans2 << endl;

  return 0;
}

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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)
#define f first
#define s second

#define single_test

int dp[1 << 16];

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> a(n, vector<int>(n));
    for (auto &it: a) {
        for (int &x: it) {
            cin >> x;
        }
    }
    // var(n);
    // return;
    const int mx = 1 << n;
    var(mx);
    // return;
    for (int mask = 0; mask < mx; mask++) {
        bitset<16> ok(mask);
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                if (ok[i] && ok[j]) {
                    dp[mask] += a[i][j];
                }
            }
        }
    }
    for (int mask = 0; mask < mx; ++mask) {
        for (int s = mask; s > 0; s = (s - 1) & mask) {
            dp[mask] = max(dp[mask], dp[s] + dp[s ^ mask]);
        }
    }
    cout << dp[(1 << n) - 1] << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h> 
#include <chrono>
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const int MAX_N=2e5+3;


const unsigned long long B=1e12+7;



int main(){
    int N,K;
    cin>>N>>K;
    vector<int>snuke(N,0);
    REP(i,K){
        int A,d;
        cin>>d;
        REP(i,d){
            cin>>A;A--;
            snuke[A]++;
        }
    }
    int res=0;
    REP(i,N)if(snuke[i]==0)res++;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
bool ask(ll x)
{
    cout<<"? "<<x<<endl;
    string ret;
    cin>>ret;
    return ret=="Y";
}
void answer(ll x)
{
    cout<<"! "<<x<<endl;
}
int main()
{
    ll var=1e9;
    if(ask(var))
    {
        while(var/10&&ask(2*var/10))
            var/=10;
        answer(var);
    }
    else{
        var/=10;
        while(!ask(var))
            var/=10;
        ll L=var,R=var*10-1,ans=-1;
        while(L<=R)
        {
            ll mid=L+R>>1;
            if(ask(10*mid))
            {
                R=mid-1;
                ans=mid;
            }
            else L=mid+1;
        }
        answer(ans);
    }
}

Measured memory_bytes: 596
package main

import (
	"fmt"
	"strings"
)

func main() {
	var S string
	fmt.Scan(&S)
	var Q, c1 int
	fmt.Scan(&Q)
	w := S
	var fw, lw []string
	for i := 0; i < Q; i++ {
		var t, f int
		var c string
		fmt.Scan(&t)
		if t == 2 {
			fmt.Scan(&f, &c)
			if f == 1 {
				if c1%2 == 0 {
					fw = append(fw, c)
				} else {
					lw = append(lw, c)
				}
			} else {
				if c1%2 == 0 {
					lw = append(lw, c)
				} else {
					fw = append(fw, c)
				}
			}
		} else {
			c1++
		}
	}
	var r string
	if len(fw) > 0 {
		r = Reverse(strings.Join(fw, "")) 
	}
	r +=w
	if len(lw) > 0 {
		r += strings.Join(lw, "")
	}
	if c1%2 == 1 {
		r = Reverse(r)
	}
	fmt.Println(r)
}

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 15876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
const int mod = 1000000007;
struct mint {
ll x;
mint(ll x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {
if ((x += a.x) >= mod) x -= mod;
return *this;
}
mint& operator-=(const mint a) {
if ((x += mod-a.x) >= mod) x -= mod;
return *this;
}
mint& operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
mint inv() const {
return pow(mod-2);
}
mint& operator/=(const mint a) {
return (*this) *= a.inv();
}
mint operator/(const mint a) const {
mint res(*this);
return res/=a;
}
};
struct combination {
vector<mint> fact, ifact;
combination(int n):fact(n+1),ifact(n+1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n) return 0;
return fact[n]*ifact[k]*ifact[n-k];
}
};
int main(){
    int n,k;cin >> n >> k;
    mint ans=0;
    k=min(k,n-1);
    combination C(n);
    for(int i=0; i<=k; i++){
        ans+=C(n,i)*C(n-1,i);
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define int int64_t
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int MOD = 1000000007;
const int INF = 2000000000;
const long double PI = acosl(-1);
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}
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; }

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    // failed to analyze input format
    // TODO: edit here
    int H1,M1,H2,M2,K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int ans = (H2-H1)*60+(M2-M1)-K;
    pa;

    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/nomura2020/nomura2020_a && sh test.sh
cd ~/Desktop/Programming/AtCoder/contest/nomura2020/nomura2020_a && sh etest.sh
cd ~/Desktop/Programming/AtCoder/contest/nomura2020/nomura2020_a && sh submit.sh
*/


Measured memory_bytes: 3644
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n;
  cin >> n;
  
  int sum = 0,i = 1;
  while(1){
    sum += i;
    if(sum >= n) break;
    i++;
  }
  
  cout << i << endl;

  return 0;
}

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

using namespace std;

//typedef pair<int,int> P;



int main(){
	char s[4];

	scanf("%s", s);

	int ans = 700;
	for(int i=0;i<3;i++){
		if(s[i]=='o') ans+=100;
	}

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

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=1000000007;



int main(){
    ll N;
    cin >> N;
    ll A;
    cin >> A;
    ll B;
    cin >> B;
    ll C;
    cin >> C;
    vector<string> s(N);
    for(ll i=0;i<N;i++){
        cin>>s[i]
    ;}
    vector<char> ans(N);
    for(ll i=0;i<N;i++){
        if(s[i]=="AB"){
            if(A==0){
                A++;B--;if(B<0){cout<<"No"<<endl;return 0;};
                ans[i]='A';
            }
            else if(B==0){
                A--;B++;ans[i]='B';
            }
            else if(A==1&&B==1&&i<N-1&&s[i+1]=="BC"){B++;A--;ans[i]='B';}
            else if(A==1&&B==1&&i<N-1&&s[i+1]=="AC"){A++;B--;ans[i]='A';}
            else if(A>=B){A--;B++;ans[i]='B';}
            else {A++;B--;ans[i]='A';}
        }
        else if(s[i]=="BC"){
            if(B==0){
                B++;C--;if(C<0){cout<<"No"<<endl;return 0;};
                ans[i]='B';
            }
            else if(B==0){
                B--;C++;ans[i]='C';
            }
            else if(B==1&&C==1&&i<N-1&&s[i+1]=="AC"){C++;B--;ans[i]='C';}
            else if(B==1&&C==1&&i<N-1&&s[i+1]=="AB"){B++;C--;ans[i]='B';}
            else if(B>=C){B--;C++;ans[i]='C';}
            else {B++;C--;ans[i]='B';}
        }
        else if(s[i]=="AC"){
            if(A==0){
                A++;C--;if(C<0){cout<<"No"<<endl;return 0;};
                ans[i]='A';
            }
            else if(A==0){
                A--;C++;ans[i]='C';
            }
            else if(A==1&&C==1&&i<N-1&&s[i+1]=="AB"){A++;C--;ans[i]='A';}
            else if(A==1&&C==1&&i<N-1&&s[i+1]=="BC"){C++;A--;ans[i]='C';}
            else if(A>=C){A--;C++;ans[i]='C';}
            else {A++;C--;ans[i]='A';}

        }
    ;}
    cout<<"Yes"<<endl;
    for(ll i=0;i<N;i++){
        cout<<ans[i]<<endl;
    ;}

    
    return 0;
}


Measured memory_bytes: 6424
#include<cstdio>
const int MaxN=200010,mod=998244353;
int N,pw2[MaxN],f[MaxN*2];
char X[MaxN];
int main(){
	scanf("%d%s",&N,X);
	for(int i=*pw2=1;i<=N;i++)pw2[i]=2ll*pw2[i-1]%mod;
	for(int k=1;k<=N;k+=2)if(N%k==0){
		int L=N/k;
		bool fl=1;
		for(int i=0;i<N&&fl;i++){
			if(X[i]=='1'){
				if(i<L||X[i-L]=='1'){
					f[L]=(f[L]+(i<L?pw2[L-i-1]:1))%mod;
				}
			}
			if(i>=L&&X[i]==X[i-L])fl=0;
		}
		if(fl)f[L]=(f[L]+1)%mod;
	}
	int ans=0;
	for(int i=1;i<=N;i++)if(N%i==0&&N/i%2==1&&f[i]){
		ans=(ans+2ll*f[i]*i)%mod;
		for(int j=i*2;j<=N;j+=i)f[j]=(f[j]+mod-f[i])%mod;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1920
def main():
    n = int(input())
    s = input()
    if len(s)%2 == 0:
        if s[:len(s)//2] == s[len(s)//2:]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    main()

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

#define testc int t;cin>>t;while(t--)
#define endl "\n"
#define rep(i,a,b) for(int i=a;i<b;++i)
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define repi(i,n) for(int i=0;i<n;++i)
#define REPI(i,n) for(int i=0;i<=n;++i)

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double
# define ull unsigned long long

# define pb push_back
# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vld vector < ld >
# define vull vector < ull >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()

# define pii pair < int , int >
# define vpii vector < pii >
# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define mod 1000000007

void solve(){
    int n,w;
    cin>>n>>w;
    vi value(n+1),weight(n+1);
    rep(i,1,n+1){
        cin>>weight[i]>>value[i];
    }
    vector<vector<long> > profit(n+1,vector<long>(w+1,0));
    rep(i,1,n+1){
        rep(j,1,w+1){
            if(j>=weight[i]){
                if(profit[i-1][j-weight[i]]+value[i]>profit[i-1][j]){
                    profit[i][j] = profit[i-1][j-weight[i]]+value[i];
                    //cout<<i<<" ";
                }else{
                    profit[i][j] = profit[i-1][j];
                }
            }else{
                profit[i][j] = profit[i-1][j];
            }
        }
    }
    /*repi(i,n+1){
        repi(j,w+1){
            cout<<profit[i][j]<<" ";
        }
        cout<<endl;
    }*/
    cout<<profit[n][w]<<endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll N;
    cin >> N;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];
    vector<ll> dp(N + 10, INF);
    dp[0] = 0;
    rep(i, N) {
        if (i + 1 < N) {
            dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]));
        }
        if (i + 2 < N) {
            dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
        }
    }
    cout << dp[N - 1] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 4740
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for(int a=1; a<=n-1; ++a){
    ans += (n-1)/a;
  }
  cout << ans << endl;
}


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

int main(){

  int n, m;
  int cnt[101] = {0};

  while(cin >> n){
    cnt[n]++;
  }
  
  m = *max_element(cnt+1, cnt+101);

  for(int i=1; i<101; i++){
    if(cnt[i] == m){
      cout << i << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    COMinit();

    for(int i=1; i<=K; i++){
        long ans = COM(K-1, i-1)*COM(N-K+1, i);
        ans = ans % MOD;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  double con = 0.0;
  int water = 0, sugar = 0;
  for (int w = 0; w <= 30; w++) {
    for (int x = 0; x <= 30; x++) {
      for (int y = 0; y <= ceil((double)f / c); y++) {
        for (int z = 0; z <= ceil((double)f / d); z++) {
          int water_weight = a * w + b * x, sugar_weight = c * y + d * z;
          int total = 100 * water_weight + sugar_weight;
          if (total <= f && sugar_weight <= water_weight * e) {
            if (con < (double)sugar_weight / total) {
              con = (double)sugar_weight / total;
              water = 100 * water_weight;
              sugar = sugar_weight;
            }
          }
        }
      }
    }
  }
  if (con == 0) water = 100 * a;

  cout << water + sugar << " " << sugar << endl;

  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair

int n, m, a[2000], t[2000];

int main() {
    for(;;) {
        scanf("%d%d", &n, &m);
        if(n==0 && m==0) return 0;
        rep(i, n) scanf("%d", a+i);
        rep(i, n) t[i] = m/a[i]*a[i];
        pair<int, int> ans(m+1, 0);
        rep(i, n) ans = min(ans, mp(t[i], a[i]));
        vector<int> cs;
        rep(i, n) if(ans==mp(t[i], a[i])) cs.push_back(i+1);
        printf("%d\n", cs.size()==1 ? cs[0] : n);
    }
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
int main(){
	int n;
	cin >> n;
	string v;
	cin >> v;
	int counter = 0;
	string ans;
	for(char c:v){
		if(c == ')') counter--;
		else counter++;
		if(counter < 0) ans.insert(ans.begin(), '('), counter = 0;
		ans.push_back(c);
	}
	while(counter > 0) ans.push_back(')'), counter--;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n;
    string a, b, c;
    cin >> n >> a >> b >> c;
    int ans = 0;
    rep(i, n) {
        if(a[i] == b[i] && b[i] == c[i]);
        else if(a[i] == b[i] || a[i] == c[i] || b[i] == c[i]) ans += 1;
        else ans += 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
	int N;
  	cin>> N;
  for (int i = 0; i < N; i++){
    string si;
  	cin >> si;
    if(i<N-1){
    	if(si == "Y"){
          cout<<"Four";
          break;
        }
      	else{
        
        }
    }
    else{
       if(si == "Y"){
          cout<<"Four";
          break;
     }
       else{
         cout<<"Three";
         break;
       }
    }
    
    
      
  }
}


Measured memory_bytes: 256