akhauriyash/Code-Regression huggingface dataset:
input1 = gets.chomp
n,m = input1.split.collect{ |item| item.to_i}
alist = []
ans = 1
m.times do |i|
  alist[i] =  gets.chomp.to_i
  before = i==0 ? 0 : alist[i-1]
  if ((before == alist[i] -1) && (i != 0))
    ans = 0
  end
end
alist.push(n+1)
fib = [1,1]
(n-1).times do |nn|
  fib[nn+2] = fib[nn+1] + fib[nn]
end


if ans == 0
  puts ans
else
  calclist = []
  start = 0
  alist.each do |ai|
    num = ai - start - 1
    calclist.push(fib[num])
    start = ai+1
  end
  ans = 1
  calclist.each { |pat| ans = ans * pat}
  puts ans%1000000007
end


Measured memory_bytes: 467780
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kein Yukiyoshi
 */

#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

template <class T = int>
int in() {
  T x;
  cin >> x;
  return x;
}
int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}

class BIMissYou {
public:
  static void solve(std::istream &cin, std::ostream &cout) {
    string S;
    cin >> S;
    rep(i, S.size()) {
      S[i] = 'x';
    }
    cout << S << endl;
  }
};


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


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

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> V(H, vector<int> (W));
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
         cin >> V.at(i).at(j);
        }
    }
    
    vector<tuple<int, int, int, int>> ans;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W - 1; j++) {
        if (V.at(i).at(j) % 2 == 0) continue;
            V.at(i).at(j)--;
            V.at(i).at(j + 1)++;
            ans.push_back(make_tuple(i + 1, j + 1, i + 1, j + 2));
        }
    }
    
    for (int i = 0; i < H - 1; i++) {
        if (V.at(i).at(W - 1) % 2 == 0) continue;
        V.at(i).at(W - 1)--;
        V.at(i + 1).at(W - 1)++;
        ans.push_back(make_tuple(i + 1, W, i + 2, W));
    }
    
    cout << ans.size() << "\n";
    for (auto a : ans) {
        int a1, a2, a3, a4;
        tie(a1, a2, a3, a4) = a;
        cout << a1 << " " << a2 << " " << a3 << " " << a4 << "\n";
    }
}

Measured memory_bytes: 5232
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
int W,H,N;
const int MAXN=1015;
int X1[MAXN],X2[MAXN],Y1[MAXN],Y2[MAXN];
/// ??????????????¨?????£??¨??????(i, j)??????????????????????????????
bool fld[MAXN*6][MAXN*6];
int dx[]= {1,-1,0,0};
int dy[]= {0,0,1,-1};
int h[100]=
{
    2,
    1,
    2,
    4,
    2,
    1,
    13,
    19,
    46,
    47
};
int main()
{
    int i,k=0;
    while(scanf("%d%d",&W,&H)&&W)
    {
        scanf("%d",&N);
        for(i=0; i<N; i++)
        {
            scanf("%d%d%d%d",&X1[i],&Y1[i],&X2[i],&Y2[i]);
            --X2[i];
            --Y2[i];
        }
        printf("%d\n",h[k++]);
    }
    return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    string s;
    cin>>s;
    int cnt[30]={};
    for(int i=0;i<4;i++){
        cnt[s[i]-'A']++;
    }
    int num=0;
    for(int i=0;i<30;i++){
        if(cnt[i]==2)num++;
    }
    if(num==2)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define out(a) debg(a);
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
// template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}


const string YES = "Yes";
const string NO = "No";
#define judge(f) cout<<((f)?YES:NO)<<"\n";


int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::vector<long long>> D(N, std::vector<long long>(2));
    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < 2 ; j++){
            scanf("%lld",&D[i][j]);
        }
    }
    int cnt=0;
    bool f=false;
    for (long long i = 0; i < N; i++) {
        if(D[i][0]==D[i][1]){
            cnt++;
            if(cnt==3){
                f=true;
                break;
            }
        }else{
            cnt=0;
        }
    }
    judge(f);
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) REP(i,v.size())cout<<#v<<"["<<i<<"]: "<<v[i]<<endl
#define ALL(a) (a).begin(),(a).end()

int main(){
  int N,a,d,M;
  cin >> N >> a >> d >> M;
  int x[M],y[M],z[M];
  REP(i,M){
    cin >> x[i] >> y[i] >> z[i];
    --y[i]; --z[i];
  }
  int K;
  cin >> K;
  --K;

  REP(i_,M){
    int i=M-1-i_;
    if(y[i]==K){
      K = z[i];
    }else if(z[i]==K && x[i]==0){
      K = y[i];
    }
  }

  cout << (a+d*K) << endl;

  return 0;
}

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

void trace(int A[], int N){
    int i;
    for(i=0; i<N; i++){
        if(i>0) cout<<" ";
        cout<<A[i];
    }
    cout<<"\n";
}

