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

#define ld			long double
#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD         1000000007
#define sd(t) 		scanf("%d",&(t))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define hii 		cout << "hii" << endl
#define okay 		cout << "okay" << endl
#define hey 		cout << "hey" << endl

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 
 
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
} 

clock_t time_p=clock();
void starboy1299()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}

const int mod = 1e9+7;
const int N = 1e3+5;
const int inf = 1e18;

void solve()
{
    int x;
    cin >> x;

    int t = 1;
    double pri = 100;
    double rate = 1.01;
    int amount = 100;
    while(amount < x){
        pri = amount*rate;
        amount = pri;
        t++;
    }

    cout << t-1 << endl;

}			 	      		        

int32_t main(){
	fast();
    int t = 1;
    // cin>> t;
    for(int i=1; i<=t; i++){
    	// cout << "Case #" << i << ": ";
    	solve();
    }
    starboy1299();
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

void solve(){
	int x, y;
	cin >> x >> y;
	int ans = max(0, 4 - x) * 100000 + max(0, 4 - y) * 100000;
	if (x == 1 && y == 1) {
		ans += 400000;
	}
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
from collections import defaultdict

N, M = map(int, input().split())
yp = []
d = defaultdict(lambda: [])
ans = ['' for _ in range(M)]
for i in range(M):
    p, y = input().split()
    d[int(p)].append([i, int(y)])


for key in d.keys():
    d[key].sort(key = lambda x : x[1])
    num = 1
    for i in range(len(d[key])):
        ans[d[key][i][0]] += '{:0=6}'.format(key) \
                + '{:0=6}'.format(num) 
        #print('city: ' + str(d[key][i][0]) + ', prefecture: ' + str(key) + ', n-th:', str(i + 1))
        num += 1

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


Measured memory_bytes: 47896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int N){
        par.assign(N,0);
        rank.assign(N,0);
        REP(i,N) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]) swap(x,y);

        //x becomes root
        par[y]=x;
        if(rank[x]==rank[y]) rank[x]++;
    }
};

const int MAX_N = 100010;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    UnionFind uf(MAX_N*2);
    REP(i,N){
        int x,y; cin >> x >> y;
        uf.unite(x,y+MAX_N);
    }
    map<int,LL> mx,my;
    for(int i = 0; i < MAX_N; i++){
        mx[uf.find(i)]++;
    }
     for(int i = MAX_N; i < 2*MAX_N; i++){
        my[uf.find(i)]++;
    }
    LL ans = 0;
    for(int i = 0; i < 2*MAX_N; i++){
        ans += mx[i] * my[i];
    }
    cout << ans - N << endl;


}

Measured memory_bytes: 26880
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

int mod = 1e9 + 7;

ll powMod(ll a, ll n){
	ll ans = 1LL;
	a %= mod;
	while(n > 0){
		if(n&1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		n /= 2; 
	}
	return ans % mod;
}

void solution(){

	ll n; cin >> n;
	vector<vector<ll>> p;
	for(int i = 0 ; i < n; i++){
		ll x, y; cin >> x >> y;
		p.push_back({x,y});
	}
	sort(all(p));
	vector<ll> sum(n), diff(n);
	for(int i = 0; i < n; i++){
		sum[i] = p[i][0] + p[i][1];
		diff[i] = p[i][0] - p[i][1];
	}

	ll mnd = *min_element(all(diff));
	ll mns = *min_element(all(sum));
	ll mxd = *max_element(all(diff));
	ll mxs = *max_element(all(sum));

	ll ans = max(mxd - mnd, mxs - mns);

	cout << ans << endl;


}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 17408
X,Y = input().split(" ")
c = 10
dic = dict()
for i in ['A','B','C','D','E','F']:
    dic[i] = c
    c+=1

if dic[X] < dic[Y]:
    print("<")
elif dic[X] == dic[Y]:
    print("=")
else:
    print(">")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int n = sc.nextInt();
		int a[] = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}
		int idx1 = 0;
		int idx2 = 0;
		int map[][] = new int[h][w];
		for (int i = 0; i < h; i++) {
			if (i % 2 == 0) {
				for (int j = 0; j < w; j++) {
					map[i][j] = idx1 + 1;
					idx2++;
					if (a[idx1] == idx2) {
						idx1++;
						idx2 = 0;
					}
				}
			} else {
				for (int j = w - 1; j >= 0; j--) {
					map[i][j] = idx1 + 1;
					idx2++;
					if (a[idx1] == idx2) {
						idx1++;
						idx2 = 0;
					}
				}
			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (j == 0) {
					sb.append(map[i][j]);
				} else {
					sb.append(" " + map[i][j]);
				}
			}
			sb.append("\n");
		}
		System.out.print(sb);
	}
}

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

