akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mem(ar,num) memset(ar,num,sizeof(ar))
#define me(ar) memset(ar,0,sizeof(ar))
#define lowbit(x) (x&(-x))
#define Pb push_back
#define  FI first
#define  SE second
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define IOS ios::sync_with_stdio(false)
#define DEBUG cout<<endl<<"DEBUG"<<endl; 
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int    prime = 999983;
const int    INF = 0x7FFFFFFF;
const LL     INFF =0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const LL     mod = 1e9 + 7;
LL qpow(LL a,LL b){LL s=1;while(b>0){if(b&1)s=s*a%mod;a=a*a%mod;b>>=1;}return s;}
LL gcd(LL a,LL b) {return b?gcd(b,a%b):a;}
int dr[2][4] = {1,-1,0,0,0,0,-1,1};
typedef pair<int,int> P;

int main(void)
{
    int n;string s;
    cin>>n>>s;
    if(n >= 3200)
    cout<<s<<endl;
    else 
    cout<<"red"<<endl;    

   return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
s = []
t = []
for i in 0..n-1
    song,time = gets.chomp.split
    s << song
    time = time.to_i
    t << time
end
x = gets.chomp
flag = 0
ans = 0
for i in 0..n-1
    if s[i] == x
        flag = 1
    elsif flag == 1 
        ans += t[i]
    end
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 998244353;
ll powll(ll x, ll y){
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    return (x * powll(y,mod-2)) % mod;
}


int main() {
    int n, m;
    cin >> n >> m;
    VVI a(n, VI(m));
    REP(i,n) REP(j,m) a[i][j] = in();

    int r = 0, p = 0;
    REP(i,n){
        while (p < m){
            int j = -1;
            FOR(k,i,n-1){
                if (a[k][p]){
                    j = k;
                    break;
                }
            }
            if (j == -1){
                p++;
                continue;
            }
            r = i + 1;
            swap(a[i], a[j]);
            FOR(j,i+1,n-1){
                if (!a[j][p]) continue;
                FOR(k,p,m-1) a[j][k] ^= a[i][k];
            }
            p++;
            break;
        }
    }

    ll ans = powll(2, m - 1) * (powll(2, n) - powll(2, n - r) + mod) % mod;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)((n>>m)&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll n,ans=INF;
char s[99];
int main(){
	scanf("%s",s);
	n=strlen(s);
	rep(i,0,n-2){
		ll ss=0;
		rep(j,0,3)ss=ss*10+s[i+j]-48;
		ans=min(ans,llabs(ss-753));
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;

int n;
bool vis[10010] = {0};

int main() {
	scanf( "%d", &n );
	vis[0] = 1;
	for( int i = 0; i < n; ++i ) {
		int s; scanf( "%d", &s );
		for( int j = 10010-s-1; j >= 0; --j )
			if( vis[j] ) vis[j+s] = true;
	}
	for( int i = 10009; i >= 0; --i ) {
		if( vis[i] && i % 10 ) {
			printf( "%d\n", i );
			return 0;
		}
	}
	puts("0");
	return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> piipi;
typedef pair<pii, pii> piipii;

#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define eb emplace_back
const int mod = 1000000007;

int l[3005], r[3005], mx[3005];
char s[3005];
int sum[3005][2];
int dp[3005][3005];
int main(){
    int n, m;
    scanf("%d%d", &n, &m);   
    scanf("%s", s+1);
    for(int i=1;i<=n;i++) mx[i] = i;
    for(int i=1;i<=m;i++){
        scanf("%d%d", &l[i], &r[i]);
        mx[l[i]] = max(mx[l[i]], r[i]);
    }

    for(int i=1;i<=n;i++){
        sum[i][s[i]-'0']++;
        sum[i][0] += sum[i-1][0];
        sum[i][1] += sum[i-1][1];
    }

    for(int i=1;i<=n;i++) mx[i] = max(mx[i], mx[i-1]);

    dp[0][0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(dp[i-1][j]){
                int c0 = sum[mx[i]][0] - j;
                int c1 = sum[mx[i]][1] - (i-1-j);
                if(c0 > 0) dp[i][j+1] = (dp[i][j+1] + dp[i-1][j])%mod;
                if(c1 > 0) dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
            }
        }
    }
    int ans = 0;
    for(int j=0;j<=n;j++) ans = (ans + dp[n][j])%mod;
    printf("%d\n", ans);
}

Measured memory_bytes: 16072
#include <bits/stdc++.h>
//#define int long long

using namespace std;

constexpr int MAXN = 1e6 + 6, MOD = 1e9 + 7;

template<typename T>
inline void read(T& x, T f = 1, char ch = getchar()) {
    x = 0;
    while (!isdigit(ch)) f = (ch == '-') ? -1 : 1, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
    x *= f;
}

int n, m, coprime;
array<int, MAXN> a, suf;
vector<int> divisor[MAXN];

int cnt[MAXN];

signed main() {
    read(n);
    for (int i = 1; i <= n; i++) read(a[i]);
    coprime = a[1];
    for (int i = 2; i <= n; i++) coprime = __gcd(coprime, a[i]);
    for (int i = 2; i <= 1e6; i++)
        for (int j = i; j <= 1e6; j += i)
            divisor[j].push_back(i);
    bool judge = true;
    for (int i = n; i >= 1; i--) {
        for (auto& c : divisor[a[i]]) {
            if (cnt[c]) {
                judge = false;
                break;
            }
        }
        if (judge == false) break;
        for (auto& c : divisor[a[i]]) {
            cnt[c]++;
        }
    }
    if (judge) {
        puts("pairwise coprime");
    } else if (coprime == 1) puts("setwise coprime");
    else puts("not coprime");
    return 0;
}

Measured memory_bytes: 118156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string n;
  cin >> n;
  int flag = 0;
  rep(i,n.size()){
      if(n[i]=='7') flag = 1;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

int main()
{
    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
    } else if(n == 2){
        int a,b;
        cin >> a;
        cin >> b;
        cout << (a+b) << endl;
    }
}


Measured memory_bytes: 256
// ITP1_4-C

import java.util.Scanner;

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

		int a;
		int b;
		String op;
		int c = 0;

		while ( true ) {
			a = sc.nextInt ();
			op = sc.next ();
			b = sc.nextInt ();
			
			if ( op.equals ( "+" ) ) {
				c = a + b;
			} else if ( op.equals ( "-" ) ) {
				c = a - b;
			} else if ( op.equals ( "*" ) ) {
				c = a * b;
			} else if ( op.equals ( "/" ) ) {
				c = a / b;
			} else if ( op.equals ( "?" ) ) {
				break;
			}
		System.out.println ( c );
		}
	}
}

Measured memory_bytes: 26020
n = int(input())
m = int(input())
inf = 1001001001
route = [[inf for _ in range(n)] for __ in range(n)]
for _ in range(m):
    a, b, c, d = map(int, input().split(','))
    route[a-1][b-1] = c
    route[b-1][a-1] = d
s, g, V, P = map(int, input().split(','))
for k in range(n):
    for i in range(n):
        for j in range(n):
            if route[i][j] > route[i][k] + route[k][j]:
                route[i][j] = route[i][k] + route[k][j]
print(int(V - P - route[s-1][g-1] - route[g-1][s-1]))



Measured memory_bytes: 5608
#include <stdio.h>
#include <cstring>
using namespace std;
int main(){
    char a[150]={},b[150]={};
    int che[150]={};
    int n,cut=0,k=0,k_1=0;
    scanf("%d",&n);
    scanf("%s",a);
    while(cut<=n){
        b[cut]=a[cut];
        for(int i=cut+1;i<n;i++){
            for(int j=0;j<=cut;j++){
                if((a[i]==b[j])&&(che[a[i]]==0)){
                    che[a[i]]=1;
                    k_1++;
                }
            }
        }
        if(k<=k_1) k=k_1;
        k_1=0;
        cut++;
        for(int i=60;i<=126;i++){
            che[i]=0;
        }
    }
    printf("%d",k);
}



Measured memory_bytes: 128
N = int(input())
L = list(map(int,input().split()))
L = sorted(L)
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if L[k] <L[i]+L[j]:
                if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                    ans += 1
print(ans)


Measured memory_bytes: 67860
import bisect

A, B, Q = list(map(int, raw_input().split()))

max_val = 10.0 ** 15

jinja = list()
jinja.append(-max_val)
for a in xrange(A): jinja.append(long(raw_input()))
jinja.append(max_val)
tera = list()
tera.append(-max_val)
for b in xrange(B): tera.append(long(raw_input()))
tera.append(max_val)

for q in xrange(Q):
    question = long(raw_input())
    idx_tera, idx_jinja = bisect.bisect_right(tera, question), bisect.bisect_right(jinja, question)

    cost = max_val
    for T in [tera[idx_tera-1], tera[idx_tera]]:
        for S in [jinja[idx_jinja-1], jinja[idx_jinja]]:
            d_T = abs(T - question) + abs(S - T) # pattern1: question -> T -> S
            d_S = abs(S - question) + abs(T - S) # pattern2: question -> S -> T
            cost = min(cost, d_T, d_S)
    print cost


Measured memory_bytes: 11748
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using ll = long long;
// using ll = boost::multiprecision::int128_t;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const ld PI    = acos(-1.0);
const int MOD  = int(1e9)+7;


int main() {
  ll a; ld b; cin >> a >> b;
  ll ans = a * round(b * 100) / 100;

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


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  vector<int> b(N);
  for(int i = 1; i < N; i++) {
    int A; cin >> A; A--;
    b.at(A)++;
  }
  for(int i = 0; i < N; i++) {
    cout << b.at(i) << endl;
  }
}

Measured memory_bytes: 4052
from collections import deque

n = int(input())
ans = [0] * n
visited = [False] * n
G = [[] for _ in range(n)]

for i in range(n-1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    G[u].append([v, w])
    G[v].append([u, w])

q = deque([])
q.append(0)
visited[0] = True

def dfs():
    while q:
        p = q.popleft()
        for u, w in G[p]:
            if visited[u]: continue
            else:
                ans[u] = (ans[p] + w) % 2
                visited[u] = True
                q.append(u)

dfs()

for i in range(n):
    print(ans[i])

Measured memory_bytes: 46132
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<set>
#include<vector>
using namespace std;
int main(){

    int n;
    cin>>n;
    if(n==1){
        cout<<"Hello World"<<endl;
    }else{
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }




return 0;
}

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

#define fast ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)

typedef long long ll;

ll n,m,k;
ll a,b,c;
ll r[11];
ll d[222][222];

const ll inf = (ll)1e14;

ll go(ll c, ll vis[], ll last) {
    if (c >= k) return 0;

    ll ret = inf;
    for (int i = 0; i < k; i++) {
        if (vis[i]) continue;
        vis[i] = 1;
        ret = min(ret, go(c + 1, vis, i) + d[r[last]][r[i]]);
        vis[i] = 0;
    }
    return ret;
}

int main() {
    fast;
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++) cin >> r[i], r[i]--;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; ++j) {
            if (i == j)
                d[i][j] = 0;
            else
                d[i][j] = inf;
        }
    }

    while (m--) {
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = min(d[a][b], c);
        d[b][a] = min(d[b][a], c);
    }

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    ll vis[11] = {0};
    ll ans = inf;
    for (int i = 0; i < k; i++) {
        vis[i] = 1;
        ans = min(ans, go(1, vis, i));
        vis[i] = 0;
    }
    cout << ans << endl;
    return 0;
}

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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol Mod=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r,q;
int h[100010];
vector<int> lo[100010];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m;
  for(int i=0;i<n;i++){
    cin >>h[i+1];
  }
  for(int i=0;i<m;i++){
    int a,b;cin >>a>>b;
    lo[a].emplace_back(b);
    lo[b].emplace_back(a);
  }
  lol ans=0;
  for(int i=1;i<=n;i++){
    bool w=true;
    for(int j=0;j<lo[i].size();j++){
      if(h[i]<=h[lo[i][j]]){
	w=false;
	break;
      }
    }
    if(w==true) ans++;
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 9172
#include <stdio.h> 
int main(void)
{
    int n, m;
    int i, j;
    int a[100][100]={};
    int b[100]={};
    int c[100]={};
     
    scanf("%d%d", &n, &m);
     
    for(i=0; i<n; i++) {
        for(j=0; j<m; j++)
            scanf("%d", &a[i][j]);
    }
    for(j=0; j<m; j++)
        scanf("%d", &b[j]);
     
    for(i=0; i<n; i++) {
        for(j=0; j<m; j++)
            c[i]+=a[i][j]*b[j];
        printf("%d\n", c[i]);
    }
     
    return 0;
}


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

int t[2010][2010], blue[2010][2010], vert[2010][2010], hori[2010][2010];

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	for(int i=0; i<N; ++i){
		string S;
		cin >> S;
		for(int j=0; j<M; ++j) t[i][j]=S[j]-'0';
	}
	for(int i=0; i<N; ++i){
		//blue and vert
		for(int j=0; j<M; ++j){
			blue[i+1][j+1]=blue[i+1][j]+t[i][j];
			if(j>0){
				vert[i+1][j+1]=vert[i+1][j]+t[i][j-1]*t[i][j];
			}
		}
		for(int j=0; j<M; ++j){
			blue[i+1][j+1] += blue[i][j+1];
			vert[i+1][j+1] += vert[i][j+1];
		}
	}
	for(int j=0; j<M; ++j){
		//hori
		for(int i=1; i<N; ++i){
			hori[i+1][j+1]=hori[i][j+1]+t[i-1][j]*t[i][j];
		}
		for(int i=0; i<N; ++i){
			hori[i+1][j+1] += hori[i+1][j];
		}
	}
	for(int i=0; i<Q; ++i){
		int xs, ys, xl, yl;
		cin >> xs >> ys >> xl >> yl;
		int B, V, H;
		B=blue[xl][yl]+blue[xs-1][ys-1]-blue[xs-1][yl]-blue[xl][ys-1];
		V=vert[xl][yl]+vert[xs-1][ys]-vert[xs-1][yl]-vert[xl][ys];
		H=hori[xl][yl]+hori[xs][ys-1]-hori[xs][yl]-hori[xl][ys-1];
		cout << B-V-H << endl;
		//cout << B << ' ' << V << ' ' << H << endl;
	}
	return 0;
}

