akhauriyash/Code-Regression huggingface dataset:
n,d = [int(z) for z in input().split()]
p=[]
for g in range(n):
      p.append([int(z) for z in input().split()])
c=0

def dist(a,b):
      s=0
      for i in range(d):
            s+= (a[i]-b[i])**2
      return s**0.5

for j in range(n):
      for k in range(j+1,n):
            z = dist(p[j],p[k])
            #print(z)
            if (type(z)==float)or(type(z)==int):
                       if (z%1==0):
                             c+=1
print(c)


Measured memory_bytes: 9384
//verma_ankit484

#include<bits/stdc++.h>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const ll mod = (ll) 1e9+7;

using namespace std;

int main()
{
  IOS
  #ifdef AV
  freopen("int.txt", "r", stdin);
  #endif
  ll a, b;
  cin >> a >> b;
  vector<ll> pp;
  ll c = 0;
  for (ll i = a; i <= b; i++) {
    c++;
    pp.push_back(i%2019);
    if (c == 2020) break;
  }
  ll k = INT_MAX;
  for (ll i = 0; i < (ll)pp.size()-1; i++) {
    for (ll j = i+1; j < (ll)pp.size(); j++) {
      k = min(k, pp[i]*pp[j]%2019);
    }
  }
  cout << k << endl;
  return 0;
}


Measured memory_bytes: 256
import scala.io.{StdIn => in}
import scala.collection.{mutable => mu}

object Main extends App {
  import MapHelper._

  val Array(n, m) = in.readLine.split(" ").map(_.toInt)
  val a = in.readLine.split(" ").map(_.toLong)
  val map = mu.HashMap.empty[Long,Int]

  a.foreach { i =>
    map.addOrUpdate(i, 1)
  }

  Iterator.continually(in.readLine)
    .take(m)
    .map(_.split(" ").map(_.toInt))
    .foreach { e =>
      map.addOrUpdate(e(1),e(0))
    }
  
  var i = 0
  var cnt = 0
  var acc = 0L
  val keys = map.keys.toArray.sorted(Ordering[Long].reverse)
  val end = keys.size
  while(cnt <= n) {
    cnt += map(keys(i))
    // println(keys(i) + " " + map(keys(i)))
    if(cnt <= n) acc += keys(i) * map(keys(i))
    else if(cnt > n) acc += keys(i) *(map(keys(i)) - (cnt - n))
    i += 1
  }
  val ans = acc
  println(ans)

  object MapHelper {
    implicit class AddOrUpdate[A](map:mu.HashMap[Long,Int]) {
      def addOrUpdate(key:Long, value:Int):mu.HashMap[Long,Int] =
      {
        if(map.contains(key)) map(key) += value
        else map += (key -> value)
        map
      }
    }
  }
}

