akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int main() {
    using namespace std;
    constexpr unsigned long MOD = 1000000007;
    string s;
    cin >> s;
    vector<unsigned long> tap(13), pre(13);
    pre[0] = 1;
    for(const auto& c : s){
        fill(tap.begin(), tap.end(), 0);
        if(c == '?')for(unsigned long i = 0; i < 13; ++i)for(unsigned long j = 0; j < 10; ++j)(tap[(i * 10 + j) % 13] += pre[i]) %= MOD;
        else for(unsigned long i = 0; i < 13; ++i)(tap[(i * 10 + c + 4) % 13] += pre[i]) %= MOD;
        swap(tap, pre);
    }
    cout << pre[5] << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ll N;
    cin>>N;
    vector<tuple<ll,ll,ll>> a(N-1);
    rep(i,N-1){
        cin>>get<0>(a[i])>>get<1>(a[i]);
        get<2>(a[i])=i;
    }
    sort(a.begin(),a.end());
    vector<ll> count(N,0);
    ll color=0;
    rep(i,N-1){
        count[get<0>(a[i])-1]++;
        count[get<1>(a[i])-1]++;
    }
    rep(i,N) if (color<count[i]) color=count[i];
    vector<ll> ed_color(N-1,0);
    vector<ll> node(N,-1);

    ll counter=0;
    rep(i,N-1){
        if (i==0){
            ed_color[get<2>(a[i])]=counter;
            node[get<1>(a[i])-1]=counter;
        }else{
            counter++;
            counter%=color;
            if (counter==node[get<0>(a[i])-1]) counter++;
            counter%=color;
            ed_color[get<2>(a[i])]=counter;
            node[get<1>(a[i])-1]=counter;
        }
    }
    cout<<color<<endl;
    rep(i,N-1) cout<<ed_color[i]+1<<endl;
}

Measured memory_bytes: 5120
#include <stdio.h>

int main()
{
    int a, b;
    scanf("%d %d",&a, &b);
    if(a + b > 16)
        printf(":(\n");
    else
        if(a > b+1 || b > a+1)
            printf(":(\n");
        else
            printf("Yay!\n");
        

    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String s;

			int input = Integer.parseInt(br.readLine());
			List<String> rightAngleList = new ArrayList<String>();

			for (int i = 1; i <= input; i++) {
				s = br.readLine();
				String[] num = s.split(" ");

				Integer[] side = convertArray(num);

					Arrays.sort(side);

					if (side[2] * side[2] == side[1] * side[1] + side[0]
							* side[0]) {

						rightAngleList.add("YES");

					} else {
						rightAngleList.add("NO");
					}

			}

			String[] rightAngles = rightAngleList.toArray(new String[0]);

			for(String rightAngle : rightAngles){
				System.out.println(rightAngle);
			}


		} finally {
			br.close();
		}

	}

	public static Integer[] convertArray(String[] str) {

		List<Integer> list = new ArrayList<Integer>();

		for (String num : str) {

			list.add(Integer.parseInt(num));

		}

		return list.toArray(new Integer[0]);

	}

}

Measured memory_bytes: 22340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;
int a[N];

int main() {
    int n;
    cin >> n;
    for(int i = 0; i < n; i++)	cin >> a[i];
    ll res = 0;
    for(int i = 1; i < n; i++) {
    	if(a[i] < a[i - 1]) {
    		res += a[i - 1] - a[i];
    		a[i] = a[i - 1];
		}
	}
	cout << res << endl;
	return 0;
}

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

int main ()
{
	 int k;
	 cin>>k;
	 int sum =0;
	 for(int i=1;i<=k;i++)
	 {
	 	 for(int j=1;j<=k;j++)
	 	 {
	 	 	int g = __gcd(i,j);
	 	 	
	 	 	 for(int l=1;l<=k;l++)
	 	 	 {
	 	 	 	    sum += __gcd(g,l);
			   }
		  }
	 }
	 cout<<sum<<endl;
	
	
	
}