Measured memory_bytes: 64896
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        String s = sc.next();
        
        if(s.length() == 2){
            System.out.println(s);
        }else{
            for(int i = s.length()-1; i >= 0; i--){
                System.out.print(s.toCharArray()[i]);
            }
        }
    }
}


Measured memory_bytes: 23764
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt, pi
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

S = input()
N = len(S)
# dp[i][j]: i番目にjまで丸をつけ終えている通り
dp = [[0] * 4 for _ in range(N + 1)]
dp[0][0] = 1

for i in range(N):
    for j in range(4):
        # i番目の文字が?でなければ
        if S[i] != '?':
            # 一つ前のものを引き継ぐ
            dp[i + 1][j] += dp[i][j]
            dp[i + 1][j] %= mod
        # ?なら
        else:
            # A, B, C３つ分引き継ぐ
            dp[i + 1][j] += 3 * dp[i][j]
            dp[i + 1][j] %= mod
    # もしS[i]がAか?ならj == 0の場合カウントを一つ増やせる
    # これでABC○A○B○Cと○A○B○CABCは区別される
    if S[i] == 'A' or S[i] == '?':
        dp[i + 1][1] += dp[i][0]
        dp[i + 1][1] %= mod
    if S[i] == 'B' or S[i] == '?':
        dp[i + 1][2] += dp[i][1]
        dp[i + 1][2] %= mod
    if S[i] == 'C' or S[i] == '?':
        dp[i + 1][3] += dp[i][2]
        dp[i + 1][3] %= mod
