akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int A[1000];

int main(){
  int i,j,v,N,a;
  scanf("%d",&N);//数列の長さ//
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }

  for(i=1;i<N;i++){
    for(a=0;a<N-1;a++){
      printf("%d ",A[a]);
    }
    printf("%d\n",A[N-1]);
    v=A[i];
    j = i-1;

    while(j >= 0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    
    }
      A[j+1] = v;   
  }

  for(a=0;a<N-1;a++){
    printf("%d ",A[a]);
  } 
  printf("%d\n",A[N-1]);

  return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 200005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;


int main() {
  string s;
  cin>>s;
  set<string> st;
  string t = "AKIHABARA";
  rep(i,1<<9) {
    string x;
    rep(j,9) {
      if (i>>j&1) {
        x += t[j];
      } else if (t[j] != 'A') x = "x";
    }
    st.insert(x);
  }
  puts(st.count(s)?"YES":"NO");
  return 0;
}






















Measured memory_bytes: 256
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rf = lambda: map(float, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

d,t,s = rm()
if d/s <= t:
  print('Yes')
else:
  print('No')













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

void output(std::vector<int> v){
  for(int i=0; i<v.size()-1; i++){
    std::cout << v[i] << " ";
  }
  std::cout << v[v.size()-1] << std::endl;
}

int main(void){
  std::vector<int> odd;
  std::vector<int> even;
  std::vector<int> A;
  int N, M;
  std::cin >> N >> M;
  
  int a;
  for(int i=0; i<M; i++){
    std::cin >> a;
    if(a%2) odd.push_back(a);
    else even.push_back(a);
  }
  
  if(odd.size() > 2){
    std::cout << "Impossible" << std::endl;
    return 0;
  }
  
  
  // create line A
  if(odd.size() >= 1){
    A.push_back(odd[0]);
  }
  for(int i=0; i<even.size(); i++){
    A.push_back(even[i]);
  }
  if(odd.size() == 2){
    A.push_back(odd[1]);
  }
  
  
  std::vector<int> B;
  
  if(A.size() == 1 && A[0] == 1){
    std::cout << 1 << std::endl
	      << 1 << std::endl
	      << 1 << std::endl;
  }else if(A.size() == 1){
    std::cout << A[0] << std::endl
	      << 2 << std::endl
	      << A[0]-1 << " " << 1 << std::endl;
  }else{
    if(A[0] != 1){
      B.push_back(A[0]-1);
    }
    for(int i=1; i<A.size()-1; i++){
      B.push_back(A[i]);
    }
    if(A.size() != 1){
      B.push_back(A[A.size()-1]+1);
    }
    
    output(A);
    std::cout << B.size() << std::endl;
    output(B);
  }
  
  
  
  
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, c;
    cin >> n >> c;

    vector<pair<int64_t, int64_t>> sushi(n);
    for (auto i : irange(0L, n)) {
        cin >> sushi[i].first >> sushi[i].second;
    }

    vector<int64_t> max_left(n + 1, 0L), max_right(n + 1, 0L);
    int64_t sl = 0, sr = 0;
    for (auto i : irange(0L, n)) {
        sl += sushi[i].second;
        max_left[i + 1] = max(max_left[i], -sushi[i].first + sl);

        sr += sushi[n - i - 1].second;
        max_right[n - i - 1] =
                max(max_right[n - i], -(c - sushi[n - i - 1].first) + sr);
    }

    int64_t ans = max({0L, max_left.back(), max_right.front()});
    sl = 0, sr = 0;
    for (auto i : irange(0L, n)) {
        sl += sushi[i].second;
        auto tl = -2 * sushi[i].first + sl + max_right[i + 1];

        sr += sushi[n - i - 1].second;
        auto tr = -2 * (c - sushi[n - i - 1].first) + sr + max_left[n - i - 1];

        ans = max({ans, tl, tr});
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
program ec12;
var 
	n,m,i,j,max,min:longint;
	a:array[1..301,1..301] of longint;
	vis,step:array[1..301] of longint;
	vis1:array[1..301] of boolean;
begin 
	readln(n,m);
	for i:=1 to n do 
	for j:=1 to m do 
	read(a[i,j]);
	min:=n;
	for i:=1 to n do 
	step[i]:=1;
	fillchar(vis1,sizeof(vis1),true);
	while true do 
	begin 	
		fillchar(vis,sizeof(vis),0);
		for i:=1 to n do 
		inc(vis[a[i,step[i]]]);
		max:=1;
		for i:=2 to m do 
		begin 	
			if vis[max]<vis[i] then 
			max:=i;
		end;
		if vis[max]<min then 
		min:=vis[max];
		vis1[max]:=false;
		for i:=1 to n do 
		begin 
			while (not vis1[a[i,step[i]]]) and (step[i]<=m) do
			inc(step[i]);
			if step[i]>m then 
			begin 
				writeln(min);
				halt;
			end;
		end;
	end;
	writeln(min);
end. 

Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
#include<utility>
#include<vector>

using namespace std;

int aa[100005];
vector<pair<int,int> > v[100005];
pair<int,int> bb[100005];
int fb[100005];

void myprint(int num)
{
	int arr[6]={0,};
	int p=5;
	while(num)
	{
		arr[p--]=num%10;
		num/=10;
	}
	for(int i=0;i<6;i++)
		printf("%d",arr[i]);
}

int main(void)
{
	int n,m; scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		scanf("%d %d",&aa[i],&bb[i].first);
		bb[i].second=i;		
		v[aa[i]].push_back(bb[i]);
	}
	for(int i=1;i<=n;i++)
	{
		sort(v[i].begin(),v[i].end());
	}
	for(int i=1;i<=n;i++)
	{
		int l = v[i].size();
		for(int j=1;j<=l;j++)
		{
			fb[v[i][j-1].second] = j;
		}
	}
	for(int i=0;i<m;i++)
	{
		myprint(aa[i]); myprint(fb[i]);
		printf("\n");
	}
	return 0;
}

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

int main(){
  int n; cin >>n;
  map<int, int> mp;
  ll sum = 0;
  rep(i,n){
    int a; cin >>a;
    mp[a]++;
    sum += a;
  }
  int q; cin >>q;
  rep(i,q){
    int b,c;
    cin >>b >>c;
    sum += (c-b)*mp[b];
    mp[c] += mp[b];
    mp[b] = 0;
    cout << sum << endl;
  }
  return 0; 
}

Measured memory_bytes: 8032
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef __float128 ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
const ll REFL=1e8;
int untested_longest_increasing_subsequence(vector<int> p) {
	vector<int> v;
	int n=p.size();
	for (auto &x:p) {
		int imin=0,imax=v.size();
		while(imin<imax) {
			int imid=(imin+imax)>>1;
			if(v[imid]<=x) imin=imid+1;
			else imax=imid;
		}
		if (imin==v.size()) v.PB(x);
		else {
			v[imin]=x;
		}
	}
	return v.size();
}

ld QUARTER=3.141592653589793238462643383279502884197169399375105820974944592307816406286L*5.0L;
void solve(vector<long long> ox, vector<long long> oy, long long n, vector<long long> vx, vector<long long> vy){
	cout<<fixed<<setprecision(20);
	if (ox[0]>ox[1]) {
		swap(ox[0],ox[1]);
		swap(oy[0],oy[1]);
	}
	ll sx=ox[0],sy=oy[0];
	ll tx=ox[1],ty=oy[1];
	if (sy>ty) {
		sy=-sy;
		ty=-ty;
		for (auto &y:vy) {
			y=-y;
		}
	}
	//for (ll i=0;i<vx.size();i++) {
	//	ll x=vx[i],y=vy[i];
	//	printf("%d %d\n",x,y);
	//}
	if (sx==tx||sy==ty) {
		ll hit=0;
		for (ll i=0;i<vx.size();i++) {
			ll x=vx[i],y=vy[i];
			if (sx<=x&&x<=tx&&sy<=y&&y<=ty) {
				hit++;
			}
		}
		ld ans=100.0L*(abs(tx-sx)+abs(ty-sy))+2ll*(QUARTER-10)*hit;
		cout<<(long double)ans<<endl; return;
	}
	vector<pii> vp;
	for (ll i=0;i<vx.size();i++) {
		ll x=vx[i],y=vy[i];
		if (sx<=x&&x<=tx&&sy<=y&&y<=ty) {
			vp.PB(MP(x,y));
		}
	}
	sort(vp.begin(),vp.end());
	vector<int> seq; for (auto &w:vp) seq.PB(w.snd);
  ll best=untested_longest_increasing_subsequence(seq);
  ld save=20-QUARTER;
  ld final=100.0L*(abs(sx-tx)+abs(sy-ty))-save*best;
  ll ddist=min(abs(sx-tx),abs(sy-ty))+1;
  //printf("ddist:%lld save:%lld. %lld %lld\n",ddist,save,abs(sx-tx),abs(sy-ty));
  if (best==ddist)final+=save+2*(QUARTER-10);
  cout<<(long double)final<<endl;
}
 
int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	vector<long long> x(2-1+1);
	vector<long long> y(2-1+1);
	long long N;
	for(ll i = 0 ; i <= 2-1 ; i++){
		scanf("%lld",&x[i]);
		scanf("%lld",&y[i]);
	}
	scanf("%lld",&N);
	vector<long long> X(N-1+1);
	vector<long long> Y(N-1+1);
	for(ll i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&X[i]);
		scanf("%lld",&Y[i]);
	}
	solve(x, y, N, X, Y);
	return 0;
}