Measured memory_bytes: 3568
#include<iostream>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int main()
{
    int n;
    cin >> n;
    int s[n];
    F(i,0,n) cin >> s[i];

    int q;
    cin >> q;
    int t[q];
    F(i,0,q) cin >> t[i];

    int cnt=0;
    F(i,0,q){
        F(j,0,n){
            if(s[j]==t[i]){
                ++cnt;
                break;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}


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

int main(){
	int K, A, B;
	cin >> K >> A >> B;

	int x = B/K;
	x *= K;
	bool flg = (A <= x);

	cout << (flg?"OK":"NG") << endl;

	return 0;	
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main()
{
  int dp [100010];
  int N;
  cin >> N;

  for(int i=0;i<100010;i++)
    dp[i] = 100010;
  dp[0] = 0;

  for(int i=0;i<N+1;i++ )
    {
      dp[i+1] = min(dp[i]+1, dp[i+1]);

      int j=6;
      while(i+j<N+1)
	{
	  dp[i+j] = min(dp[i]+1, dp[i+j]);
	  j *= 6;
	}
      j = 9;
      while(i+j<N+1)
	{
	  dp[i+j] = min(dp[i]+1, dp[i+j]);
	  j *= 9;
	}
    }

  cout << dp[N] << endl;
}
  


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long INF = 1LL << 60;
const int iINF = 1 << 20;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    string s;
    cin >> s;

    cout << ((s == "ARC") ? "ABC" : "ARC") << endl; 
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	ll x,y,a,b,c,i,sum=0;
	cin>>x>>y>>a>>b>>c;
	ll p[a],q[b],r[c],arr[a+b+c];
	for(i=0;i<a;i++)
	{
	    cin>>p[i];
	}
	for(i=0;i<b;i++)
	{
	    cin>>q[i];
	}
	for(i=0;i<c;i++)
	{
	    cin>>r[i];
	}
	sort(p,p+a);
	reverse(p,p+a);
	sort(q,q+b);
	reverse(q,q+b);
	sort(r,r+c);
	reverse(r,r+c);
	for(i=0;i<x;i++)
	{
	    arr[i]=p[i];
	}
	for(i=x;i<x+y;i++)
	{
	    arr[i]=q[i-x];
	}
	for(i=x+y;i<x+y+c;i++)
	{
	    arr[i]=r[i-x-y];
	}
	sort(arr,arr+x+y+c);
	reverse(arr,arr+x+y+c);
	for(i=0;i<x+y;i++)
	{
	    sum=sum+arr[i];
	}
	cout<<sum;
	
	return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<cstring>
#include<cstdlib>

const int MAX=10010;

void countingSort(std::vector<int> &A,std::vector<int> &sorted){
    int count[MAX];
    int n=A.size();
    memset(count,0,sizeof(count));
    for(int i=0;i<n;i++)
        count[A[i]]++;
    for(int i=0;i<MAX;i++)
        count[i+1]+=count[i];
    for(int i=n-1;i>=0;i--)
        sorted[--count[A[i]]]=A[i];
}

int main(void){
    int n;
    std::cin>>n;
    std::vector<int> A(n);
    for(int i=0;i<n;i++)
        std::cin>>A[i];
    std::vector<int> sorted(n);
    countingSort(A,sorted);
    for(int i=0;i<n;i++)
        std::cout<<(i?" ":"")<<sorted[i];
    std::cout<<std::endl;

    return 0;
}


Measured memory_bytes: 18232
#include <iostream>
#include <string>
#include <deque>
#include <algorithm>

using namespace std;

void printVector(deque<int> data) {
    auto iter = data.begin();
    cout << *iter++;
    for (; iter != data.end(); iter++) {
        cout << " " << *iter;
    }
    cout << endl;
}

int main(void) {
    int n;
    cin >> n;

    char command[20];
    int value;
    deque<int> data;

    for(int i = 0; i < n; i++) {
        scanf("%s%d", command, &value);
        if (command[0] == 'i') {
            data.push_front(value);
        }
        else if (command[0] == 'd' && command[6] == '\0') {
            deque<int>::iterator iter = find(data.begin(), data.end(), value);
            if (iter != data.end()) {
                data.erase(iter);
            }
        }
        else if (command[0] == 'd' && command[6] == 'F') {
            data.pop_front();
        }
        else if (command[0] == 'd' && command[6] == 'L') {
            data.pop_back();
        }
    }
    printVector(data);


    return 0;
}



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

using namespace std;

int n, m;
bool a1[501][501], a2[501][501];
string s;

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

    cin >> n >> m;
    for (int i = 1; i <= n; ++i) {
        cin >> s;
        for (int j = 0; j < m; ++j) {
            if (s[j] == '#') {
                a1[i][j] = 1;
                a2[i][j] = 1;
            }
        }
        if (i == 1 || i == n)
            continue;
        a1[i][0] = 1;
        a2[i][m - 1] = 1;
        for (int j = 1; j < m - 1; ++j) {
            if (i & 1)
                a1[i][j] = 1;
            else
                a2[i][j] = 1;
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < m; ++j)
            cout << (a1[i][j] ? '#' : '.');
        cout << '\n';
    }
    cout << '\n';
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < m; ++j)
            cout << (a2[i][j] ? '#' : '.');
        cout << '\n';
    }
    return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <complex>
#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define REP(i,a) FOR(i,0,a)
#define real() X
#define imag() Y
#include <iostream>
using namespace std;
typedef long long ll;
ll DP[2][20001];
ll INF=ll(1)<<60;
int main() {
	int N,M,p,s;
	vector<ll> manju;
	cin >> N >> M;
	REP(i,N){
		cin >>p;
		manju.push_back(p);
	}
	sort(manju.begin(),manju.end(),greater<ll>());
	FOR(i,1,20001)
		DP[0][i]=INF;
	REP(i,M){
		cin >> s >> p;
		if(!i)
			DP[0][s]=p;
		else{
			REP(j,s)
				DP[i%2][j]=DP[(i+1)%2][j];
			FOR(j,s,20001)
				DP[i%2][j]=min(DP[(i+1)%2][j],DP[(i+1)%2][j-s]+p);
		}
		FOR(j,1,20001)
			DP[(i+1)%2][j]=INF;
	
	}
	ll sum=0,maxim=0;
	REP(i,20001){
		maxim=max(maxim,sum-DP[(M-1)%2][i]);
		if(i<manju.size())
		sum+=manju[i];
	}
	cout << maxim << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1652
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
int main() {
  ll X;
  cin >> X;
  int ans = 0;
  ll s = 100;
  for(int i = 0;i < 4000; i++){
    s = s + s/100;
    ans++;
    if (s >= X){
      break;
    }
  }
     cout << ans << endl;
 
  
}
    
    

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	string S; 
	cin >> S; 
	if(S.at(5) == '0' && (S.at(6) == '1' || S.at(6) == '2' || S.at(6) == '3' || S.at(6) == '4')){
		cout << "Heisei" << endl; 
	}
	else cout << "TBD" << endl; 
}

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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

template<typename T>
T gcd(T x, T y)
{
	return y ? gcd(y, x % y) : x;
}

void hawawa()
{
	int n;
	cin >> n;
	switch (n)
	{
	case 1:
		cout << "Hello World\n";
		break;
	case 2:
		int a, b;
		cin >> a >> b;
		cout << a + b << "\n";
		break;
	}
}

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


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

int main()
{
    vector<int> H(3);

    for (int i = 0; i < 3;i++){
        cin >> H.at(i);
    }

    sort(H.begin(), H.end());

    cout << (H.at(0) + H.at(1)) << endl;
}

Measured memory_bytes: 256
object Main extends App {
    var n = io.StdIn.readInt
    var ss = Range(0, n).map(t=>io.StdIn.readLine.split("").sorted.mkString(""))
    val words = collection.mutable.Map[String, Int]()
    var ans:Long = 0
    ss.foreach{s=>
        ans += words.getOrElse(s, 0)
        words += s -> (words.getOrElse(s, 0)+1) // map
    }
    //println(words.values.map{x=>toLong*(x.toLong-1L)/2}.sum)
    println(ans)
}

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

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

  long long cnt = 0;

  if(K == 0) {
    cnt = (long long)N * (long long)N;
    cout << cnt << endl;
    return 0;
  }

  for(int b = 1; b <= N; b++){
    p = N/b;
    r = N%b;

    cnt += p*max(b-K,0) + max(r+1-K,0);
  }

  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    for (int i = 0; i < 10; ++i) {
      x = (r * x) - d;
      System.out.println(x);
    }
  }
}