print(dp[N][3] % mod)

Measured memory_bytes: 101044
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(){
    int N;
    cin >> N;
    long long int num[N];
    for(int a = 0;a < N;a++){
        cin >>num[a];
    }
    int counter = 0;
    while(1){
        bool pos = true;
        for(int a = 0;a < N;a++){
            if(num[a] % 2 != 0){
                pos = false;
                break;
            }
        }
        if(!pos)break;
        if(pos){
            for(int a = 0;a < N;a++){
                num[a] = num[a] / 2;
            }
            counter++;
        }
    }
    cout<<counter<<endl;
    return 0;
}


Measured memory_bytes: 256
A = input()
f = ['+', '-']

def check(A):
    for i in range(2):
        for j in range(2):
            for k in range(2):
                x  = A[0]+f[i]+A[1]+f[j]+A[2]+f[k]+A[3]
                if eval(x) == 7:
                    return x

print(check(A)+'=7')

Measured memory_bytes: 3060
mod=10^9+7
p(a,b)=b>0?p(a*a%mod,b>>1)*(b%2>0?a:1)%mod : 1
s=chomp(readline())
ans=0
q=0
for c=s
	if c=='?'
		q+=1
	end
end
A=[0,0]
AB=[0,0,0]
for i=1:length(s)
	if s[i]=='A'
		A[1]=(A[1]+1)%mod
	elseif s[i]=='B'
		AB[1]=(AB[1]+A[1])%mod
		AB[2]=(AB[2]+A[2])%mod
	elseif s[i]=='C'
		for j=1:min(3,q+1)
			ans=(ans+AB[j]*p(3,q+1-j)%mod)%mod
		end
	else
		for j=1:min(3,q)
			ans=(ans+AB[j]*p(3,q-j)%mod)%mod
		end
		AB[2]=(AB[2]+A[1])%mod
		AB[3]=(AB[3]+A[2])%mod
		A[2]=(A[2]+1)%mod
	end