int main(){
	string s;

getline(cin, s);
	for(int i = 0; i < s.size(); i++){
		if(s[i] >= 'a' && s[i] <= 'z')
		s[i] -= 'a' - 'A';
	}
	cout << s << endl;



}

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

int main(){
  
  int a;
  cin >> a;
  
  if( a%2 == 0 ){
    
    cout << a/2 << endl;
    
  }
  
  
  else{
    
    cout << a/2 + 1 << endl;
    
  }
  
}


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

const bool DEBUG = false;

int main(int argc, char const *argv[]) {
  int N;
  cin >> N;
  Table A(N, vector<int>(N - 1));
  for (size_t i = 0; i < N; i++) {
    for (size_t j = 0; j < N - 1; j++) {
      cin >> A[i][j];
    }
  }

  if (DEBUG) {
    for (size_t i = 0; i < N; i++) {
      for (size_t j = 0; j < N - 1; j++) {
        cout << A[i][j] << ", ";
      }
      cout << endl;
    }
  }

  int total = N * (N - 1);
  int days = 0;
  bool not_finished = true;
  vector<int> matched;
  while (not_finished) {
    bool found = false;
    matched.clear();
    for (size_t i = 0; i < N; i++) {
      // if (matched.find(i) != matched.end()) continue;
      if (A[i].size() == 0) continue;
      int opponent = A[i][0] - 1;
      if (DEBUG) cout << i + 1 << " vs " << opponent + 1 << endl;
      // if (A[opponent].size() == 0) {
      //   cout << "-1" << endl;
      //   return 0;
      // }
      if (i == A[opponent][0] - 1) {
        if (DEBUG) cout << "found" << endl;
        found = true;
        matched.push_back(i);
        // matched.insert(i);
        // matched.insert(opponent);
      }
    }
    total -= matched.size();
    for (auto &&player : matched) A[player].erase(A[player].begin());

    if (!found) {
      cout << "-1" << endl;
      return 0;
    }
    if (DEBUG) cout << "total: " << total << endl;
    not_finished = total > 0;
    days++;
  }

  cout << days << endl;

  return 0;
}


Measured memory_bytes: 6272
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class UnionFindTree
{
    vector<int> parent;
    vector<int> diff;
    pair<int, int> find(int x){
        if(parent[x] == x)
            return make_pair(x, 0);
        pair<int, int> p = find(parent[x]);
        parent[x] = p.first;
        diff[x] += p.second;
        return make_pair(parent[x], diff[x]);
    }
public:
    UnionFindTree(int n){ // コンストラクタ
        parent.resize(2*n);
        for(int i=0; i<n; ++i){
            parent[i]   = n + i;
            parent[n+i] = n + i;
        }
        diff.assign(2*n, 0);
    }
    void unite(int x, int y, int c){
        int x2 = find(x).first;
        int y2 = find(y).first;
        if(x2 != y2){
            parent[x2] = y2;
            diff[x2] = c - diff[x] + diff[y];
            find(x);
        }
        diff[x] -= c;
        diff[y] -= c;
    }
    int getDiff(int x, int y)
    {
        pair<int, int> p1 = find(x);
        pair<int, int> p2 = find(y);
        if(p1.first == p2.first)
            return p1.second - p2.second;
        else
            return INT_MAX;
    }
};

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

    UnionFindTree uft(n);
    while(--q >= 0){
        string s;
        int a, b;
        cin >> s >> a >> b;
        -- a;
        -- b;

        if(s == "IN"){
            int c;
            cin >> c;
            uft.unite(a, b, c);
        }
        else{
            int ret = uft.getDiff(a, b);
            if(ret == INT_MAX)
                cout << "WARNING" << endl;
            else
                cout << ret << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 2592
// Problem : C - Traveling Plan
// Contest : AtCoder Regular Contest 093
// URL : https://atcoder.jp/contests/arc093/tasks/arc093_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define cerr if(1)cerr
#define size(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define sort(a, n) sort(a + 1, a + n + 1)
#define temptts template <class T, class... Ts>

const int N = 1e6 + 1, mod = 1e9 + 7, inf = 2e9;

int n, ans = 0, a[N];

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		ans += abs(a[i] - a[i - 1]);
	}
	ans += abs(a[n]);
	for (int i = 1; i <= n; i++) {
		cout << ans - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]) << '\n';
	}
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    vector<vector<char>> a(h+2,vector<char>(w+2,'#'));
    FOR(i,1,h+1){
        FOR(j,1,w+1){
            cin>>a[i][j];
        }
    }
    FOR(i,0,h+2){
        FOR(j,0,w+2){
            cout<<a[i][j];
        }
        cout<<'\n';
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string S,T,U;
    int A,B;
    cin>>S>>T>>A>>B>>U;
    if(S==U) cout<<A-1<<" "<<B<<endl;
    else cout<<A<<" "<<B-1<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <numeric>
#include <map>
#include <sstream>
#include <bitset>
using namespace std;


int main()
{
    string S;
    cin>>S;
    string ans="";
    int counter=0;
    for(int i=0;i<S.size();i++){
        int count=0;
        string answer="";
        for(int j=i;j<S.size();j++){
            if(S[j]=='A'||S[j]=='T'||S[j]=='G'||S[j]=='C'){
                answer+=S[j];
                count+=1;
            }
            else{
                break;
            }
        }
    
        if(count>counter){
            ans=answer;
            counter=count;
        }
    }
    
    cout<<ans.size()<<endl;
    
    
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC127_a solver = new ABC127_a();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC127_a {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int B = in.nextInt();

            if (A <= 5) {
                out.println(0);
                return;
            }
            if (A >= 13) {
                out.println(B);
                return;
            }
            if (A <= 12) {
                out.print(B / 2);
                return;
            }
        }

    }
}