Measured memory_bytes: 11632
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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

//ａをbで割る
long long mod_div(long long a,long long b){
  if(a % b == 0)return a/b;
  long long tmp = MOD - 2,c = b,ret = 1;
  while(tmp > 0){
    if(tmp & 1){
      ret *= c;ret %= MOD;
    }
    c *= c;c %= MOD;tmp >>= 1;
  }
  return a*ret%MOD;
}

//階乗の上限
#define MAX_K 333333
vector<long long> kaijo(MAX_K);
long long combination(long long n, long long r){
  if(n < r || n < 0 || r < 0)
    return 0;
  if(kaijo[0] != 1){
    kaijo[0] = 1;
    for(long long i = 1;i < MAX_K;i++)kaijo[i] = (kaijo[i-1] * i) % MOD;
  }
  long long ret = kaijo[n];
  long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
  return mod_div(ret,tmp);
}

ll dp[3300][2];
int main()
{
  int H, W, N;
  cin >> H >> W >> N;
  vector<pair<ll, P>> kabe;
  REP(i, N) {
    int r, c;
    cin >> r >> c;
    r--; c--;
    kabe.PB(MP(r + c, MP(r, c)));
  }
  kabe.PB(MP(0, MP(0, 0)));
  kabe.PB(MP(H-1 + W-1, MP(H-1, W-1)));
  sort(ALL(kabe));

  dp[0][0] = 1;
  for (int i = 0; i < kabe.size(); i++) {
    for (int j = i + 1; j < kabe.size(); j++) {
      int h = kabe[j].SE.FI - kabe[i].SE.FI;
      int w = kabe[j].SE.SE - kabe[i].SE.SE;
      if (h < 0 || w < 0) continue;
      for (int k = 0; k <= 1; k++) {
        (dp[j][(k + 1)%2] += dp[i][k] * combination(h + w, h))%=MOD;
      }
    }
  }

  cout << (MOD + (dp[N+1][1] - dp[N+1][0])) % MOD << endl;

  return 0;
}