end
println(ans)


Measured memory_bytes: 153752
package main

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

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	N, _ := strconv.Atoi(stdin.Text())
	A := make([]int, N)
	for i := 0; i < N; i++ {
		stdin.Scan()
		A[i], _ = strconv.Atoi(stdin.Text())
	}
	I := make([]int, N)
	J := make([]int, N)
	j := 1
	for i := 0; i < N-1; i++ {
		I[i] += -j
		I[i+1] += j
		J[i] += j
		J[i+1] += -j
		j = -j
	}
	sort.Sort(sort.IntSlice(A))
	sort.Sort(sort.IntSlice(I))
	sort.Sort(sort.IntSlice(J))
	tmp1, tmp2 := 0, 0
	for i := 0; i < N; i++ {
		tmp1 += A[i] * I[i]
		tmp2 += A[i] * J[i]
	}
	if tmp1 < tmp2 {
		fmt.Println(tmp2)
	} else {
		fmt.Println(tmp1)
	}
}


Measured memory_bytes: 4608
using System;
using System.Linq;
using System.Collections.Generic;
// Gluttony
namespace E
{
    class Program
    {
        static long Solve(int n, long k, List<long> a, List<long> f)
        {
            a.Sort();
            f.Sort();
            f.Reverse();
            var scores = a.Zip(f, (ai, fi) => new { ai, fi });
            var max = scores.Select(s => s.ai * s.fi).Max();

            Func<long, bool> pred = x =>
            {
                return scores.Select(score => Math.Max(0, score.ai - x / score.fi)).Sum() <= k;
            };

            Func<long, long, long> binarySearch = null;
            binarySearch = (start, end) => {
                if (start + 1 >= end)
                {
                    return pred(start)
                    ? start
                    : end;
                }
                var m = (start + end) / 2;
                return pred(m)
                    ? binarySearch(start, m)
                    : binarySearch(m, end);
            };

            return binarySearch(0, max);
        }