Measured memory_bytes: 21204
#include <iostream>
using namespace std;
 
int main() {
    string s;
    cin >> s;
 
    int N = s.size();
 
    static int opt[1 << 26];
    for (int mask = 0; mask < (1 << 26); mask++) opt[mask] = 1 << 28;
 
    opt[0] = 0;
    static int dp[300000];
    int mask = 0;
    for (int i = 0; i < N; i++) {
        mask ^= 1 << (s[i] - 'a');
        dp[i + 1] = opt[mask] + 1;
        for (int j = 0; j < 26; j++) {
            dp[i + 1] = min(dp[i + 1], opt[mask ^ (1 << j)] + 1);
        }
 
        opt[mask] = min(opt[mask], dp[i + 1]);
    }
    cout << dp[N] << endl;
 
    return 0;
}

Measured memory_bytes: 263556
n, k = gets.split(" ").map(&:to_i)
array = gets.split(" ").map(&:to_i).map{|n| (1 + n) / 2.to_f }
rerult_sum = array[0..(k-1)].inject(:+)
array_add = [rerult_sum]

(n - k).times do |i|
    rerult_sum -= array[i]
    rerult_sum += array[i+k]
    array_add << rerult_sum
end

puts array_add.max


Measured memory_bytes: 18052
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define li long long int
#define ld long double
#define eb push_back
#define pb pop_back
#define INF 1e18+10
#define MINF -1e18-10
#define rep(i,a,b) for(li i=a;i<b;i++)
#define size(a) a.size()
#define rev(a) reverse(a.begin(),a.end())
#define len(a) a.length()
#define f first
#define s second
#define sort(a) sort(a.begin(),a.end())
#define vli vector<li>
#define vvli vector<vli >
#define pli pair<li,li>199
#define vpli vector<pli>
#define inp(t) li t;cin>>t; while(t--)
using namespace std;
const li mod = 1e9+7;
const long int MAXN = 2e5+100;
#define PI 3.14159265358979323846264338327950

