akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
    ll N, M;
    while(cin >> N >> M) {
        if(N == 0) break;
        vector<ll> often(N);
        vector<ll> need(M);
        ll i, j, k;
        for(i = 0; i < N; i++) {
            cin >> often[i];
        }
        for(i = 0; i < M; i++) {
            cin >> need[i];
        }
        sort(need.begin(), need.end());
        vector<ll> d(1 << N, 0); //1が立ってるoftenを使った時のぬくもり
        for(i = 0; i < 1 << N; i++) {
            for(j = 0; j < N; j++) {
                if(i >> j & 1) d[i] += often[j];
            }
        }
        vector<vector<ll>> dp(M + 1, vector<ll>(1 << N, 0));
        for(j = 0; j < M; j++) {
            for(i = 0; i < 1 << N; i++) {
                dp[j + 1][i] = dp[j][i] + abs(d[i] - need[j]);
                for(k = 0; k < N; k++) {
                    if(i >> k & 1) dp[j + 1][i] = min(dp[j + 1][i], dp[j + 1][i - (1 << k)]);
                }
            }
        }
        cout << dp[M][(1 << N) - 1] << endl;
    }
    return 0;
}


Measured memory_bytes: 29772
def LI():
    return list(map(int, input().split()))


N = int(input())
A = LI()
x = []
for i in range(N):
    x.append(A[i]-(i+1))