Measured memory_bytes: 21972
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>

using namespace std;

int main() {
	int n, a, len;
	int d[100000];
	fill_n(d, 100000, INT_MAX / 2);
	cin >> n >> a;
	d[0] = a;
	len = 1;
	for (int i = 1; i < n; i++) {
		cin >> a;
		if (d[len-1] < a)
			d[len++] = a;
		else {
			int j = len;
			for ( ; j >= 0; j--)
				if (d[j] < a)
					break;
			d[j+1] = a;
		}
	}
	cout << len << endl;
	return 0;
}

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

typedef long long ll;
const ll INF = 1LL << 60;

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

int N;
ll h[100010];
ll dp[100010];

ll rec(int i){
    if(dp[i] < INF) return dp[i];
    if(i == 0) return 0;
    
    ll res = INF;
    chmin(res,rec(i-1) + abs(h[i] - h[i-1]));
    if(i > 1) chmin(res,rec(i-2) + abs(h[i] - h[i-2]));
    
    return dp[i] = res;
}


int main(void){
    cin >> N;
    
    for(int i = 0 ; i < N ; i++){
        cin >> h[i];
    }
    for(int i = 0 ; i < N ; i++){
        dp[i] = INF;
    }
    
    cout << rec(N-1) << endl;
}


Measured memory_bytes: 9788
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  lint h;
  cin >> h;
  lint x = 1;
  while (x <= h) x *= 2;
  cout << x - 1 << endl;
  return 0;
}

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