li power(li a, li b) { a%=mod; li ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
li add(li a,li b) { return (((a%mod)+(b%mod))%mod);}
li sub(li a,li b) { return (((a%mod)-(b%mod))%mod);}
li mul(li a,li b) { return (((a%mod)*(b%mod))%mod);}

// vector<li> v[MAXN];
// li ances[MAXN];
// bool visited[MAXN];
// li n,m;

// void bfs(li node)
// { 
//    queue <li> q;
//    q.push(node);

//    visited[node] = true;
//    n-=1;
   
//    while (!q.empty()) 
//    {
//       li u = q.front(); 
//       q.pop();
//       for(li j = 0;j < (li)size(v[u]);j++) 
//       {
//          li nodes = v[u][j];
         
//          if (!visited[nodes]) 
//          {
//             n-=1;
//             ances[nodes] = u;
//             q.push(nodes);
//             visited[nodes] = true;
//          }
//       }
//    }
// }

void solve()
{
   li n;
   cin>>n;

   li aa,bb,cc;
   cin>>aa>>bb>>cc;

   rep(i,1,n)
   {
     li a,b,c;
     cin>>a>>b>>c;

     li x = max(a+bb,a+cc);
     li y = max(b+aa,b+cc);
     li z = max(c+aa,c+bb);

     aa = x;
     bb = y;
     cc = z;
   }
   
   cout<<max(aa,max(bb,cc))<<endl;

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

Measured memory_bytes: 256
inf=float("inf")
v,e=map(int,input().split())
STD=[list(map(int,input().split())) for _ in range(e)]

D=[[inf for _ in range(v)] for _ in range(v)]
for s,t,d in STD:
    D[s][t]=d

DP=[[-1 for _ in range(v)] for _ in range(1<<v)]


def bitDP(s,g,DP):
    if DP[s][g]>=0:return DP[s][g]
    if s==(1<<v)-1 and g==0:
        DP[s][g]=0
        return 0

    ans=inf
    for i in range(v):
        if (s>>i & 1)==0:
            ans=min(ans,bitDP(s|(1<<i),i,DP)+D[g][i])
    DP[s][g]=ans
    return ans


ans=bitDP(0,0,DP)
print(ans if ans!=inf else -1)


Measured memory_bytes: 15968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

VI pm;
int n;

int main() {
	pm.push_back( 2 );
	for ( int i = 3; i < 50000; i += 2 ) {
		bool can_add = true;
		for ( int j = 0; j < pm.size() && sq(pm[j]) <= i; j++ ) {
			if ( i % pm[ j ] == 0 ) {
				can_add = false;
				break;
			}
		}
		if ( can_add ) {
			pm.push_back( i );
		}
	}
	while ( ~scanf("%d", &n) && n ) {
		int ans = 0;
		for ( int i = 0; i < pm.size() && pm[i] <= n / 2; i++ ) {
			ans += binary_search( pm.begin(), pm.end(), n - pm[ i ] );
		}
		printf( "%d\n", ans );
	}
	return 0;
}

Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 605000
#define inf (int)1e9
#define ll long long
#define eps 1e-9
#define mm 1000000007ll
#define low(x) x&(-x)
#define pb push_back
#define mp make_pair
#define PII pair<int,int>
using namespace std;
ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
int n;
ll ans=1;
char s[3][505];
int main(){
//	freopen("in.txt","r",stdin);
//	freopen("1.txt","w",stdout);
	n=read();
	scanf("%s",s[1]+1);
	scanf("%s",s[2]+1);
	int now=1,pre=0,ans=1;
	while (now<=n){
		if (s[1][now]==s[2][now]){
			if (pre==0) ans=ans*3LL%mm;
			if (pre==1) ans=ans;
			if (pre==2) ans=ans*2ll%mm; 
			pre=2;
			now++;
		}
		else {
			if (pre==0) ans=ans*6ll%mm;
			if (pre==1) ans=ans*3ll%mm;
			if (pre==2) ans=ans*2ll%mm;
			pre=1;
			now+=2;
		}
	}
	printf("%lld\n",ans%mm);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

long double getRadian(double x, double y, double x2, double y2) {
	double radian = atan2(y2 - y, x2 - x);
	return radian;
}

int n;

signed main() {
	cin >> n;
	cout << (n - 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(),a.end());
  int sum = 0;
  for (int i = 0; i < N; i++){
    sum += a[i];
    if (x < sum){
      cout << i;
      break;
    }
  }
  if (x > sum){
    cout << N - 1;
  } else if (x == sum){
    cout << N;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<numeric>
#include<algorithm>
#include<complex>
#include<queue>
#include<stdlib.h>
#include<map>
#include<cmath>
#include<stdio.h>
#include<stdlib.h>
#include<set>

#define ll long long
#define MOD 1000000007

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N);
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        cin >> B[i];
    }
    for(int i=0;i<N;i++){
        cin >> C[i];
    }
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    sort(C.begin(),C.end());
    ll a_num,c_num;
    ll ans=0;
    for(int i=0;i<N;i++){
        auto itra = lower_bound(A.begin(),A.end(),B[i]);
        auto itrc = upper_bound(C.begin(),C.end(),B[i]);
        a_num=itra-A.begin();
        c_num=C.end()-itrc;
        ans+=a_num*c_num;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll n,m,s,c;
	cin>>n>>m;
	vector<int> arr(n,-1);
	vector<bool> ok(n,1);
	bool tmp=1;
	map<ll,ll> mp;
	for(auto i=0;i<m;++i){
		cin>>s>>c;
		if(ok[s-1]){
			arr[s-1]=c;
			ok[s-1]=0;
			mp[s-1]=c;
		}
		if(!ok[s-1] && mp[s-1]!=c)tmp=0;
	}
	for(auto i=0;i<n;++i){
		if(ok[i]){
			if(i==0)arr[i]=1;
			else
				arr[i]=0;
		}
	}
	if(arr[0]==0 && n>1){
		cout<<"-1\n";
		return 0;
	}
	else
		if(n==1 && ok[0]){cout<<0<<'\n'; return 0;}
	if(tmp){
		for(auto i=0;i<n;++i)cout<<arr[i];
	}
	else
		cout<<"-1";
	cout<<'\n';
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

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

N=[0]*3
m=[0]*3

N[0]=int(n/10)
N[1]=int(N[0]/10)
N[2]=int(N[1]/10)

m[0]=int(n%10)
m[1]=int(N[0]%10)
m[2]=int(N[1]%10)

for i in range(0,3):
    if m[i]==1:
        m[i]=9
    elif m[i]==9:
        m[i]=1

print(int(m[2]*100+m[1]*10+m[0]))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(){
    ll X, y;
    cin >> X;
    ll c = 0;
    while(1){
        if(X >= 500){
            X = X-500;
            c += 1000;
        }
        else if(X >= 5){
            X = X-5;
            c += 5;
        }
        else{
            break;
        }
    }

    cout << c << endl;
}

Measured memory_bytes: 256
import numpy as np
S = input()
mcount = np.zeros(2)
s1 = int(S[0])
s2 = int(S[1]) 
s3 = int(S[2]) 
s4 = int(S[3])
s5 = s1 * 10 + s2
s6 = s3 * 10 + s4
if s5 == 0 or s5 >= 13:
  mcount[0] = 1
if s6 == 0 or s6 >= 13:
  mcount[1] = 1
if mcount[0] == 0 and mcount[1] == 0:
  print("AMBIGUOUS")
elif mcount[0] == 1 and mcount[1] == 0:
  print("YYMM")
elif mcount[0] == 0 and mcount[1] == 1:
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 12468
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( int i=a;i<b;i++)
#define REPR(i,a,b) for(int i=a;i>=b;i--)
#define adb(a) for(auto i:a) cout << i << " "; cout << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define PI 3.14159265358979323846
const ll N = 100005;

struct LessSecond
{
    template<typename T, typename U>
    bool operator()(const std::pair<T, U> &x, const std::pair<T, U> &y) const
    {
        return x.second < y.second;
    }
};

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }

ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); }

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m - 2, m); }


