akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	rep(i, n) cin >> a[i] >> b[i] >> c[i];
	vector<vector<int>> abc(n, vector<int>(3));
	rep(i, n) {
		abc[i][0] = a[i];
		abc[i][1] = b[i];
		abc[i][2] = c[i];
	}

	vector<vector<int>> dp(n + 1, vector<int>(3, 0));
	Rep(i,1, n + 1) {
		Rep(j,0, 3) {
			dp[i][j] = max(dp[i][j], dp[i - 1][(j + 1) % 3] + abc[i - 1][j]);
			dp[i][j] = max(dp[i][j], dp[i - 1][(j + 2) % 3] + abc[i - 1][j]);
		}
	}

	cout << max({ dp[n][0], dp[n][1], dp[n][2] }) << endl;

	return 0;
}


Measured memory_bytes: 12416
import sys
import numpy as np


def main():
  scan = sys.stdin.readline
  
  n = int(scan().rstrip())
  a = np.array(tuple(int(a_i) for a_i in scan().rstrip().split()))
  
  print(int(np.sum(np.log2(a & -a))))


if __name__ == "__main__":
  main()
  

Measured memory_bytes: 21876
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int A, B;
  cin >> A >> B;
  // result *  8 / 100 = A
  // -> 100 * A / 8 <= result < 100 * (A + 1) / 8
  // result * 10 / 100 = B
  // -> 100 * B / 10 <= result < 100 * (B + 1) / 10
  int lower = max((100 * A + 7) / 8, (100 * B + 9) / 10);
  int upper = min((100 * (A + 1) + 7) / 8, (100 * (B + 1) + 9) / 10);
  int result = (lower < upper) ? lower : -1;
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 1005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N,K;
map<int,int> zz;
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
int f(int x) {
    if(x == 1) return K;
    if(zz.count(x)) return zz[x];
    int res = fpow(K,x / 2);
    if(x & 1) res = mul(res,K);
    for(int i = 1 ; i <= x / i ; ++i) {
	if(x % i == 0) {
	    update(res,MOD - f(i));
	    int j = x / i;
	    if(j != i && j != x) update(res,MOD - f(j));
	}
    }
    zz[x] = res;
    return res;
}
void Solve() {
    read(N);read(K);
    int ans = 0;
    for(int i = 1 ; i <= N / i; ++i) {
	if(N % i == 0) {
	    int t = mul(f(i),i);
	    if(i % 2 == 0) t = mul(t,(MOD + 1) / 2);
	    update(ans,t);
	    int j = N / i;
	    t = mul(f(j),j);
	    if(j % 2 == 0) t = mul(t,(MOD + 1) / 2);
	    if(j != i) update(ans,t);
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(i) begin(i), end(i)

const int INF = 0x3fffffff;
const ll MINF = 0x7fffffffffff;
const ld DINF = numeric_limits<ld>::infinity();
const int MOD = 1000000007;
const int MODD = 998244353;
const ld EPS = 1e-9;
const ld PI = 3.1415926535897932;

template<class T> bool chmin(T &a, const T &b){ if(a > b){ a = b; return 1; } else return 0; }
template<class T> bool chmax(T &a, const T &b){ if(a < b){ a = b; return 1; } else return 0; }
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }

ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / gcd(a, b); }
ll pow_mod(ll n,ll k,ll m){ll r = 1;for(; k > 0;k >>= 1) {if (k & 1) r = (r * n) % m; n = (n * n) % m;}return r;}

//ここから。
int main(){
    int N;
    cin >> N;
    vector<int> a(N+2,0);
    ll sumlf = 0;
    rep(i,N+1){
        cin >> a[i];
        sumlf += a[i];
    }
    ll maxlf = 1;
    ll ans = 0;
    rep(i,N+1){
        maxlf -= a[i];
        sumlf -= a[i];
        if(maxlf < 0){
            cout << -1 << endl;
            return 0;
        }
        if(maxlf == 0 && a[i+1] != 0){
            cout << -1 << endl;
            return 0;
        }
        ans += (maxlf + a[i]);
        if(maxlf*2 > sumlf){
            maxlf = sumlf;
        }else{
            maxlf *= 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
#define pb push_back
#define x first
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
const int INF = 1e9, MOD = 1e9 + 7; /// think
const ll LINF = 1e18;


const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0};
inline bool inside (int x, int y, int n, int m) {
    return 0 <= x && 0 <= y && x < n && y < m;
}

template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; }
template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; }

vector <vector <int> > edge, bad;
set <int> cur;
vector <int> used;
inline void dfs (int v) {
    used[v] = 1;
    cur.insert(v);
    for (int to : edge[v]) {
        if (!used[to]) {
            dfs(to);
        }
    }
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    edge.resize(n);
    bad.resize(n);
    int a, b;
    for (int i = 0; i < m; i++) {
        cin >> a >> b;
        --a, --b;
        edge[a].pb(b);
        edge[b].pb(a);
    }
    for (int i = 0; i < k; i++) {
        cin >> a >> b;
        --a, --b;
        bad[a].pb(b);
        bad[b].pb(a);
    }
    used.resize(n);
    vector <int> ans(n);
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            cur.clear();
            dfs(i);
            for (int v : cur) {
                int nice = sz(cur) - 1 - sz(edge[v]);
                set <int> B;
                for (int j : edge[v]) {
                    B.insert(j);
                }
                for (int j : bad[v]) {
                    if (B.count(j)) continue;
                    if (cur.count(j)) {
                        --nice;
                    }
                }
                ans[v] = nice;
            }
        }
    }
    for (auto &i : ans) {
        cout << i << ' ';
    }
    cout << '\n';
}