        static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');
            int n = Convert.ToInt32(line[0]);
            long k = Convert.ToInt64(line[1]);
            var a = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x));
            var f = Console.ReadLine().Split(' ').Select(x => Convert.ToInt64(x));
            Console.Write(Solve(n, k, a.ToList(), f.ToList()));

        }
    }
}


Measured memory_bytes: 46712
# coding:utf-8

n = map(int, raw_input().split())
t, a = map(int, raw_input().split())

h = raw_input().split()

# print n
# print t
# print h[0]

hdiff = [0] * n[0]
for i in range(n[0]):
    hdiff[i] = abs(t - a - int(h[i]) * 0.006)

# print hdiff

ans = hdiff.index(min(hdiff))
print ans + 1

#if (b%2 == 1 and c%2 == 1):
#    print "Yes"
#else:
#    print "No"


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

using namespace std;

int N,Q;
int w[110]={0},Ning[110]={0};

int main()
{
	cin>>N;
	Ning[0]=0;
	for(int i=1;i<=N;i++)
	{
		cin>>w[i];
		Ning[i]=Ning[i-1]+w[i];
	}
	Q=Ning[N];
	for(int i=1;i<=N;i++)
	{
		int T=abs(Ning[N]-Ning[i]-Ning[i]);
		Q=min(T,Q);
	}
	cout<<Q<<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);
		long a = sc.nextLong();
		long b = sc.nextLong();


		if(a>=b) {
			System.out.println(a*b/res(a,b));
		}else {
			System.out.println(a*b/res(b,a));
		}


	}
	public static Long res(long a,long b) {
		long res;
		res = a%b;
		if(res==0) {
			return b;
		}
		return res(b,res);
	}
}




Measured memory_bytes: 23252
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int n, d;
	cin >> n >> d;
	int ans;
	ans = n / (2 * d + 1);
	if (n % (2 * d + 1) != 0)
		ans++;
	cout << ans << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(), x.end()
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const int MAX_N = 500;

int main() {
    int n, m; cin >> n >> m;
    vvll x(n,vll(3));
    rep(i,n)rep(j,3) cin >> x[i][j];
    ll ans = -inf;
    rep(i,1<<3) {
        vll tmp(n,0);
        rep(j,n) {
            rep(k,3) {
                if (i>>k&1) tmp[j] += -x[j][k];
                else tmp[j] += x[j][k];
            }
        }
        sort(tmp.rbegin(),tmp.rend());
        ll sum = 0;
        rep(j,m) sum += tmp[j];
        ans = max(ans,sum);
    }
    cout << ans << endl;
}

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

typedef long long int ll;
ll n;
ll arr[100005];

map <ll,ll> bit;

ll compute(ll idx){
    ll ans = 0;
    while(idx>=0){
        ans = max(ans,bit[idx]);
        idx = (idx&(idx+1))-1;
    }
    return ans;
}

void update(ll idx,ll delta){

    while(idx<n){

        bit[idx] = max(bit[idx],delta);
        idx = (idx|(idx+1));
    }

}

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

    cin>>n;
    for(ll i=0;i<n;i++){
        cin>>arr[i];
    }

    map <ll,ll> mp;
    ll ans = 0;
    set < pair <ll,ll> > s;
    for(ll i=0;i<n;i++){

        auto x = s.lower_bound({arr[i],0});
        if(x==s.begin()){
            s.insert({arr[i],++ans});
        }
        else{
            x--;
            ll c = x->second;
            s.erase(x);
            s.insert({arr[i],c});
        }

    }
    cout<<ans<<endl;






}


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