int main() {
  int N;
  int counter=0;
  cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) {
	  cin >> A.at(i) >> B.at(i);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  reverse(B.begin(),B.end());
  counter=counter+B.at(N-1)+A.at(N-1);
  cout<<counter<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cmath>

using namespace std;

#define all(c) ((c).begin()),((c).end())
#define debug(c) cerr<<"> "<<#c<<" = "<<(c)<<endl;
#define iter(c) __typeof((c).begin())
#define tr(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back

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

int go(int x, int y, char m[21][21], int w, int h) {
	int dx[] = {1, -1, 0, 0};
	int dy[] = {0, 0, 1, -1};
	m[y][x] = '#';
	int res = 1;
	rep (i, 4) {
		int tx = x + dx[i];
		int ty = y + dy[i];
		if(tx < 0 || tx >= w || ty < 0 || ty >= h) continue;
		if(m[ty][tx] == '.') res += go(tx, ty, m, w, h);
	}
	return res;
}

int main(){
	for (int w, h; cin >> w >> h, (w | h) != 0; ) {
		char m[21][21];
		int sx, sy;
		rep (i, h) rep (j, w) {
			cin >> m[i][j];
			if (m[i][j] == '@') sx = j, sy = i;
		}
		cout << go(sx, sy, m, w, h) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>

#define INF 100000000

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[m] = {0};
    for (int i = 0; i < n; i++)
    {
        int k, tmp;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            cin >> tmp;
            a[tmp - 1]++;
        }
    }
    int ans = 0;
    for (int i = 0; i < m; i++)
    {
        if (a[i] == n)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    int a, b ; cin >> a >> b;
    string res;
    if(a == b) res = "Draw";
    else if(a == 1) res = "Alice";
    else if(b == 1) res = "Bob";
    else if(a > b) res = "Alice";
    else res = "Bob";
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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 ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class FLaminate {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, k; cin >> n >> k;
      // as-is
      //vector<vector<ll>> dp1(n+1, vector<ll>(k+1, LLONG_MAX/2));
      // set-before
      //vector<vector<ll>> dp2(n+1, vector<ll>(k+1, LLONG_MAX/2));

      // map (pos, k, cost)
      map<P, ll> dp1, dp2;

      vector<ll> h(n);
      rep(i, n) {
        cin >> h[i];
      }

      dp1[P(0, 0)] = 0;

      rep(i, n) {
        // no move
        for(auto& e: dp1) {
          P p = {e.first.first, h[i]};
          if (dp2.find(p) == dp2.end()) {
            dp2[p] = e.second + max(0LL, h[i] - e.first.second);
          }
          chmin(dp2[p], e.second + max(0LL, h[i] - e.first.second));
        }

        // moves
        for(auto& e: dp1) {
          if (e.first.first >= k) continue;
          P p = {e.first.first+1, e.first.second};
          if (dp2.find(p) == dp2.end()) {
            dp2[p] = e.second;
          }
          chmin(dp2[p], e.second);
        }
        swap(dp1, dp2);
        dp2.clear();
      }

      ll ans = LLONG_MAX;
      for(auto& e: dp1) {
        chmin(ans, e.second);
      }
      cout << ans << endl;
    }
};

signed main() {
  FLaminate solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
int main(){
	ll n,a,b,ans=0;cin>>n>>a>>b;
	vector<ll> x(n);
	rep(i,n)cin>>x[i];
	rep(i,n-1)ans+=min(a*(x[i+1]-x[i]),b);
	cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll n, k;
  cin >> n >> k;

  cout << (n % k == 0 ? 0 : 1) << "\n";
}

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

int main ()
{
  vector<int> num(3);
  
  for (int i = 0; i < 3; i++)
    cin >> num.at(i);
  
  sort (num.begin() , num.end());
  
  if (num.at(0) & num.at(1) == 5 && num.at(2) == 7)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}

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

const double PI = 3.14159265358979323846;

double square(double d) {
  return d * d;
}

int main() {

  int A, B, H, M;
  
  cin >> A >> B >> H >> M;
  
  double hAngle = (H + M / 60.0) * PI / 6.0;
  double mAngle = M * PI / 30.0;
  
  cout << setprecision(32) << sqrt(square(A * cos(hAngle) - B * cos(mAngle)) 
               + square(A * sin(hAngle) - B * sin(mAngle))
              ) << endl;
  
}

Measured memory_bytes: 4160
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define pye cout << "Yes" << endl;
#define pno cout << "No" << endl;
#define prin(num) cout << num << endl;
#define sprin(str) cout << "str" << endl;
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 100001
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;


int main() {
    ll N, n;
    cin >> N;
    ll i;
    ll d[MAX];
    for(i=0; i<=N; i++)
        d[i]=N;
    d[0]=0;
    ll psix, pnin;
    for(n=1; n<=N; n++) {
        for(psix=1; psix<=n; psix*=6)
            d[n]=min(d[n], d[n-psix]+1);
        
        for(pnin=1; pnin<=n; pnin*=9)
            d[n]=min(d[n], d[n-pnin]+1);
    }
    
    prin(d[N]);
}


Measured memory_bytes: 1024
ret = 0

n = int(input())

def dfs(i, f):
    if i > n:
        return
    if f == 7:
        global ret
        ret += 1
    dfs(i*10+3, f|1)

    dfs(i*10+5, f|2)
    dfs(i*10+7, f|4)

dfs(0, 0)
print(ret)

Measured memory_bytes: 3060
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{

    int n;
    cin >> n;
    vector<pair<int64_t, int64_t>> vs(n);
    for (auto& v : vs)
    {
        cin >> v.first >> v.second;
    }
    sort(vs.begin(), vs.end());

    cout << (vs.back().first + vs.back().second) << endl;

}


Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	int n, a=0, b=0; cin>>n; int x[n];
	for(int i=0; i<n; i++){
		cin>>x[i];
		if(x[i]%2!=0) a++;
		else if(x[i]%4==0) b++;
	}
	if(a<=b || n%2!=0 && a<=(n+1)/2 && b>=a-1) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


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

int main() {
	int W, H, x, y, r;
	
	cin >> W >> H >> x >> y >> r;

	if (x - r >= 0 && x - r <= W - 2*r) {
		if (y - r >= 0 && y - r <= H - 2 * r) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int ans = 1;
    while(1){
        if(ans * 2 <= N){
            ans *= 2;
        }
        else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
 
int main () {
long long n;
cin >>n;
long long ansA =0;
long long ansB =0;

for (int i= 1;i <= n;i++){
 ansB +=i;
  if(i%3 ==0 ||i%5 == 0)ansA +=i;
}

cout<<ansB -ansA<<endl;
return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n;
  vi v;
  map<int,int>data;
  cin>>n;
  rep(i,n){
    int a;
    cin>>a;v.pb(a);
  }
  sort(all(v));reverse(all(v));
  ll ans=0;
  rep(i,v.size()){
    if(!data[v[i]]){
      ans++;
      data[v[i]]++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    string s,t;cin>>s>>t;
    int ans = 0;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3836
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <random>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<int> v[200020];

int main(){
  int n;
  cin >> n;
  if(n%2){
    cout << (n-1)*(n-1)/2 << endl;
    rep(i,n){
      rep(j,n){
        if(i<j){
          if(i+j+2!=n){
            cout << i+1 << ' ' << j+1 << endl;
            v[i].push_back(j);
            v[j].push_back(i);
          }
        }
      }
    }
  }else{
    cout << (n-2)*n/2 << endl;
    rep(i,n){
      rep(j,n){
        if(i<j){
          if(i+j+2!=n+1)cout << i+1 << ' ' << j+1 << endl;
        }
      }
    }
  }
return 0;}

Measured memory_bytes: 4992
h,w=map(int,input().split())
dx=[-1,1,0,0]
dy=[0,0,-1,1]
a=[]
for i in range(h):
    a.append(list(input()))
for i in range(h):
    for j in range(w):
        if a[i][j]=="#":
            frag=False
            if j-1>=0 and a[i][j-1]=="#":
                frag=True
            if j+1<=w-1 and a[i][j+1]=="#":
                frag=True
            if i-1>=0 and a[i-1][j]=="#":
                frag=True
            if i+1<=h-1 and a[i+1][j]=="#":
                frag=True
            if frag==False:
                print("No")
                exit()
print("Yes")

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

int a[3][3];
int d[3][3];

int main() {
	rep(i,3)rep(j,3) cin >> a[i][j];
	int n;
	cin >> n;
	rep(ni,n) {
		int x;
		cin >> x;
		rep(i,3)rep(j,3) if(a[i][j] == x) d[i][j] = 1;
	}
	bool ans = false;
	rep(i,3) {
		int cnt = 0;
		rep(j,3) cnt += d[i][j];
		if(cnt == 3) ans = true;
	}
	rep(i,3) {
		int cnt = 0;
		rep(j,3) cnt += d[j][i];
		if(cnt == 3) ans = true;
	}
	{
		int cnt = 0;
		rep(j,3) cnt += d[j][j];
		if(cnt == 3) ans = true;
	}
	{
		int cnt = 0;
		rep(j,3) cnt += d[j][2-j];
		if(cnt == 3) ans = true;
	}
	puts(ans?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    int N;
    int A,B;
    string w_now;
    string w;
    vector<string> words;
    bool flag = true;

    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> w; 
        if(i == 0){
            w_now = w;
        }else{
            if(w.front() == w_now.back()){
                w_now = w;
            }else{
                flag = false;
            }
        }
        auto itr = find(words.begin(), words.end(), w_now);    //  最初の要素5へのイテレータを返す
        if( itr != words.end() ) {     // 発見した場合
            flag = false;
        }
        words.push_back(w_now);
    }

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

Measured memory_bytes: 256
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    let b = Array.init n (fun _ -> Scanf.scanf " %d" (fun b -> b)) in
    let c = Array.init n (fun i -> a.(i) - b.(i)) in
    Array.sort compare c;
    let s = Array.fold_left (+) 0 c in

    Printf.printf "%d\n" @@
        if s < 0 then -1 else (
            let rec phase2 i j sum =
                if sum >= 0 then i + (n - 1 - j) else
                    phase2 i (j - 1) (sum + c.(j))
            in
            let rec phase1 i sum =
                if c.(i) < 0 then phase1 (i + 1) (sum + c.(i))
                             else phase2 i (n - 1) sum
            in
            phase1 0 0
        )
)

Measured memory_bytes: 6144
import datetime
while 1:
  y1,m1,d1,y2,m2,d2=map(int,raw_input().split(" "))
  if y1==m1==d1==y2==m2==d2==-1: break
  a=datetime.date(y1,m1,d1)
  b=datetime.date(y2,m2,d2)
  print (b-a).days

Measured memory_bytes: 4408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  vector<int> dp(n,INF);
  dp[0]=0;
  for(int i=1; i<n; i++){
    for(int j=max(i-k,0); j<i; j++){
      chmin(dp[i],dp[j]+abs(a[i]-a[j]));
    }
  }
  cout << dp[n-1] << endl;
}


Measured memory_bytes: 1024
H, W = map(int, input().split())

if H == 1 or W == 1:
    print(1)
else:
    if H % 2 == 0:
        e_h = H // 2
        o_h = H // 2
    else:
        e_h = H // 2 + 1
        o_h = H // 2
    if W % 2 == 0:
        print(e_h * (W // 2) + o_h * (W // 2))
    else:
        print(e_h * (W // 2 + 1) + o_h * (W // 2))


Measured memory_bytes: 2940
lst1 = [1,3,5,7,8,10,12]
lst2 = [4,6,9,11]
lst3 = [2]

x, y = [int(n) for n in input().split()]

if x in lst1 and y in lst1:
    print("Yes")

elif x in lst2 and y in lst2:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 2940
#define INF 1000000
#define rep(i,n) for((i)=0;(i)<=(int)(n);(i)++)
void warshall_floyd(void);
int min(int,int);

int graph[10][10],n;

int main(void){
  int a,b,c,i,j,sum[10],ans1,ans2;

  while(scanf("%d",&n),n){

    rep(i,9)sum[i]=0;
    ans1=INF;

    rep(i,9){
      rep(j,9){
	graph[i][j]=INF;
      }
      graph[i][i]=0;
    }
    
    rep(i,n-1){
      scanf("%d %d %d",&a,&b,&c);
      graph[a][b]=graph[b][a]=c;
    }
    warshall_floyd();

    rep(i,9)
      rep(j,9)
	if(graph[i][j]<INF)sum[i]+=graph[i][j];

    rep(i,9){
      if(ans1>sum[i] && sum[i]>0){
	ans1=sum[i];
	ans2=i;
      }
    }
    printf("%d %d\n",ans2,ans1);
  }
  return 0;
}

void warshall_floyd(void){
  int i,j,k;

  rep(k,9)
    rep(i,9)
      rep(j,9)
	graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
}

int min(int x,int y){
  return x<y?x:y;
}

Measured memory_bytes: 0
package main

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

func solve(a, b, c int) int {
	if a == 1 && b >= c && b < 10 {
		return 1
	}
	if a == 1 {
		return 0
	}
	ret := 0
	for i := c; i < 10 && i < b; i++ {
		ret += solve(a-1, b-i, i+1)
	}
	return ret
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for {
		scanner.Scan()
		a, _ := strconv.Atoi(scanner.Text())
		if a == 0 {
			break
		}
		scanner.Scan()
		b, _ := strconv.Atoi(scanner.Text())
		fmt.Println(solve(a, b, 0))
	}
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll S[15][15];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans = 0;
    memset(S, 0, sizeof(S));
    REP(i, N) {
        ll a = i + 1;
        ll s = a % 10;
        ll p = a % 10;
        while (a > 0) {
            p = a % 10;
            a /= 10;
        }
        S[p][s]++;
    }
    REP(i, N) {
        ll a = i + 1;
        ll s = a % 10;
        ll p = a % 10;
        while (a > 0) {
            p = a % 10;
            a /= 10;
        }
        ans += S[s][p];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <stdio.h>
int main(){
 
  char string[100]={};
  int size=0,t=0;
 
  scanf("%s",string);
  while(string[size]!='\0'){
    size++;
  }
 
  for(int i=0;i<(size-1)/2;i++){
 
  if((string[i]!=string[size-i-1])||(string[i]!=string[((size-3)/2)-i])||(string[((size+1)/2)+i]!=string[size-i-1])){
    t=1;
    break;
  }
 
  }
 
 
  switch(t){
  case 1:
   printf("No");
   break;
 
  default :
   puts("Yes");
  }
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> C(N - 1), S(N - 1), F(N - 1);
  for (int i = 0; i < N - 1; i++) cin >> C.at(i) >> S.at(i) >> F.at(i);

  for (int i = 0; i < N; i++) {
    int time = 0;
    for (int j = i; j < N - 1; j++) {
      int tmp = S.at(j);
      while (tmp < time) tmp += F.at(j);
      time = max(time, tmp);
      time += C.at(j);
    }
    cout << time << "\n";
  }
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns               #-}
{-# LANGUAGE DerivingStrategies         #-}
{-# LANGUAGE FlexibleContexts           #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE RankNTypes                 #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# LANGUAGE TypeApplications           #-}
{-# LANGUAGE UndecidableInstances       #-}
import qualified Data.Vector.Unboxing as VU

main :: IO ()
main = do
  s <- readLn @Int

  print $ sum $ zipWith (\m i -> nCkMod (m+i-1) m) [s-3,s-6..0] [1..]

  return ()

modulus :: Int
-- modulus = 10^9 + 7
modulus = 1000000007

newtype IntMod = IntMod Int deriving Eq deriving newtype VU.Unboxable

fromIntegralIntIntMod :: Int -> IntMod
fromIntegralIntIntMod n = IntMod (n `mod` modulus)
{-# RULES
"fromIntegral/Int->IntMod"
    fromIntegral = fromIntegralIntIntMod
#-}

instance Show IntMod where
  show (IntMod x) = show x

instance Num IntMod where
  IntMod x + IntMod y = IntMod ((x + y) `mod` modulus)
  IntMod x - IntMod y = IntMod ((x - y) `mod` modulus)
  IntMod x * IntMod y = IntMod ((x * y) `mod` modulus)
  fromInteger n = IntMod (fromInteger (n `mod` fromIntegral modulus))
  abs = undefined
  signum = undefined

powMod :: IntMod -> Int -> IntMod
powMod !x 1 = x
powMod !x !k
  | even k = powMod (x * x) (k `div` 2)
  | otherwise = x * powMod (x * x) (k `div` 2)

invMod :: IntMod -> IntMod
invMod 0  = error "inverse of 0"
invMod !x = powMod x (modulus - 2)

nPkMod :: Int -> Int -> IntMod
nPkMod !n' !k' = go 1 n' k'
  where go :: IntMod -> Int -> Int -> IntMod
        go !a !_ 0  = a
        go !a !n !k = go (a * fromIntegral n) (n - 1) (k - 1)

nCkMod :: Int -> Int -> IntMod
nCkMod !n !k = nPkMod n k * invMod (nPkMod k k)


Measured memory_bytes: 4236
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif
            var line1 = Console.ReadLine();
            var line2 = Console.ReadLine();
            var line3 = Console.ReadLine();
            var solver = new Solver(line1, line2, line3);
            var answer = solver.Solve();
            Console.WriteLine(answer);
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public Solver(string line1, string line2, string line3)
        {
            var item = line1.Split().Select(elem => long.Parse(elem)).ToArray();
            this.N = (int)item[0];
            this.M = (int)item[1];
            this.K = item[2];
            this.A = line2.Split().Select(elem => long.Parse(elem)).ToList();
            this.B = line3.Split().Select(elem => long.Parse(elem)).ToList();
        }

        public int N { get; set; }
        public int M { get; set; }
        public long K { get; set; }
        public List<long> A { get; set; }
        public List<long> B { get; set; }

        public string Solve()
        {
            var ret = 0L;

            var a = new List<long> { 0 };
            for (int i = 0; i < this.N; i++)
            {
                a.Add(a[i] + this.A[i]);
            }

            var b = new List<long> { 0 };
            for (int i = 0; i < this.M; i++)
            {
                b.Add(b[i] + this.B[i]);
            }

            var j = this.M;
            for (int i = 0; i <= this.N; i++)
            {
                if (a[i] > this.K)
                {
                    break;
                }

                ret = Math.Max(ret, i + this.UpperBound(b, this.K - a[i]) - 1);
                // while (b[j] > this.K - a[i])
                // {
                //     j -= 1;
                // }

                // ret = Math.Max(ret, i + j);
            }

            return ret.ToString();
        }

        private int UpperBound(List<long> b, long val)
        {
            var left = 0;
            var right = b.Count() - 1;
            while (left <= right)
            {
                var mid = (left + right) / 2;
                if (b[mid] <= val)
                {
                    left = mid + 1;
                }
                else
                {
                    right = mid - 1;
                }
            }

            return left;
        }
    }
}


Measured memory_bytes: 77456
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>n>>m;
    c=0;
    while (n--)
    {
        cin>>x>>y;
        if(x*x+y*y<=m*m)c++;
    }
    
    
    
    
    cout<<c  <<endl;
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int x;
    cin >> x;
    int sum = 0;
    int n = x;
    
    while (x > 0) {
        sum += x % 10;
        x /= 10;
    }

    if (n % sum == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int n; cin >> n;
    ll d; cin >> d;
    ll a; cin >> a;

    vector<pair<ll, ll>> xh(n);
    rep(i, n){
        ll x, h;
        cin >> x >> h;

        //h = (h+a-1)/a;
        xh.at(i) = make_pair(x, h);
    }

    sort(xh.begin(), xh.end());

    queue<pair<ll, ll>> q;
    ll ans = 0;
    ll tot = 0;
    d = d*2;
    rep(i, n){
        ll x = xh.at(i).first;
        ll h = xh.at(i).second;

        while(q.size()&&q.front().first < x){
            tot -= q.front().second;
            q.pop();
        }
        h -= tot;
        if(h>0){
            ll num = (h+a-1)/a;
            ans += num;
            ll dm = num*a;
            tot += dm;
            q.emplace(x+d, dm);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    p = list(map(int, input().split()))
    q = [0]
    for i in p:
        q.append((i*(i+1)//2)/i)
    r = list(accumulate(q))
    res = 0
    for i in range(k, n+1):
        res = max(res, r[i]-r[i-k])
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 79968
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 200005;
const int mod = 998244353;
int v[10005];
ll dp[10005][1005];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    map<int,int>mp;
    f(n) {
        int x;
        cin >> x;
        mp[x]++;
    }
    if (mp.size() == 1 && mp.begin()->F == 0) {
        cout << "Yes\n";
        exit(0);
    }
    if (n % 3 != 0) {
        cout << "No\n";
        exit(0);
    }
    vector<int>v;
    for (auto &i : mp) {
        while(i.S >= n /3) {
            i.S -= n /3;
            v.pb(i.F);
        }
    }
    if (v.size() == 3 && (v[0] ^ v[1]) == v[2]) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
}

Measured memory_bytes: 3840
#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int aa, bb, cc;
    aa = max(max(a, b), c);
    cc = min(min(a, b), c);
    bb = a + b + c - aa - cc;
    cout << 10 * aa + bb + cc;
    return 0;
}


Measured memory_bytes: 256
// type a
//a...いけそう
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma endregion

int n;
vector<int> d;

int main() {
	cin >> n;
	d.resize(n);
	int a = 0;
	int b = mod;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		a = max(a, d[i]);
		b = min(b, d[i]);
	}
	cout << a - b << endl;

	return 0;
}

Measured memory_bytes: 3624
n = int(input())
p = list(map(int,input().split()))
 
cnt = 0
 
for i in range(1,n-1):
  if (p[i-1] < p[i] and p[i] < p[i+1]) or (p[i-1] > p[i] and p[i] > p[i+1]):
     cnt += 1
  
print(cnt)

Measured memory_bytes: 3060
class Solution:
    def solve(self, a: int, b: int) -> str:

        if a < b:
            return str(a) * b
        else:
            return str(b) * a


if __name__ == '__main__':

    # standard input
    a, b = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(a, b))


Measured memory_bytes: 2940