Measured memory_bytes: 26152
#include <bits/stdc++.h>
using namespace std;
string s;
const int mx=1e5+123;
const int inf = 2000000000;
int a[mx],dp[mx],n,k;

int slv(int i) {

   if(i>=n)
     return 0;
    int temp=inf;
   if(dp[i]!=-1)
       return dp[i];

   for(int j=1;j<=k;j++){

       if(i+j<=n)
         temp=min(temp,abs(a[i+j]-a[i])+slv(i+j));
   }
      return  dp[i]=temp;
}
int main()
{
   memset(dp,-1,sizeof(dp));

    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    cout<<slv(1)<<endl;




    return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ASomethingOnIt {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    string s;
	    in >> s;
	    int cnt = 0;
	    for(int i=0; i<s.length(); i++){
	        if(s[i] == 'o') cnt++;
	    }
	    out << 700 + cnt*100 << endl;
	}
};


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


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=(ll)1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;

signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    string S;
    cin >> S;
    string T;
    cin >> T;
    ll n=S.size();
    ll m=T.size();
    ll ans=INF;
    for(ll i=0;i<n-m+1;++i){
        ll count=0;
        for(ll j=0;j<m;++j){
            if(T[j]!=S[i+j])count++;
        }
        chmin(ans,count);
    }
    prt(ans);

    return 0;
}



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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = abs(a - b);
  int y = abs(b - c);
  int z = abs(c - a);
  bool jd = false;
  if(x <= d && y <= d)jd = true;
  else if(z <= d)jd = true;
  cout << ((jd) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	    
		String x = "";
		try {
			x = in.readLine();
			Dice d = new Dice (x.split(" "));

			int num = Integer.parseInt(in.readLine());
			for (int i = 0; i < num; i++) {
				String q = in.readLine();
				System.out.println(d.getAns(q));
			}
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

class Dice {
	private int t, b, n, s, e, w;
	private HashMap<String, String> str = new HashMap<String, String>();
	
	public Dice(String[] num) {
		t = Integer.parseInt(num[0]);
		s = Integer.parseInt(num[1]);
		e = Integer.parseInt(num[2]);
		w = Integer.parseInt(num[3]);
		n = Integer.parseInt(num[4]);
		b = Integer.parseInt(num[5]);
		
		for (int i = 0; i < 6; i++) {
			for (int j = 0; j < 6; j++) {
				if (i == j) continue;
				
				int index = getE(i * 6 + j);
				str.put(num[i] + " " + num[j], num[index]);
			}
		}
	}
	
	public String getAns(String pat) {
		return str.get(pat);
	}
	
	public int getE(int num) {
		switch (num) {
		case 1:
		case 11:
		case 34:
		case 24:
			return 2;
		case 2:
		case 17:
		case 33:
		case 18:
			return 4;
		case 4:
		case 29:
		case 31:
		case 6:
			return 3;
		case 3:
		case 23:
		case 32:
		case 12:
			return 1;
		case 22:
		case 26:
		case 13:
		case 9:
			return 5;
		case 27:
		case 19:
		case 8:
		case 16:
			return 0;	
		}
		return 0;
	}
	
	public void move(char c) {
		int tmp = 0;
		
		switch (c) {
		case 'N' :
			tmp = t;
			t = s;
			s = b;
			b = n;
			n = tmp;
			break;
		case 'S' :
			tmp = t;
			t = n;
			n = b;
			b = s;
			s = tmp;
			break;
		case 'E' :
			tmp = t;
			t = w;
			w = b;
			b = e;
			e = tmp;
			break;
		case 'W' :
			tmp = t;
			t = e;
			e = b;
			b = w;
			w = tmp;
			break;
		}
	}

	public int getTop() {
		return t;
	}
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define np next_permutation
#define b32 bitset<32>

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

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

    int N; cin >> N;
    V<ll> A = V<ll>(N); rep(i,N) cin >> A[i];
    sort(ALL(A));
    ll ans = 0;

    if(A.size() == 2) {
        cout << abs(A[0] - A[1]) << endl;
        return 0;
    }

    V<ll> B = V<ll>(A);
    ll t_ans = abs(B[N-1] - B[1]) + abs(B[N-1] - B[0]);
    ll last[2]; last[0] = B[1], last[1] = B[0];
    rep(i,2) B.erase(B.begin()); B.erase(B.end()-1);

    while(B.size() > 0) {
        if(B.size() >= 2) {
            t_ans += abs(last[0] - B[B.size()-1]) + abs(last[1] - B[B.size()-2]);
            last[0] = B[B.size()-1]; last[1] = B[B.size()-2];
            B.erase(B.end()-1); B.erase(B.end()-1);
        } else {
            t_ans += abs(min(last[0], last[1]) - B[0]);
            break;
        }
        // cout << "a" << endl;

        if(B.size() == 0) break;
        else if(B.size() >= 2) {
            // cout << "b1" << endl;
            t_ans += abs(last[0] - B[0]) + abs(last[1] - B[1]);
            last[0] = B[0]; last[1] = B[1];
            B.erase(B.begin()); B.erase(B.begin());
            // cout << "b2" << endl;
        } else {
            t_ans += abs(max(last[0], last[1]) - B[0]);
            break;
        }
        // cout << "b" << endl;
    }
    ans = max(ans, t_ans);

    B = V<ll>(A);
    t_ans = abs(B[0] - B[N-1]) + abs(B[0] - B[N-2]);
    last[0] = B[N-1], last[1] = B[N-2];
    rep(i,2) B.erase(B.end()-1); B.erase(B.begin());

    while(B.size() > 0) {
        if(B.size() >= 2) {
            // cout << "b1" << endl;
            t_ans += abs(last[0] - B[0]) + abs(last[1] - B[1]);
            last[0] = B[0]; last[1] = B[1];
            B.erase(B.begin()); B.erase(B.begin());
            // cout << "b2" << endl;
        } else {
            t_ans += abs(max(last[0], last[1]) - B[0]);
            break;
        }

        if(B.size() == 0) break;
        else if(B.size() >= 2) {
            t_ans += abs(last[0] - B[B.size()-1]) + abs(last[1] - B[B.size()-2]);
            last[0] = B[B.size()-1]; last[1] = B[B.size()-2];
            B.erase(B.end()-1); B.erase(B.end()-1);
        } else {
            t_ans += abs(min(last[0], last[1]) - B[0]);
            break;
        }
    }
    ans = max(ans, t_ans);

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int x = 0;
	for (int i = a; i <= b; i++){
		if (c % i == 0){
			x++;
		}
	}
	cout << x << endl;



	return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

//しっかり制約確認したか?
int main()
{
    int n; cin >> n;
    if(n % 1000 == 0)cout << 0 << endl;
    else cout << 1000-(n%1000) << endl;

    system("pause");
}


Measured memory_bytes: 3692
n = int(input())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
#p = 1
now_1 = 0
for i in range(n):
    now_1 += float(abs(x[i]-y[i]))
print("{:.10}".format(now_1))
#p = 2
now_2 = 0
for i in range(n):
    now_2 += float(abs(x[i]-y[i])**2)
print("{:.10}".format(now_2**0.5))
# p = 3
now_3 = 0
for i in range(n):
    now_3 += float(abs(x[i]-y[i])**3)
print("{:.10}".format(now_3**(1/3)))
# p = 4
ls = []
for i in range(n):
    ls.append(float(abs(x[i]-y[i])))
print("{:.10}".format(max(ls)))


Measured memory_bytes: 5656
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int main()
{
	int N;
	int i,j; 
	int yakusu,count;
	scanf("%d", &N);
	yakusu = 0;
	count = 0;
	for (i = 1; i <= N; i=i+2) {
		for (j = 1; j <= i; j++) {
			if (i%j == 0)
				yakusu++;
		}
		if (yakusu == 8)
			count++;
		yakusu = 0;
	}
	printf("%d", count);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main()
{
 string s;
 cin>>s;
 long long sum=0;
 for(int i=0;i<s.length();i++)
 sum+=(s[i]-'0');
 int a=sum%9;
 if(!a) cout<<"Yes";
 else cout<<"No"
;  return 0;
}

Measured memory_bytes: 3320
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAX_N = 100000;
bool isPrime[MAX_N+1];
int sum[MAX_N+1];

int main() {
    // Dijkstra
    for (int i = 0; i <= MAX_N; i++) {
        isPrime[i] = true;
    }
    isPrime[0] = isPrime[1] = false;
    for (int i = 2; i <= sqrt(MAX_N); i++) {
        for (int j = i + i; j <= MAX_N; j += i) {
            isPrime[j] = false;
        }
    }
    // sum
    for (int i = 3; i <= MAX_N; i += 2) {
        if (isPrime[i] && isPrime[(i+1)/2]) {
            sum[i]++;
        }
    }
    for (int i = 3; i <= MAX_N; i++) sum[i] += sum[i-1];
    // input and output
    int q, l, r;
    cin >> q;
    while (q--) {
        scanf("%d %d", &l, &r);
        cout << sum[r] - sum[l-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please



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

	
	int N;
	cin >> N;

	int A[301][301];
	rep1(i, N) {
		rep1(ii, N) {
			cin >> A[i][ii];
		}
	}

	int shouryaku[301][301] = {};
	rep1(k, N) {
		rep1(i, N) {
			rep1(j, N) {
				if (A[i][j] > A[i][k] + A[k][j]) {
					co(-1);
					Would you please return 0;
					//アホか！
				}
				else if (A[i][j] == A[i][k] + A[k][j] && i != k && j != k) {
					shouryaku[i][j] = 1;
				}
			}
		}
	}

	ll goukei = 0;
	rep1(i, N) {
		rep1(ii, N) {
			if(shouryaku[i][ii] == 0) goukei += A[i][ii];
		}
	}

	co(goukei / 2);

	Would you please return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef array<double, 3> P;
typedef double D;
const double EPS = 1e-8;


P tasu(P a, P b) {
	P c;
	for (int i = 0; i < 3; i++) c[i] = a[i] + b[i];
	return c;
}
P kake(D a, P b) {
	P c;
	for (int i = 0; i < 3; i++) c[i] = a * b[i];
	return c;
}

double dist(P a, P b) {
	double x = a[0] - b[0];
	double y = a[1] - b[1];
	double z = a[2] - b[2];
	return sqrt(x * x + y * y + z * z);
}

double mint(P a0, P b0, P da, P db, double ar0, double br0, double dar, double dbr) {
	double m = 0;
	double M = 1e6;
	while (m + EPS * 3 < M) {
		double t = m;
		double A[2] = {};
		double dm = (M - m) /  3;
		for (int i = 0; i < 2; i++) {
			t += dm;
			P a = tasu(a0 , kake(t, da));
			P b = tasu(b0 , kake(t, db));
			double d = dist(a, b);
			double r1 = ar0 - t * dar;
			double r2 = br0 - t * dbr;
			A[i] = d - r1 - r2;
		}
		if (A[0] < A[1]) M = t;
		else m = t - dm;
	}
	return (m + M) / 2;
}

double hantei(P a0, P b0, P da, P db, double ar0, double br0, double dar, double dbr) {
	double m = mint(a0, b0, da,  db, ar0,  br0, dar, dbr);
	m = min(m, ar0 / dar);
	m = min(m, br0 / dbr);
	if (dist(tasu(a0 , kake(m , da)), tasu(b0 , kake(m , db)))  + EPS > br0 - dbr * m + ar0 - dar * m ) return 0;
	double M = m;
	m = 0;
	while (m + EPS / 10 < M) {
		double t = (M + m) / 2;
		P a = tasu(a0 , kake(t , da));
		P b = tasu(b0 , kake(t , db));
		double d = dist(a, b);
		double r1 = ar0 - t * dar;
		double r2 = br0 - t * dbr;
		double A = d - r1 - r2;
		if (A < 0) M = t;
		else m = t;
	}
	return m;
}

double hyou[201][201];
double points[201][8];
int main() {
	cout << setprecision(20) << fixed;
	int N;
	while(cin >> N, N) {
		for(int n = 0; n < N; n++) {
			
			P a;
			double x, y, z, dx, dy, dz, r0, dr;
			cin >> x >> y >> z >> dx >> dy >> dz >> r0 >> dr;
			double A[8] = {x , y , z , dx , dy , dz , r0 , dr};
			for(int i = 0; i < 8; i++) points[n][i] = A[i];
		}
		double star[205] = {};

		for(int i = 0; i < 203; i++) star[i] = 0;
	vector<tuple<double , int, int>> vt;
	for (int i = 0; i < N; i++) {
		double ar0, br0, dar, dbr;
		ar0 = points[i][6];
		dar = points[i][7];
		for (int j = 0; j < i; j++) {
			P a0,b0,db,da;
			br0 = points[j][6];
			dbr = points[j][7];
			for(int k = 0; k < 3; k++) {
				a0[k] = points[i][k];
				b0[k] = points[j][k];
				da[k] = points[i][k + 3];
				db[k] = points[j][k + 3];
			}
			double T = hantei(a0, b0, da,  db, ar0,  br0, dar, dbr);
			
			if (T > 0.0) {
				vt.push_back(make_tuple(T, i, j));
			}
		}
		vt.push_back(make_tuple(ar0 / dar, i, 201));
		
	}
	sort(vt.begin(), vt.end());
	for(auto e : vt) {
		D d = get<0>(e);
		int a = get<1>(e);
		int b = get<2>(e);
		//cout << "(" <<d << ","<< a << "," << b << ")" <<endl;
		if (star[a] == 0.0 and star[b] == 0.0) {
			star[a] = d;
			star[b] = d;
		}
		star[201] = 0;
	}
	for (int i = 0; i < N; i++) {
		cout << star[i] << endl;
	}
	}
}



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

int main(void){
	int H, W;

	while (true){
		cin >> H >> W;

		if (H == 0 && W == 0) break;

		for (int y = 0; y < H; y++){
			for (int x = 0; x < W; x++){
				if (y % 2 == 0){
					if (x %2 == 0)cout << "#";
					else cout << ".";
				}
				else{
					if (x % 2 == 0)cout << ".";
					else cout << "#";
				}
			}
			cout << "\n";
		}
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 1124
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
ll mod=1e9+7;
int main()
{
    string s;
    cin>>s;
    int n=s.length()-1;
    if(s[n]=='s')
    s+="es";
    else
    {
        s+='s';
    }
    cout<<s<<endl;
    
}

Measured memory_bytes: 3620
#include <bits/stdc++.h> 
typedef long long ll;
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF = 1ll<<60;

int main(){
    int n,k; cin>>n>>k;
    vector<ll> h(n);
    vector<ll> dp(1e5+1000);

    for(int i=0; i<n; i++) cin>>h[i];
    for(int i=0; i<1e5+1000; i++) dp[i] = INF;

    dp[0] = 0;

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

    cout<<dp[n-1]<<endl;

    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" <<endl;
    else cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll; //long longをllとして簡略

int main(){
  int c[3][3]={0};
  rep(i,3){
    rep(j,3){
      cin >> c[i][j];
    }
  }
  rep(i,100){//0
    int b1,b2,b3,a2,a3;
    b1 = c[0][0]-i;//1
    b2 = c[0][1]-i;//0
    b3 = c[0][2]-i;//1
    a2 = c[1][0]-b1;//1
    a3 = c[2][0]-b1;//0
    if(a2+b2== c[1][1] && a2+b3== c[1][2] && a3+b2== c[2][1] && a3+b3== c[2][2]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 100000007
#define SIZE 500006
int vec[SIZE];

int main()
{
     // ios::sync_with_stdio(false);
     // cin.tie(0);
     
      int t,i,n,a,b;
      cin>>a>>b;
      if((b*2)<a)
        cout<<a-b*2<<"\n";
      else
        cout<<"0"<<"\n";
     

    return 0;
}


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

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

int main()
{
  long long int W, H, x, y;
  cin >> W >> H >> x >> y;
  long long int g_x = W/2;
  long long int g_y = H/2;
  int judge = 0;
  if(W%2 == 0 && x==g_x){
    if(H%2 ==0 && y==g_y){
      judge = 1;
    }
  }

  double s_out = (double)( W * H ) / 2.0;
  cout << s_out << " " << judge << endl;
  return 0;
}

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

int main(){
	int n,i;
	string s;
	cin>>n>>s;
	
	if(n>=s.size()) cout<<s;
	else{
		for(i=0;i<n;i++)
		cout<<s[i];
		cout<<"...";
	}
	return 0;
}

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

const int mod = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	string s;
	cin >> n >> s;
	
	long long dp[n - 1][n + 1];
	memset(dp, 0, sizeof(dp));
	(s[0] == '<' ? dp[0][2] = 1 : dp[0][1] = 1);
	for (int i = 1; i < n - 1; i++) {
		if (s[i] == '>') {
			dp[i][i + 2] = 0;
			for (int j = i + 1; j; j--) {
				dp[i][j] = (dp[i][j + 1] + dp[i - 1][j])%mod;
			}
		} else {
			dp[i][1] = 0;
			for (int j = 2; j <= i + 2; j++) {
				dp[i][j] = (dp[i][j - 1] + dp[i - 1][j - 1])%mod;
			}
		}
	}
	long long ans{};
	for (int i = 1; i <= n; i++) ans = (ans + dp[n - 2][i])%mod;
	cout << ans;
}

Measured memory_bytes: 73904
from collections import Counter
N = int(input())

S = [input() for _ in range(N)]

ctr = Counter(S[0]) # 引数で渡したリストとかタプルの中にOOが何個みたいな形のオブジェクトを生成
for s in S[1:]:
    ctr &= Counter(s) #論理積をとって、同じ部分だけ残していく

ans = ""
for k,v in sorted(ctr.items()):
    ans += k*v

print(ans)

Measured memory_bytes: 3316
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	cout << (N^M) << endl;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;

//===



bitset<25700> dp[85][85];



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

	int H, W; cin >> H >> W;
	vector<Vi> A(H, Vi(W)), B(H, Vi(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> A[i][j];
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> B[i][j];
		}
	}

	constexpr int bias = 12850;

	int d = A[0][0] - B[0][0];
	dp[1][1].set(d + bias);
	dp[1][1].set(-d + bias);

	for (int i = 1; i <= H; ++i) {
		for (int j = 1; j <= W; ++j) {
			d = abs(A[i - 1][j - 1] - B[i - 1][j - 1]);
			dp[i][j] |= (dp[i - 1][j] << d);
			dp[i][j] |= (dp[i - 1][j] >> d);
			dp[i][j] |= (dp[i][j - 1] << d);
			dp[i][j] |= (dp[i][j - 1] >> d);
		}
	}

	int ans = I_INF;

	for (int i = 0; i < bias * 2; ++i) {
		if (dp[H][W][i]) {
			ans = min(ans, abs(i - bias));
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N,tmp;
    cin >> N;
    int M[N];
    for(int i=0;i<N;i++){
        M[i]=0;
    }
    for(int i=0;i<N-1;i++){
        cin >> tmp;
        M[tmp-1]++;
    }
    for(int i=0;i<N;i++){
        cout << M[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 4444
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar_unlocked()
#define pc(x) putchar_unlocked(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=n%10+48;n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

long long n, cnt;
std::set<long long> done;

typedef unsigned long long ull;
typedef __uint128_t L;
struct FastMod {
    ull b, m;
    FastMod(ull b) : b(b), m(ull((L(1) << 64) / b)) {}
    ull reduce(ull a) {
        ull q = (ull)((L(m) * a) >> 64);
        ull r = a - q * b; // can be proven that 0 <= r < 2*b
        return r >= b ? r - b : r;
    }
};

FastMod F(2);

void go(long long i){
    if(done.count(i))
        return;
    done.insert(i);
    long long m = n;
    F = FastMod(i);
    while(F.reduce(m) == 0)
        m /= i;
//    while(m % i == 0)
//        m /= i;
//    m %= i;
    m = F.reduce(m);

    if(m == 1){
//        print(i);
        cnt++;
    }
}

int main(){
    scan(n);
    if(n == 2){
        print(1);
        return 0;
    }
    else if(n == 3){
        print(2);
        return 0;
    }
    
    go(n);
    go(n-1);
    
    for(long long i = 2; i*i <= n; i++){
        go(i);
        go(n/i);
    }
    
    print(cnt);
    
    return 0;
}
/*
 n, n-1, then factor

1000000000000
 */

Measured memory_bytes: 93952
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;

int main(){
    ll n,k;
    cin>>n>>k;
    ll ans= min(n%k,abs(n%k-k));
    cout<<ans<<endl;
}

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

int dp[2][DAY + 1][DAY + 1];
vector< vector<pair<int, int> > > data;
int N;
/*
int dfs(int idx, int n1, int n2){
	if(idx >= 366) return 0;
	if(n1 < idx) n1 = 0;
	if(n2 < idx) n2 = 0;
	if(dp[idx][n1][n2] != -1) return dp[idx][n1][n2];
	int ans = dfs(idx + 1, n1, n2);
	if(n1 < idx && n2 < idx){
		for(int i = 0; i < data[idx].size(); i++){
			for(int j = i + 1; j < data[idx].size(); j++){
				int n3 = data[idx][i].first;
				int n4 = data[idx][j].first;
				ans = max(ans, dfs(idx + 1, max(n3, n4), min(n3, n4)) + data[idx][i].second + data[idx][j].second);
			}
		}
	}
	if(n2 < idx){
		for(auto p : data[idx]){
			int n3 = p.first;
			ans = max(ans, dfs(idx + 1, max(n1, n3), min(n1, n3)) + p.second);  
		}
	}
	//printf("(%d %d %d) = %d\n", idx, n1, n2, ans);
	return dp[idx][n1][n2] = ans;
}
*/

int main(){
	while(cin >> N, N){
		data.assign(366, vector<pair<int ,int> >());
		for(int i = 0; i < N; i++){
			int a, b, w;
			cin >> a >> b >> w;
			data[a].push_back(pair<int, int>(b, w));
		}
		for(int i = 0; i < 2; i++){
			for(int j = 0; j < 366; j++){
				for(int k = 0; k < 366; k++){
					dp[i][j][k] = 0;
				}
			}
		}
		for(int i = DAY;  i > 0; i--){
			for(int j = 0; j <= DAY; j++){
				for(int k = 0; k <= DAY; k++){
					int idx = i;
					int n1 = j;
					int n2 = k;
					if(n1 < idx) n1 = 0;
					if(n2 < idx) n2 = 0;
					int ci = idx % 2;	

					int ans = dp[ci][n1][n2];
					if(n1 < idx && n2 < idx){
						for(int i = 0; i < data[idx].size(); i++){
							for(int j = i + 1; j < data[idx].size(); j++){
								int n3 = data[idx][i].first;
								int n4 = data[idx][j].first;
								ans = max(ans, dp[ci][max(n3, n4)][min(n3, n4)] + data[idx][i].second + data[idx][j].second);
							}
						}
					}
					if(n2 < idx){
						for(auto p : data[idx]){
							int n3 = p.first;
							ans = max(ans, dp[ci][max(n1, n3)][min(n1, n3)] + p.second);  
						}
					}
					dp[(i+1)&1][j][k] = ans;
				}
			}
		}

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

Measured memory_bytes: 4140
#include<stdio.h>
int main()
{
    char S[10];
    int i;
    scanf("%s", S);
    ///printf("%s", S);
    if(S[1] == 'B')
    {
        printf("ARC\n");
    }
    else if(S[1] == 'R')
    {
        printf("ABC\n");
    }

}


Measured memory_bytes: 1644
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
using vl=vector<ll>;
using vb=vector<bool>;
using vs=vector<string>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
const ll oo =0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })
int main(){ cin.sync_with_stdio(0);
	ll A, B; cin >> A >> B;

	FOR(a, 0, 1000) {
		ll f = (a * A + 1) - a;
		if (f >= B) {
			cout << a << endl;
			return 0;
		}
	}

} //cin.tie(0) bei schnellem Wechseln


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  int[] doIt(String data){
    int time = -1;
    int lpmax = data.length();
    int[] res = new int[lpmax];
    
    for(int i = 0;i<lpmax;i++){
      switch(data.charAt(i)){
        case 'c':
          time = 0;
          res[i] = time++;
          break;
        case '.':
          res[i] = time;
          if(time != -1) time++;
          break;
      }
    }
    return res;
  }

  void dispLine(int[] data){
    int lpmax = data.length;
    for(int i = 0;i<lpmax;i++){
      System.out.print(data[i]);
      if(i != lpmax - 1) System.out.print(" ");
    }
    System.out.println();
  }
  
  public static void main(String[] args){
	    Scanner sc = new Scanner(System.in);
	    int h = sc.nextInt(),w = sc.nextInt();
	    int[][] res = new int[h][w];
	    Main ma = new Main();

	    for(int i = 0;i<h;i++) res[i] = ma.doIt(sc.next());
	    for(int i = 0;i<h;i++) ma.dispLine(res[i]);
	    sc.close();
	  }
}

Measured memory_bytes: 35352
import java.util.Scanner;

public class Main {
	
	Scanner sc = new Scanner(System.in);
	public void run() {
			int n = sc.nextInt();
			sc.nextLine();
			calc(n);
	}

	public void calc(int n){
		for(int i = 0; i < n; i++){
			String line = sc.nextLine();
			String[] mcxis = line.split(" ");
			int n1 = getNum(mcxis[0]);
			int n2 = getNum(mcxis[1]);
			System.out.println(getMCXI(n1 + n2));
		}
	}
	public int getNum(String s){
		int t = 1;
		int sum = 0;
		for(int i = 0; i < s.length(); i++){
			char c = s.charAt(i);
			if(c == 'm') {
				sum = sum + t * 1000;
				t = 1;
			}
			else if(c == 'c') {
				sum = sum + t * 100;
				t = 1;
			}
			else if(c == 'x') {
				sum = sum + t * 10;
				t = 1;
			}
			else if(c == 'i') {
				sum = sum + t;
				t = 1;
			}
			else{
				t = Integer.parseInt(""+c);
			}
		}
		return sum;
	}
	public String getMCXI(int n){
		String ans = "";
		if(n > 999){
			int m = n / 1000;
			if(m == 1) ans = ans + "m";
			else ans = ans + m + "m";
			n = n - m * 1000;
		}
		if(n > 99){
			int c = n / 100;
			if(c == 1) ans = ans + "c";
			else ans = ans + c + "c";
			n = n - c * 100;
		}
		if(n > 9){
			int x = n / 10;
			if(x == 1) ans = ans + "x";
			else ans = ans + x + "x";
			n = n - x * 10;
		}
		if(n != 0){
			if(n == 1) ans = ans + "i";
			else ans = ans + n + "i";
		}
		return ans;
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

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

const long INF = (1l << 30);
const long LINF = (1l << 60); //1.15*10^18

long n, m;

int main(){
    scanf("%ld%ld", &n, &m);
    if(n * 2 > m){
        printf("%ld\n", m / 2l);
    }else{
        printf("%ld\n", n + (m-2l*n)/4l);
    }
}


Measured memory_bytes: 256
#include<stdio.h>

int n;
char c;

int main(void)
{
	int i;
	char kango[7] = "Hoshino";
	
	scanf( "%d ", &n );
	
	while ( n-- ) {
		i = 0;
		while ( (c = getchar()) != EOF ) {
			if ( c == kango[i] ) {
				i++;
				if ( i >= 7 ) {
					c = 'a';
					i = 0;
				}
			}
			else
				if ( i > 0 ) {
					if ( c == kango[0] )
						i = 1;
					else
						i = 0;
				}
				
			putchar( c );
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 564
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
  
        int a = sc.nextInt();
        int b = sc.nextInt();
    
        if (a > b) {
            System.out.println("a > b");
        } else if (a < b){
            System.out.println("a < b");
        } else {
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26140
'use strict';
function Main(input) {
  let five = input.toString().split('5').length - 1;
  let seven = input.toString().split('7').length - 1;
  (five == 2 && seven == 1) ? console.log('YES') : console.log('NO');
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 6904
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;


int main(void) {
	
	while (1) {
		int n;
		int sa;
		stack< pair<int, char> > sta;
		pair<int, char > now;

		cin >> n;
		
		if (n == 0) {
			break;
		}
		vector<string> s(n);
		FOR(i, 0, n - 1) {
			cin >> s[i];
		}
		
		if (s[0][0] >= '0'&&s[0][0] <= '9') {
			sta.push(make_pair(s[0][0] - '0', 'o'));
		}
		else {
			sta.push(make_pair(-1, s[0][0]));
		}
		//cout << "a" << endl;
		FOR(i, 1, n-1) {
			if (s[i - 1].size() <= s[i].size()) {
				if (s[i][s[i].size()-1] >= '0'&&s[i][s[i].size()-1] <= '9') {
					sta.push(make_pair(s[i][s[i].size()-1] - '0', 'o'));
				}
				else {
					sta.push(make_pair(-1, s[i][s[i].size()-1]));
				}
			}
			else {
				sa = s[i - 1].size() - s[i].size();
				FOR(j, 1, sa) {
					int a[100] = {};
					int pos = 1;
					int count = 0;

					while (1) {
						now = sta.top();
						sta.pop();
						if (now.first == -1) {
							if (now.second == '*') {
								count = 1;
								FOR(k, 1, pos - 1) {
									count *= a[k];
								}

							}
							else {
								count = 0;
								FOR(k, 1, pos - 1) {
									count += a[k];
								}
							}
							sta.push(make_pair(count, 'o'));
							break;
						}
						else {
							a[pos] = now.first;
							pos++;
						}

					}
				}
				if (s[i][s[i].size() - 1] >= '0'&&s[i][s[i].size() - 1] <= '9') {
					sta.push(make_pair(s[i][s[i].size() - 1] - '0', 'o'));
				}
				else {
					sta.push(make_pair(-1, s[i][s[i].size() - 1]));
				}
				
			}
		}

		FOR(j, 1, s[n-1].size()-1) {
			int a[100] = {};
			int pos = 1;
			int count = 0;

			while (1) {
				now = sta.top();
				sta.pop();
				if (now.first == -1) {
					if (now.second == '*') {
						count = 1;
						FOR(k, 1, pos - 1) {
							count *= a[k];
						}

					}
					else {
						count = 0;
						FOR(k, 1, pos - 1) {
							count += a[k];
						}
					}
					sta.push(make_pair(count, 'o'));
					break;
				}
				else {
					a[pos] = now.first;
					pos++;
				}

			}
		}

		now = sta.top();
		cout << now.first << endl;

	}

	return 0;
}


Measured memory_bytes: 3156
using System;

namespace rensyuu1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Trim().Split(' ');
            int[] num1 = new int[n];
            int[] num2 = new int[n];
            for (int i1 = 0; i1 < n; i1++)
            {
                num1[i1] = int.Parse(str[i1]);
            }

            for (int i2 = 0; i2 < n; i2++)
            {
                num2[i2] = num1[n - i2 - 1];
            }

            Console.WriteLine(string.Join(" ", num2));
        }
    }
}


Measured memory_bytes: 15960
n = int(input())
A = [int(x) for x in input().split()]
mn = min(A)
mx = max(A)

A.remove(mn)
A.remove(mx)


moves = []
for a in A:
    if a >= 0:
        moves.append((mn, a))
        mn -= a
    else:
        moves.append((mx, a))
        mx -= a

moves.append((mx,mn))
mx -= mn
print(mx)
print('\n'.join(str(a)+' '+str(b) for a,b in moves))


Measured memory_bytes: 95292
#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 d, g;
    cin >> d >> g;
    vector<int> p(d);
    vector<int> c(d);
    rep(i,d) cin >> p[i] >> c[i];
    ll ans = 1e9;
    ll sum, num;
    for(int bit = 0; bit <(1<<d); ++bit){
        sum = 0, num = 0;
        for(int i = 0; i < d; ++i){
            if(bit & (1<<i)){
                num+=p[i];
                sum+=c[i]+(i+1)*100*p[i];
            }
        }
        if(sum >= g) ans = min(ans , num);
        else{
            for(int i = d-1; i>=0; --i) {
                if(bit &(1<<i)) continue;
                for(int k = 0; k < p[i]; ++k){
                    if(sum>=g) break;
                    sum+=100*(i+1);
                    ++num;
                }
            }
            ans = min(ans, num);
        }  
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn (int)(2e5)
#define i64 long long
#define all(x) x.begin(),x.end()
using namespace std;
unordered_map<string, int>MP;

void init() { MP.clear(); }

int main() {
	// your code goes here
	int n,k;
	string s;
	while(scanf("%d",&n)==1){
		getchar();
		init();
		for(int i=0;i<n;i++) {
			cin>>s;
			sort(all(s));
			MP[s]++;
		}
		
		i64 ans = 0;
		for(auto p : MP){
			i64 cnt = p.second;
			ans+= cnt*(cnt-1)/2LL;
		}
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 10660
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <map>
#include <iomanip>
#include <stdio.h>
#include <bitset>
#include <queue>
#include <set>

constexpr long long INFLL = 1e18;

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll x, k, d;
    cin >> x >> k >> d;
    map<ll, ll> check;
    bool c = false;
    check[x] = k;
    if (abs(x) / d > 0)
    {
        ll count = abs(x) / d;
        if (k >= count)
        {
            if (x > 0)
            {
                x = x - d * count;
            }
            else
            {
                x = x + d * count;
            }
            k -= count;
        }
        else
        {
            if (x > 0)
            {
                x = x - d * k;
            }
            else
            {
                x = x + d * k;
            }
            k = 0;
        }
    }
    while (k > 0)
    {
        if (x > 0)
        {
            x -= d;
        }
        else
        {
            x += d;
        }
        if (check[x] == 0)
        {
            check[x] = k;
        }
        else
        {
            c = true;
            k--;
            break;
        }

        k--;
    }
    if (c)
    {
        if (k % 2 == 0)
        {
            cout << abs(x) << endl;
        }
        else
        {
            if (x > 0)
            {
                x -= d;
            }
            else
            {
                x += d;
            }
            cout << abs(x) << endl;
        }
    }
    else
    {
        cout << abs(x) << endl;
    }

    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;

#define MOD 998244353

int main(){
    string s,t;
    cin >> s >> t;
    for (ll i=0;i<s.size();i++){
        for (ll j=i;j<s.size()+i;j++){
            if (j>=s.size()){
                if (s[j-s.size()]!=t[j-i]){
                    break;
                }
            }else if(s[j]!=t[j-i]){
                break;
            }
            if (j==s.size()+i-1){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}




Measured memory_bytes: 256