int main() {
  int N,T;
  cin>>N>>T;
  vector<int> c(N);
  vector<int> t(N);
  vector<int> y(N);
  for(int i=0;i<N;i++){
  cin>>c.at(i);
    y.at(i)=1001;
  cin>>t.at(i);
    if(t.at(i)<=T){ y.at(i)=c.at(i);}
    
  }
  
  sort(y.begin(),y.end());
  if(y.at(0)==1001){
  cout<<"TLE"<<endl;}
  else{
  cout<<y.at(0)<<endl;}
}


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

int main() {
	int n;
	cin >> n;
	vector<int> stones;
	for(int i = 0; i < n; i++){
		int temp;
		cin >> temp;
		stones.push_back(temp);
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(stones[1] - stones[0]);
	for(int i = 2; i < n; i++){
		dp[i] = min(dp[i-1] + abs(stones[i] - stones[i - 1]), dp[i - 2] + abs(stones[i] - stones[i - 2]));
		//cout << dp[i] << endl;
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1144
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n=Integer.parseInt(sc.next());
int[] a=new int[n];
for(int i=0;i<n;i++){
a[i]=Integer.parseInt(sc.next());
}
int ans=0;
for(int k :a){
ans+=k-1;
}
System.out.println(ans);
}}

Measured memory_bytes: 24660
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

typedef std::complex<double> Com;

//geometric library
//#include <complex>
//typedef complex<double> Com;
//c++ -std=c++14

//内積
double dot_product(const Com a, const Com b){
	return (conj(a)*b).real();
}
//外積
double cross_product(const Com a, const Com b){
	return (conj(a)*b).imag();
}
//点と直線の距離
double dist_dot_line(const Com st, const Com en, const Com dt){
    return std::abs(cross_product(dt-st, en-st) / std::abs(en-st));
}
//点と線分の距離
double dist_dot_seg(const Com st, const Com en, const Com dt){
	if(dot_product(en-st, dt-st) <= 0){
		return std::abs(dt-st);
	}else if(dot_product(st-en, dt-en) <= 0){
		return std::abs(dt-en);
	}else{
		return dist_dot_line(st, en, dt);
	}
}
//線分の交差判定
//平行・接触は含まない(接触を含みたいときはdist_seg==0を使う)
bool seg_crossing(const Com st1, const Com en1, const Com st2, const Com en2){
	double cross1 = cross_product(en1-st1, st2-st1) * cross_product(en1-st1, en2-st1);
	double cross2 = cross_product(en2-st2, st1-st2) * cross_product(en2-st2, en1-st2);
	return (cross1 < 0) && (cross2 < 0);//
}
//線分と線分の距離
double dist_seg(const Com st1, const Com en1, const Com st2, const Com en2){
	if(seg_crossing(st1, en1, st2, en2)){
		return 0;
	}
	return std::min(std::min(dist_dot_seg(st1, en1, st2), dist_dot_seg(st1, en1, en2)), std::min(dist_dot_seg(st2, en2, st1), dist_dot_seg(st2, en2, en1)));
}

double x[8];
Com p[4];

void solve(){
    for(int i = 0; i < 8; i++){
        scanf("%lf", x+i);
    }
    for(int i = 0; i < 4; i++){
        p[i] = Com(x[2*i], x[2*i+1]);
    }
    if(dist_seg(p[0], p[1], p[2], p[3]) == 0){
        printf("1\n");
    }else{
        printf("0\n");
    }
}

long n;
int main(){
    scanf("%ld", &n);
    for(int i = 0; i < n; i++){
        solve();
    }
}



Measured memory_bytes: 3284
#include<iostream>
using namespace std;
int main(){
long n,f=0;
double w,h;
char c;
while(cin>>n){
cin>>c>>w>>c>>h;
if(w/h/h>=25){cout<<n<<endl;f=1;}
}
if(f==0)cout<<"該当なし"<<endl;
return 0;
}

Measured memory_bytes: 1232
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

const double pi = 3.141592653589793;
vector<double> x(101), y(101);
int n; 

double naiseki(double x1, double y1, double x2, double y2) {
  return x1 * x2 + y1 * y2;
}

// 角度 theta の方向を最終的に向くとして計算
// theta は radian
double calc(const double& theta) {
  double res = 0.0;
  double dx = cos(theta), dy = sin(theta);
  for (int i = 0; i < n; ++i) {
    res += max(0.0, naiseki(dx, dy, x[i], y[i]));
  }
  return res;
}

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

  //auto start = chrono::system_clock::now();

  cin >> n;
  rep(i, n) cin >> x[i] >> y[i];

  int step = 5000000;

  double ans = 0.0;

  for (int i = 0; i < step; ++i) {
    double theta = 2.0 * pi * i / step;
    chmax(ans, calc(theta));
  }

  //auto end = chrono::system_clock::now();
  //auto dur = end - start;
  //auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
  //cerr << msec << '\n';

  cout << setprecision(15) << ans << '\n';

  return 0;
}

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

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

    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin>>a.at(i);
    }

    int alice=0,bob=0;

    // aの要素を大きい順にソート
    sort(a.begin(),a.end());
    reverse(a.begin(),a.begin());

    if(n%2==0){
        for(int i=0; i<n; i+=2){
            alice+=a.at(i);
            bob+=a.at(i+1);
        }
    }else{
        for(int i=0; i<n-1; i+=2){
            alice+=a.at(i);
            bob+=a.at(i+1);
        }
        alice+=a.at(n-1);
    }

    cout<<abs(alice-bob)<<endl;
}