int main()
{


    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        int a;
        cin >> a;
        cout << a + pow(a, 2) + pow(a, 3);
    }
    return 0;
}



Measured memory_bytes: 4240
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int M, D, cnt;

int main() {
	cin >> M >> D;
	for (int i = 1; i <= M; ++i) {
		for (int j = 1; j <= D; ++j) {
			if (j % 10 >= 2 && j / 10 >= 2 && (j % 10)*(j / 10) == i) {
				++cnt;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
bool check(int w, int h, int flg);
int main() {
    int n;
    cin >> n;
    int k;
    cin >> k;
    int w, h;
    for (int i = 0; i < k; i++) {
        cin >> w >> h;
        w = min(w, n - w + 1); //upper-left
        h = min(h, n - h + 1);
        //cout << w << " " << h << endl;
        if (check(w, h, 1) || check(h, w, 1)) { //縦方向と横方向
            cout << 1 << endl;
        } else if (check(w, h, 2) || check(h, w, 2)) {
            cout << 2 << endl;
        } else {
            cout << 3 << endl;
        }
    }
}
bool check(int w, int h, int flg) {
    if (w % 3 == flg && (w - h) <= 0) {
        return 1;
    }
    return 0;
}



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

int main(void) {
	int N;
	cin >> N;
	int* Xto = new int[N + 1];
	int* Yto = new int[N + 1];
	int* Time = new int[N + 1];
	Time[0] = 0;
	Xto[0] = 0;
	Yto[0] = 0;
	string ans = "Yes";
	for (int i = 0; i < N; i++) {
		cin >> Time[i + 1]>> Xto[i + 1] >> Yto[i + 1];
	}
	for (int i = 0; i < N; i++) {
		int difftime = Time[i + 1] - Time[i];
		int distance = abs(Xto[i + 1] - Xto[i]) + abs(Yto[i + 1] - Yto[i]);
		int going = difftime - distance;
		if (!(going % 2 == 0 && difftime >= distance)) {
			ans = "No";
			break;
		}
	}
	cout << ans;

	delete[] Xto;
	delete[] Yto;
	delete[] Time;
	return 0;
}


Measured memory_bytes: 4512
#include <stdio.h>
#define N 100

int main(){
  int graph[N][N];
  int i,n,u,k,v,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      graph[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      graph[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j) printf(" ");
      printf("%d",graph[i][j]);
    }
    printf("\n");
  }

  return 0;
}




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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 2e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
vector < pair < int, int > > g[N];
ll dp[N];
ll t[N * 4];
ll add[N * 4];

void push (int v, int tl, int tr) {
	t[v] += add[v];
	if (tl != tr) {
		for (int to : {v << 1, v << 1 | 1})
			add[to] += add[v];
	}
	add[v] = 0;
}

void build (int v, int tl, int tr) {
	if (tl == tr) {
		t[v] = INF * (tl > 0);
		return;
	}

	int tm = (tl + tr) >> 1;
	build (v << 1, tl, tm);
	build (v << 1 | 1, tm + 1, tr);

	t[v] = min(t[v << 1], t[v << 1 | 1]);
}

void upd (int l, int r, ll x, int v = 1, int tl = 0, int tr = n) {
	push(v, tl, tr);
	if (tl > r || l > tr) return;
	if (tl >= l && tr <= r) {
		add[v] += x;
		push(v, tl, tr);
		return;
	}

	int tm = (tl + tr) >> 1;
	upd (l, r, x, v << 1, tl, tm);
	upd (l, r, x, v << 1 | 1, tm + 1, tr);

	t[v] = min(t[v << 1], t[v << 1 | 1]);
	
}

int main () {
   	SpeedForce;
	cin >> n >> m;
	ll all = 0;
	for (int i = 1; i <= m; i ++) {
		int l, r, x;
		cin >> l >> r >> x;
		g[r].pb({l, x});
		all += x;
	}

	build(1, 0, n);

	for (int i = 1; i <= n + 1; i ++) {
		for (auto it : g[i - 1]) {
			upd(0, it.F - 1, it.S);
		}
		dp[i] = t[1];
		upd (i, i, dp[i] - INF);
	}

	cout << all - dp[n+1] << '\n';
	        
   	return Accepted;
}

// B...a

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

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

  long long sum = 0;
  if (A >= K) {
    cout << K << endl;
  }
  else if (A + B >= K) {
    cout << A << endl;
  }
  else {
    cout << A - (K - A - B) << endl;
  }

  return 0;
}


Measured memory_bytes: 3600
import java.lang.Integer.bitCount
import kotlin.math.max

fun main(args: Array<String>) {
    val n = readInt()
    val g = Array(15) { Array(15) { -1 } }
    for (i in 0 until n) {
        val m = readInt()
        repeat(m) {
            var (a, x) = readIntList()
            a--
            g[i][a] = x
        }
    }
    var ans = 0
    for (i in 0 until (1 shl n)) {
        val d = MutableList(n) { 0 }
        for (j in 0 until n) {
            // j番目のビットが立っていたら
            if ((i shr j) and 1 == 1) d[j] = 1
        }
        var ok = true
        for (j in 0 until n) {
            // d[j]は正直者と仮定
            if (d[j] == 1) {
                for (k in 0 until n) {
                    if (g[j][k] == -1) continue
                    // 仮定と証言に矛盾
                    if (g[j][k] != d[k]) ok = false
                }
            }
        }
        if (ok) ans = max(ans, bitCount(i))
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 42908
#include<bits/stdc++.h>
#define ll          long long
#define ld          long double
#define mod         (1000000000+7)
#define ull         unsigned long long
#define pb          push_back
#define	endl		'\n'
#define pi          acos(-1)
#define pii         pair<ll int,ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define SIZE(X)     ((int)((X).size()))
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define FOR(i,s,n)  for(int i=s;i<n;i++)
#define FORE(i,s,n) for(int i=s;i<=n;i++)
#define ERASE(x)    x.erase(unique(x.begin(),x.end()),x.end()) //removes repeated element;
#define Fast        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);

using namespace std;
const int N = 100010;
vector <ll> is_prime(N+1 , true);
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b){return (a.first > b.first);}
bool sortbysecdesc(const pair<int,int> &a,const pair<int,int> &b){return a.second>b.second;}
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second);}
ll int pow(ll int x, ll int y) { ll int res = 1; while (y > 0) { if (y & 1) res = ((res) * (x)); res %= N; y = y >> 1; x = ((x) * (x)); } return res; }
int powm(int x, int y, int p)  {  int res = 1; x = x % p; while (y > 0) {if (y & 1) res = (res * x) % p; y = y >> 1; x = (x * x) % p;}   return res; }
ll int power(ll int a , ll int b) { if(b == 1) return a; if(b == 0) return 1; ll int m1 = power(a,b/2); if(b%2) return m1*m1*a; return m1*m1; }
void seive_of_eras(ll n) { is_prime[0] = 0; is_prime[1] = 0; for(ll i=2;i*i<=n;i++) { if(is_prime[i]) { for(ll j=i*i;j<=n;j+=i) { is_prime[j] = false; } } } }
bool isprime (ll a) { if(a<=1) return false; if(a==2||a==3) return true; if(a%2==0||a%3==0) return false; for(ll i=5;i*i<=a;i=i+6) { if(a%i==0||a%(i+2)==0) return false; } return true; }

void codeit()
{
    ll n; cin>>n;
    ld d; cin>>d;
    ld a; ll m = 0;
    for(ll i=0;i<n;i++)
    {
        ll x , y; cin>>x>>y;
        a = sqrt(power(x*1.0, 2) + power(y*1.0 , 2));
        if(d-a>=0)
            m++;
    }
    cout<<m<<endl;
}

int main()
{
    //Fast
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ull tt; //cin>>tt;
    tt = 1;
    for(ull i=0;i<tt;i++)
        codeit();
}


Measured memory_bytes: 3896
SA = input()
SB = input()
SC = input()

indexA = 0
indexB = 0
indexC = 0
turn = 'A'
winner = ''
while 1:
    if turn == 'A':
        if indexA == len(SA):
            winner = 'A'
            break
        if SA[indexA] == 'a':
            turn = 'A'
        elif SA[indexA] == 'b':
            turn = 'B'
        elif SA[indexA] == 'c':
            turn = 'C'
        indexA += 1
    elif turn == 'B':
        if indexB == len(SB):
            winner = 'B'
            break
        if SB[indexB] == 'a':
            turn = 'A'
        elif SB[indexB] == 'b':
            turn = 'B'
        elif SB[indexB] == 'c':
            turn = 'C'
        indexB += 1
    elif turn == 'C':
        if indexC == len(SC):
            winner = 'C'
            break
        if SC[indexC] == 'a':
            turn = 'A'
        elif SC[indexC] == 'b':
            turn = 'B'
        elif SC[indexC] == 'c':
            turn = 'C'
        indexC += 1
print(winner)


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

using namespace std;

int main() {
    int a, b, c;
    string s;
    cin >> a >> s[0] >> b >> s[1] >> c;
    if (b >= 5)
        cout << "TBD" << endl;
    else
        cout << "Heisei" << endl;
    return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    vector<int> V{A, B, C};

    int cnt_5 = 0, cnt_7 = 0;
    for (int i = 0; i < 3; i++) {
        if (V[i] == 5) cnt_5++;
        if (V[i] == 7) cnt_7++;
    }

    if (cnt_5 == 2 && cnt_7 == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
//======================================
//author @Amit Singh : global_const
//======================================

#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<climits>
using namespace std;
#define yeah ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define vi vector<int>
#define pb push_back
#define loop(i,n) for(int i=0;i<n;++i)
signed main()
{ yeah;
  int t;
  cin>>t;
  long long int arr[t];
  long long int multi=1;
  bool flag=0;
  loop(i,t)
  {cin>>arr[i];
   if(arr[i]==0)
   {flag=1;
    break; 
   }
  }	
 if(flag==1)
 cout<<0<<endl;
 else
 {loop(i,t)
   {multi*=arr[i];
    if(arr[i]>multi||multi>1000000000000000000)
    {cout<<-1<<endl;
   	return 0;
   	}
   }
   cout<<multi<<endl;
  }
 return 0;
}

Measured memory_bytes: 4440
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map> 
#include <unordered_set>
#include <functional>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int rev_mod(long long int num){
	long long int pow_num = MOD - 2;
	long long int mod_num = MOD;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

long long int fact[2100000], factm[2100000];

long long int comb(long long int n, long long int k){
	return fact[n] * factm[k] % MOD * factm[n - k] % MOD;
}

int main(){
	fact[0] = factm[0] = 1;
	for(long long int i = 1; i < 2100000; i++){
		fact[i] = fact[i - 1] * i % MOD;
		factm[i] = factm[i - 1] * rev_mod(i) % MOD;
	}
	long long int r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	long long int ans = 0;
	if(r1 == r2 && c1 == c2){
		cout << comb(r1 + c1, r1) << endl;
		return 0;
	}
	long long S = comb(r1 + c1, r1);
	ans += S;
	for(long long int i = r1 + c1 + 1; i < r2 + c2; i++){
		S *= 2;
		S %= MOD;
		if(i <= r1 + c2){
			S += comb(i - 1, r1 - 1);
		}else{
			S -= comb(i - 1, c2);
			S += MOD;
		}
		if(i <= r2 + c1){
			S += comb(i - 1, c1 - 1);
		}else{
			S -= comb(i - 1, r2);
			S += MOD;
		}
		S %= MOD;
		ans += S;
		ans %= MOD;
	}
	ans += comb(r2 + c2, r2);
	ans %= MOD;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 33024
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#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 all(x)  (x).begin(), (x).end()
#define MAX 10000
using namespace std;
typedef long long ll;

int main(){
  int n;  cin >> n;
  int min = 1000000000;
  int max = 0;
  rep(i, 0, n){
    int tmp;  cin >> tmp;
    if(min > tmp){
      min = tmp;
    }
    if(max < tmp){
      max = tmp;
    }
  }
  cout << max - min << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  std::string S;
  std::cin >> S;
  //std::vector<int > count(S.length()+4, 0);
  long long ans = 0;
  int counter = 0;
  int index = S.length()-1;
  char next = 'C';
  while(index>=0){
    if (S[index]=='A'){
      if (next=='C'){
        ans += counter;
      } else {
        counter = 0;
        next='C';
      }
    } else if (S[index]==next){
      if (next=='C'){
        next='B';
      } else if (next=='B'){
        next='C';
        counter++;
      }
    } else if (S[index]=='C'){
      next='B';
      counter=0;
    } else {
      counter = 0;
      next='C';
    }
    index--;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 640
solve :: String -> String
solve s = replicate r0 '(' ++ s ++ replicate l0 ')'
    where
        sol l r "" = (l, r)
        sol l r (c : cs)
            | c == '(' = sol (l + 1) r cs
            | l == 0 = sol l (r + 1) cs
            | otherwise = sol (l - 1) r cs
        (l0, r0) = sol 0 0 s

main :: IO ()
main = getLine >> getLine >>= putStrLn . solve


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e15;

LL dp[1<<15][101];
LL sum[1<<15];
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N, M;
  while(cin >> N >> M,N){
	VL xs(N), ys(M);
	REP(i,N){
	  cin >> xs[i];
	  dp[1<<i][0] = xs[i];
	}
	REP(i,M) cin >> ys[i];
	SORT(ys);

	sum[0] = 0;
	FOR(b,1,1<<N) sum[b] = sum[b^(b&-b)] + dp[b&-b][0];

	fill((LL*)dp, (LL*)dp+(1<<15)*101, INF);
	dp[0][0] = 0;
	
	REP(i,M){
	  REP(b,1<<N){
		REP(j,N) if(b>>j&1) mini(dp[b][i], dp[b^(1<<j)][i]);
		mini(dp[b][i+1], dp[b][i] + abs(ys[i] - sum[b]));
	  }
	}

	LL ans = INF;
	REP(b,1<<N) mini(ans, dp[b][M]);
	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 29348