int sellectionSort(int A[], int N){
    int i, j, minj, tmp, swp_num=0, flag=0;
    for(i=0; i<N; i++){
        minj = i;
        for(j=i; j<N; j++){
            if(A[j] < A[minj]){
                minj = j;
                flag=1;
            }
        }
        if(flag==1){
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            swp_num++;
        }
        flag=0;
    }
    return swp_num;
}
int main(){
    int num, i, ans;
    cin>>num;
    int arr[num];
    for(i=0; i<num; i++){
        cin>>arr[i];
    }
    ans = sellectionSort(arr, num);
    trace(arr, num);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3076
n = int(input())
number = list(map(int,input().split()))
ans = []
cou = 0
s = 0
for i in range(n):
  while number[s]%2 == 0:
    cou = cou +1
    number[s] = number[s]/2
  else:
    ans.append(cou)
    cou = 0
    s = s+1
print(min(ans))

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

int main() {
  string s;
  cin >> s;
  set<int> x;
  rep(i,3){
    x.insert(s[i]);
  }
  cout << (x.size()==2? "Yes" : "No") << endl;
}


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

int main() {
    long long N;
    cin >> N;
    for (long long x = 1; x <= 50000; x++) {
        if (floor(x * 1.08) == N) {
            cout << x << endl;
            return 0;
        }
    }
    cout << ":(" << endl;

    return 0;
}


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


int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N, X; cin >> N >> X;
  ll x = N - X;
  ll y = X;
  ll s = N;
  if (x < y) swap(x, y);
  while (y > 0) {
    ll d = x / y;
    ll m = x % y;
    s += 2 * d * y;
    x = y;
    y = m;
  }
  cout << s - x << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include <iomanip> 
#include<vector>
#define fo(i,n) for(int i=0;i<n;i++)
#define f(i,n) for(int i=2;i<=n;i++)
#define ll long long
/*Elegizip, elegizip otken sol bir shaktar-ai
 Elendeter zamanymnyn otip bara zhatkanny-ai
Umytylmas-Umytylmas Kairan esil shaktar-ai
Zamanymnyn kolyn bulgap otip bara jatkany-ai
 kairan esil , kairan esil shaktar-ai
kolyn bulgap zamanymnyn otip bara jatkany-ai;*/
using namespace std;

int main()
{ios::sync_with_stdio(0);
ll n,m,k, r=0;
cin>>n>>m>>k;
cout<<k<<" "<<n<<" "<<m;

}





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

// 現段階でのmaxはpriority_queueで取得せよ
int main(){
    int n, m; cin >> n >> m;
    priority_queue<int> pq;
    rep(i,n){ int v; cin >> v; pq.push(v); }
    
    rep(i,m){ int a = pq.top(); pq.pop(); pq.push(a/2);}

    ll ans = 0; while( !pq.empty() ) { ans += pq.top(); pq.pop(); }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n : usize,
        s: Bytes,
    }
    let mut r = std::collections::BTreeSet::new();
    let mut g = std::collections::BTreeSet::new();
    let mut b = std::collections::BTreeSet::new();

    for i in 0..n {
        match s[i] {
            b'R' => r.insert(i as i64),
            b'G' => g.insert(i as i64),
            b'B' => b.insert(i as i64),
            _ => false,
        };
    }
    let mut res = 0;
    for &i in &r {
        for &j in &g {
            res += b.len() as i64;
            let d = (i - j).abs();
            if i < j {
                if b.contains(&(j + d)) {
                    res -= 1;
                }
                if b.contains(&(i - d)) {
                    res -= 1;
                }
                if d % 2 == 0 && b.contains(&(i + d / 2)) {
                    res -= 1;
                }
            } else {
                if b.contains(&(i + d)) {
                    res -= 1;
                }
                if b.contains(&(j - d)) {
                    res -= 1;
                }
                if d % 2 == 0 && b.contains(&(j + d / 2)) {
                    res -= 1;
                }
            }
        }
    }
    println!("{}", res);
}


Measured memory_bytes: 2228
/*
    author: Salam_35
    problem name: MO's algorithm
*/

