akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    #endif
    // int T;cin>>T;while(T--) 
    {
        ll x, y;
        cin>>x>>y;
        if(y&1) {
            cout<<"No\n";
            return 0;
        }
        ll t = 2*x - (y/2);
        // cout<<t<<endl;
        if(t<=x && t>=0) cout<<"Yes\n";
        else cout<<"No\n";
    }
    return 0;
}

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

const int INF = pow(2, 31) - 1;
#define ll long long
#define DEBUG(x) cout << "DEBUG>" << #x << ":" << x << endl;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main() {
  long long X, Y;
  cin >> X >> Y;
  int ans = 1;
  while(true) {
    X = 2 * X;
    if(X <= Y) {
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(){
    int n,x; cin>>n>>x;
    vector<int> l(n);
    vector<int> d(n);
    d[0]=0;
    int cnt=1;
    for(int i=1;i<=n;i++){
        int l; cin>>l;
        d[i]=d[i-1]+l;
        if(d[i]<=x) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    int pi,a[n];

    for(i=1; i<=n; i++)
    {
        scanf("%d",&pi);
        a[pi]=i;
    }
    for(i=1; i<=n; i++)
        printf("%d ",a[i]);

    printf("\n");     //:D
    return 0;
}


Measured memory_bytes: 1152
n,x = map(int,input().split())
L=list(map(int,input().split()))
 
cnt =0
pos =0
jp=[]
for i in range(len(L)+1):
  if pos<=x:
    cnt +=1
    jp.append(pos)
    if i<(len(L)):
      pos +=L[i]
    else:
      break
  else:
    break

print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
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 all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
typedef long long ll;
//
int main(){
   string s;cin>>s;
   int cou=0;
   for(auto e:s){
      if(e=='p')cou++;
   }
   int ans=s.size()/2-cou;
   cout<<ans<<endl;
}

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    for ( int j = N - 1; j >= i; j-- ) {
      if ( A[j].value < A[j - 1].value ) {
        Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    int minj = i;
    for ( int j = i; j < N; j++ ) {
      if ( A[j].value < A[minj].value ) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    if ( i > 0 ) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
  for ( int i = 0; i < N; i++ ) {
    if ( C1[i].suit != C2[i].suit ) return false;
  }
  return true;
}

int main() {
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    cin >> C1[i].suit >> C1[i].value;
  }
  for ( int i = 0; i < N; i++ ) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if ( isStable(C1, C2, N) ) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}

Measured memory_bytes: 3068
import java.io.*;
 
 
class Main{
  public static void main(String[] args)throws IOException{
     
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
 
    String[] strAry = str.split(" ");
     
    int x = Integer.parseInt(strAry[0]);
    int y = Integer.parseInt(strAry[1]);
 
    System.out.println(x*y +" "+ 2*(x+y));
  }
}

Measured memory_bytes: 24328
# -*- coding: utf-8 -*-

a, b = map(int, input().split())
count = 0
for v in range(a, b+1):
    t = str(v)
    n = len(t)
    if all([t[i] == t[n-i-1] for i in range(int(n/2))]):
        count += 1
print(count)

Measured memory_bytes: 3060
def main(M_1: int, D_1: int, M_2: int, D_2: int):
    print(M_2 - M_1)


if __name__ == "__main__":
    M_1, D_1 = map(int, input().split())
    M_2, D_2 = map(int, input().split())

    main(M_1, D_1, M_2, D_2)


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

bool cmp (pair < int, int > a, pair < int, int > b) {
  return a.second > b.second;
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n;
  cin >> n;
  vector < pair < int, int > > seqs(n);
  vector < pair < int, int > > begs, ends;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    stack < char > st;
    for (int j = 0; j < int(s.size()); ++j) {
      if (!st.empty()) {
        if (st.top() == '(' && s[j] == ')')
          st.pop();
        else
          st.push(s[j]);
      }
      else
        st.push(s[j]);
    }
    pair < int, int > seq = make_pair(0, 0);
    while (!st.empty()) {
      if (st.top() == ')')
        ++seq.first;
      else
        ++seq.second;
      st.pop();
    }
    seqs[i] = seq;
    if (seq.second - seq.first >= 0)
      begs.push_back(seq);
    else
      ends.push_back(seq);
  }
  sort(begs.begin(), begs.end());
  sort(ends.begin(), ends.end(), cmp);
  int b = 0;
  for (int i = 0; i < int(begs.size()); ++i) {
    b -= begs[i].first;
    if (b < 0) {
      cout << "No\n";
      return 0;
    }
    b += begs[i].second;
  }
  for (int i = 0; i < int(ends.size()); ++i) {
    b -= ends[i].first;
    if (b < 0) {
      cout << "No\n";
      return 0;
    }
    b += ends[i].second;
  }
  if (b == 0)
    cout << "Yes\n";
  else
    cout << "No\n";
}

Measured memory_bytes: 19064
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
typedef long long int ll;
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	if(a<=5){
		cout << "0" << endl;
    }else if(a<13){
		cout << b/2 << endl;
    }else{
		cout << b << endl;
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, int>Pair;
//union_find木テンプレ
//問いに応じて最大の頂点数を定めること
#define MAXN 100100
long int par[MAXN];//親番号
long int rank[MAXN];//木の深さ
long int siz[MAXN];//属する集団のサイズ
//初期化関数
void init(int n){
	rep(i,n){par[i]=i;::rank[i]=0;siz[i]=1;}
}
//木の根を求める関数
int find(int x){
	if(par[x]==x){return x;}
  	else{return par[x]=find(par[x]);}
}
//xとｙの集合を併合する関数
void unite(int x,int y){
	x=find(x);y=find(y);
	if(x==y)return;
	if(::rank[x]<::rank[y]){
    	par[x]=y;
      	siz[y]+=siz[x];
    }else{
    	par[y]=x;
      	siz[x]+=siz[y];
      	if(::rank[x]==::rank[y])::rank[x]++;
    }
}
//同じかどうかとサイズがいくらか。
bool same(int x, int y){return find(x)==find(y);}
int size(int x){return siz[find(x)];}

int main() {
    int N,M,K;
  	cin >>N>>M>>K;
  	init(N);
  	vector<vector<int>> dame(N);
  	rep(i,M){
    	int a,b;
    	cin>>a>>b;a--,b--;
      	unite(a,b);
      	dame.at(b).push_back(a);
      	dame[a].push_back(b);
    }
  	rep(i,K){
    	int c,d;
      	cin >>c>>d;c--,d--;
    	if(same(c,d)){
          dame[c].push_back(d);
          dame[d].push_back(c);
        }
    }
  //解答パート
  for(int i=0;i<N;i++){
   	cout<<size(i)-dame[i].size()-1<<" "; 
  }
}


Measured memory_bytes: 9856
import Data.List (tails)

main :: IO ()
main = getLine >> readInts >>= print . solve . reverse

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: [Int] -> Int
solve = length . filter headHighest . init . tails

headHighest :: [Int] -> Bool
headHighest (h:hs) = all (h >=) hs


Measured memory_bytes: 508
a = int(input())
X = [input() for i in range(a)]
ac = X.count('AC') 
wa = X.count('WA')
tle = X.count('TLE')
re = X.count('RE')
print('AC x', ac)
print('WA x', wa)
print('TLE x', tle)
print('RE x', re)

Measured memory_bytes: 16216
/*
    quid-pro-quo: LOGIC for AC
    written by: codercell07
    LANG: C++ 11
    Problem: random
*/
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(NULL)
#define testcases freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout)
#define ui unsigned int
#define ll long long
#define pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<ll>
#define vvll vector<vector<ll>>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define sz(x) (int)x.size()
#define pq priority_queue /*maxim at top(max-heap)*/
#define pqmax priority_queue<int, vector<int>, greater<int>> /*minim at top(min-heap)*/
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define asc(x) sort(all(x))
#define desc(x) sort(all(x), greater<int>())
#define time_el (double)time/CLOCKS_PER_SEC
using namespace std;
const int MAX=2e6; //dummy, make sure change as per constraints
const ll M=1e9+7, inf=1e18;
const char nl='\n';
 
ll apbmc(ll a, ll b, ll c){ a%=c; ll res=1; while(b){ if(b&1) res=res*a%c; a=a*a%c; b>>=1; } return res;}
ll apb(ll x, ll y){ ll temp; if(y==0) return 1;  temp=apb(x, y/2); if(y%2==0) return temp*temp;  else return temp*temp*x;}
 

void solve(){   
    //clock_t time;
    string s1, s2; cin>>s1>>s2;
    int n1=sz(s1), n2=sz(s2);
    vvi v(n1+1, vi(n2+1));
    for(int i=0; i<=n1; i++){
        for(int j=0; j<=n2; j++){
            if(i==0 or j==0){
                // do nothing
            }
            else{
                if(s1[i-1]==s2[j-1]){
                    v[i][j]=v[i-1][j-1]+1;
                }else{
                    v[i][j]=max({v[i-1][j-1], v[i][j-1], v[i-1][j]});
                }
            }
        }
    }
    int idx=v[n1][n2];
    vector<char> lcs(idx);
    int i=n1, j=n2;
    while(i>0 and j>0){
        if(s1[i-1]==s2[j-1])
            lcs[idx-1]=s1[i-1], idx--, i--, j--;
        else if(v[i-1][j]>v[i][j-1]) i--;
        else j--;
    }
    for(char c: lcs) cout<<c;
}
int main(){
    fastio;
    // #ifndef ONLINE_JUDGE
    //     testcases;
    // #endif // !DEBUG
    cout<<fixed<<setprecision(9);
    
    //int t; cin>>t; while(t--) solve();    
    solve();

    return 0;
}
//points to check:
//  * check for constraints, mainly array!
//  * EDGE CASES
//  * check for integer overflow, use long long!
//  * learn, do, solve, share something, NOW!

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

using namespace std;

bool cmp(pair<pair<int,int>,int> a, pair<pair<int,int>,int> b){
  if(a.first.first==b.first.first){
    if(a.first.second==b.first.second) return a.second > b.second;
    return a.first.second < b.first.second;
  }else return a.first.first > b.first.first;
}

int main(){
  int m,t,p,r;
  while(cin >> m >> t >> p >> r && (m || t || p || r)){
    vector<vector<int> > unc(t,vector<int>(p,0));
    vector<pair<int,int> > cntc(t,make_pair(0,0)),cost(t,make_pair(0,0));
    for(int i=0;i<t;++i) { cntc[i].second=i; cost[i].second=i; }
    for(int i=0;i<r;++i){
      int mi,ti,pi,ji; cin >> mi >> ti >> pi >> ji;
      if(ji==0) {
	cost[ti-1].first+=(mi + unc[ti-1][pi-1]*20);
	cntc[ti-1].first++;
      } else unc[ti-1][pi-1]++;
    }
    vector<pair<pair<int,int>,int> > rank(t);
    for(int i=0;i<t;++i) {
      rank[i].first.first=cntc[i].first;
      rank[i].first.second=cost[i].first;
      rank[i].second=i + 1;
    }
    sort(rank.begin(),rank.end(),cmp);
    cout << rank[0].second;
    for(int i=1;i<t;++i){
      if(rank[i-1].first.first==rank[i].first.first &&
	 rank[i-1].first.second==rank[i].first.second)
	cout << "=";
      else cout << ",";
      cout << rank[i].second;
    }
    cout << endl;
  }
}



Measured memory_bytes: 3176
import java.util.Scanner;

/**
 *
 * https://atcoder.jp/contests/abc158/tasks/abc158_a
 *
 * @author shouma
 *
 */

public class Main {
	public static void main(String args[]) {
		//strにはAかBの文字列が入る。(３文字)
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		//AAAのみやBBBのみだと、バスは運行しない→Noを出力
			if(str.contains("AAA") || str.contains("BBB")){
				System.out.println("No");
			}else {
				System.out.println("Yes");
			}
        scan.close();
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

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

    int n;
    cin >> n;

    vector< P > red(n), blue(n);
    rep (i, n) cin >> red[i].first >> red[i].second;
    rep (i, n) cin >> blue[i].first >> blue[i].second;

    sort(red.begin(), red.end(), greater<P>());
    sort(blue.begin(), blue.end());

    vector< bool > used(n, false);
    int ans = 0;
    rep (i, n)
    {
        int idx = -1;
        int ym = 300;
        rep (j, n)
        {
            if (!(used[j] || red[i].first >= blue[j].first || red[i].second >= blue[j].second))
            {
                if (ym > blue[j].second)
                {
                    ym = blue[j].second;
                    idx = j;
                }
            }
        }
        if (idx == -1) continue;
        ++ans;
        used[idx] = true;
    }

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



Measured memory_bytes: 256
x = int(input())


def prime_factorize(n):
    r = []
    while n % 2 == 0:
        r.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            r.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        r.append(n)
    return r


for i in range(x, x+100):
    l = prime_factorize(i)
    if i in l:
        l.remove(i)
    if not l:
        print(i)
        exit()

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

int main() {
  int N; cin >> N;
  string S; cin >> S;
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(S.substr(i, 3) == "ABC") ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{
    int k , s;
    std::cin >> k >> s;

    int ans = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int z = s - i - j;
            if(z >= 0 && z <= k){
                ans++;
            }
        }
    }
    std::cout << ans;
    return 0;
}




Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int a, b;
    cin >> a >> b;

    cout << (a + b) % 24 << '\n';


    return 0;
}

Measured memory_bytes: 3536
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
    int i=0;
    for(int j=0; j<k; j++) {
        llong s=0;
        while(s+T[i] <= P) {
            s += T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve() {
    llong left=0;
    llong right=100000 * 10000;
    llong mid;
    while(right-left>1) {
        mid = (left + right)/2;
        int v = check(mid);
        if(v>=n) right=mid;
        else left=mid;
    }
    
    return right;
}

int main() {
    cin >> n >> k;
    for (int i=0; i<n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    return 0;
}


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


int main() {
    int N, M;
    cin >> N >> M ;
    
    int xm, ym;
    cin >> xm >> ym;
    
    
    for (int i = 0; i<N; i++) {
        int get;
        cin >> get;
        xm = max(get, xm);
    }
    for (int i = 0; i<M; i++) {
        int get;
        cin >> get;
        ym = min(get, ym);
    }
    
    if (xm >= ym) {
        cout <<"War"<< endl;
    } else {
        cout <<"No War"<< endl;
    }
    
    return 0;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#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(){
  int n=0;
  bool flag = false;
  vector <vector<int>> a(3,vector<int>(3,0));
  rep(i,3)rep(j,3)cin >> a[i][j];
  cin >> n;
  vector <int> b(n);
  rep(i,n)cin >> b[i];
  rep(i,3)rep(j,3){
    rep(k,n)if(a[i][j]==b[k])a[i][j]=-1;
  }
  if(a[1][1]==-1){
    if(a[0][1]==a[2][1]&&a[0][1]==-1)flag = true;
    if(a[1][0]==a[1][2]&&a[1][0]==-1)flag = true;
    if(a[0][0]==a[2][2]&&a[0][0]==-1)flag = true;
    if(a[0][2]==a[2][0]&&a[0][2]==-1)flag = true;
  }
  if(a[0][0]==-1&&a[1][0]==-1&&a[2][0]==-1)flag = true;
  if(a[0][0]==-1&&a[0][1]==-1&&a[0][2]==-1)flag = true;
  if(a[2][0]==-1&&a[2][1]==-1&&a[2][2]==-1)flag = true;
  if(a[0][2]==-1&&a[1][2]==-1&&a[2][2]==-1)flag = true;
  if(flag)cout << "Yes" << endl;
  else cout << "No";
}


Measured memory_bytes: 256
function main()
  
  N = parse(Int,readline())
  
  dict = Dict()
  s = ""
  for i in 1:N
    s = collect(chomp(readline()))
    s = sort(s)
    dict[s] = get(dict,s,0)+1
  end
  
  ans = 0
  for i in values(dict)
    ans += div(i*(i-1),2)
  end
  
  println(ans)
  
end

main()

Measured memory_bytes: 159340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll power(ll a,ll b){
if(b==0)
    return 1;
if(b==1)
    return a;
ll t=power(a,b/2);
if(b%2==0)
    return t*t;
return a*t*t;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("ouput.txt","w",stdout);
    #endif // ONLINE_JUDGE
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    */

ll n,d;
cin>>n>>d;
ll ans=0;
while(n--){
    ll x,y;
    cin>>x>>y;
    ld te=sqrt(x*x+y*y);
    if(te<=(ld)d)
        ans++;
}
cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3676
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*
        PEOPLE'S LIVES DON'T END WHEN THEY DIE.
        IT ENDS WHEN THEY LOSE FAITH
                                     -ITACHI UCHIHA
        EXPLAINATION BELOW->
        SAME AS EDITORIAL
       
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
vector<pair<int,int>>Attack;
ll dp_health[10005];
ll recursion(ll h)
{
    if(dp_health[h]!=-1)return dp_health[h];
    else
    {
        ll ans=INT64_MAX;
        int i;
        for(i=0;i<sz(Attack);i++)
        {
            ll health=h-Attack[i].F;
            if(health<0)health=0;
            
            ans=min(ans,Attack[i].S+recursion(health));
        }
        dp_health[h]=ans;
    }
    return dp_health[h];
}
void solve()
{
  memset(dp_health,-1,sizeof(dp_health));
  dp_health[0]=0;
  int h,n,i,a,b;cin>>h>>n;
  fo(i,0,n)
  {
      cin>>a>>b;
      Attack.pb(mp(a,b));
  }
  recursion(h);
  cout<<dp_health[h]<<"\n";
}
int main()
{
   fastio
   solve();
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main()
{
	long long  n,m=0,h=0,a=0,r=0,c=0,sum=0;
	char s[105];
	scanf("%lld",&n);
	while(n--)
    {
        getchar();
        scanf("%s",s);
        if(s[0]=='M') m++;
        if(s[0]=='A') a++;
        if(s[0]=='R') r++;
        if(s[0]=='C') c++;
        if(s[0]=='H') h++;
    }
    //printf("%lld %lld %lld %lld %lld\n",m,a,r,c,h);
    sum+=m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+r*c*h+a*c*h;
	printf("%lld\n",sum);
 }


Measured memory_bytes: 128
while 1:
  H, W = map(int, raw_input().split())
  s = ""

  if H == 0 and W == 0:
    break

  for i in range(H):
    for j in range(W):
      if i%2 == 0:
        if j%2 == 0:
          s = s + "#"
        else:
          s = s + "."
      else:
        if j%2 == 0:
          s = s + "."
        else:
          s = s + "#"
    print s
    s = ""
  print ""

Measured memory_bytes: 6340
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    double dp[N+1][N+1] = {};//i枚投げたとき、j枚が表の確率
    dp[0][0] = 1;
    vector<double> V(N);
    rep(i,0,N)cin >> V[i];
    rep(i,0,N)rep(j,0,N){
        dp[i+1][j] += dp[i][j] * (1 - V[i]);
        dp[i+1][j+1] += dp[i][j] * (V[i]);
        //dp[i+1][j+1] = dp[i][j] * V[i] + dp[i][j+1] * (1 - V[i]);
    }
    double ans = 0;
    rep(i,N/2 + 1,N+1)ans += dp[N][i];
    //cout << ans << endl;
    printf("%.10lf\n",ans);
}

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

int main(void){
  while(1){
    int n, width, height, s, t;
    cin >> n;
    if(n == 0) return 0;
    cin >> width >> height;
    
    vector< vector<int> > grid(height, vector<int>(width, 0));
    for(int i=0; i < n; i++){
      int x, y; cin >> x >> y;
      grid[y-1][x-1] = 1;
    }
    cin >> s >> t;

    int ans = 0;
    for(int i=0; i <= height - t; i++){
      for(int j=0; j <= width - s; j++){
	int number = 0;
	
	for(int k=0; k < t; k++){
	  for(int l=0; l < s; l++){
	    if(grid[i+k][j+l] == 1){
	      number++;
	    }
	  }
	}
	if(number > ans){
	  ans = number;
	}
      }
    }
    cout << ans << endl;
  }
}
    

Measured memory_bytes: 1256
function main(input) {
  input=input.trim();
  const x1 = parseInt(input.split(" ")[0], 10);
  const y1 = parseInt(input.split(" ")[1], 10);
  const x2 = parseInt(input.split(" ")[2], 10);
  const y2 = parseInt(input.split(" ")[3], 10);
  console.log(x2+y1-y2);
  console.log(y2+x2-x1);

  console.log(x1+y1-y2);
  console.log(y1+x2-x1);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;
int n,m,s[2009],t[2009],dp[2009][2009];
signed main(){
    cin>>n>>m;
    for(int i=0;i++<n;)cin>>s[i];
    for(int i=0;i++<m;)cin>>t[i];
    for(int i=0;i++<n;)for(int j=0;j++<m;){
        dp[i][j]=dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
        if(s[i]==t[j])dp[i][j]+=dp[i-1][j-1]+1;
        (dp[i][j]+=mod)%=mod;
    }
    cout<<(dp[n][m]+1)%mod<<endl;
}

Measured memory_bytes: 31616
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define F first
#define S second
int main(void){
    ll n,m;
    cin>>n>>m;
    if(n==1){
        if(m==1)cout<<1<<endl;
        else cout<<m-2<<endl;
    }else if(m==1){
        if(n==1)cout<<1<<endl;
        else cout<<n-2<<endl;
    }else{
        cout<<(n-2)*(m-2)<<endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}


int main(){
    int A,B;
    cin >>A >>B;
    int ans;
    if(A<=5){
        ans=0;
    }else if(A<13){
        ans=B/2;
    }else{
        ans=B;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def find(x):
    if parents[x] != x:
        parents[x] = find(parents[x])
    return parents[x]

nv, ne = map(int, input().split(' '))
parents = [i for i in range(nv)]
edges = []
for i in range(ne):
    s, t, w = map(int, input().split(' '))
    edges.append((s, t, w))

sum = 0
forest = [[v] for v in range(nv)]
edges.sort(key=lambda tup: tup[2])
for s, t, w in edges:
    u = find(s)
    v = find(t)
    if u != v:
        parents[u] = v
        sum += w

print(sum)

Measured memory_bytes: 28120
N = int(input())
cnt = ['z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y']
ans2 = ''
for i in range(10**20):
  ans1 = cnt[N%26]
  ans2 = ans1 + ans2
  if N%26 == 0:
     N -= 1
  if N < 26:
    break
  N = N//26
print(ans2)

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

int main() {
  int N;
  
  cin >> N;
  
  int n1, n2, n3, n4;
  
  n1 = N % 10;
  n2 = (N % 100) / 10;
  n3 = (N % 1000) / 100;
  n4 = (N % 10000) / 1000;
  
  if ((n1 == n2 && n2 == n3) || (n2 == n3 && n3 == n4))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 384
def find(x):
    if parents[x] != x:
        parents[x] = find(parents[x])
    return parents[x]

nv, ne = map(int, input().split(' '))
parents = [i for i in range(nv)]
edges = []
for i in range(ne):
    s, t, w = map(int, input().split(' '))
    edges.append((s, t, w))

sum = 0
edges.sort(key=lambda tup: tup[2])
for s, t, w in edges:
    u = find(s)
    v = find(t)
    if u != v:
        parents[u] = v
        sum += w

print(sum)

Measured memory_bytes: 26696
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def solve(N: int, K: int, C: int, S: str):
    memo = [-1] * (N + 1)
    def rec(idx):
        if idx >= N:
            idx = N
            memo[idx] = 0
            return memo[idx]
        if memo[idx] >= 0:
            return memo[idx]
        if S[idx] == 'o':
            ret = 1 + rec(idx + C + 1)
        else:
            ret = rec(idx + 1)
        memo[idx] = ret
        return ret

    dp = [0] * (N + 1)
    for i in range(N):
        if memo[i] < 0:
            rec(i)
        dp[i + 1] = max(dp[i + 1], dp[i])
        if S[i] == 'o':
            if i - C < 0:
                tmp = 0
            else:
                tmp = dp[i - C]
            dp[i + 1] = max(dp[i + 1], tmp + 1)
    #print(memo)
    #print(dp)

    ret = []
    for i in range(N):
        if S[i] == 'o' and dp[i] + memo[i + 1] < K:
            ret.append(i + 1)
    if not ret:
        print('')
    for r in ret:
        print(r)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, K, C, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 219068
a,b,h,m = gets.split.map(&:to_i)

rh = (h + m / 60.0) * 2 * Math::PI / 12
rm = m * 2 * Math::PI / 60

xa = a * Math.sin(rh)
xb = b * Math.sin(rm)
ya = a * Math.cos(rh)
yb = b * Math.cos(rm)
puts Math.sqrt((xa - xb)**2 + (ya - yb)**2)


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0;i<N;i++)cin >> H.at(i);

    // 端の旅館からは必ず海が見れる
    int num_viewable = 1;

    for(int i=1;i<N;i++){
        bool f_viewable = true;
        for(int j=0;j<i;j++){
            if(H.at(i)<H.at(j))f_viewable = false;
        }
        if(f_viewable)num_viewable++;
    }

    cout << num_viewable << endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

//-----------------------ここから-----------


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

    vector<int> h(n);

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

    int ans = 0;
    while(true){
        int maximum = 0;
        for(int i = 0; i < n; i++){
            maximum = max(maximum, h[i]);
        }
        if(maximum == 0)break;

        int i = 0;
        while(i < n){
            if(h[i] == 0){
                i++;
            } else {
                ans++;
                while(h[i] > 0 && i < n){
                    h[i]--;
                    i++;
                }
            }
        }
    }

    cout << ans << endl;

    
}



Measured memory_bytes: 256
import numpy as np

s = input().split()
N = int(s[0])
D = int(s[1])
X=np.empty((0,D),int)
count=0
# X=[[]*int(s[1])]*int(s[0])
for i in range(0,N):
    s = input().split()
    X=np.append(X,np.array([s],dtype='int16'),axis=0)

for i in range(0, N-1):
    for j in range(i+1,N):
        if np.sqrt(np.sum(np.square(X[i]-X[j]))).is_integer()==True:
            count+=1

print(count)

Measured memory_bytes: 12396
import Data.List

main = do
  k <- readLn :: IO Integer


  print 50
  putStrLn $ unwords . map show $
    zipWith3 (\a b c -> a+b+c)
    (replicate 50 (49+k`div`50))
    (replicate 50 (-k`mod`50))
    (replicate (fromIntegral $ k`mod`50) 51 ++ replicate (50 - (fromIntegral $ k`mod`50)) 0)
  


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

int main() {
	int s,i,j,x,y,c[15][15],d[17][15];
	while(cin >> x >> y) {
		if (x+y==0) break;
		for (i=0;i<y;i++) for (j=0;j<x;j++) cin >> c[i][j];
		for (i=0;i<y+2;i++) for (j=0;j<x;j++) d[i][j]=(i==0);
		for (i=0;i<y-1;i++) for (j=0;j<x;j++) {
			s=d[i][j];
			if (c[i][j]==0) { 
				if (j>0) if (c[i+1][j-1]==0) d[i+1][j-1]+=s;
				if (j<x-1) if (c[i+1][j+1]==0) d[i+1][j+1]+=s;
				if (c[i+1][j]!=1) d[i+1][j]+=s;
			}
			if (c[i][j]==2 && c[i+2][j]!=1) d[i+2][j]+=s;
		}
		s=0;
		for (i=y-1;i<=y;i++) for (j=0;j<x;j++) s+=d[i][j];
		if (y==1) { s=0; for (i=0;i<x;i++) s+=(c[0][i]==0);}
		cout << s << endl; 
	 }
	return 0;
}

Measured memory_bytes: 1160
#include"bits/stdc++.h"
using namespace std;
int main(){
	int m,n;
	cin>>m>>n;
	set<char> x;
	char temp;
	for(int i=0;i!=n;++i){
		cin>>temp;
		x.insert(temp);
	}
	while(1){
		bool check=true;
		string s=to_string(m);
		for(auto i:s){
			if(x.find(i)!=x.end()){
				check=false;
				break;
			}
		}
		if(check)
			break;
		else
			++m;
	}
	cout<<m;
}

Measured memory_bytes: 256
#include<stdlib.h>
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<cstring>
#include<time.h>
#include<queue>
using namespace std;
#define INF 100000
char map[1001][1001];
int h,w,n;
int d1[4]={0,1,0,-1};
int d2[4]={1,0,-1,0};
int i,j,x[10],y[10];
int bfs(int num){
	int gy=y[num+1],gx=x[num+1];
	int d[1001][1001];
	for(int i=0;i<1001;i++){
		for(int j=0;j<1001;j++){
			d[i][j]=INF;
		}
	}
	queue<int> qx;queue<int> qy; 
	qx.push(x[num]);qy.push(y[num]);
	d[y[num]][x[num]]=0;
	while(qx.size()+qy.size()!=0){
		int ny,nx;
		ny=qy.front();qy.pop();
		nx=qx.front();qx.pop();
		if(ny==gy&&nx==gx){
			break;
		}
		for(int i=0;i<4;i++){
			int mx=nx+d1[i],my=ny+d2[i];
			if(0<=mx&&mx<w&&0<=my&&my<h&&map[my][mx]!='X'&&d[my][mx]==INF){
				d[my][mx]=d[ny][nx]+1;
				qx.push(mx);
				qy.push(my);
			}
		}
	}
	return d[gy][gx];
}
int main(){
	int ans=0;
	cin>>h>>w>>n;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>map[i][j];
			if(map[i][j]=='S'){
				y[0]=i;x[0]=j;
			}else if('0'<map[i][j]&&map[i][j]<='9'){
				y[(int)(map[i][j]-'0')]=i;
				x[(int)(map[i][j]-'0')]=j;
			}
		}
	}

	for(int i=0;i<n;i++){
		ans+=bfs(i);
	}
	
	cout<<ans<<endl;
	return 0;
}	

Measured memory_bytes: 6104
package main
 
import "fmt"
 
func main() {
  var a int
  x := 0
  fmt.Scanf("%d",&a)
  if a % 10 == 1 {
    x += 1
  }
  a /= 10	
  if a % 10 == 1 {
    x += 1
  }
  a /= 10	
  if a % 10 == 1 {
    x += 1
  }

  fmt.Print(x)
}

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

string table[10] = {
    "",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        string s;
        cin >> s;
        int idx = 0, cnt = -1, chr = 0;
        string t = "";
        while(idx < s.size()){
            if(s[idx] == '0'){
                if(chr != 0)t.push_back(table[chr][cnt%table[chr].size()]);
                cnt = -1;
                chr = 0;
                idx++;
            }else{
                chr = s[idx] - '0';
                while(s[idx] == chr + '0' && idx < s.size()){
                    idx++;
                    cnt++;
                }
            }
        }
        cout << t << endl;
    }

    return 0;
}


Measured memory_bytes: 2988
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define isu isupper
#define isl islower
#define lb(a,k) lower_bound(all(a),k)
#define ub(a,k) upper_bound(all(a),k)
#define bs(a,k) binary_search(all(a),k)

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;



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

    msi m;
    string st[] = {"AC", "WA", "TLE", "RE"};
    rep (i, N) {
        string s;
        cin >> s;
        m[s]++;
    }

    rep (i, 4) cout << st[i] << " x " << m[st[i]] << endl;
}


Measured memory_bytes: 3612
import itertools
r,g,b,n = map(int,input().split())
r_max,g_max,b_max = int(n/r),int(n/g),int(n/b)
ans = 0
for i,j in itertools.product(range(0,r_max+1),range(0,g_max+1)):
  if (n - (i*r+j*g))%b == 0 and n - (i*r+j*g) >= 0:
    ans+=1
print(ans)

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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define count(v,x) count(v.begin(),v.end(),x)
#define find(v,x) find(v.begin(),v.end(),x)


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

void solve(){
    string s;
    cin >> s;
    int ans=0;
    int len=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'|| s[i]=='C' || s[i]=='G' || s[i]=='T'){
            len++;
            ans=max(len,ans);
        }
        else{
            len=0;
        }
    }
    cout << ans << endl;

}

int main(){
    solve();
    return 0;
}





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

using namespace std;
typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,t;
  cin >> a >> b >> t;
  ll n=t/a;
  cout<<(b*n)<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main () {
    char num[1000];

    cin >> num;

    if ( num[2] == num[3] && num[4] == num[5] ) {
        cout << "Yes" << endl;   
    }
    else {
        cout << "No" << endl;   
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    int n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    ll a[3] = {};
    for(auto x : s)a[x%3]++;
    ans = a[0] * a[1] * a[2];
    for(int j = 1; j < n - 1; j++){
        int i = j - 1;
        int k = j + 1;
        while(i >= 0 and k < n){
            if(s[i] != s[j] and s[j]!= s[k] and s[i]!= s[k])ans--;
            i--;
            k++;
        }
    }
    cout << ans << endl;
}


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

int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  string str;
  cin >> str;
  if(str == "Sunny") cout << "Cloudy" << endl;
  else if(str == "Cloudy") cout << "Rainy" << endl;
  else cout << "Sunny" << endl;
  return 0;
}


/*





















*/


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

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

  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a,a+3);
  if(a[0] == a[2]){
    cout << 1 << endl;
    return 0;
  }
  else if(a[0] == a[1] || a[1] == a[2]){
    cout << 2 << endl;
    return 0;
  }
  else{
    cout << 3 << endl;
  }
}

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

std::string S, T;
std::string ans;
std::vector<std::string> aaa;
int main() {
	std::cin >> S >> T;
	int t = T.size();
	int s = S.size();
	bool good = false;
	for (int i = S.size()- t; i >= 0; i--) {
		ans = S;
		bool kk = true;
		for (int j = 0; j < t; j++) {
			if (S[i+j] == '?') {
				continue;
			}
			else if (S[i + j] != T[j]) {
				kk = false;
			}
		}
		if (kk) {
			good = true;
			for (int k = 0; k < i; k++) {
				if (S[k] == '?')ans[k] = 'a';
				else ans[k] = S[k];
			}
			for (int k = 0; k < t; k++) {
				ans[k + i] = T[k];
			}
			for (int k = i + t; k < s; k++) {
				if (S[k] == '?')ans[k] = 'a';
				else ans[k] = S[k];
			}
			aaa.push_back(ans);
		}
	}
	std::sort(aaa.begin(), aaa.end());
	std::cout << (good ?aaa[0]:"UNRESTORABLE") << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define substr(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll k;
  cin>>k;
  if(k<=(ll)2*(1e16)){
    cout<<2<<endl;
    if(k%2){
      cout<<k/2+2<<" "<<k/2<<endl;
    }else{
      cout<<k/2+1<<" "<<k/2<<endl;
    }
  }else{
    ll num=k/((ll)(1e16));
    if(k%((ll)(1e16))){
      num++;
    }
    num=50;
    vvi list(100);
    ll now=0;
    for(int i=0;i<num;i++){
      for(int j=0;j<num;j++){
	list[i].pb(now);
	now=(now+1)%(num+1);
      }
    }
    /*    for(int i=0;i<num;i++){
      for(int j=0;j<num;j++)
	cout<<list[i][j]<<" ";
      cout<<endl;
      }*/
    //cout<<k%num<<endl;
    cout<<num<<endl;
    for(int i=0;i<num;i++){
      cout<<list[k%num][i]+(k/num)<<" ";
    }
    cout<<endl;
  }
  return 0;
}


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

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	long long h[n];
	for(int i=0;i<n;i++){
		scanf("%lld",&h[i]);
	}
	sort(h,h+n);
	long long ans=0;
	for(int i=0;i<n-k;i++){
		ans+=h[i];
	}
	printf("%lld",ans);
}

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

ll f(ll a) {
  if (a%4==0) return a;
  if (a%4==1) return 1;
  if (a%4==2) return a+1;
  return 0;
}

int main() {
  ll a,b; cin>>a>>b;
  cout<<(f(b)^f(a-1))<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define MAXI(vec)                                                              \
  std::distance(vec.begin(), *std::max_element(vec.begin(), vec.end()));
#define MINI(vec)                                                              \
  std::distance(vec.begin(), *std::min_element(vec.begin(), vec.end()));
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define MATMUL(a, b, c)                                                        \
  REP(i, a.size())                                                             \
  REP(j, b[0].size()) REP(k, a[0].size()) c[i][j] ^= a[i][k] & b[k][j];
#define CLA2(a) REP(i, a.size()) REP(j, a[0].size()) a[i][j] = 0;

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

int main() {
  ll N = 0, x = 0, y = 0, ans = 0;
  vector<ll> A;
  cin >> N >> x;
  REP(i, N) {
    ll po = 0;
    cin >> po;
    A.push_back(po);
  }
  sort(ALL(A));
  REP(i, N) {
    y += A[i];
    if (y > x) {
      break;
    } else {
      ans++;
    }
  }
  if (x > y)
    ans--;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {
  def revP(l:List[String],stack:List[Int]):Int =  {
    l match {
      case Nil => stack(0)
      case hd::tl =>
        val stack2 =
          if(hd!="+" && hd!="-" && hd!="*") hd.toInt::stack
          else {
            val x::y::tail = stack
            if(hd=="+") (y+x)::tail
            else if(hd=="-") (y-x)::tail
            else if(hd=="*") (y*x)::tail
            else Nil
          }
        revP(tl,stack2)
    }
  }

  def main(args:Array[String]) = {
    val l = readLine.split(" ").toList
    println(revP(l,Nil))
  }
}

Measured memory_bytes: 43648
#include <iostream>

int main(void){
  int radius,weigh,height,x,y;
  std::cin >> weigh >> height >> x >> y >> radius;
  if(x + radius <= weigh && y + radius <= height){
    if(x - radius >= 0 && y - radius >= 0){
      std::cout << "Yes\n";
      return 0;
    }
  }
  std::cout << "No\n";
  return 0;
}


Measured memory_bytes: 3100