Measured memory_bytes: 98096
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k,s;
    cin >> k >> s;
    int count = 0;
    for(int i = 0;i <= k;i++) {
        for(int j = 0;j <= k;j++) {
            if(s - i - j < 0) {
                break;
            }
            if(s - i - j <= k) {
                count++;
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}


//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

//ABC158のE見る
int main() {
	ll M, D; cin >> M >> D;

	ll ans = 0;
	for (int m = 1; m <= M; m++) {
		for (int d = 1; d <= D; d++) {
			ll d1 = d % 10;
			ll d2 = d / 10;
			if (d1 >= 2 && d2 >= 2 && d1 * d2 == m) ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 8064
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 1005;
const int mod = 1000000007;



int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  cin>>s;
  cout<<s.substr(0, 3)<<endl;
  return 0;
}

Measured memory_bytes: 3592
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	static int n;
	static long INF = (long)1e18;
	static int[] v, w;
	static long[][] memo;
	
	public static long dp(int i, int r) {
		if(r < 0)
			return -INF;
		if(i == n || r == 0)
			return 0;
		if(memo[i][r] != -1)
			return memo[i][r];
		
		return memo[i][r] = Math.max(v[i] + dp(i + 1, r - w[i]), dp(i + 1, r));
		
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		n = sc.nextInt();
		int weight = sc.nextInt();
		
		v = new int[n];
		w = new int[n];
		for(int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		
		memo = new long[n][weight + 1];
		for(int i = 0; i < n; i++)
			Arrays.fill(memo[i], -1);
		
		System.out.println(dp(0, weight));
	}
}


Measured memory_bytes: 127444
#include <stdio.h>

int main(void)
{
	int n,y;
	
	scanf("%d %d",&n,&y);
	
	int i,j;
	
	
	
	for(i = 0;i < 2001;i++){
		for(j = 0;j < 2001;j++){
			int remain = y -(10000*i+5000*j);
			if(remain < 0){
				break;
			}
			
			if(remain%1000 == 0){
				int maisuu = remain/1000;
				
				if(maisuu == n-(i+j)){
					printf("%d %d %d\n",i,j,maisuu);
					goto end;
				}
			}
		}
	}
	
	
	printf("-1 -1 -1\n");
	
	end:
	
	return 0;
	
}
	
	
	
				
				
			

Measured memory_bytes: 128
#include <algorithm>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <numeric>

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	int l = s.size();
	long sum = 0;
	for (uint32_t i = 0; i < pow(2, l-1); i++) {
		int last_j = -1;
		for (int j = 0; j < l-1; j++) {
			if (((i>>j) & 1) == 1) {
				string sub = s.substr(l-1-j, j-last_j);
				last_j = j;
				sum += stol(sub);
			}
		}
		string sub = s.substr(0, l-1-last_j);
		sum += stol(sub);
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String args[]) {
 		Scanner scan = new Scanner(System.in);      	
      	int rows = scan.nextInt();
      	int cols = scan.nextInt();
        scan.nextLine();
      	boolean[][] grid = new boolean[rows][cols];
      	for(int r = 0; r < rows; r++){
          	char[] line = scan.nextLine().toCharArray();
        	for(int c = 0; c < cols; c++){
            	char cell = line[c];
              	grid[r][c] = cell == '.';
            }
        }
      	scan.close();
      	Solver solver = new Solver(grid);      	      	
      	System.out.println(solver.solve());
	}
  
  public static class Solver{
    private int mod = 1_000_000_007;
 	private boolean[][] grid;
    
    public Solver(boolean[][] grid){
    	this.grid = grid;
    }
    
    public int solve() 
    { 
      int rows = grid.length;
      int cols = grid[0].length;
      
      int[][] dp = new int[rows][cols];
	  fillFirstRow(dp, cols);     
      fillFirstCol(dp, rows);
      
      for(int r = 1; r < rows; r++){
      	for(int c = 1; c < cols; c++){
          if(!grid[r][c]) dp[r][c] = 0;
          else{
            dp[r][c] = (dp[r-1][c] + dp[r][c-1])%mod;
          }
        }
      }
      return dp[rows-1][cols-1];
    } 
    private void fillFirstRow(int[][] dp, int cols){
      int c = 0;
      for(; c < cols; c++){
        if(grid[0][c]){
          dp[0][c] = 1;
        }else break;
      }
      for(; c < cols; c++) dp[0][c] = 0;
    }
    private void fillFirstCol(int[][] dp, int rows){
      int r = 0;
      for(; r < rows; r++){
        if(grid[r][0]){
          dp[r][0] = 1;
        }else break;
      }
      for(; r < rows; r++) dp[r][0] = 0;
    }
  }
}

Measured memory_bytes: 45440
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


int main() {
char a[10],b[10],c[10];
cin >> a >> b >> c;
int a_num = strlen(a);
int b_num = strlen(b);
string ans ="NO";
if(a[a_num-1]==b[0]&&b[b_num-1]==c[0]) ans="YES";
cout << ans << endl;
return 0;
}


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

int gcd(int x, int y)
{
	while(x % y != 0){
		int r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int n, ans, a[100005];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	ans = a[0];
	for(int i = 1; i < n; i++)
		ans = gcd(ans,a[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
k = int(input())

if ((k % 2 == 0) or (k % 5 == 0)):
    print(-1)

else:
    if k % 7 == 0:
        d = (9 * k) // 7
    else:
        d = 9 * k
    
    res = 10

    for i in range(1, 100000000):
        if res % d == 1:
            print(i)
            exit()
        else:
            res = (res % d) * 10
    print(-1)


Measured memory_bytes: 9132
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);

		String[] tokens = in.readLine().split(" ");
		long A = Long.parseLong(tokens[0]);
		long B = Long.parseLong(tokens[1]);
		long C = Long.parseLong(tokens[2]);
		long D = Long.parseLong(tokens[3]);
		long result = 0;
		result += B / C;
		result += B / D;
		result -= B / (C * D / gcd(D, C));
		long result2 = (A - 1) / C;
		result2 += (A - 1) / D;
		result2 -= (A - 1) / (C * D / gcd(D, C));
		result -= result2;
		long result3 = B - A + 1 - result;
		System.out.println(result3);
		in.close();
	}

	static long gcd(long large, long small) {
		if (large == small) {
			return small;
		}else if(large % small == 0) {
			return small;
		} else {
			large = large % small;
			return gcd(small, large);
		}
	}
}


Measured memory_bytes: 22612
/*jai_ganeshdeva*/

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
#define INF (lld)1e18
#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 
#define pll pair <lld,lld>
#define modA(cccc,bbbb ,p) (((cccc+bbbb)%p+p)%p)
#define modS(cccc,bbbb ,p) (((cccc-bbbb)%p+p)%p)
#define modM(cccc,bbbb ,p) ((((cccc%p)*(bbbb%p))%p+p)%p)
/*
long long int modp(lld a,lld p,lld n)
{
    lld d[100];
    lld i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

lld fac[200001]; 

void getfac(lld p)
{
    fac[0] = 1; 
    for (lld i=1 ; i<=200000; i++) 
        fac[i] = fac[i-1]*i%p; 
}    

long long int nCrmodp(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
     
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}
*/
lld p1=1000000007,p2=998244353;
lld l,r,mid,ans=0;
lld n,i,j,k,m;
lld x,y,n1,b=0,a,n2,h,z,c;
lld p=1000000000;
double pi=3.1415926535;
 vector<vector<lld> > v(100001+1);
vector<lld> par(100001+1);
vector<bool> visited(100001,false);
queue<lld> q;
void bfs(lld x)
{
    q.pu(x);
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        if(visited[x]==true) continue;
        visited[x]=true;
         l=v[x].size();
        for(i=0;i<l;i++)
        {
            if(par[v[x][i]] ==0)
            {
                par[v[x][i]]=x;
                q.pu(v[x][i]);
            }
        }
    }
}

void solve()
{
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    } 
    par[1]=-1;
    i=1;
    bfs(i);
    for(i=2;i<=n;i++)
    {
        if(visited[i]==false)
        {
            //cout<<i<<" ";
            cout<<"No";
            return;
        }
    }
    cout<<"Yes\n";
    for(i=2;i<=n;i++)
    {
        cout<<par[i]<<"\n";
    }
}   


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    
    // cin>>t;
    //cout<<t;
    //getfac(p2);
    for(int i=0;i<t;i++)
    {
       //cout<<"Case #"<<i+1<<": ";
            solve();
    //    cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 12968
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,t;cin>>n>>t;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll MIN=INF;
  ll MAX=0;
  vl vec(n);
  vl diff(n);
  rep(i,n){
    MIN=min(MIN,a[i]);
    diff[i]=a[i]-MIN;
    vec[i]=MIN;
    //cout<<diff[i]<<endl;
  }
  ll MAXd=0;
  rep(i,n)MAXd=max(MAXd,diff[i]);
  set<ll>S;
  rep(i,n){
    if(MAXd==diff[i]){
      S.insert(vec[i]);
    }
  }
  cout<<S.size()<<endl;
}

Measured memory_bytes: 4992
/*明日を変えるなら今日変えなきゃ*/
#include<iostream> 
#include<stdio.h>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<functional>
#include<string.h>
#define debug(a)	cout << "*" << a << "*" << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef unsigned long long ull;
char s[100005];
ll n, mod = 1000000007;
int main()
{
	while (~scanf("%s", s))
	{
		ll a = 1, b = 0;
		for (int i = 0; i < strlen(s); i++)
		{
			if (s[i] == '1')
			{
				b = (b * 3 + a) % mod;
				a = a * 2 % mod;
			}
			else
				b = b * 3 % mod;
		}
		printf("%lld\n", (a + b) % mod);
	}
}

Measured memory_bytes: 384
object Main extends App {

  import scala.io.StdIn._
  solve
  def solve: Unit = {
    val n = readLine.trim.toInt
    val dayToMillennium = Date(1000, 1, 1).dayFromBegin
    for (_ ← 0 until n){
      val Array(y, m, d) = readLine.trim.split(' ').map(_.toInt)
      println(dayToMillennium - Date(y, m, d).dayFromBegin)
    }
  }
  object Date{
    private val sum3YearsDay = 590
    private val sumNormalYearsDay = 195
  }
  case class Date(year: Int, month: Int, day: Int) {
    def dayFromBegin: Int = {
      dayFromBeginToYearsDay + dayFromYearsDayToMonthBegin + dayFromMonthBegin
    }
    private def dayFromBeginToYearsDay: Int = {
      (year - 1) / 3 * Date.sum3YearsDay + (year - 1) % 3 * Date.sumNormalYearsDay
    }
    private def dayFromYearsDayToMonthBegin: Int = {
      if (year % 3 == 0) (month - 1) * 20
      else (month - 1) * 20 - (month - 1) / 2
    }
    private def dayFromMonthBegin: Int = {
      day
    }
  }
}



Measured memory_bytes: 44128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	ll h,a;
	cin >> h >> a;
	ll count =0;
	while (1) {
		if (h <=0) break;
		h = h - a;
		count++;
	}
	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
const int maxn = 1e5+100;
string s[maxn];
int a[5];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> s[i];
    for (int i = 0; i < n; ++i)
        if (s[i] == "AC")
            a[0]++;
        else if (s[i] == "WA")
            a[1]++;
        else if (s[i] == "TLE")
            a[2]++;
        else if (s[i] == "RE")
            a[3]++;
    cout << "AC x " << a[0] << endl;
    cout << "WA x " << a[1] << endl;
    cout << "TLE x " << a[2] << endl;
    cout << "RE x " << a[3] << endl;
    return 0;
}

Measured memory_bytes: 6720
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int w, a, b;
	cin >> w >> a >> b;

	if (a < b) {
		cout << max(b - a - w, 0) << endl;
	}
	else {
		cout << max(a - b - w, 0) << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstdlib>
#include<bitset>
#include<utility>
 
typedef long long ll;
#define INF 1000000000
#define MOD 1000000007
 
using namespace std;
 
ll dp[100][2];
 
int main() {
	int a,b;
	cin >> a >> b;
	cout << (b%a==0?a+b:b-a) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan =new Scanner(System.in);
		int N=scan.nextInt();
		int D=scan.nextInt();
		int X[]=new int[N];
		int Y[]=new int[N];
		int count =0;
		double distance[]=new double[N];
		double resultX[]=new double[N];
		double resultY[]=new double[N];
		double result[]=new double[N];
		for(int i=0;i<N;i++) {
				X[i]=scan.nextInt();
				Y[i]=scan.nextInt();
				resultX[i]=Math.pow(X[i],2);
				resultY[i]=Math.pow(Y[i],2);
				result[i]=resultX[i]+resultY[i];
		}
		
	
		for(int i=0;i<N;i++) {
			distance[i]=Math.sqrt(result[i]);
		}
		
		for(int i=0;i<N;i++) {
		if(D>=distance[i]) {
			count+=1;
		}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 67948
import java.util.Scanner;
 
class Main {
	int n;
	boolean[] dp;
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}
	Main(Scanner sc){
		n = sc.nextInt();
		dp = new boolean[n+1];
		dp[0] = true;
	}
	void solve(){
		for(int i=1;i<=n;i++){
			if(i-4>=0){
				dp[i] = dp[i-4]||dp[i];
			}
			if(i-7>=0){
				dp[i] = dp[i-7]||dp[i];
			}
		}
		if(dp[n]){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22732
function C173(_input) {
    var lines = _input.split("\n");
    var [height, width, num] = lines.shift().split(' ').map(v => v*1);
    var result = 0;

    for (let is = 0; is < 1<<height; is++) {
        for (let js = 0; js < 1<<width; js++) {
            let count = 0;
            for (let i = 0; i < height; i++) {
                for (let j = 0; j < width; j++) {
                    if (is>>i&1) continue;
                    if (js>>j&1) continue;
                    if (lines[i][j] === '#') {
                        count++;
                    }
                }
            }
            if (count !== num) continue;
            result++;
        }
    }

    console.log(result);
}
C173(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32316
from itertools import permutations
a =int(input())
b =int(input())
c =int(input())
d =int(input())
e =int(input())

def ceil(x):
  if x%10==0:
    return x
  else:
    return (x//10*10)+10
  
perm = list(permutations([a,b,c,d,e]))
ans = 1000
for i in perm:
  ans = min(ans,sum(map(ceil, i[:4]))+i[-1])
print(ans)

Measured memory_bytes: 3064
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

int N;
string s;

void solve()
{
    int ans = 0;
    REP(i, s.size()-2) {
        if (s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
            ans++;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> s;
    solve();
    return 0;
}

// vim:set foldmethod=marker:


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

answer=0
for i in range(1,N+1):
  p=N//i
  r=N%i
  a1=p*max(0,i-K)
  a2=max(0,r-K+1)
  answer+=a1+a2
  #print(i,a1,a2)
  
if K==0:
  answer-=N
print(answer)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main(){
	var a, b int
	for{
		fmt.Scan(&a, &b)
		if a == 0 && b == 0 {
			break
		}
		for i:=0; i<a; i++{
			for j:=0; j<b; j++{
				fmt.Print("#")
			}
			fmt.Print("\n")
		}
		fmt.Print("\n")
	}
}


Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
using namespace std;
typedef long long ll;

int main() {
    ll a, b, ans;
    cin >> a >> b;

    ans = (a*b)/__gcd(a, b);
    cout << ans << '\n';
    
    return 0;
}

Measured memory_bytes: 256
integer N,K,f(0:21,0:lshift(1,20)),g(0:21,0:lshift(1,20)),pos,t,i,j,jj,ans,len,tmp,fir
character(lshift(1,20)+1) str
read*,N,K
f=0
g=0
do i=0,N
  read*,str
  do j=0,lshift(1,i)
    f(i,j)=merge(1,0,str(j+1:j+1)=='1')
  end do
end do
do i=1,N
  do j=0,lshift(1,i)
    fir=and(rshift(j,(i-1)),1)
    pos=0
    do while (pos<i .and. AND(rshift(j,(i-pos-1)),1)==fir)
      pos=pos+1
    end do
    g(i,j)=merge(-1,pos,pos==i)
  end do
end do
ans=0
len=0
do i=0,N
  do j=1,n-i
    do jj=0,lshift(1,i+j)-1
      f(i, rshift(jj,j)) = f(i, rshift(jj,j))+f(i+j,jj)
      t=g(j,and(jj,(lshift(1,j)-1)))
      if (t/=-1)then
        tmp=f(i+j-t,OR(lshift(rshift(jj,j),j-t),AND(jj,lshift(1,j-t)-1)))
        f(i+j-t,OR(lshift(rshift(jj,j),(j-t)),AND(jj,lshift(1,j-t)-1)))=tmp+f(i+j,jj)
      endif
     end do
   end do
  do j=lshift(1,i)-1,0,-1
    if (f(i,j)>=K)then
      ans=j
      len=i
    endif
  end do
end do
do i=len,1,-1
  write(*,"(A)",advance='no') char(and(rshift(ans,i-1),1)+ichar('0'))
end do
write(*,*)
end program


Measured memory_bytes: 184572
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cmath>
#include<complex>
#include<utility>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define ALL(C)     (C).begin(),(C).end()
#define mp         make_pair
#define pb         push_back
#define fir first
#define sec second

const int N = 10010;

typedef pair<short,short> pii;

short  isexist[N]={0};
short testcase=0;
int x[N];
vector<pii> inx[N];

int req[N];

void makedata(int n,int *x1,int *x2,int *y1,int *y2,
	      int &px,int *xd,vector<pii> *IN){
  testcase++;
  rep(i,n){
    isexist[x1[i]]=testcase;
    isexist[x2[i]]=testcase;
  }
  rep(i,N)if (isexist[i]==testcase)x[px]=i,IN[px++].clear();

  rep(i,n){
    int j=lower_bound(xd,xd+px,x1[i])-xd;
    while(j < px && xd[j] < x2[i]){
      bool isin=false;
      rep(k,IN[j].size()){
	short Y1 = y1[i],Y2=y2[i];
	short &Y3=IN[j][k].fir;
	short &Y4=IN[j][k].sec;
	if (Y4 <= Y1 || Y2 <= Y3)continue;
	isin=true;
	Y3=min(Y1,Y3);
	Y4=max(Y2,Y4);
	break;
      }
      if (!isin)IN[j].pb(mp(y1[i],y2[i]));
      j++;
    }
  }
}

pair<int,int> solve(int n,vector<pii> *in,int *c){
  int area=0;
  int len=0;
  rep(i,n-1){
    sort(in[i].begin(),in[i].end());
    short l=-1,h=-1;
    short width;
    width=c[i+1]-c[i];
    rep(j,in[i].size()){
      short &nowl=in[i][j].fir,&nowh=in[i][j].sec;
      if (nowl >= h){
	if (nowl != h)len+=2*width;
	area+=(nowh-nowl)*width;
      }else if (nowh > h){
	area+=(nowh-h)*width;
      }
      l=nowl;
      h=max(h,nowh);
    }
  }
  return mp(area,len);
}

main(){
  int n,q;
  static int x1[N],y1[N],x2[N],y2[N];
  while(cin>>n>>q && n){
    rep(i,n){
      cin>>x1[i]>>y1[i]>>x2[i]>>y2[i];
    }
    int px=0,py=0;
    makedata(n,x1,x2,y1,y2,px,x,inx);
    pair<int,int> ansx=solve(px,inx,x);

    cout << ansx.first << endl;
    if (q == 2){
      px=0;
      makedata(n,y1,y2,x1,x2,px,x,inx);
      pair<int,int> ansy= solve(px,inx,x);      
      cout << ansx.second+ansy.second << endl;
    }
    rep(i,px)inx[i].clear();
  }
  return false;
}

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

using namespace std; 

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define fr(i,a,b) for(int i=a;i>=b;i--)
#define fp(i,a,b,p) for(int i=a;i<b;i+=p)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;
typedef  vector<long long> vl;


vector<int> dp(100005);	
vector<vector<int>> v(100005);

int dfs(int dx){

	int ans = 0;


	if(dp[dx]!=-1){

		return dp[dx];
	}

	for(auto u: v[dx]){

		ans = max(ans,1+dfs(u));
	}

	dp[dx] = ans;

	return ans;

}

int main(){

	
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif

	int n,m,x,y;

	cin >> n >> m;

	f(i,0,n){

		dp[i] = -1;
	}

	f(i,0,m){
		cin >> x >> y; 

		x--; 
		y--; 

		v[x].pb(y);
	}

	int ans = 0;

	f(i,0,n){

		int cnt = 0;

		if(dp[i]==-1){
			cnt = dfs(i);
		}else{
			cnt = dp[i];
		}

		ans = max(ans,cnt); 

	}

	cout << ans << endl;


}

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

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

  vector <int> road(n, 0);
  for (int i = 0; i < m; i++) {
    int a, b;

    cin >> a >> b;
    road.at(a - 1)++;
    road.at(b - 1)++;
  }

  // output
  for (int i = 0; i < n; i++)
    cout << road.at(i) << endl;
}


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

using namespace std;
typedef long long ll;
const int N=1e5+10;

int main()
{
    ll x;
    cin>>x;
    int ans=0;
    ll money=100;
    while(1){
        if(money>=x) break;
        money=money+(ll)(money*0.01);
        ans++;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
 
using namespace std;
#define LOCAL  1
#define UPLOAD 2
#define ll long long
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
 
  string S = input<string>(); 

  for(int i=0;i<S.length();i++){
    cout << "x";
  }
  cout << endl;
 
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    //Balance
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(), sum = 0;
        int[] W = new int[n];
        for (int i = 0; i < n; i++) {
            W[i] = sc.nextInt();
            sum += W[i];
        }
        int sum1 = 0, sum2 = sum, minDiff = Integer.MAX_VALUE;
        for (int w : W) {
            sum1 += w;
            sum2 -= w;
            minDiff = Math.min(minDiff, Math.abs(sum1 - sum2));
        }
        sc.close();
        System.out.println(minDiff);
    }
}


Measured memory_bytes: 23764
use std::error::Error;
use std::io;

pub fn main() {
    if let Err(_e) = run() {
        panic!("failed.");
    }
}

fn run() -> Result<(), Box<dyn Error>> {
    let mut input = String::new();
    io::stdin().read_line(&mut input)?;
    let n: i64 = input.trim().parse()?;
    input.clear();

    let mut result = (-(n * -25 - 26) as f64).log(26f64);
    let t_result = (result - 1f64) as i64;
    if (1 + t_result) as f64 == result {
        result = (t_result - 1) as f64;
    } else {
        result = t_result as f64;
    }
    let result = result as i64;
    let mut result_str = String::new();
    let mut remain = n - (26 - 26i64.pow(1 + result as u32)) / -25;
    remain -= 1;
    for i in 0..=result {
        let m = remain % 26;
        result_str.insert(0, char::from(m as u8 + 97));
        remain /= 26;
    }
    println!("{}", result_str);

    Ok(())
}


Measured memory_bytes: 2760
#include <stdio.h>

void answer(int a,int b,int c);

int main(void){
    int a,b,c;
    
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
	answer(a,b,c);
    
    return 0;
}

void answer(int a, int b,int c){

	if(1>a || 10000<a || 1>b || 10000<b || 1>c || 10000<c){
	printf("1<=a,b,c<=10,000の数字を入力して下さい\n");
	exit(1);	
	}

	if(a<=b && b<=c){
	printf("%d %d %d\n",a,b,c);
    }else if(a<=c && c<=b){
	printf("%d %d %d\n",a,c,b);
    }else if(b<=a && a<=c){
	printf("%d %d %d\n",b,a,c);
	}else if(b<=c && c<=a){
	printf("%d %d %d\n",b,c,a);
	}else if(c<=a && a<=b){
    printf("%d %d %d\n",c,a,b);
    }else if(c<=b && b<=a){
	printf("%d %d %d\n",c,b,a);
    }else{
    printf("等しい数字が存在します\n");
	}		
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  vector<int> a;
  load(a, n);

  double sum = 0.0;
  for (int i = 0; i < n; ++i) {
    sum += 1.0 / a[i];
  }
  printf("%.6lf", 1.0 / sum);
}

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

typedef long long ll;

ll mod = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,k;
	cin >> n >> k;
	ll ans = 0;
	for (ll i = k; i <= n+1; i++)
	{
		ll l = (0 + i - 1) * i / 2;
		ll r = ((n - i + 1) + n) * i / 2;
		ans += r - l + 1;
		ans %= mod;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3200
//created by missever

#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;

typedef pair<int,int> P;
const int maxn = 200005;
int p1[maxn],p2[maxn],t[maxn];
map<P,int> q;

int ff(int f[],int x)
{
    if(f[x] != x) f[x] = ff(f,f[x]);
    return f[x];
}

int main(){
    int n,k,l,i,u,v,a,b;
    scanf("%d%d%d",&n,&k,&l);
    for(i = 0;i <= n; i++) p1[i] = p2[i] = i;
    for(i = 0;i < k; i++)
    {
        scanf("%d%d",&u,&v);
        a = ff(p1,u);
        b = ff(p1,v);
        if(a != b) p1[a] = b;
    }
    for(i = 0;i < l; i++)
    {
        scanf("%d%d",&u,&v);
        a = ff(p2,u);
        b = ff(p2,v);
        if(a != b) p2[a] = b;
    }
    for(i = 1;i <= n; i++) q[P(ff(p1,i),ff(p2,i))]++;
    for(i = 1;i <= n; i++) printf("%d%c",q[P(ff(p1,i),ff(p2,i))]," \n"[i == n]);
    return 0;
}


Measured memory_bytes: 13568
#include<bits/stdc++.h>                //dinic求网络最大流算法模板，时间复杂度为O(m*n*n) 
#define maxn 300
#define INF 999999999
#define pb push_back
using namespace std;
struct lines{
    int to,flow,cap;
}l[maxn*maxn*5];
vector<int> g[maxn];
int cur[maxn],d[maxn],t=-1,S,T;
bool v[maxn];
char s[maxn][maxn];
inline void add(int from,int to,int cap){
    l[++t]=(lines){to,0,cap},g[from].pb(t);
    l[++t]=(lines){from,0,0},g[to].pb(t);
}
 
inline bool BFS(){
    memset(v,0,sizeof(v)),v[S]=1,d[S]=0;
    queue<int> q; q.push(S);
    int x; lines e;
     
    while(!q.empty()){
        x=q.front(),q.pop();
        for(int i=g[x].size()-1;i>=0;i--){
            e=l[g[x][i]];
            if(e.flow<e.cap&&!v[e.to]) v[e.to]=1,d[e.to]=d[x]+1,q.push(e.to);
        }
    }
     
    return v[T];
}
 
int dfs(int x,int A){
    if(x==T||!A) return A;
    int flow=0,f,sz=g[x].size();
    for(int &i=cur[x];i<sz;i++){
        lines &e=l[g[x][i]];
        if(d[x]+1==d[e.to]&&(f=dfs(e.to,min(e.cap-e.flow,A)))){
            A-=f,flow+=f;
            e.flow+=f,l[g[x][i]^1].flow-=f;
            if(!A) break;
        }
    }
     
    return flow;
}
 
inline int max_flow(){
    int an=0;
    while(BFS()){
        memset(cur,0,sizeof(cur));
        an+=dfs(S,INF);
    }
    return an;
}
int n,m;
char ch;
int main()
{
	int m;
	int a,sum=0;
	scanf("%d%d",&n,&m);
	S=0,T=n+m+1;
	for(int i=1;i<=n;i++)
	{
	    scanf("%s",s[i]+1);	
	    for(int j=1;j<=m;j++)
	    {
	    	if(s[i][j]=='S')
	    	{
	    		add(0,i,INF);
	    		add(i,0,0);
	    		add(0,n+j,INF);
	    		add(n+j,0,0);
			}
			else if(s[i][j]=='T')
			{
				add(i,n+m+1,INF);
				add(n+m+1,i,0);
				add(n+j,n+m+1,INF);
				add(n+m+1,n+j,0);
			}
			else if(s[i][j]=='o')
			{
				add(i,n+j,1);
				add(n+j,i,1);
			}
	    }
	} 
	int ans=max_flow();
	if(ans>=999999999)
	{
		printf("-1");
	}
	else printf("%d",ans);
	return 0;
}

Measured memory_bytes: 944
N,M = [int(a) for a in input().split()]


#iから進める場所をリストにして保管
edges = {i:[] for i in range(1,N+1)}
for i in range(M):
  a,b = [int(a) for a in input().split()]
  edges[a].append(b)
  edges[b].append(a)


#深さ優先探索
def search(lst):
    #lst(通過点)の数がN(頂点数)と等しくなったら探索終了（成功）
  if len(lst) == N:
    return 1
  else:
    a = lst[-1]
    #lstの最後尾（現在地）が次に進める場所をnextとしてリスト化
    #nextに以前通った場所が入っていないか確認
    next = [n for n in edges[a] if n not in lst]
    #次に進める場所がなくなったら探索終了（失敗）
    if len(next) == 0:
      return 0

    tot = 0
    #再帰でさらに探索
    for n in next:
      tot += search(lst + [n])

    return tot


ans = search([1])

print(ans)


Measured memory_bytes: 9212
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>

using namespace std;

#define ll long long
#define rep(i, n) for (i = 0; i < n; i++)

vector<vector<int>> A(3, vector<int>(3));
int N;
vector<int> b;
vector<vector<bool>> match(3, vector<bool>(3, false));

int main()
{
  for (int i = 0; i < 3; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      cin >> A[i][j];
    }
  }
  cin >> N;
  b.resize(N);
  for (int i = 0; i < N; i++)
  {
    cin >> b[i];
  }

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < 3; j++)
    {
      for (int k = 0; k < 3; k++)
      {
        if (b[i] == A[j][k])
        {
          match[j][k] = true;
        }
      }
    }
  }

  bool bingo = false;
  for (int i = 0; i < 3; i++)
  {
    bool ok = true;
    for (int j = 0; j < 3; j++)
    {
      if (!match[i][j])
        ok = false;
    }
    if (ok)
      bingo = true;
  }

  for (int i = 0; i < 3; i++)
  {
    bool ok = true;
    for (int j = 0; j < 3; j++)
    {
      if (!match[j][i])
        ok = false;
    }
    if (ok)
      bingo = true;
  }

  if (match[0][0] && match[1][1] && match[2][2])
  {
    bingo = true;
  }

  if (match[2][0] && match[1][1] && match[0][2])
  {
    bingo = true;
  }

  if (bingo)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

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

    ll n,x;
    cin>>n;
    x=n%10;
    if(x==3)
    {
        cout<<"bon"<<endl;
    }
   else if(x==2||x==4||x==5||x==7||x==9)
        cout<<"hon"<<endl;
   else if(x==0||x==1||x==6||x==8)
        cout<<"pon"<<endl;

    return 0;
}



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

int main() {
  int N, M;
  while(1){
  cin >> N >> M;
  if(N == 0 && M == 0) break;
  for(int i = 0; i < N; i++){
      for(int a = 0; a < M; a++){
           cout << "#";
      }
        cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3016
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

int main(int argc, char* argv[]) {
  std::string S;
  std::cin >> S;
  std::cout << (S <= "2019/04/30" ? "Heisei" : "TBD") << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,k,t[100000],sa[100000],i;
	long long sum;
	scanf("%d %d",&n,&k);
	for(i=0;i<n;i++){
		scanf("%d",&t[i]);
	}
	for(i=1;i<n;i++){
		sa[i]=t[i]-t[i-1];
	}
	sort(sa+1,sa+n);
	sum=1;
	for(i=1;i<n;i++){
		if(i>n-k){
			sum++;
		}
		else{
			sum+=sa[i];
		}
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 3520
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())

    for i in range(1,n+1):
        if i*i>n:
            break
        if n%i==0:
            m=i
            l=n//i

    print(m-1+l-1)
    
if __name__=="__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  string s; 
  cin >> s;

  if(s == "AAA" || s == "BBB") No;
  else Yes;

  return 0;
}

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

int s[100010], t[100010], e[100010];

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

	int n, m;
	cin >> n >> m;

	int i0 = 0;
	while(1){
		cin >> s[i0] >> t[i0] >> e[i0];
		if(s[i0] == 0 && t[i0] == 0 && e[i0] == 0) break;
		++i0;
	}

	int l;
	cin >> l;

	for(int i = 0; i < l; ++i){
		int b[100010];
		for(int j = 0; j < m; ++j){
			cin >> b[j];
		}
		int score[100010] = {};
		for(int j = 0; j < i0; ++j){
			score[s[j] - 1] += e[j] * b[t[j] - 1];
		}
		for(int j = 0; j < n; ++j){
			if(j != 0) cout << " ";
			cout << score[j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 2244
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

signed main()
{
	IO_OP;
	
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++) {
		if(s[i] == '?') {
			s[i] = 'D';
		}
	}
	cout << s << endl;

}





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

int main(){
    long long int h,ans = 0;
    cin >> h;
    if(h == 1) cout << 1 << endl; 
    else{
        long long int t = log2(h);
        
        for(long long int i=1 ; i <= t ;i++){
            ans += pow(2,i);
        }
        ans += 1;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;

int main(){
    int h,n;
    cin >> h >> n;
    int a[n];
    int sum=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }

    if(sum>=h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;
using ll = long long int;

// to format a document: ctrl + K -> ctrl + D

int main() {
    int r, D, x;
    cin >> r >> D >> x;

    for (int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
  Scanner sc;

  class Dance {
    boolean u;
    boolean r;
    boolean d;
    boolean l;

    Dance() {
      u = r = d = l = true;
    }

    void wall() {
      u = r = d = l = false;
    }

    boolean adj(int n) {
      switch ( n ) {
      case 0:
        return u;
      case 1:
        return r;
      case 2:
        return d;
      case 3:
        return l;
      }
      return false;
    }

    int[][] ofs = new int[][] { { 0, -1 }, { 1, 0 }, { 0, 1 }, { -1, 0 } };

    int[] trans(int n) {
      return ofs[ n ];
    }
  }

  void run() {
    for ( ;; ) {
      int w = ni();
      int h = ni();

      if ( ( w | h ) == 0 ) {
        break;
      }

      Dance[][] adj = new Dance[h + 2][w + 2];
      for ( int i = 0; i <= h + 1; ++i ) {
        for ( int j = 0; j <= w + 1; ++j ) {
          adj[ i ][ j ] = new Dance();
        }
      }
      for ( int i = 0; i <= h + 1; ++i ) {
        adj[ i ][ 0 ].r = adj[ i ][ 1 ].l = false;
        adj[ i ][ w ].r = adj[ i ][ w + 1 ].l = false;
      }
      for ( int i = 0; i <= w + 1; ++i ) {
        adj[ 0 ][ i ].d = adj[ 1 ][ i ].u = false;
        adj[ h ][ i ].d = adj[ h + 1 ][ i ].u = false;
      }
      adj[ 0 ][ 1 ].wall();
      adj[ 0 ][ 1 ].d = true;

      for ( int i = 1; i <= 2 * h - 1; ++i ) {
        int idx = ( i + 1 ) >> 1;
        if ( ( i & 1 ) != 0 ) {
          for ( int j = 1; j <= w - 1; ++j ) {
            adj[ idx ][ j ].r = adj[ idx ][ j + 1 ].l = ni() == 0;
          }
        } else {
          for ( int j = 1; j <= w; ++j ) {
            adj[ idx ][ j ].d = adj[ idx + 1 ][ j ].u = ni() == 0;
          }
        }
      }

      int sx = 1;
      int sy = 0;
      int ex = w;
      int ey = h;
      Queue<Integer> qx = new LinkedList<Integer>();
      Queue<Integer> qy = new LinkedList<Integer>();
      boolean[][] done = new boolean[h + 2][w + 2];
      int[][] cost = new int[h + 2][w + 2];
      qx.add( sx );
      qy.add( sy );
      done[ sy ][ sx ] = true;
      cost[ sy ][ sx ] = 0;
      while (qx.size() > 0) {
        int x = qx.poll();
        int y = qy.poll();
//        debug( x, y );
//        debug( adj[ y ][ x ].u, adj[ y ][ x ].r, adj[ y ][ x ].d,
//            adj[ y ][ x ].l );

        for ( int i = 0; i < 4; ++i ) {
          if ( adj[ y ][ x ].adj( i ) ) {
            int[] d = adj[ y ][ x ].trans( i );
            int dx = x + d[ 0 ];
            int dy = y + d[ 1 ];
//            debug( "\t", dx, dy, x, y, i );
            if ( done[ dy ][ dx ] ) {
              continue;
            }
            cost[ dy ][ dx ] = cost[ y ][ x ] + 1;
            done[ dy ][ dx ] = true;
            qx.add( dx );
            qy.add( dy );
          }
        }
      }

      System.out.println( cost[ ey ][ ex ] );
    }
  }

  Main() {
    sc = new Scanner( System.in );
  }

  int ni() {
    return sc.nextInt();
  }

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

  void debug(Object... os) {
    System.err.println( Arrays.deepToString( os ) );
  }
}

Measured memory_bytes: 90080