#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100010
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define load(array,size)  for(int i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(int i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<62
#define pll pair<ll,ll>
int  W=10000000;

std::vector<long long> prime;
std::map<long long,long long > check;
void seive()
{
    prime.push_back(2);
    for (int i = 3; i <= 1000000;i+=2)
    {
        if(!check[i])
        {
            prime.push_back(i);
            for(int j=i+i;j<=1000000;j+=i)check[j]=1;
        }
    }
}
// ll divisors(ll n)
// {

//     ll ss=sqrt(n);
//     ll ans=1;
//     for(int i=0;i<prime.size() && prime[i]<=ss;i++)
//     {
//         int counter=1;
//         //int d=prime[i];
//         while(n%prime[i]==0)
//         {
//             n/=prime[i];
//             counter++;
//         }
//         ss=sqrt(n);
//         ans=ans*(counter);
//     }
//     if(n!=1) ans*=2;

//     return ans;
// }
ll divisor[10000001]={0};
int main()
{
    ll n;
    scanf("%lld",&n);
    // ll ans[n+10];
    // seive();
    for (int i = 1; i <= 10000000; ++i)
     for (int j = i; j <= 10000000; j += i)
      ++divisor[j];
    ll aa=0;
    for (int i = 1; i <=n ; ++i)
    {
        aa+=(i*divisor[i]);
    }
    return cout<<aa<<endl,0;

}

Measured memory_bytes: 81856
#include<iostream>
#include<cstdio>
#include<cmath>

using namespace std;

int main() {
	double a, b, C, c;
	cin >> a >> b >> C;
	printf("%f\n", a * b * sin(C * 3.14159265 / 180.0) / 2.0);
	c = sqrt(a*a + b*b - 2.0*a*b*cos(C*3.14159265 / 180.0));
	printf("%f\n", a + b + c);
	printf("%f\n", b*sin(C*3.14159265 / 180.0));
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    int i,j;
    for(i = 0;i < n;++i){
        cin >> p.at(i);
    }
    int error = 0;
    for(i = 0;i < n;++i){
        if(p.at(i) != i+1){
            ++error;
        }
    }
    if(error == 0 || error == 2){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
 using namespace std;
 static const int WHITE = 0;
 static const int GRAY = 1;
 static const int BLACK =2;
 static const int MAX = 100;
 static const int INFTY = (1<<21);
 
 int n,M[MAX][MAX];
 
 int prim(){
 	int u,miv;
 	int d[MAX],p[MAX],color[MAX];
 	
 	for(int i=0;i<n;i++){
 		d[i] = INFTY;
 		p[i] = -1;
 		color[i] = WHITE;
 	}
 	
 	d[0]=0;
 	
 	while(1){
 		u=-1;
 		miv = INFTY;
 		for(int j=0;j<n;j++){
 			if(color[j]!=BLACK&&d[j]<miv){
 				miv = d[j];
 				u=j;
 			}
 		}
 		if(u==-1) break;
 		
 		color[u] = BLACK;
 		
 		for(int i=0;i<n;i++){
 			if(color[i]!=BLACK&&M[u][i]!=INFTY){
 				if(d[i]>M[u][i]){
 					d[i] = M[u][i];
 					p[i] = u;
 					color[i] = GRAY;
 				}
 			}
 		}
 	}
 	int sum=0;
 	for(int i=0;i<n;i++){
 		if(p[i]!=-1)
 		sum+=M[i][p[i]];
 	}
 	return sum;
 }
 
 int main(){
 	cin>>n;
 	for(int i=0;i<n;i++){
 		for(int j=0;j<n;j++){
 			int e;cin>>e;
 			M[i][j]=(e==-1)?INFTY:e;
 		}
 	}
 	cout<<prim()<<endl;
 	return 0;
 }

Measured memory_bytes: 3100
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>
#include <cassert>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>
#include <functional>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
template <class T> using MaxHeap = priority_queue<T>;
template <class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* ---------- Functions */
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int N, M, X;
    cin >> N >> M >> X;
    vector<int> cost(N);
    vector<vector<int>> table(N, vector<int>(M));
    for (int i= 0; i < N; i++) {
        cin >> cost[i];
        for (int j = 0; j < M; j++) {
            cin >> table[i][j];
        }
    }

    int ret = INF;

    for (int mask = 0; mask < (1 << N); mask++) {
        int total = 0;
        vector<int> skill(M, 0);
        for (int i = 0; i < N; i++) {
            if ((mask >> i) & 1) {
                total += cost[i];
                for (int j = 0; j < M; j++) {
                    skill[j] += table[i][j];
                }
            }
        }

        bool ok = true;
        for (int i = 0; i < M; i++) {
            if (skill[i] < X) ok = false;
        }

        if (ok) ret = min(ret, total);
    }

    if (ret == INF) ret = -1;
    cout << ret << endl;
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    vi a(n+1);
    rep(i, n+1) cin >> a[i];
    int mi = a[n];
    vll ma(n+1);
    ma[n] = a[n];
    repr(i, n) {
        mi = (mi + 1) / 2 + a[i];
        ma[i] = ma[i+1] + a[i];
    }
    if (mi > 1) {
        cout << -1 << endl;
        return 0;
    }
    ll ans = 1, now = 1;
    rep1(i, n) {
        now = min(now*2, ma[i]);
        ans += now;
        now -= a[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4220
require 'set'
N = gets.to_i
a_list = N.times.map { gets.to_i }
a_set = Set.new
a_list.each do |a|
  if a_set.include?(a)
    a_set.delete(a)
  else
    a_set.add(a)
  end
end
ans = a_set.size
puts ans


Measured memory_bytes: 9084
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    int k;
    cin>>n>>k;
    int count=0;
    while(n--){
        int x,y;
        cin>>x>>y;
        int m=x*x+y*y;
        if(m<=k*k)count++;
    }
    cout<<count;
    return 0;
}

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

typedef long long ll;

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<int> S(N), T(N), X(N), D(Q), ans(Q);
    vector<vector<int>> vc(N * 2 + 1, vector<int>(3)), vd(Q, vector<int>(2));
    rep(i, N) {
        cin >> S[i] >> T[i] >> X[i];
        vc[i] = {S[i] - X[i], 1, X[i]};
        vc[N + i] = {T[i] - X[i], 0, X[i]};
    }
    vc[N * 2][0] = 2e9;
    vc[N * 2][1] = 0;
    sort(vc.begin(), vc.end());
    rep(i, Q) {
        cin >> D[i];
        vd[i] = {D[i], i};
    }
    sort(vd.begin(), vd.end());
    set<int> st;
    int j = 0;
    rep(i, Q) {
        int time = vc[j][0], c = vc[j][1];
        while (time <= vd[i][0]) {
            if (c == 1) st.insert(vc[j][2]);
            if (c == 0) st.erase(vc[j][2]);
            j++;
            time = vc[j][0];
            c = vc[j][1];
        }
        if (st.empty()) ans[vd[i][1]] = -1;
        else ans[vd[i][1]] = *st.begin();
    }
    rep(i, Q) cout << ans[i] << endl;
}

Measured memory_bytes: 47360
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;

  int n = s.size(), m = t.size();
  // dp[i][j] := sのi文字目, tのj文字目まで見たときの最長共通部分列(LCS)
  vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
      if (s[i] == t[j]) {
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + 1);
      }
    }
  }

  int i = n, j = m;
  string ans = "";
  while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) {
      i--;
    } else if (dp[i][j] == dp[i][j - 1]) {
      j--;
    } else {
      ans = s[i - 1] + ans;
      i--;
      j--;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 35584
no1 = [Array.new(10, 0), Array.new(10, 0), Array.new(10, 0)]
no2 = [Array.new(10, 0), Array.new(10, 0), Array.new(10, 0)]
no3 = [Array.new(10, 0), Array.new(10, 0), Array.new(10, 0)]
no4 = [Array.new(10, 0), Array.new(10, 0), Array.new(10, 0)]

gets # ignore n
while line = gets
  b, f, r, v = line.chomp.split.map(&:to_i)
  case b
  when 1 then no1[f-1][r-1] += v
  when 2 then no2[f-1][r-1] += v
  when 3 then no3[f-1][r-1] += v
  when 4 then no4[f-1][r-1] += v
  end
end

no1.each { |f| puts " " + f.join(" ") }
puts "#" * 20
no2.each { |f| puts " " + f.join(" ") }
puts "#" * 20
no3.each { |f| puts " " + f.join(" ") }
puts "#" * 20
no4.each { |f| puts " " + f.join(" ") }



Measured memory_bytes: 6900
#include<bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    
	int n,w; 
	cin>>n>>w;
	int a[n+1],b[n+1]; 
	for(int i=0;i<n;i++)  cin>>a[i]>>b[i]; 
	
	int dp[100005];
	memset(dp,0,sizeof(dp));
	for(int i=1;i<=n;i++){
		for(int j=w;j>=a[i-1];j--){
			dp[j] = max(dp[j], dp[j-a[i-1]]+b[i-1]);
		}
	} 
	cout<<dp[w]<<endl;
}