Measured memory_bytes: 3072
use std::cmp::min;

fn main() {
  let mut s = String::new();
  std::io::stdin().read_line(&mut s).ok();
  s.clear();
  std::io::stdin().read_line(&mut s).ok();
  let xs: Vec<i32> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
  let mut ans = 1_000_000_000;
  for p in 1..101 {
    let mut sum = 0;
    for x in xs.iter() {
      sum += (x - p) * (x - p);
    }
    ans = min(ans, sum);
  }
  println!("{}", ans);
}

Measured memory_bytes: 2096
import java.util.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map { it.toInt() } // list of ints

private fun readDouble() = readLn().toDouble()
private fun readDoubles() = readStrings().map { it.toDouble() }

fun main(){

    val scanner = Scanner(System.`in`)

    val a = scanner.next().toBigDecimal()
    val b = scanner.next().toBigDecimal()
    println((a*b).toBigInteger())
}



Measured memory_bytes: 36616
using System;

namespace AtTest
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int sn = 0;
            int subN = n;
            while (subN > 9)
            {
                sn += subN % 10;
                subN /= 10;
            }
            sn += subN;
            if (n % sn == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

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

		int[] m = new int[200];
		int N = sc.nextInt();
		int X  = sc.nextInt();
		int min = Integer.MAX_VALUE;
		int sum = 0;
		for (int i = 0; i < N; i++)
			m[i] = sc.nextInt();

		for (int i = 0; i < N; i++)
			X -= m[i];
		for (int i = 0; i < N; i++)
			if (m[i] < min)
				min = m[i];
		sum = N + (X / min);
		System.out.println(sum);
	}
}

Measured memory_bytes: 23124
# -*- coding: utf-8 -*-
import numpy as np
# 整数の入力
A, B, C, X = int(input()), int(input()), int(input()), int(input())

num = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X == a*500+b*100+c*50:
                num += 1
print(num)
        