x.sort()
B = x[N//2]

ans = 0
for i in range(N):
    ans += abs(A[i]-(B+i+1))
print(ans)

Measured memory_bytes: 30908
import sys
import math
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
from collections import deque
def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def S(): return sys.stdin.readline().rstrip()
def LS(): return sys.stdin.readline().split()
def LS2(N): return [sys.stdin.readline().split() for i in range(N)]
def FILL(i,h): return [i for j in range(h)]
def FILL2(i,h,w): return [FILL(i,w) for j in range(h)]
def FILL3(i,h,w,d): return [FILL2(i,w,d) for j in range(h)]
def FILL4(i,h,w,d,d2): return [FILL3(i,w,d,d2) for j in range(h)]
def sisha(num,digit): return Decimal(str(num)).quantize(Decimal(digit),rounding=ROUND_HALF_UP)
#'0.01'や'1E1'などで指定、整数に戻すならintをかます
MOD = 1000000007
INF = float("inf")
sys.setrecursionlimit(10**5+10)
#input = sys.stdin.readline

N,K = MI()
llist = [0]*N
for i in range(K):
    d = I()
    l = LI()
    for man in l:
        llist[man-1] += 1
print(llist.count(0))


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

int main(void)
{
    int x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int difx = x2 - x1, dify = y2 - y1;
    int x3, x4, y3, y4;
    x3 = x2 - dify, y3 = y2 + difx;
    x4 = x1 - dify, y4 = y1 + difx;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 3628
input()
an = [int(i) for i in input().split()]
score = [0]*13
ans = 0

for i in an:
  score[i//400] += 1   
for i in score[:8]:
  if i:
    ans += 1

k = sum(score[8:])

if ans == 0 and k:
  print(1,k)
else:
  print(ans,ans+k)

Measured memory_bytes: 3064
from collections import deque


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    explosion = FIFO deque and damage, range
    """
    N, D, A = read_ints()
    XH = []
    for _ in range(N):
        XH.append(read_ints())
    XH.sort()
    explosion = deque([])
    current_damage = 0
    count = 0
    for i in range(N):
        while len(explosion) != 0 and explosion[0][1] < XH[i][0]:
            current_damage -= explosion.popleft()[0]
        if current_damage < XH[i][1]: # damage is not enough
            left_health = XH[i][1]-current_damage
            more_bombs = (left_health//A+(1 if left_health%A != 0 else 0))
            count += more_bombs
            more_damage = more_bombs*A
            current_damage += more_damage
            explosion.append((more_damage, XH[i][0]+2*D))
    return count


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 110456
#define _USE_MATH_DEFINES
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MAX 50100

static bool gosei[MAX];

void a() {
	for (int i = 2; i <= sqrt(MAX); i++)
		if (gosei[i] == false) {
			for (int j = 2, k = 0; (k = i*j) <= MAX; j++)
				gosei[k] = true;
		}
}

int M(int n) {
	for (int i = 1;; i++)
		if (!gosei[n + i])
			return n + i;
}

int m(int n) {
	for (int i = 1;; i++)
		if (!gosei[n - i])
			return n - i;
}

int main() {
	a();
	for (int b; cin >> b;)
		cout << m(b) << " " << M(b) << endl;
	return 0;
}

Measured memory_bytes: 1204
#include <stdio.h>

int main(void)
{
	int a, b;
	char op;

	while (1)
	{
		scanf("%d %c %d", &a, &op, &b);

		switch (op)
		{
		case ('+'):
			printf("%d\n", a + b);
			break;
		case ('-'):
			printf("%d\n", a - b);
			break;
		case ('*'):
			printf("%d\n", a * b);
			break;
		case ('/'):
			printf("%d\n", a / b);
			break;
		default:
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 600
t = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

x = (b[0] - a[0]) * t[0]
y = (b[1] - a[1]) * t[1]

if x + y == 0
    puts x == y ? 0 : "infinity"
elsif x == 0 || y == 0 || (x > 0 && x + y > 0) || (x < 0 && x + y < 0)
    puts 0
else
    s, t = x.abs.divmod((x + y).abs)
    puts t != 0 ? s * 2 + 1 : s * 2
end

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

namespace AtCoder124
{
    class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] H = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int hmax = H[0];
            int res = 0;
            for (int i = 0; i < N; i++)
            {
                if (hmax <= H[i])
                {
                    res++;
                    hmax = H[i];
                }
            }
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 13268
N,W = map(int,input().split())

dp = [-1]*(W+1)
dp[0] = 0

for _ in range(N):
    value,weight = map(int,input().split())
    for i in range(weight,W+1):
        if dp[i-weight] == -1:
            pass
        else:
            dp[i] = max(dp[i],dp[i-weight]+value)

ans = 0
for i in range(W+1):
    ans = max(ans,dp[i])

print(ans)


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

int main(){
  int n, m;
  cin >> n >> m;
  n++;
  vector<int> ans;
  for(int i = 0; i < (n + 1)/2; i++){
    ans.push_back(0);
  }
  for(int i = (n + 1)/2; i < n - 1; i++){
    ans.push_back(m);
  }
  for(int i = 0; i < ans.size(); i++){
    if(i != ans.size() - 1)cout << ans[i] << " ";
    else cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

long long factorial(long long i){ // 階乗
  if(i > 0)
    return i * factorial(i-1);
  else
    return 1;
}

// a^n mod
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n>0) {
    if(n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^(-1) mod
long long modinv(long long a, long long mod) {
  return modpow(a, mod-2, mod);
}

int main() {
  long long N, A, B, C;
  const long long mod = 1000000007;
  cin >> N >> A >> B >> C;

  // N!(mod )をあらかじめ計算しておく
  vector<long long> factmod;
  factmod.push_back(1); // 0! = 1 と定義
  for(int i=1; i<2*N+10; i++) {
    long long tmp = (factmod[i-1]*i) %mod;
    if (tmp<0) tmp+=mod;
    factmod.push_back(tmp);
  }

  long long invAplusB = modinv(A+B, mod);
  long long invFactorialNm1 = modinv(factmod[N-1], mod);
  long long invHandmC = modinv(100-C, mod);
  long long res = 0;
  
  long long mothA = modpow(A, N, mod)%mod * invFactorialNm1%mod * 100 %mod * invHandmC %mod;
  long long mothB = modpow(B, N, mod)%mod * invFactorialNm1%mod * 100 %mod * invHandmC %mod;
  
  rep(i, N) {   // 引き分けなし A: N, B:i Aで勝つ
    //res += (N+i) * factorial(N-1+i) * pow(A, N) * pow(B, i)/ pow(A+B, N+i) / factorial(N-1) /factorial(i) * 100.0 /  (100.0-C);
    res += (N+i) * factmod[N-1+i]%mod  * modpow(B, i, mod)%mod * modpow(invAplusB, N+i, mod)%mod  * modinv(factmod[i], mod)%mod * mothA%mod;
    res = res % mod;
  }
  rep(i, N) {   // 引き分けなし A: i, B: Nで B勝つ
    //res += (N+i) * factorial(N-1+i) * pow(B, N) * pow(A, i)/ pow(A+B, N+i) / factorial(N-1) /factorial(i) * 100.0 /  (100.0-C);
    res += (N+i) * factmod[N-1+i]%mod * modpow(A, i, mod)%mod * modpow(invAplusB, N+i, mod)%mod * modinv(factmod[i], mod)%mod * mothB % mod;
    res = res % mod;
  }

  if(res<0) res += mod;
  
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 2420
n = int(input())
H = list(map(int, input().split()))

ans = 0
for l in range(n):
    while H[l] > 0:
        r = l + 1
        while r < n:
            if H[r] > 0:
                r += 1
            else:
                break
    
        for j in range(l, r):
            H[j] += -1

        ans += 1

print(ans)


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll x = 1; x < 10; x++) {
        for (ll y = 1; y < 10; y++) {
            ll cnt1 = 0, cnt2 = 0;
            for (ll i = 1; i <= N; i++) {
                ll t = i % 10;
                ll h;
                ll i_cpy = i;
                while (i_cpy >= 10) {
                    i_cpy /= 10;
                }
                h = i_cpy;

                if (h == x && t == y) {
                    ++cnt1;
                }
                if (t == x && h == y) {
                    ++cnt2;
                }
            }
            ans += cnt1 * cnt2;
        }
    }

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

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
int main(){
  char c[1000];
  int i,x;
  int sum;
  int co;
  while(1){
    co=0;
    sum=0;
    scanf("%s",&c);
    for(i=0;;i++){
      if(c[i]=='\0'){
	co=i;
	break;
      }
    }
    if(c[0]=='0')break;
    
    for(i=0;i<co;i++){
      x =c[i]-'0';
      sum+=x;

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

Measured memory_bytes: 964
from itertools import chain, permutations, dropwhile
from heapq import merge
from functools import wraps

def comp_wild(a,b):
  return all(x==y or "?" in (x,y) for x,y in zip(a, b))

def listify(fn):
  @wraps(fn)
  def wraper(*args, **kwargs):
    return list(fn(*args, **kwargs))
  return wraper

@listify
def includers(a,b):
  for i in range(len(a)-len(b)+1):
    if comp_wild(a[i:],b):
      yield i

@listify
def connectors(a,b):
  la = len(a)
  for i in range(max(la-len(b)+1, 1), la):
    if comp_wild(b, a[i-la:]):
      yield i
  yield la

class K(int):
  def __new__(cls, *args, **kwargs):
    cb = kwargs.pop("cb", lambda:True)
    i = int.__new__(cls, *args, **kwargs)
    i.cb = cb
    return i

def iter_from(it, fm):
  return dropwhile(fm.__gt__, it)

def solve(a,b,c):
  keys = sorted((a,b,c), key=len, reverse=True)
  len_keys = list(map(len, keys))
  inc = {(i,j):includers(keys[i],keys[j]) for i,j in permutations(range(3), 2)}
  con = {(i,j):connectors(keys[i],keys[j]) for i,j in permutations(range(3), 2)}
  
  for i in inc[0,1]:
    for j in inc[0,2]:
      if j+len_keys[2] <= i or i+len_keys[2] <= j or j-i in inc[1,2] or j-i in con[1,2] or i-j in con[2,1]:
        return len_keys[0]
  
  def candicates(x,y,z):
    return chain(
      
      (K(i+len_keys[z], cb=lambda:(
       (inc[x,y] and inc[x,y][0]+len_keys[y] <= i) or 
       (inc[z,y] and len_keys[x] <= i+inc[z,y][-1]) or 
       any((i-j in con[y,z] if i>j else j-i in inc[z,y]) for j in iter_from(inc[x,y]+con[x,y], i-len_keys[y]))
      )) for i in iter_from(con[x,z], len_keys[y]-len_keys[z]+1)),
      
      (K(min(i+next(iter_from(q, len_keys[x]-i+1))+len_keys[z] for i in p)) for (p, q) in [sorted((con[x,y], con[y,z]), key=len)]),
    )
  
  can = merge(*(candicates(*xyz) for xyz in permutations(range(3),3)))
  
  for k in can:
    if k.cb():
      return k
  
  return sum(len_keys)

print(solve(*(input() for _ in range(3))))

Measured memory_bytes: 3908
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    int N;
    cin >> N;
    string S;
    cin >> S;
    if (N % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < N/2; i++) {
        if (S[i] != S[i+N/2]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 1000000007
int u[1100000];
vector<int> y;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,d=0,e=0,f=0,g=0;
  cin >>u[0]>>u[1]>>u[2];
  sort(u,u+3);
  a=u[2]-u[0];
  cout <<a<<'\n';
  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){   
	ll n,m,ans=1;
	cin>>n>>m;
	for(ll i=m;i<=n;i++){
		ans+=i*n+i+1-i*i;
		if(ans>mod)ans%=mod;
	}
	cout<<ans<<endl;
} 

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

const ll INF = 1001001001;

const double PI=3.141592653;

const ll sosu = 1000000007;//大きい素数

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}

int main(){
  ll a,b,v,w,t;
  cin>>a>>v>>b>>w>>t;
  if(z(b,a)<=t*(v-w)){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}


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



int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  int n; cin >> n;
  string s; cin >> s;
  vector<int> pre(n), suf(n);
  int Q; cin >> Q;

  while (Q--) {
    int k; cin >> k;
    int cnt[256] = {0};
    LL col = 0;
    LL ans = 0;
    for (int i = 0; i < k; ++i) {
      ++cnt[s[i]];
      if (s[i] == 'C') col += cnt['M'];
    }
    for (int i = 0; i < n; ++i) {
      if (s[i] == 'D') ans += col;
      else if (s[i] == 'M') col -= cnt['C'];
      --cnt[s[i]];
      int j = i + k;
      if (j >= n) continue;
      ++cnt[s[j]];
      if (s[j] == 'C') col += cnt['M'];
    }
    cout << ans << '\n';
  }

}



Measured memory_bytes: 9244
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> A(M);
    REP(i, M)cin >> A[i];

    int left = 0, right = 0;
    REP(i, M) {
        if (A[i] < X) {
            left++;
        }
        else {
            right++;
        }
    }
    cout << min(left, right) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int a[101], b[101];
int main(void)
{
    while (1) {
        int n, m, i, j, s, t, resT, resH, minS;
        scanf("%d%d", &n, &m);
        if (n==0 && m==0) break;

        for(s=i=0;i<n;++i) { scanf("%d", a+i); s+=a[i]; }
        for(t=i=0;i<m;++i) { scanf("%d", b+i); t+=b[i]; }

        minS=1<<30;
        resT=resH=-1;
        for(i=0;i<n;++i) {
            for(j=0;j<m;++j) {
                if (s-a[i]+b[j]==t+a[i]-b[j] && minS>a[i]+b[j]) {
                    resT=a[i];
                    resH=b[j];
                    minS=a[i]+b[j];
                }
            }
        }
        if (resT==-1) {
            puts("-1");
        }
        else {
            printf("%d %d\n", resT, resH);
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include <stdio.h>

int main()
{
    long a, b;
    long d, r;
    double f;

    scanf("%ld %ld", &a, &b);
    d = a / b;
    r = a % b;
    f = (double)a / b;
    printf("%ld %ld %.5lf\n", d, r, f);

    return 0;
}

Measured memory_bytes: 640
n = int(input())
s = input()
count = 0
if n % 2 == 0:
    for i in range(n//2):
        if s[i] != s[i+n//2]:
            count += 1
else:
    count +=1
if count == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
import sys, os, math, bisect, itertools, collections, heapq, queue

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def koch(N, ax, ay, bx, by):
    if N == 0: return

    # 度をラジアンに変換
    radians = math.radians(60)
    # 線分を3等分する、
    # 座標sと座標tの位置を求める
    sx = (2 * ax + bx) / 3
    sy = (2 * ay + by) / 3
    tx = (ax + 2 * bx) / 3
    ty = (ay + 2 * by) / 3

    # 座標sと座標tから正三角形となる座標uを求める
    ux = (tx - sx) * math.cos(radians) - (ty - sy) * math.sin(radians) + sx
    uy = (tx - sx) * math.sin(radians) + (ty - sy) * math.cos(radians) + sy

    # 座標aと座標sのコッホ曲線を求める
    koch(N - 1, ax, ay, sx, sy)
    print('{:.08f} {:.08f}'.format(sx, sy))  # 座標s

    # 座標sと座標uのコッホ曲線を求める
    koch(N - 1, sx, sy, ux, uy)
    print('{:.08f} {:.08f}'.format(ux, uy))  # 座標u

    # 座標uと座標tのコッホ曲線を求める
    koch(N - 1, ux, uy, tx, ty)
    print('{:.08f} {:.08f}'.format(tx, ty))  # 座標t

    # 座標tと座標bのコッホ曲線を求める
    koch(N - 1, tx, ty, bx, by)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    print('{:.08f} {:.08f}'.format(0, 0))  # 座標a
    koch(N, 0, 0, 100, 0)
    print('{:.08f} {:.08f}'.format(100, 0))  # 座標b


if __name__ == '__main__':
    main()



Measured memory_bytes: 7164
#include<bits/stdc++.h>
using namespace std;
#define set_null(a,n) memset(a,0,sizeof(a))
#define pi acos(-1)
#define ll long long int
#define fr(a,b) for(int p=a;p<b;p++)
#define modulo 1000000007

int main()
{
    int n;
    cin>>n;
    cout<<setprecision(10)<<2*pi*n<<endl;

    return 0;
}



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

int main()
{
	int a,b,c,tmp ;

	cin >> a >> b >> c ;

	if(a>c)
	{
		tmp = a;
		a = c;
		c = tmp ;
	}

	if(a>b)
	{
		tmp = a;
		a = b ;
		b = tmp;
	}

	if(b>c)
	{
		tmp = b;
		b = c;
		c = tmp;
	}
		
		
	cout << a << " " << b << " " <<  c  << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int N,b;
	string a;
	vector<pair<pair<string,int>,int>> A;
	cin >> N;
	
	for(int i=0;i<N;i++)
	{
		cin >> a >> b;
		A.push_back(make_pair(make_pair(a,-b),i));
	}

	sort(A.begin(), A.end());
	
	for(int i=0;i<N;i++)
	{
		cout << A[i].second+1 <<endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
int a[200005];
int main()
{
    int n,ans=-1;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		int d;
		cin>>d;
		a[d]=a[d-1]+1;
		ans=max(ans,a[d]);
	}
	cout<<(n-ans)<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        final Scanner lineScanner = new Scanner(System.in);
        final int A = lineScanner.nextInt();
        final int B = lineScanner.nextInt();
        int cost = 0;
        if (A >= 13) {
        	cost = B;
        } else if (A >= 6 && A <= 12) {
        	cost = B / 2 ;
        } else {
        	cost = 0;
        }
        System.out.println(cost);
    }
}

Measured memory_bytes: 21844
# import string
import sys

sys.setrecursionlimit(10 ** 5 + 10)


def input(): return sys.stdin.readline().strip()


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    from itertools import accumulate


    B = [0] + A
    B = list(accumulate(B))  # 累積和を格納したリスト作成

    # この問題は長さが1-Nの連続部分の和の最大値を出せというものなので以下の通り

    S=B[-1]
    minans = 10 ** 20
    for i in range(1,N):
        val=abs(B[i]-(S-B[i]))
        minans=min(minans,val)
    print(minans)


resolve()

Measured memory_bytes: 93288
import pprint
import copy
N=int(input())
S=input()
dig=[[] for i in range(10)]
chkigid=[0]*10
ansdigid=[0]*10
#print(dig)
cnt=0
for i in range(N):
    dig[int(S[i])].append(i)#dig[int(S[i])][chkigid[int(S[i])]][2]=i
    chkigid[int(S[i])]=chkigid[int(S[i])]+1
    #pprint.pprint(dig)
    #pprint.pprint(chkigid)
    #input()
#print(dig)
for i in range(10):
    for j in range(10):
        #dig2=copy.deepcopy(dig)
        v1 = float("inf")
        if len(dig[i])!=0:
            v1 = dig[i][0]
        v2 = float("inf")
        if len(dig[j])!=0:
            v2= dig[j][len(dig[j])-1]
        if (v1<v2)and(v1!=float("inf"))and(v2!=float("inf")):
            for k in range(10):
                for l in range(len(dig[k])):
                    if v1<dig[k][l]<v2:
                        #print(dig2[k][l][0])
                        cnt=cnt+1
                        break
        #pprint.pprint(dig)
        #print(i,v1,j,v2,cnt)
        #input()
print(cnt)




Measured memory_bytes: 41564
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// 
int N;
string ans;

int main(){
    cin >> N;
    if(N==25){
        ans = "Christmas";
    }else if(N==24){
        ans = "Christmas Eve";
    }else if(N==23){
        ans = "Christmas Eve Eve";
    }else{
        ans = "Christmas Eve Eve Eve";
    }

    cout << ans << endl;
    return 0;
}




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

void solve(long long K){
    ll ans =0;
    unordered_map<ll,ll> mp;
    ll remain = 0;
    while(true){
        remain = remain*10+7;
        remain = remain %K;
        if(mp.find(remain) != mp.end()){
            cout << -1 << endl;
            return;
        }
        ans++;
        mp[remain]++;
        if(remain ==0){
            break;
        }

        

    }
    cout << ans << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 42700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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

	int N, K;
	cin >> N >> K;

	int B[4000][4000] = {};
	int W[4000][4000] = {};
	int white = 0;

	rep(i, N) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if (c == 'B') {
			B[x % (2 * K)][y % (2 * K)]++;
			B[x % (2 * K) + 2 * K][y % (2 * K)]++;
			B[x % (2 * K)][y % (2 * K) + 2 * K]++;
			B[x % (2 * K) + 2 * K][y % (2 * K) + 2 * K]++;
		}
		else {
			W[x % (2 * K)][y % (2 * K)]++;
			W[x % (2 * K) + 2 * K][y % (2 * K)]++;
			W[x % (2 * K)][y % (2 * K) + 2 * K]++;
			W[x % (2 * K) + 2 * K][y % (2 * K) + 2 * K]++;
			white++;
		}
	}

	rep(i, 4 * K - 1) {
		rep(ii, 4 * K) {
			B[i + 1][ii] = B[i][ii] + B[i + 1][ii];
			W[i + 1][ii] = W[i][ii] + W[i + 1][ii];
		}
	}
	rep(i, 4 * K) {
		rep(ii, 4 * K - 1) {
			B[i][ii + 1] = B[i][ii] + B[i][ii + 1];
			W[i][ii + 1] = W[i][ii] + W[i][ii + 1];
		}
	}

	int saidai = 0;
	rep(i, 2 * K) {
		rep(ii, 2 * K) {
			int goukei = white;
			goukei += B[i][ii] - B[i + K][ii] - B[i][ii + K] + B[i + K][ii + K];
			goukei += B[i + K][ii + K] - B[i + K + K][ii + K] - B[i + K][ii + K + K] + B[i + K + K][ii + K + K];
			goukei -= W[i][ii] - W[i + K][ii] - W[i][ii + K] + W[i + K][ii + K];
			goukei -= W[i + K][ii + K] - W[i + K + K][ii + K] - W[i + K][ii + K + K] + W[i + K + K][ii + K + K];
			saidai = max(saidai, goukei);
		}
	}

	co(saidai);


	Would you please return 0;
}

Measured memory_bytes: 125312
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
class BIT:
  def __init__(self, n):
    self.n = n
    self.data = [0] * (n + 1)
    self.el = [0] * (n + 1)
  def sum(self, i):
    s = 0
    while i > 0:
      s += self.data[i]
      i -= i & -i
    return s
  def add(self, i, x):
    self.el[i] += x
    while i <= self.n:
      self.data[i] += x
      i += i & -i
  def get(self, i, j = None):
    if j is None:
      return self.el[i]
    return self.sum(j) - self.sum(i)

fwk = BIT(2001)
res = 0
for i in range(N):
  res += fwk.get(a[i], 2001)
  res %= mod
  fwk.add(a[i], 1)
res *= K
res %= mod

for i in range(N):
  res += (K * (K - 1) // 2) % mod * fwk.get(a[i], 2001) % mod
  res %= mod
print(res)

Measured memory_bytes: 41968
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

ll gcd(ll a, ll b) {
	if (a % b == 0) {
		return b;
	}
	else {
		return gcd(b, a % b);
	}
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
};
//fixed << setprecision(2)
bool  Array_check(ll y, ll x,ll d,ll w) {
	if (x < 0 || x >= w || y<0 || y>=d) {
		return false;
	}
	else {
		return true;
	}
	
}

//小文字=大文字+32

int main() {
	ll d,t,s;
	cin >> d >> t >> s;
	if (s * t >= d) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

}
	



Measured memory_bytes: 3640
import java.util.*;
 
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        sc.close();

        int max = Math.max(A, Math.max(B, C));
        int min = Math.min(A, Math.min(B, C));
        int mid;
        if( (A >= B && B >= C) ||
            (C >= B && B >= A))
            mid = B;
        else if( (C >= A && A >= B) ||
            (B >= A && A >= C))
            mid = A;
        else 
            mid = C;
        int count = 0;
        
        if((mid - min) % 2 == 0){
            count += (max-mid) + (mid-min)/2;
        } else {
            count += (max-mid) + (mid-1-min)/2 + 2;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21972
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma region header
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
#pragma endregion
#pragma endregion

long long modpow(long long a, long long n, long long d) {
	long long hi = 1;
	while (n > 0) {
		if (n & 1) hi = hi * a % d;
		a = a * a % d;
		n >>= 1;
	}
	return hi;
}
lint modinv(lint a, lint d) {
	return modpow(a, d - 2, d);
}
vector<lint> b(3000000), e(3000000);
void m() {
	b[0] = 0;
	b[1] = 1;
	e[0] = modinv(b[0], 1000003);
	e[1] = modinv(b[1], 1000003);
	for (int i = 2; i < 3000000; i++) {
		b[i] = b[i - 1] * i % 1000003;
		e[i] = modinv(i, 1000003);
	}
	return;
}

int main(void) {
	ios::sync_with_stdio(false);
	cin.tie(0);
	m();
	int q; cin >> q;
	for (int i = 0; i < q; i++) {
		lint x, d, n; cin >> x >> d >> n;
		if (d == 0) {
			cout << modpow(x, n, 1000003) << endl;
			continue;
		}
		else {
			if (n >= 1000003) {
				cout << 0 << endl;
				continue;
			}
			if (x == 0) {
				cout << 0 << endl;
				continue;
			}
			cout << b[x * e[d] % 1000003 + n - 1] * modinv(b[x * e[d] % 1000003 - 1], 1000003) % 1000003 * modpow(d, n, 1000003) % 1000003 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 50112
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint dpT[100000], dpA[100000], N, u, v, a, b;
vector<lint> to[100000];

int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> N >> u >> v; u--; v--;
	REP(i, N - 1) {
		cin >> a >> b; a--; b--;
		to[a].push_back(b);
		to[b].push_back(a);
	}

	REP(i, N) {
		dpT[i] = INF;
		dpA[i] = INF;
	}

	queue<lint> que;
	que.push(u);
	dpT[u] = 0;
	while (!que.empty()) {
		lint curr = que.front(); que.pop();
		REP(i, SZ(to[curr])) {
			lint next = to[curr][i];
			if (dpT[curr] + 1 < dpT[next]) {
				dpT[next] = dpT[curr] + 1;
				que.push(next);
			}
		}
	}

	que.push(v);
	dpA[v] = 0;
	while (!que.empty()) {
		lint curr = que.front(); que.pop();
		REP(i, SZ(to[curr])) {
			lint next = to[curr][i];
			if (dpA[curr] + 1 < dpA[next]) {
				dpA[next] = dpA[curr] + 1;
				que.push(next);
			}
		}
	}

	lint maxv = 0;
	REP(i, N) {
		if (dpT[i] < dpA[i]) {
			chmax(maxv, dpA[i]);
		}
	}
	maxv--;
	cout << maxv << endl;
}


Measured memory_bytes: 8064
#include <stdio.h>
#include <utility>
#include <vector>
#include <queue>
using namespace std;

typedef long long int ll;
constexpr int kN = int(1E5 + 10), kM = int(5E5 + 10);
constexpr ll kInf = ll(1E16 + 10);

#define F first
#define S second
#define PB push_back

struct Edge {
	int to, cost;
};

vector<Edge> graph[kN];
ll dis[kN];

int main() {
	int n, m, s, l, r, c, cnt = 0;
	pair<ll, int> nxt;
	priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> pq;
	scanf("%d%d%d", &n, &m, &s);
	for (int i = 0; i < m; i++) {
		scanf("%d%d%d", &l, &r, &c);
		graph[l].PB({r, c});
	}
	
	for (int i = 0; i < n; i++) dis[i] = kInf;
	dis[s] = 0;
	pq.push({0, s});
	while (!pq.empty()) {
	    if (cnt++ > m * n) {
	        printf("NEGATIVE CYCLE\n");
	        return 0;
	    }
		nxt = pq.top();
		pq.pop();
		if (nxt.F > dis[nxt.S]) continue;
		for (Edge i : graph[nxt.S]) if (dis[nxt.S] + i.cost < dis[i.to]) {
			dis[i.to] = dis[nxt.S] + i.cost;
			pq.push({dis[i.to], i.to});
		}
	}
	for (int i = 0; i < n; i++) if (dis[i] == kInf) printf("INF\n");
	else printf("%lld\n", dis[i]);
}



Measured memory_bytes: 13108
#define C

#ifdef C
#include <stdio.h>
#define abs(a) ((a) < 0 ? -(a) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define isdigit(a) ((a) >= '0' && (a) <= '9' ? true : false)
#endif
#ifdef Cpp
#include <bits/stdc++.h>
using namespace std;
#endif

#define freopen(x) freopen(x".in", "r", stdin);freopen(x".out", "w", stdout)
#define repl(i, t) for (int i = fi[t]; i; i = ne[i])
#define rep(i, a, b) for (int i = (int) a;  i <= (int) b; ++i)
#define per(i, a, b) for (int i = (int) a;  i >= (int) b; --i)
#define _r read()
#define readtype long long

typedef long long var;

const int INF = 0x3f3f3f3f;

readtype read();

int main() {
  int n = _r;
  long double sum = 0;
  rep(i, 1, n) sum += (long double) 1 / _r;
  printf("%.5Lf", (long double) 1 / sum);
  return 0;
}

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();

		String ans = "";
		outer:
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (sc.next().equals("snuke")) {
					ans = String.valueOf((char)('A' + j)) + (i + 1);
					break outer;
				}
			}
		}

		System.out.println(ans);
		sc.close();
	}
}



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

bool IsPrime(long num){
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    long x;
    cin>>x;
    if(x==2){
        cout<<2<<endl;
        return 0;
    }else if(x%2==0) x++;
    for(long i=x;i<2*x;i+=2){
        if(IsPrime(i)){
            cout<<i<<endl;
            return 0;
        } 
    }
}

Measured memory_bytes: 3528
var
	n,i,ans,x,a:Longint;
function gcd(a,b:Longint):Longint;
begin
	if b=0 then gcd:=a else gcd:=gcd(b,a mod b);
end;
begin
	read(n,x);
	for i:=1 to n do begin
		read(a);dec(a,x);if a<0 then a:=-a;
		ans:=gcd(ans,a);
	end;
	writeln(ans);
end.

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
mod=10**9+7
n,k=map(int,input().split())
A=list(map(int,input().split()))
K=k

B,C=[],[]
for i in A:
    if i>=0:B.append(i)
    else:C.append(i)

B.sort()
C.sort(key=lambda x:abs(x))

ans,flag=1,1
while k!=0:
    if k>=2:
        point=0
        if len(B)>=2 and len(C)>=2:
            if B[-1]*B[-2]>C[-1]*C[-2]:
                ans *=B.pop()
                point=1
            else:ans *=C.pop()*C.pop()
        elif len(B)>=2:ans *=B.pop()*B.pop()
        elif len(C)>=2:ans *=C.pop()*C.pop()
        else:flag=0
        k -=2-point
    else:
        if len(B)>=1:ans *=B.pop()
        else:flag=0
        k -=1
    ans %=mod

if flag:print(ans)
else:
    ans=1
    A=sorted(A,key=lambda x:abs(x))
    for i in range(K):
        ans *=A[i]
        ans %=mod
    print(ans)

Measured memory_bytes: 112260
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
int dp[1001][1001] = {{0}};
int main(){
  int w,n;
  char ch;
  int P[1001]={0},W[1001]={0},t = 1;
  while(cin >> w,w ){
    cin >> n;
    for(int i = 0 ; i < n ; i++ ){
      cin >> P[i] >> ch >> W[i];
    }
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j <= w ; j++ ){
	if(j - W[i] >= 0 ){ 
	  dp[i+1][j] = max(dp[i][j],dp[i][j-W[i]] + P[i]);
	}else dp[i+1][j] = dp[i][j];
      }
    }
    cout << "Case " << t << ":" << endl;
    for(int i = w ; i >= 0 ; i--){
      if(dp[n][i] != dp[n][w]){
	cout << dp[n][w] << endl << i + 1 << endl;
	break;
      }
    }
    t++;
  }
  return 0;
}

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a,b=2,c=0,d=0,e,n,m,x,y;
  c(n);
  rep(i,1,10){
    if(n<=111*i){
      co(111*i);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, greater<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 10'000;
const int LOGN = 19;

int n, m, k;

void solve(int test) {
  cin >> n;
  for (int i = 1; i < min(10, n + 1); ++i) {
    int rest = n / i;
    if (i * rest == n && rest < 10) {
      cout << "Yes\n";
      return;
    }
  }
  cout << "No\n";
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


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

char S[101], T[101];

int main(){
	int N, i, j;
	char tmp;
	scanf("%s", S);
	scanf("%s", T);
	for(N = 0; S[N] != '\0'; N++){}
	for(i = 0; i < N; i++){
		tmp = S[0];
		for(j = 1; j < N; j++){
			S[j - 1] = S[j];
		}
		S[N - 1] = tmp;
		if(strcmp(S, T) == 0){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	string s; cin>>s;
	for(auto &i:s){
		i+=n;
		if(i>'Z') i-=26;
	}
	cout<<s<<"\n";
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
from itertools import permutations


def main():
    N, M = map(int, input().split())
    graph = defaultdict(list)
    for _ in range(M):
        a, b = map(int, input().split())
        graph[a].append(b)
        graph[b].append(a)

    ans = 0
    for route in permutations(range(2, N + 1), N - 1):
        ok = True
        now = 1
        for node in route:
            if node in graph[now]:
                now = node
            else:
                ok = False
        ans += ok

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
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 H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();

		System.out.println((H - h)*(W -w));
	}

}


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

int main(){
  int a;
  cin >> a;
  int x = a;
  set<int>cnt;
  int res = 0;
  while(cnt.count(x) == 0){
    cnt.insert(x);
    if(x % 2 == 0){
      x /= 2;
    }
    else{
      x = x * 3 + 1;
    }
    res++;
  }
  cout << res + 1 << endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl "\n"
#define BMW_GTR ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
using namespace std;

//ll const N = 32000;

int main()
{
    BMW_GTR;

    string S, T;
    cin >> S >> T;

    int minn = T.size(), flag = 0;

    for(int i = 0; i <= S.size() - T.size(); i++)
    {
        int k = 0, cnt = 0;
        for(int j = i; j < i + T.size(); j++)
        {
            if(S[j] != T[k])cnt++;
            k++;
        }

        if(cnt < minn)minn = cnt;
    }

    cout << minn;

    return 0;
}


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		long[] sum = new long[k+1];

		for(int i = k;i>0;i-- ) {
			long s = divn(k/i,n);

			for(int j=2;j*i<k+1;j++) {
				s -= sum[j*i];
				s = div(s);
			}
			sum[i]=s;
		}
		long ans = 0;
		for(int i =1;i<k+1;i++) {
			ans += sum[i]*i;
			ans = div(ans);
		}
		System.out.println(ans);

	}

	static long divn(int target, int times) {
		int sqtimes = (int)Math.sqrt(times);
		long ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		long holder = ans;
		ans = 1;
		for(int i =0;i<sqtimes;i++) {
			ans = (ans*holder)%(1000000000+7);
		}
		for(int i=0;i<times - sqtimes*sqtimes;i++) {
			ans = (ans * target)%(1000000000+7);
		}
		return ans;
	}

	static long div(long a) {
		if(a<0)a+=1000000000+7;
		return a%(1000000000+7);
	}

	static int gcd(int a,int b,int c) {
		int ans = 1;
		int max = Math.max(Math.max(a, b),c);
		for(int i =max;i>0;i--) {
			if(a%i==0) {
				if(b%i==0) {
					if(c%i==0) {
						ans = i;
						break;
					}
				}
			}
		}
		return ans;
	}





}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 37080
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      int X=sc.nextInt();
      int Y=sc.nextInt();
      int Z=sc.nextInt();
      int buffer;
      buffer=X;
      X=Y;
      Y=buffer;
      buffer=X;
      X=Z;
      Z=buffer;
      System.out.println(X+" "+Y+" "+Z);
   }
}


Measured memory_bytes: 39364
def main():
	H, W, D = map(int,input().split())
	pos = [0]*(H*W)
	for i in range(H):
		A = list(map(int, input().split()))
		for j in range(W):
			pos[A[j]-1] = [i, j]
	Q = int(input())
	lr = [0]*Q
	for i in range(Q):
		lr[i] = list(map(int, input().split()))
	ans = [[0] for _ in range(D)]
	for i in range(H*W-D):
		s_pos = pos[i]
		e_pos = pos[i+D]
		d = abs(s_pos[0]-e_pos[0])+abs(s_pos[1]-e_pos[1])
		ans[i%D].append(ans[i%D][-1]+d)
	for i in range(Q):
		s = lr[i][0]-1
		e = lr[i][1]-1
		print(ans[e%D][e//D]-ans[s%D][s//D])


if __name__ == '__main__':
    main()

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

using namespace std;

int main() {
  string S;
  cin >> S;
  int N = S.length();
  vector<int> cnt_mod(2019);
  cnt_mod[0] = 1;
  int now = 0;
  int exp = 1;
  long long ans = 0;
  for (int i = N - 1; i >= 0; i--) {
    int d = S[i] - '0';
    now += exp * d;
    now %= 2019;
    exp = (exp * 10) % 2019;
    ans += cnt_mod[now];
    cnt_mod[now]++;
  }
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3728
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

bool check(int n) {
    int prev = 0;
    while (n) {
        int a = n & 1;
        if (prev && a) {
            return false;
        }
        prev = a;
        n >>= 1;
    }
    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, K;
    cin >> H >> W >> K;
    if (W == 1) {
        cout << 1 << endl;
        return 0;
    }
    auto dp = make_v(H + 1, W, 0);

    dp[0][0] = 1;

    const lli mod = 1000000007;

    REP(h, 0, H) {
        REP(i, 0, 1 << (W - 1)) {
            if (!check(i)) {
                continue;
            }
            vector<int> tmp = dp[h];
            REP(j, 0, W - 1) {
                if (i & (1 << j)) {
                    swap(tmp[j], tmp[j + 1]);
                }
            }
            REP(j, 0, W) {
                dp[h + 1][j] = (dp[h + 1][j] + tmp[j]) % mod;
            }
            /*
            dump(i);
            REP(a, 0, W) {
                cout << dp[h + 1][a] << " \n"[a == W - 1];
            }
            //*/
        }
    }
    cout << dp[H][K - 1] << endl;
    /*
    REP(i, 0, H + 1) {
        REP(j, 0, W) {
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }
    //*/
    return 0;
}


Measured memory_bytes: 256