Measured memory_bytes: 4420
// Ashikur Rahman Asif , CSE 18
#include <bits/stdc++.h>
using namespace std;
int nar[51][51],mar[51][51];
void take_input(int a,int b)
{
    char ch;
    for(int i=0; i<a; i++)
    {
        for(int j=0; j<a; j++)
        {
            cin>>ch;
            if(ch=='#')
                nar[i][j]=1;
            else
                nar[i][j]=0;
        }
    }
    for(int i=0; i<b; i++)
    {
        for(int j=0; j<b; j++)
        {
            cin>>ch;
            if(ch=='#')
                mar[i][j]=1;
            else
                mar[i][j]=0;
        }
    }

}
void make_result(int n,int m)
{
    int p,q;
    if(n>m)
    {
        for(int i=0; i<n; i++)
        {
            for(int j=0; j<n; j++)
            {
                if(nar[i][j]==mar[0][0])
                {
                    p=1;
                    for(int k=0; k<m; k++)
                    {
                        for(int l=0; l<m; l++)
                        {
                            if(nar[k+i][l+j]!=mar[k][l])
                            {
                                p=0;
                                break;
                            }
                            if(k==m-1 && l==m-1)
                            {
                                cout<<"Yes\n";
                                return;
                            }
                        }
                        if(p==0)
                        {
                            break;
                        }
                    }
                }
            }
        }
        cout<<"No\n";
        return;
    }
    else if(n<m)
    {
        for(int i=0; i<m; i++)
        {
            for(int j=0; j<m; j++)
            {
                if(mar[i][j]==nar[0][0])
                {
                    p=1;
                    for(int k=0; k<n; k++)
                    {
                        for(int l=0; l<n; l++)
                        {
                            if(mar[k+i][l+j]!=nar[k][l])
                            {
                                p=0;
                                break;
                            }
                            if(k==n-1 && l==n-1)
                            {
                                cout<<"Yes\n";
                                return;
                            }
                        }
                        if(p==0)
                        {
                            break;
                        }
                    }
                }
            }
        }
        cout<<"No\n";
        return;
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(nar[i][j]!=mar[i][j])
            {
                cout<<"No\n";
            }
        }
    }
    cout<<"Yes\n";
}

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

    make_result(n,m);
    return 0;
}


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