Measured memory_bytes: 12504
#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 pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	int N;
	cin >> N;
	string S[50];
	rep(i, N) cin >> S[i];

	int A[26][50] = {};

	rep(i, N) {
		rep(ii, S[i].size()) {
			A[S[i][ii] - 'a'][i]++;
		}
	}

	string kotae;
	rep(i, 26) {
		int kari = *min_element(A[i], A[i] + N);
		rep(ii, kari) kotae += (char)('a' + i);
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	list := getStdinIntArr()
	N := list[0]
	M := list[1]
	X := list[2]
	C := make([]int, N)
	A := make([][]int, N)
	for i := 0; i < N; i++ {
		A[i] = make([]int, M)
	}

	for i:=0 ; i<N ; i++ {
		list2 := getStdinIntArr()
		C[i] = list2[0]
		for j:=0 ; j<M ; j++ {
			A[i][j] = list2[j+1]
		}
	}

	maxBit := (1 << N) - 1
	moneyMin := math.MaxInt32
	for bit := 1; bit <= maxBit ; bit++ {
		money := 0
		AC := make([]int, M)
		for i:=0 ; i<N ; i++ {
			mask := 0
			if i==0 {
				mask = 1
			} else {
				mask = 1 << i
			}
			if (bit & mask) != 0 {
				money += C[i]
				for n:=0 ; n<M ; n++ {
					AC[n] += A[i][n]
				}
			}
		}
		flag := true
		for i:=0 ; i<M ; i++ {
			if AC[i] < X {
				flag = false
				break
			}
		}
		if flag && money < moneyMin {
			moneyMin = money
		}
	}

	if moneyMin == math.MaxInt32 {
		fmt.Printf("%d", -1)
	} else {
		fmt.Printf("%d", moneyMin)
	}

	fmt.Printf("\n")
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 2136
#include<iostream>
#include<vector>
#include<string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

VI A,B;
int N;

int main(){

	cin >> N;
	A.resize(N);
	B.resize(N);
	REP(i,N){
		cin >> A[i] >> B[i];
	}
	long long ans = 0;
	RFOR(i,0,N){
		if((A[i]+ans)%B[i] == 0)
			continue;
		ans += ((A[i]+ans)/B[i]+1)*B[i] - (A[i]+ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), a + n
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define MOD(x) ((x) % (1e9 + 7))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n;
	scanf("%d", &n);
	REP(i, 9) {
		REP(j, 9) {
			if((i + 1) * (j + 1) == n) {
				puts("Yes");
				return 0;
			}
		}
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
def isPrime(x):
    if x < 2:
        return 0
    elif x == 2:
        return 1
    if x%2 == 0:
        return 0
    ir=int(x**(0.5))+1
    for i  in range(3,ir,2) :
        if x%i == 0:
            return 0
    return 1

q=int(input())

l=[0]*q
r=[0]*q
for i in range(q):
    l[i],r[i]=map(int,input().split())
    
ps=[0]
pcnt=0
for i in range(1,max(r)+1):
    if i%2==1 and isPrime(i) and isPrime((i+1)//2):
        pcnt+=1
    ps.append(pcnt)        

#print(ps)

for i in range(q):
    print(ps[r[i]]-ps[l[i]-1])
    



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

int main()
{
  int n; cin >> n;
  long long sum = 0;
  for(int i = 1; i < n+1; i++){
    if((i%3 != 0) && (i%5 != 0)) sum += i;
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    ll cnt = 0;
    rep(i,n) {
        int a;
        cin >> a;
        while(a%2==0){
            a/=2;   
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define SIZE 2005
#define MOD 924844033

using namespace std;
typedef long long int ll;

int dp[SIZE][2];//0だったら1個前使える
int nxt[SIZE][2];

int main()
{
	int n,K;
	scanf("%d %d",&n,&K);
	dp[0][0]=1;
	for(int i=0;i<min(n,2*K);i++)
	{
		if(i<K)
		{
			for(int k=0;k<=n;k++)
			{
				swap(dp[k][0],dp[k][1]);
			}
		}
		for(int j=i;j<n;j+=2*K)
		{
			memset(nxt,0,sizeof(nxt));
			for(int k=0;k<=n;k++)
			{
				if(dp[k][0]>0)
				{
					nxt[k][0]+=dp[k][0];
					if(nxt[k][0]>=MOD) nxt[k][0]-=MOD;
					nxt[k+1][0]+=dp[k][0];
					if(nxt[k+1][0]>=MOD) nxt[k+1][0]-=MOD;
					if(j+K<n)
					{
						nxt[k+1][1]+=dp[k][0];
						if(nxt[k+1][1]>=MOD) nxt[k+1][1]-=MOD;
					}
				}
				if(dp[k][1]>0)
				{
					nxt[k][0]+=dp[k][1];
					if(nxt[k][0]>=MOD) nxt[k][0]-=MOD;
					if(j+K<n)
					{
						nxt[k+1][1]+=dp[k][1];
						if(nxt[k+1][1]>=MOD) nxt[k+1][1]-=MOD;
					}
				}
			}
			for(int k=0;k<=n;k++) dp[k][0]=nxt[k][0],dp[k][1]=nxt[k][1];
		}
		for(int j=0;j<=n;j++)
		{
			//printf("[%d %d] ",dp[j][0],dp[j][1]);
			dp[j][0]+=dp[j][1];
			if(dp[j][0]>=MOD) dp[j][0]-=MOD;
			dp[j][1]=0;
		}//puts("");
	}
	ll ret=0,fac=1;
	for(int i=n;i>=0;i--)
	{
		//printf("%d ",dp[i][0]);
		ll way=fac*(ll) dp[i][0]%MOD;
		if(i%2==0)
		{
			ret+=way;
			if(ret>=MOD) ret-=MOD;
		}
		else
		{
			ret-=way;
			if(ret<0) ret+=MOD;
		}
		fac=fac*(ll) (n-i+1)%MOD;
	}//puts("");
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h> 
using namespace std; 
  
const int MAX = 5e5+7; 
  
// structure to store queries 
struct Query 
{ 
    int l, r, idx; 
}; 
  
// cmp function to sort queries according to r 
bool cmp(Query x, Query y) 
{ 
    return x.r < y.r; 
} 
  
// updating the bit array 
void update(int idx, int val, int bit[], int n) 
{ 
    for (; idx <= n; idx += idx&-idx) 
        bit[idx] += val; 
} 
  
// querying the bit array 
int query(int idx, int bit[], int n) 
{ 
    int sum = 0; 
    for (; idx>0; idx-=idx&-idx) 
        sum += bit[idx]; 
    return sum; 
} 
  
void answeringQueries(int arr[], int n, Query queries[], int q) 
{ 

    int bit[n+1]; 
    memset(bit, 0, sizeof(bit)); 

    int last_visit[MAX]; 
    memset(last_visit, -1, sizeof(last_visit)); 

    int ans[q]; 
    int query_counter = 0; 
    for (int i=0; i<n; i++) 
    { 
        
        if (last_visit[arr[i]] !=-1) 
            update (last_visit[arr[i]] + 1, -1, bit, n); 
  

        last_visit[arr[i]] = i; 
        update(i + 1, 1, bit, n); 

        while (query_counter < q && queries[query_counter].r == i) 
        { 
            ans[queries[query_counter].idx] = 
                     query(queries[query_counter].r + 1, bit, n)- 
                     query(queries[query_counter].l, bit, n); 
            query_counter++; 
        } 
    } 

    for (int i=0; i<q; i++) 
        cout << ans[i] << endl; 
} 
  
int main() 
{ 
    int n,q;
    cin>>n>>q;

    int a[n];
    for (int i=0; i<n; i++)
        cin>>a[i];

    Query queries[q]; 

    for (int i=0; i<q; i++)
    {
        cin>>queries[i].l>>queries[i].r;
        queries[i].l--;
        queries[i].r--;
        queries[i].idx = i;
    }
     q = sizeof(queries)/sizeof(queries[0]); 
    sort(queries, queries+q, cmp); 
    answeringQueries(a, n, queries, q); 
    return 0; 
} 


Measured memory_bytes: 17444
n = int(input())
B = list(map(int, input().split()))
A = [0] * n
A[0] = B[0]
for i in range(1, n-1):
    if B[i-1] < B[i]:
        A[i] = B[i-1]
    else:
        A[i] = B[i]

A[n-1] = B[n-2]

print(sum(A))


Measured memory_bytes: 38384
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def ap(a) a.each{|u| p u} end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end

n,m = inp
t = []
m.times do
  t.push(inp)
end
min = 0
ans = 0
t.sort_by!{|u|u[1]}
t.each do |a|
  unless(a[0] < min)
    min = a[1]
    ans += 1
  end
end
p ans

Measured memory_bytes: 13584
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }
 
 
 
int main(int argc, char const *argv[]) {
  int x,a;
  cin >> x >> a;
  if(x<a) cout << "0" << endl;
  else cout << "10" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll a[200000];
ll d[200000];
bool used[200000];

int main(){
	int n;cin>>n;
	rep(i,n)cin>>a[i];
	int x=0;
	used[0]=true;
	while(!used[(x+2)%n]){
		used[(x+2)%n]=true;
		d[(x+2)%n]=(a[(x+1)%n]-a[x])*2+d[x];
		(x+=2)%=n;
	}
	ll sum=0;
	rep(i,n){
		sum+=d[i];
	}
	ll sum2=accumulate(a,a+n,0LL);
	ll add=(sum2-sum)/n;
	rep(i,n){
		cout<<d[i]+add<<' ';
	}
	cout<<endl;
}

Measured memory_bytes: 2944
n,m=map(int,input().split())
l=[]
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort()
s=l[0][1]
ans=1
for i in range(1,m):
    if l[i][0]>=s:
        ans+=1
        s=l[i][1]
    if l[i][1]<=s:
        s=l[i][1]
print(ans)


Measured memory_bytes: 27880
#include <cstdio>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  int C;
  scanf("%zu %d", &N, &C);

  std::vector<std::vector<int>> D(C, std::vector<int>(C));
  for (int i=0; i<C; ++i)
    for (int j=0; j<C; ++j)
      scanf("%d", &D[i][j]);

  std::vector<std::vector<int>> c(N, std::vector<int>(N));
  for (size_t i=0; i<N; ++i)
    for (size_t j=0; j<N; ++j) {
      scanf("%d", &c[i][j]);
      --c[i][j];
    }

  std::vector<std::vector<int>> d(3, std::vector<int>(C));
  for (size_t i=0; i<N; ++i) {
    for (size_t j=0; j<N; ++j) {
      for (int k=0; k<C; ++k) {
        d[(i+j)%3][k] += D[c[i][j]][k];
      }
    }
  }

  int res=2e9;
  for (int i=0; i<C; ++i) {
    for (int j=0; j<C; ++j) {
      if (i == j) continue;
      for (int k=0; k<C; ++k) {
        if (i == k || j == k) continue;
        res = std::min(res, d[0][i]+d[1][j]+d[2][k]);
      }
    }
  }
  printf("%d\n", res);
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

string N;
int dp[10][2][2][1 << 3];
int mp[10] = {0, 0, 0, 0, 0, 1, 0, 2, 0, 0};
int rec(int i, bool less, bool zero, int s) {
    auto& DP = dp[i][less][zero][s];
    if (DP != INF) return DP;
    if (i == SZ(N)) {
        if (__builtin_popcount(s) == 3) return DP = 1;
        else return DP = 0;
    }
    int ret = 0;
    if (less) {
        REP(d, 10) {
            if (d == 3 || d == 5 || d == 7) {
                ret += rec(i + 1, true, false, s | (1 << mp[d]));
            }
        }
        if (zero) ret += rec(i + 1, true, true, s);
    } else {
        if (N[i] == '3' || N[i] == '5' || N[i] == '7') {
            ret += rec(i + 1, false, false, s | (1 << mp[N[i] - '0']));
        }
        REP(d, N[i] - '0') {
            if (d == 3 || d == 5 || d == 7) {
                ret += rec(i + 1, true, false, s | (1 << mp[d]));
            }
        }
        if (zero) ret += rec(i + 1, true, true, s);
    }
    return DP = ret;
}
signed main() {
    REP(i, 10) REP(j, 2) REP(k, 2) REP(l, 1 << 3) dp[i][j][k][l] = INF;
    cin >> N;
    cout << rec(0, 0, 1, 0) << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
int a,b,c;
scanf("%d %d",&a,&b);
if(a>0){
c=1;
}
else{
if(a+b==0){
c=0;
}
else if(a+b>0){
c=1;
}
else{
c=-1;
}
}
printf("%d\n",c);
return 0;
}


Measured memory_bytes: 1952
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = 0;
		String n = sc.nextLine();
		String p = sc.nextLine();
		String[] p2 = p.split(" ");
		ArrayList<Integer> p3 = new ArrayList<Integer>();
		for (int i = 0; i < p2.length; i++) {
			p3.add(Integer.valueOf(p2[i]));
		}
		for (int i = 0; i < p3.size() - 2; i++) {
			if (((p3.get(i) < p3.get(i + 1)) && (p3.get(i + 1) < p3.get(i + 2)))
					|| ((p3.get(i) > p3.get(i + 1)) && (p3.get(i + 1) > p3.get(i + 2)))) {
				k++;
			}
		}

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

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

ll modpow(ll a, int n)
{
  ll ret = 1;
  while (n > 0) {
    if (n & 1) {
      ret = (ret * a) % MOD;
    }
    a = (a * a) % MOD;
    n >>= 1;
  }
  return ret;
}

ll combi(int n, int r, vector<ll>& fact, vector<ll>& inv_fact)
{
  if (r > n) { return 0; }
  ll ret = (fact[n] * inv_fact[r]) % MOD;
  ret = (ret * inv_fact[n - r]) % MOD;
  return ret;
}

int main()
{
  int H, W, A, B; scanf("%d %d %d %d", &H, &W, &A, &B);

  int N = H + W;
  vector<ll> fact(N + 5, 1);
  for (int i = 1; i <= N; ++i) {
    fact[i] = (i * fact[i - 1]) % MOD;
  }
  vector<ll> inv_fact(N + 5, 1);
  inv_fact[N] = modpow(fact[N], MOD - 2);
  for (int i = N - 1; i >= 0; --i) {
    inv_fact[i] = (inv_fact[i + 1] * (i + 1)) % MOD;
  }

  ll ans = 0;
  for (int i = B; i < W; ++i) {
    ll val = combi(H - 1 - A + i, i, fact, inv_fact) *
             combi(A - 1 + W - 1 - i, A - 1, fact, inv_fact);
    ans = (ans + val) % MOD;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 3328
A, B = map(int, input().split())
if A > B:
    A, B = B, A

length = int(A ** 0.5) + 2
Ax = A
s = [1] * length
ans, i, lim, t = 1, 2, A ** 0.5, set()
while i < lim:
    if s[i] == 1:
        for j in range(i*2, length, i):
            s[j] = 0
        if A % i == 0:
            if B % i == 0:
                ans += 1
            while Ax % i == 0:
                Ax //= i
    i += 1

if Ax >= length and B % Ax == 0:
    ans += 1
print(ans)


Measured memory_bytes: 10868
#include<stdio.h>
void sort(int numbers[],int arraysize);
int main(void)
{
	int a[3];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a,3);
	if(a[0]+a[1] == a[2]) printf("Yes");
	else printf("No");
	return 0;
}


void sort(int numbers[], int arraysize)
{
  int i, j, temp;

  for (i = 0; i < (arraysize - 1); i++) {
    for (j = (arraysize - 1); j > i; j--) {
      if (numbers[j-1] > numbers[j]) {
        temp = numbers[j-1];
        numbers[j-1] = numbers[j];
        numbers[j] = temp;
      }
    }
  }
}


Measured memory_bytes: 256
from collections import deque
N,K=map(int,input().split())
A= [0]+list(map(int,input().split()))
t=1
r=set()
q=deque([])
loop_flag=False

if K<=N:
  for i in range(1,K+1):
    t = A[t]
  print(t)
else:
  for i in range(K):
    #print(i,r)
    q.append(t)
    if t not in r:
      r.add(t)
      t=A[t]
    else:
      break
  start=0
  while q:
    a=q.popleft()
    if a==q[-1]:         
      loop_leng=i-start
      break
    start +=1
  
  K -=start
  K = K%loop_leng
  #print(start,loop_leng)
  
  t=1
  for i in range(1,start+1):
    #print(t,A[t])
    t = A[t]
  for i in range(1,K+1):
    t = A[t]  
  print(t)

Measured memory_bytes: 32712
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


using namespace std;

const int INF = 1001001001;

int main (){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    int m;
    vector<pair<int, int>> key;

    cin >> n >> m;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b){
            int c;
            cin >> c;
            --c;
            s |= 1 << c;

        }
        key.emplace_back(s, a);

    }

    vector<int> dp(1<<n, INF);
    dp[0] = 0;
    rep(s, 1 << n){
        rep(i, m){
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }

    }

    int ans = dp.back();
    if (ans == INF) ans = -1;
    cout << ans << endl;

    return 0;





}

Measured memory_bytes: 256
def B():
    n = int(input())
    s = []
    for _ in range(n):
        s.append(input())
    import collections
    c = collections.Counter(s)
    ret_l = ["AC","WA","TLE","RE"]
    for t in ret_l:
        print(t +  " x " + str(c[t]))
B()

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n; cin >> n;
  vector<int> v;
  for(int i = 0; i < n; i++) {
    int z; cin >> z;
    z--;
    v.push_back(z);
  }
  int now = 0, c = 0;
  for(;;) {
    if(now == 1) {
      cout << c << endl;
      return 0;
    }
    if(c >= n) {
      cout << -1 << endl;
      return 0;
    }
    c++;
    now = v[now];
  }

  return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

int main() {
    int H, W;
    cin >> H >> W;

    int sy, sx, gy, gx;
    cin >> sy >> sx;
    cin >> gy >> gx;
    --sy; --sx; --gy; --gx;
    
    vector<string> S(H);
    for_(i,0,H) cin >> S[i];

    auto in_range = [&](int y, int x) {
        return 0 <= y and y < H and 0 <= x and x < W;
    };

    using pii = pair<int, int>;
    deque<pii> deq;
    deq.push_back(pii(sy, sx));

    vector<vector<int>> cost(H, vector<int>(W, -1));
    cost[sy][sx] = 0;

    while (!deq.empty()) {
        pii p = deq[0]; deq.pop_front();
        int y = p.first, x = p.second;

        for_(d,0,4) {
            int ny = y + dy[d], nx = x + dx[d];
            if (!in_range(ny, nx)) continue;
            if (S[ny][nx] == '#') continue;
            if (cost[ny][nx] == -1 or cost[ny][nx] > cost[y][x]) {
                cost[ny][nx] = cost[y][x];
                deq.push_front(pii(ny, nx));
            }
        }

        for_(a,-2,3) for_(b,-2,3) {
            int ny = y + a, nx = x + b;
            if (!in_range(ny, nx)) continue;
            if (S[ny][nx] == '#') continue;
            if (cost[ny][nx] == -1 or cost[ny][nx] > cost[y][x] + 1) {
                cost[ny][nx] = cost[y][x] + 1;
                deq.push_back(pii(ny, nx));
            }
        }
    }

    cout << cost[gy][gx] << endl;
}

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

int main(){
  int n; cin >> n;
  int m; cin >> m;
  int a[n]; for(int i = 0; i < n; i++) cin >> a[i];
  priority_queue<int> q; for(int i = 0; i < n; i++) q.push(a[i]);
  
  int tmp = 0;
  long int sum = 0;
  
  for(int i = 0; i < m; i++){
    tmp = q.top();
    q.pop();
    q.push(tmp/2);
  }
  
  while(!q.empty()){
    sum += q.top();
    q.pop();
  }
  
  cout << sum << endl;
  
  return 0;
}

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

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(v) (v).begin(),(v).end()
#define endl '\n'

using namespace std;

const int N = 100005;
const int MOD = 1e9 + 7;
const int INF = 2000000000;
const ll INFLL = 1LL * INF * INF;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - max({a, b, c}) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int func(int n){
    if (n%2 == 0){
        return n/2;
    }
    else{
        return 3 * n + 1;
    }
}

int main(){
    int s[1000001] = {0};
    int r = 0;
    scanf("%d", &s[1]);
    int flag = 0;
    for (int i=2; flag == 0; i++){
        s[i] = func(s[i-1]);
        for(int j = 1; j< i; j++){
            if(s[j] == s[i]){
                flag = 1;
                r = i;
                break;
            }
        }
    }

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

Measured memory_bytes: 4096
#include <stdio.h>
#include <stdlib.h>
#define NIL NULL
 
struct node{
 
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
 
typedef struct node * Node;
  
Node root;
 
void insert(int k){
 
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
   
  while(x != NIL){
     
    y = x;
     
    if(z->key < x->key) x = x->left;
    else  x = x->right;
  }
   
  z->parent = y;
   
  if( y ==  NIL ) root = z;
  else if( z->key < y->key ) y->left = z;
  else  y->right = z;
   
   
}
 
void inorder(Node u){
 
  if(u->left != NIL) inorder(u->left);
 
  printf(" %d",u->key);
 
  if(u->right != NIL) inorder(u->right);
}
void preorder(Node u){
 
  printf(" %d",u->key);
   
  if(u->left != NIL) preorder(u->left);
  if(u->right != NIL) preorder(u->right);
   
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    
    if ( com[0] == 'i' ){
      scanf("%d", &x);
       insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
 
  return 0;
}

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

int main()
{
		int m, i, j, k;
		string s, sub, temp;
		while (1) {
				cin >> s;
				if (s=="-") break;
				cin >> m;
				int h[m];
				for (i=0; i<m; i++) cin >> h[i];

				for (i=0; i<m; i++) {
						s = s.substr(h[i],s.size()-h[i]) + s.substr(0,h[i]);
				}
				cout << s << "\n";
		}
}

Measured memory_bytes: 3164
import math
a,b,x=list(map(int,input().split()))
maxv=a*a*b
sukima=maxv-x
teimenseki=sukima/a
y=teimenseki*2/a

if x > (maxv/2):
    print(math.degrees(math.atan(y/a)))
else:
    tei=x/a
    z=tei*2/b
    print(math.degrees(math.atan(b/z)))

Measured memory_bytes: 3060
def check(nums):
    for i in range(9):
        if(nums[i]>4):return False

    for head in range(9):
        anums=nums[:]
        if(anums[head]<2):continue
        anums[head]-=2

        for i in range(9):
            if(anums[i]>=3):
                anums[i]-=3
            while(anums[i]>0):
                if i>=7:break
                ok=True
                for j in range(i,i+3):
                    if anums[j]<=0:
                        ok=False
                if not ok:
                    break
                for j in range(i,i+3):
                    anums[j]-=1

        if not any(anums):
            return True

    return False


while True:
    st=''
    try:
        st=input()
    except:
       break
    nums=[0 for i in range(9)]
    for c in st:
        nums[int(c)-1]+=1

    anss=[]
    for n in range(0,9):
        nums[n]+=1
        if(check(nums[:])):anss.append(n+1)
        nums[n]-=1

    if(len(anss)==0):anss.append(0)
    print(' '.join(map(str,anss)))

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a + b == 15)
        cout << '+' << endl;
    else if (a * b == 15)
        cout << '*' << endl;
    else
        cout << 'x' << endl;
    return 0;
}

Measured memory_bytes: 3556
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>

int main()
{
    int n, k;
    int ans = 0;
    std::cin >> n >> k;
    std::vector<int> prices(n);
    for (auto&& p : prices) {
        std::cin >> p;
    }
    std::sort(prices.begin(), prices.end());
    for (int i = 0; i < k; i++) {
        ans += prices.at(i);
    }
    std::cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3176
def main():
    import sys
    input = sys.stdin.readline
    
    n = int(input())
    A = [int(x) for x in input().split()]
    ans = 0
    mod = 10 ** 9 + 7
    # 制約がai <= 2^60なので
    for d in range(61):
        # d桁目ごとに考える
        x = 0
        for a in A:
            if (a >> d) & 1:
                x += 1
        ans += x * (n-x) * 2**d
        ans %= mod
    print(ans)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 50848
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	long long K;
	cin >> K;

	if (K % 2 == 0 || K % 5 == 0)
	{
		cout << -1;
		return 0;
	}

	int result = 1;
	long long N = 7;
	for (int i = 0; i < 1000000; i++)
	{
		if (N % K == 0)
		{
			break;
		}

		N = (N * 10 + 7) % K;
		result++;
	}

	cout << result;

	return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>


long long extgcd(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    long long ret = extgcd(b, a%b, x, y);
    std::tie(x, y) = std::make_pair(y, x - a / b * y);
    return ret;
}


std::pair<long long, long long> crt(long long m1, long long r1, long long m2, long long r2) {
    long long x = 0, y = 0;
    long long d = extgcd(m1, m2, x, y);
    if (r1%d != r2%d) {
        return { -1, -1 };
    }
    long long mod = m1 / d * m2;
    long long rem = r1 + (r2 - r1) / d * m1 * x;
    rem = (rem % mod + mod) % mod;
    return { mod, rem };
}


int main() {
    int n; long long m; std::cin >> n >> m;
    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    long long mod = a[0], rem = a[0] / 2;
    for (int i = 1; i < n; i++) {
        std::tie(mod, rem) = crt(mod, rem, a[i], a[i] / 2);
        if (mod == -1) {
            std::cout << 0 << std::endl;
            return 0;
        }
    }
    std::cout << m / mod + (rem > 0 && m % mod >= rem) << std::endl;
    return 0;
}


Measured memory_bytes: 1152
/*  */
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <deque>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <cctype>
#include <cassert>
#include <functional>
#include <iterator>
#include <iomanip>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,1024000")

#define sti				set<int>
#define stpii			set<pair<int, int> >
#define mpii			map<int,int>
#define vi				vector<int>
#define pii				pair<int,int>
#define vpii			vector<pair<int,int> >
#define rep(i, a, n) 	for (int i=a;i<n;++i)
#define per(i, a, n) 	for (int i=n-1;i>=a;--i)
#define clr				clear
#define pb 				push_back
#define mp 				make_pair
#define fir				first
#define sec				second
#define all(x) 			(x).begin(),(x).end()
#define SZ(x) 			((int)(x).size())
#define lson			l, mid, rt<<1
#define rson			mid+1, r, rt<<1|1
#define getBits(x)		__builtin_popcount(x)
#define getBitIdx(x)	__builtin_ffs(x)

typedef long long LL;



int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// #ifndef ONLINE_JUDGE
		// freopen("data.in", "r", stdin);
		// freopen("data.out", "w", stdout);
	// #endif
	
	int n, t;
	int pre, cur;
	LL ans = 0;
	
	scanf("%d %d", &n, &t);
	rep(i, 0, n) {
		if (i == 0) {
			scanf("%d", &pre);
		} else {
			scanf("%d", &cur);
			if (pre+t <= cur)
				ans += t;
			else
				ans += cur - pre;
			pre = cur;
		}
	}
	if (n > 0) ans += t;
	cout << ans << endl;
	
	// #ifndef ONLINE_JUDGE
		// printf("time = %ldms.\n", clock());
	// #endif
	
	return 0;
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> A(n);
    for(auto &x:A){
        cin >> x;
        if(x==0){
            cout << 0 << endl;
            return 0;
        }
    }
    ll ret = A[0];
    for(i=1;i<n;i++){
        if(INF/ret<A[i]){
            cout << -1 << endl;
            return 0;
        }
        ret *= A[i];
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3984