Measured memory_bytes: 764
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll x;

int main() {
	cin >> x;
	if (x >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if((a==b && a!=c && b!=c) || (a!=b && a==c && b!=c) || (a!=b && a!=c && b==c))
        cout<<"Yes";
    else
        cout<<"No";
}


Measured memory_bytes: 256
n, m, k = map(int, input().split())
# tmp = m
mod = 998244353
ans = m * pow(m-1, n-1, mod)
ans %= mod
ncm = 1
ncm_list = [0 for _ in range(k)]
for i in range(k):
    ncm *= n-1-i
    ncm *= pow(i+1, mod-2, mod)
    ncm %= mod
    ncm_list[i] = ncm

powm_list = [0 for _ in range(k)]
tmp = m * pow(m-1, n-k-1, mod)
if k != 0:
    powm_list[k-1] = tmp
    for i in range(k-2, -1, -1):
        tmp *= (m-1)
        tmp %= mod
        powm_list[i] = tmp

for i in range(k):
    ans += ncm_list[i] * powm_list[i]
    ans %= mod

print(ans)

Measured memory_bytes: 102588
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

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;
}

const int INF = 1e9;

int main() {
    IOS
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    int dp[n];
    for (int i = 0; i < n; i++) dp[i] = INF;
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
    }
    cout << dp[n-1] << endl;
}

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