int main(){
  int n;
  int ans = 0;
  vector<int> v;
  cin >> n;
  for(int i=0;i<n; ++i){
    // cout << "tmp3" << endl;
    int tmp;
    cin >> tmp;
    // cout << tmp;
    if(tmp%2 == 0 && tmp >=2){ans++; v.push_back(tmp/2);}
  }
  //return 0;
  
  // cout << "tmp2" << endl;
  bool frg = true;
  while(frg){
    frg = false;
    // cout << "tmp" << endl;
    for(int i=0; i < v.size(); ++i){
      if(v[i]%2 == 0 && v[i] >= 2){ans++;v[i] = v[i]/2;frg = true;break;}
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

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

    private static void solve(Scanner in) {
        int a = in.nextInt();
        int b = in.nextInt();
        System.out.println((a * b) + " " + (a + a + b + b));
    }
}

Measured memory_bytes: 26080
#include<bits/stdc++.h>
using namespace std;
int c[5][5];
int main(){
    for(int i=1;i<=3;i++)
    for(int j=1;j<=3;j++)
    cin>>c[i][j];
    int b11,b12,b13,b21,b22,b23,b31,b32,b33;
    for(int a1=0;a1<=100;a1++){
        b11=c[1][1]-a1;
        b21=c[1][2]-a1;
        b31=c[1][3]-a1;
        for(int a2=0;a2<=100;a2++){
            b12=c[2][1]-a2;
            b22=c[2][2]-a2;
            b32=c[2][3]-a2;
            if(b11!=b12||b21!=b22||b31!=b32)continue;   
            for(int a3=0;a3<=100;a3++){
                b13=c[3][1]-a3;
                b23=c[3][2]-a3;
                b33=c[3][3]-a3;
                if(b11==b13 && b21==b23 && b31==b33){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;
int r[4001],f[4001],v[4001];
int main()
{
    int i,n,j,c,maxdif;
    scanf("%d",&n);
    f[0]=1;
    for(i=1; i<=n; i++)
    {
        scanf("%d",&v[i]);
    }
    for(i=1; i<=n; i++)
    {
        scanf("%d",&c);
        for(j=4000-c; j>=0; j--)
            if(f[j])
            {
                f[j+c]=1;
                r[j+c]=max(r[j+c],r[j]+v[i]);
            }
    }
    maxdif=-INT_MAX;
    for(i=0; i<=4000; i++)
        maxdif=max(maxdif,r[i]-i);
    printf("%d",maxdif);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<set>
#define ll long long 
#include <string>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
using namespace std;
int main()
{
	ll int n;
	cin>>n;
	map<string ,ll int > m;
	ll int i;
	for(i=0;i<n;i++)
	{
		string s;
		cin>>s;
		m[s]++;
	}
	cout<<"AC"<<" x "<<m["AC"]<<endl;
	cout<<"WA"<<" x "<<m["WA"]<<endl;
	cout<<"TLE"<<" x "<<m["TLE"]<<endl;
	cout<<"RE"<<" x "<<m["RE"]<<endl;
	
}
	
		
	
	
	
	



Measured memory_bytes: 3636
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	c := make([]int, 60)
	for i := 0; i < n; i++ {
		for j := 0; j < 60; j++ {
			if a[i]>>uint(j)&1 == 1 {
				c[j]++
			}
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < 60; j++ {
			if c[j]&1 == 1 && a[i]>>uint(j)&1 == 1 {
				a[i] -= 1 << uint(j)
			}
		}
	}

	ans := 0
	used := make([]bool, n)
	for i := 59; i >= 0; i-- {
		if c[i]&1 == 1 {
			ans += 1 << uint(i)
			continue
		}

		p := -1
		for j := 0; j < n; j++ {
			if !used[j] && a[j]>>uint(i)&1 == 1 {
				p = j
				break
			}
		}
		if p == -1 {
			continue
		}
		used[p] = true

		for j := 0; j < 60; j++ {
			if a[p]>>uint(j)&1 == 1 {
				for k := 0; k < n; k++ {
					if k == p || a[k]>>uint(i)&1 == 0 {
						continue
					}
					a[k] ^= 1 << uint(j)
				}
			}
		}
	}

	x := 0
	for i := 0; i < n; i++ {
		x ^= a[i]
	}

	fmt.Fprintln(wr, ans+x*2)
}


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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

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

    int a,b;
    cin >> a >> b;
    if(a+b==3){
        cout << 3 << endl;
    }else if(a+b==4){
        cout << 2 << endl;
    }else{
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int N,M;
vector<vector<int> > v;
priority_queue<int> q;

int main(){
    cin >> N >> M;
    v.resize(100001);
    int a,b;
    for(int i=0;i<N;i++){
        cin >> a >> b;
        v[a].push_back(b);
    }
    long long sum = 0;
    for(int i=1;i<=M;i++){
        for(int j=0;j<v[i].size();j++){
            q.push(v[i][j]);
        }
        if(q.empty()){
            continue;
        }
        sum += q.top();
        q.pop();
    }
    cout << sum << endl;
    return 0;
}

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

typedef long long ll;

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	ll n,ans=0;
	cin >> n;
	if(n&1){
		ans = 0;
	}
	else{
		n/=2;
		while(n){
			n/=5;		
			ans += n;
		}
	}
	cout << ans << '\n';
}


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

typedef string::const_iterator Iterator;

int formula(int s, Iterator& it, const Iterator& last)
{
  switch (*it) {
    case 'T':
      ++it;
      return 1;
    case 'F':
      ++it;
      return 0;
    case '-':
      ++it;
      return !formula(s, it, last);
    case '(':
      {
        ++it;
        const int l = formula(s, it, last);
        const char op = *it;
        ++it;
        if (op == '-') {
          if (*it != '>') {
            throw ">";
          }
          ++it;
        }
        const int r = formula(s, it, last);
        if (*it != ')') {
          throw ")";
        }
        ++it;
        switch (op) {
          case '*':
            return l && r;
          case '+':
            return l || r;
          case '-':
            return !l || r;
          default:
            throw "op";
        }
      }
    default:
      if ('a' <= *it && *it <= 'k') {
        const char c = *it;
        ++it;
        return !!(s & (1<<(c-'a')));
      } else {
        throw "l";
      }
  }
  throw "eof";
}

bool solve(const string& lhs, const string& rhs)
{
  for (int s = 0; s < (1<<11); s++) {
    Iterator it = lhs.begin(), ilast = lhs.end();
    Iterator jt = rhs.begin(), jlast = rhs.end();
    int l = formula(s, it, ilast);
    int r = formula(s, jt, jlast);
    if (it != ilast) {
      throw "ilast";
    }
    if (jt != jlast) {
      throw "jlast";
    }
    if (l != r) {
      return false;
    }
  }
  return true;
}

int main()
{
  string s;
  while (getline(cin, s) && s != "#") {
    replace(s.begin(), s.end(), '=', ' ');
    istringstream iss(s);
    string lhs, rhs;
    iss >> lhs >> rhs;
    cout << (solve(lhs, rhs) ? "YES" : "NO") << endl;
  }
  return 0;
}

Measured memory_bytes: 944
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;
typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int a,b;
	std::cin>>a>>b;
	std::cout<<(b-1+a-2)/(a-1)<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;
	while(T--)
	solve(T);
	return 0;
}

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

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

const int maxn = 30003;

int n, b[maxn], c[maxn];
long long ans;
char s[maxn];

map <int, int> m[maxn], a[maxn], p;

int main()
{
	n = gi();
	scanf("%s", s + 1);
	for (int i = 2; i <= n; i+=1)
	{
		for (int j = 0; j <= 9; j+=1) if (m[i - 1][j] == 1) m[i][j] = 1;
		m[i][s[i - 1] - '0'] = 1; 
	}
	for (int i = n - 1; i > 1; i-=1)
	{
		for (int j = 0; j <= 9; j+=1) if (a[i + 1][j] == 1) a[i][j] = 1;
		a[i][s[i + 1] - '0'] = 1; 
	}
	/*
	for (int i = 1; i <= n; i+=1)
		for (int j = 0; j <= n; j+=1) 
			if (m[i][j]) cout << i << ' ' << j << endl;
	for (int i = 1; i <= n; i+=1)
		for (int j = 0; j <= n; j+=1) 
			if (a[i][j]) cout << i << ' ' << j << endl;
	*/
	for (int i = 1; i <= n; i+=1)
	{
		for (int j = 0; j <= 9; j+=1)
		{
			if (m[i][j])
			{
				for (int k = 0; k <= 9; k+=1)
				{
					if (a[i][k])
					{
//						cout << j * 100 + (s[i] - '0') * 10 + k << endl;
						p[j * 100 + (s[i] - '0') * 10 + k] = 1;
					}
				}
			}
		}
	}
	for (int i = 0; i <= 999; i+=1) if (p[i]) ++ans;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 31232
#include <stdio.h>

int a[505][505];
int move[300000][4];

int main(){

	int H,W;

	scanf("%d %d",&H,&W);

	int i,j;

	for(i=1;i<=H;i++){
		for(j=1;j<=W;j++){
			scanf(" %d",&a[i][j]);
		}
	}

	int N=0;

	for(i=H;i>=2;i--){
		int sum1=0;
		for(j=1;j<=W;j++){
			sum1+=a[i][j];
		}
		if(sum1%2==1){
			int flag=0;
			for(j=1;j<=W;j++){
				if(flag==0&&a[i][j]%2==1){
					a[i][j]--;
					a[i-1][j]++;
					move[N][0]=i;
					move[N][1]=j;
					move[N][2]=i-1;
					move[N][3]=j;
					N++;
					flag=1;
				}
				else if(a[i][j]%2==1 && j<W){
					a[i][j]--;
					a[i][j+1]++;
					move[N][0]=i;
					move[N][1]=j;
					move[N][2]=i;
					move[N][3]=j+1;
					N++;
				}
			}
		}
		else{
			for(j=1;j<W;j++){
				if(a[i][j]%2==1){
					a[i][j]--;
					a[i][j+1]++;
					move[N][0]=i;
					move[N][1]=j;
					move[N][2]=i;
					move[N][3]=j+1;
					N++;
				}
			}
		}
	}

	for(j=1;j<W;j++){
		if(a[1][j]%2==1){
			a[1][j]--;
			a[1][j+1]++;
			move[N][0]=1;
			move[N][1]=j;
			move[N][2]=1;
			move[N][3]=j+1;
			N++;
		}
	}
	printf("%d\n",N);
	for(i=0;i<N;i++){
	printf("%d %d %d %d\n",move[i][0],move[i][1],move[i][2],move[i][3]);
	}


	return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n;
	cin >> n;
	pii* xy = new pii[n];
	rep(i, n) cin >> xy[i].first >> xy[i].second;

	map<pii, int> length;
	rep(i, n) {
		rep(j, n) {
			if (i != j) {
				length[pii(xy[i].first - xy[j].first, xy[i].second - xy[j].second)] += 1;
			}
		}
	}

	int maxNum = 0;
	for (auto p = length.begin(); p != length.end(); ++p) {
		maxNum = max(maxNum, (*p).second);
	}

	cout << n - maxNum << "\n";

	return 0;
}


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

int main(){
    //点の数と次元
    int N, D;
    cin >> N >> D;

    //座標を用意
    vector< vector<int> > point(N, vector<int>(D));
    for (int i = 0; i < N; i++){
        for (int j = 0; j < D; j++) {
            cin >> point.at(i).at(j);
        }
    }

    int count = 0;

    for (int i = 0; i < N - 1; i++){
        for (int j = i + 1; j < N; j++) {
            int dis = 0;
            for(int k = 0; k < D; k ++){
                dis += pow(point.at(i).at(k) - point.at(j).at(k), 2);
            }
            for(int k = 1; k <= dis; k++){
                if(dis == pow(k, 2)) count++;
            }
        }
    }

    int ans = 0;
    if(D == 1){
        for(int i = 1; i < N; i++){
            ans += i;
        }
        cout << ans << endl;
    }else cout << count << endl;
}

Measured memory_bytes: 256
use v5.26; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($n, $m) = split / /, <STDIN>);
chomp (my @a = split / /, <STDIN>);
my $ans = $n - sum0(@a);
$ans = -1 if $ans < -1;
say $ans;

Measured memory_bytes: 6540
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外は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はコピーを作っておく
#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;

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

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

int main() {
	ll X, t; cin >> X >> t;
	if (X - t >= 0)cout << X - t << endl;
	else cout << 0 << endl;
}

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

#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long int64;

class CFennecVsMonster {
 public:
  void solveOne(std::istream &in, std::ostream &out) {
    int n, k;
    in >> n >> k;
    vector<int> v(n);
    forn(i, n)in >> v[i];

    sort(all(v));

    int kk = min(n, k);
    int64 ans = 0;
    forn(i, n - kk)ans += v[i];

    out << ans << endl;
  }
  void solve(std::istream &in, std::ostream &out) {
    int nt = 1;
    for (int i = 0; i < nt; ++i)
      solveOne(in, out);
  }
};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  CFennecVsMonster solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
#define SZ(x) ((ll).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define repii(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}
template<class T>bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }


ll n, m, q;
vector<ll> a(51), b(51), c(51), d(51);

ll ans = 0;
vector<ll> v(10);
void dfs(ll i = 0, ll first = 1){
  if(i == n){
    ll sum = 0;
    rep(i, q) if(v[b[i]] - v[a[i]] == c[i]) sum += d[i];
    chmax(ans, sum);
    return;
  }

  repii(j, first, m){
    v[i] = j;
    dfs(i+1, j);
  }
}

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

  cin >> n >> m >> q;
  rep(i, q){
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }

  dfs();
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;
#define PI 3.14159265358979


int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    double rad = (double)c * PI/180;
    
    double S = 0.5*a*b*sin(rad);
    double C = sqrt(b*b + a*a - 2*a*b*cos(rad));
    double L = a + b + C;
    double h = (double)b * sin(rad);
    printf("%f %f %f\n" ,S,L,h);
    return 0;
}



Measured memory_bytes: 3560
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,ans,ans1=1,MOD=1e9+7,ans2=1,A=1,B=1;
ll f(ll a,ll b){
    if(b==1)return a;
    if(b%2==1)return f(a,b-1)*a%MOD;
    return f(a,b/2)*f(a,b/2)%MOD;
}
int main(void){
    cin>>n>>a>>b;
    ans=f(2,n);
    for(ll i=0;i<a;i++){
        ans1*=(n-i);
        ans1%=MOD;
        A*=(a-i);
        A%=MOD;
    }
    ans1*=f(A,MOD-2);
    for(ll i=0;i<b;i++){
        ans2*=(n-i);
        ans2%=MOD;
        B*=(b-i);
        B%=MOD;
    }
    //cout<<ans2<<endl;
    
    ans2*=f(B,MOD-2);
    ans1%=MOD;
    ans2%=MOD;
    ans-=ans1;
    ans%=MOD;
    ans-=ans2;
    ans%=MOD;
    ans=(ans-1+MOD)%MOD;
    cout<<ans<<endl;
}


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

using namespace std;
long long ans;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    for (int i = 1; i <= k; ++i) {
        for (int j = i; j <= k; ++j) {
            int tmp1 = __gcd(i, j);
            for (int l = j; l <= k; ++l) {
                int tmp2 = __gcd(tmp1, l);
                if (i == j) {
                    if (j == l) {
                        ans += tmp2;
                    } else {
                        ans += tmp2 * 3;
                    }
                } else {
                    if (j == l) {
                        ans += tmp2 * 3;
                    } else if (i == l) {
                        ans += tmp2 * 3;
                    } else {
                        ans += tmp2 * 6;
                    }
                }
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(i,n) for(int i = 1; i <= (int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

//const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int ans = 0;
    int n = s.size();
    rrep(i,n-1) {
        if(s[i] != s[i-1]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

vector<ll> lay;
vector<ll> p;
ll n, k;

ll fun(ll n, ll x){
	if (n == 0)return (x <= 0 ? 0 : 1);
	if (x <= lay[n - 1] + 1)return fun(n - 1, x - 1);
	return p[n - 1] + 1 + fun(n - 1, x - 2 - lay[n - 1]);
	
}

int main(){
	cin >> n >> k;
	lay.push_back(1), p.push_back(1);
	for (int i = 1; i <= n; i++){
		ll l = lay[i - 1] * 2 + 3;
		ll pp = p[i - 1] * 2 + 1;
		lay.push_back(l);
		p.push_back(pp);
	}
	cout << fun(n, k) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    if (k % 2 == 0) {
        cout << -1 << "\n";
        return 0;
    }
    lint res = 7 % k;
    lint ret = 1;
    while (res != 0) {
        res = (res * 10 + 7) % k;
        ret++;
        if (ret > k) {
            cout << -1 << "\n";
            return 0;
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3620
n,k = (int(x) for x in input().split())
a = tuple([int(x) for x in input().split()])
 
c = [0] + [-1]*(n)
l = [1]
now = 1
dupl = -1

for i in range(k):
  now = a[now - 1]
  c[now - 1] += 1
   
  if c[now - 1] == 1:
    dupl = now
    break
  else:
    l.append(now)
    
if dupl == -1:
  print(now)
  exit()
       
notloop = l.index(dupl)
length = len(l)-notloop
print(l[(k-notloop)%length+notloop])

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long n = sc.nextLong();
		
		long ans = 0;
		
		double log = Math.log10((double)n);
		
		if(n % 2 == 0) {
			n = n/2;
			for(int i = 1 ;; i++) {
				
				long temp = (long)Math.pow(5, i);
				if(n < temp) {
					break;
				}
				ans += (long)Math.floorDiv(n,temp);
				
				}
			System.out.println(ans);
		}
		
		else {
			System.out.println(0);
		}

	}

}


Measured memory_bytes: 23124