int main() {
	int a,b;
	cin >> a >> b;
	cout << max(0,a-2*b) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;

#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<"";cout<<endl
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
// #define endl '\n'

#define mod 1000000007

ll add(ll a, ll b){return (a%mod + b%mod)%mod;}
ll sub(ll a , ll b){return (a%mod - b%mod + mod)%mod;}
ll mul(ll a, ll b){return (a%mod * b%mod)%mod;}
ull poww(ull a,ull b){ull res=1;while(b){if(b&1){res*=a;}a=a*a;b>>=1;}return res;}
ll poww(ll a,ll b,ll MOD){ll res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define dbg(x) cout<<#x<<" :: "<<x<<endl;
#define dbg2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define dbg4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;

#define upb upper_bound
#define lwb lower_bound

//end of template

int main(int argc, char const *argv[])
{
	crap;
	int n, k;
	string s;
	cin >> n >> k >> s;
	s[k-1] = s[k-1] + 32;
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,D=get_i
ans=0
N.times do
  x,y=get_i
  ans+=1 if D>=(x**2+y**2)**0.5 
end
puts ans

Measured memory_bytes: 14920
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;
	int n;
	cin>>n;
	int ans=0;
	for(int i=2;i<1000010;i++)
	{
		int c=0;
		while(n%i==0)
		{
			c++;
			n/=i;
		}
		for(int j=1;j<10000;j++)
		{
			if(c<j)
			break;
			ans++;
			c-=j;
		}
	}
	if(n>1)
	ans++;
	cout<<ans<<endl;
	return 0;
}


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

bool is_prime(int n){
  if(n==1){return false;}
  else{
    for (int j=2;j*j<=n;j++){
      if(n%j==0){return false;}
    }
    return true;
  }
}

int main(){
  int N;cin>>N;
  int count =0;
  ll num=2;
  while(count<N){
    if(is_prime(num)&&num%5==1){
      cout << num << ' ';
      count++;
    }
    num++;
    
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize "Ofast,omit-frame-pointer,inline"
using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define rep(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


int main() {

	REP(i, 5) {
		int a;
		cin >> a;
		if (a == 0) {
			cout << i + 1 << endl;
			return 0;
		}
	}


}

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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<double> p(N);
    for (int i = 0; i < N; i++)
        cin >> p[i];
    vector<double> E(N);
    double ans = 0.0;
    for (int i = 0; i < N; i++)
    {
        E[i] = (p[i] + 1.0) / 2.0;
        if (i < K)
            ans += E[i];
    }
    double e = ans;
    for (int i = 0; i < N - K; i++)
    {
        e = e + E[i + K] - E[i];
        ans = max(ans, e);
    }
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int fun(int a,int k){
	for(int i=1;;i++){
		a*=2;
		if(a>=k)return i;
	}
}
int n,k;
int main(){
	cin>>n>>k;
	double sum=0;
	for(int i=1;i<=n;i++){
		int tmp=fun(i,k);
		if(i<k)sum+=(1.0/n*pow(1.0/2,tmp));
		else sum+=1.0/n;
	}
	printf("%.12f",sum);
	return 0;
}

Measured memory_bytes: 384
#include"bits/stdc++.h"
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
#define ll long long
#define endl '\n'
//       Author
//        ::
//    (  NOBODY  )
//   No Copyright .....You can copy and paste it without my permission...................................
// !!!!!!!!!!!!!!!
#define pb push_back
#define N 300009
int a[N],b[N],c[N];
int dp[200080];
int node,edge;
vector<int>g[100003];
int do_it(int n)
{
    if(g[n].size()==0)return 0;
    if(dp[n]!=0)return dp[n];
    for(auto c:g[n])
    {
      dp[n]=max(dp[n],1+do_it(c));
    }
   return dp[n];
}
int main()
{
    FAST_IO;
    memset(dp,0,sizeof(dp));
    cin>>node>>edge;
    int ans=0;
    for(int i=0; i<edge; i++)
    {
        int x,y;
        cin>>x>>y;
        g[x].pb(y);
    }
    for(int i=1; i<=node; i++)
    {

        ans=max(ans,do_it(i));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
string s,t,b="~";//C-Dubious Document 2 
bool check(string a1,string b1)
{
	for(int i=0;i<a1.size();i++)
	{
		if(a1[i]!='?'&&a1[i]!=b1[i])
		{
			return false;
		}
	}
	return true;
}
int main()
{
	cin>>s>>t;
	for(int i=0;i<=(int)s.size()-(int)t.size();i++)
	{       
		string temp=s.substr(i,t.size());
		if(check(temp,t))
		{ 
			string tem=s;	
			for(int j=i;j<i+t.size();j++)
			{
				tem[j]=t[j-i];
			}
			for(int j=0;j<i;j++)
			{
				if(tem[j]=='?')
					tem[j]='a';
			}
			for(int j=i+t.size();j<tem.size();j++)
			{
				if(tem[j]=='?')
					tem[j]='a';				
			}	
			b=min(b,tem);					
		}
	}
	if(b=="~")
		cout<<"UNRESTORABLE";
	else
		cout<<b;
	return 0;		 
}

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

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

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};

int n;
int h[100010];
int dp[100010];

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;

	dp[0] = 0;
	for(int i=1;i<n;i++) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if(1 < i) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout<< dp[n - 1] <<endl;
	
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
H = list(map(int, input().split()))
flag = 0
No = 0
 
for i in range(N-1):
    diff = H[i+1]-H[i]   
    
    if diff < -1 or (diff == -1 and flag ==1):
        No = 1
    elif diff == -1 and flag == 0:
        flag = 1
    elif diff > 0:
        flag = 0    
        
if No == 0: print("Yes")
else: print("No")

Measured memory_bytes: 14252
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int numInput = sc.nextInt();
        int i;
        int living[][][] = new int[4][3][10];
        int b, f, r, v;
        for (i = 0; i < numInput; i++) {
            b = sc.nextInt() - 1;
            f = sc.nextInt() - 1;
            r = sc.nextInt() - 1;
            v = sc.nextInt();
            living[b][f][r] += v;
        }
        for (b = 0; b < 4; b++) {
            if (b != 0) System.out.println("####################");
            for(f = 0; f < 3; f++) {
                for(r = 0; r < 10; r++) {
                    System.out.print(" " + living[b][f][r]);
                }
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 29384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  string s,t; cin >> s >> t;
  bool ans = 1;
  rep(i,s.size()){
    if(s[i] != t[i]) ans = 0;
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        if((a+b)==c)
        {
            cout<<"Yes"<<endl;
        }
        else if((a+c)==b)
        {
            cout<<"Yes"<<endl;
        }
        else if((b+c)==a)
        {
            cout<<"Yes"<<endl;
        }
        else
        {
            cout<<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
B = []

job = {}
for _ in range(N):
  a, b = map(int, input().split())
  job.setdefault(b, []).append(a)
wa = 0
flag = 0
for k, v in sorted(job.items()):
  wa += sum(v)
  if k < wa:
    print("No")
    flag = 1
    break
if flag == 0:
  print("Yes")
    
  

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

int main() {
    int N, K;
    cin >> N >> K;
    int ans = K;
    for (int i = 1; i < N; i++){
        ans *= K - 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256