akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//templete
vpint node;
//↓RMQpint
struct SegMinPint{
private:
	int n;
	vector<pint> node;
public:
	//vpintをセグ木にsetする
	SegMinPint(vpint v){
		int sz=v.size();
		n=1;while(n<sz) n*=2;
		node.resize(2*n-1,mp(INF,INF));
		for(int i=0;i<sz;i++) node[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--) node[i]=min(node[2*i+1],node[2*i+2]);
	}
	//x番目の要素をvalに変える
	void update(int x, pint val){
		x+=(n-1);
		node[x]=val;
		while(x>0){
			x=(x-1)/2;
			node[x]=min(node[2*x+1],node[2*x+2]);
		}
	}
	//区間[a,b)の最小値を得る
	pint getmin(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0) r=n;
		if(r<=a || b<=l) return mp(INF,INF);
		if(a<=l && r<=b) return node[k];
		pint vl=getmin(a,b,2*k+1,l,(l+r)/2);
		pint vr=getmin(a,b,2*k+2,(l+r)/2,r);
		return min(vl,vr);
	}
};
//RMQpint
int main() {
	int N,M;
	cin>>N>>M;
	vpint v;
	for(int i=0;i<N;i++){
		int a,b;
		cin>>a>>b;
		if(M-a>=0)
			v.eb(M-a,b);
	}
	sort(v.begin(),v.end());
	int hi[SIZE]={};
	for(int i=0;i<SIZE;i++)
		hi[i]=-1;
	for(int i=0;i<v.size();i++){
		pint p=v[i];
		if(hi[p.first]==-1)
			hi[p.first]=i;
		//cout<<"# "<<p.first<<" "<<p.second<<endl;
		node.eb(-p.second,i);
	}
	for(int i=M-1;i>=0;i--){
		if(hi[i]==-1)
			hi[i]=hi[i+1];
	}
	ll ans=0;
	SegMinPint T(node);
	for(int i=M-1;i>=0;i--){
		if(hi[i]==-1)
			continue;
		pint use=T.getmin(hi[i],node.size());
		//cout<<"!"<<hi[i]<<" "<<node.size()<<endl;
		ans+=-1*use.first;
		T.update(use.second,mp(0,use.second));
		//cout<<use.first<<" "<<use.second<<endl;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5108
#include "bits/stdc++.h"
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
#define gcd(a,b) __gcd(a,b)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vc vector<char>
#define pb(n) push_back(n)
#define pp pop_back()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define type(a) typeid(a).name();
#define print(arr) cout << "[" ;for(unsigned int i=0;i<(unsigned int) arr.size();i++){ (i==arr.size()-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define Arr(arr,l) cout << "[" ;for(unsigned int i=0;i<(unsigned int) l;i++){ (i==l-1)?cout << arr[i]:cout << arr[i] << ",";}cout << "]" << endl
#define console(arr) cout << "["<<endl; for(ll i=0;i<(ll)arr.size();++i){cout << " [";for(ll j=0;j<(ll)arr[i].size();++j){(j==(int)arr[i].size()-1)?cout << arr[i][j]:cout << arr[i][j] << ",";}cout << "]"<<endl;} cout << "]"<<endl
#define starting() auto start = high_resolution_clock::now()
#define ending() auto stop = high_resolution_clock::now();auto duration = duration_cast<microseconds>(stop - start);cout << endl << endl << "Execution Time : "<<duration.count()/1000 << " ms" << endl
 
template <typename T1,typename T2>
void mapped(map<T1,T2>m){for(auto ite=m.begin();ite!=m.end();++ite){cout << "'" << ite->first << "'"<<" : "<<ite->second <<endl;}}
 
template <typename T1 , typename T2>
void mappedArr(map<T1,vector<T2>>m){for(auto ity=m.begin();ity!=m.end();++ity){cout << "'"<< ity->first <<"'"<<" : "<<"[";
for(int i=0;i<(int)ity->second.size();++i){(i==(int)ity->second.size()-1)?cout << ity->second[i]:cout << ity->second[i] << ",";}cout << "]"<<endl;}}
 
string int_to_string(int x){ stringstream ss; ss << x; string ni = ss.str(); return ni;}
int char_to_int(char c){ int n = (int)c - 48; return n; }
int string_to_int(string x){ int n; stringstream s(x); s >> n; return n; }
 
template <typename T1,typename T2>
void ArrPair(vector<pair<T1,T2>>vp){for(int i=0;i<(int)vp.size();++i){
cout << "(" << vp[i].first << "," << vp[i].second << ")"<<endl ;}}
 
const int MOD = 1e9 + 7;
const ll INF = 1e18L + 5;
 
int main(){
   ll a,b,n;
   cin >> a >> b >> n;
   ll val = 0;
   ll p = (a%n !=0 )?n - (a%n):0;
   ll z1 = a + p;
   ll z2 = b - (b%n);
   val = (z2 - z1)/n;
   val++;
   cout << val;
}














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

int main(){
    const long long MODULO = (1e9) + 7;
    int N;
    cin >> N;

    long long pow8 = 1;
    long long pow9 = 1;
    long long pow10 = 1;
    for(int i = 1; i <= N; ++i){
        pow8 = (8 * pow8) % MODULO;
        pow9 = (9 * pow9) % MODULO;
        pow10 = (10 * pow10) % MODULO;
    }

    long long answer = ((pow10 - 2 * pow9 + pow8) % MODULO + MODULO) % MODULO; 
    cout << answer;

    return 0;
}

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

using ld = double;
using ll = long long;
using ull = unsigned long long;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;

const int SZ = 1 << 13;
char buff[SZ], *pos = buff + SZ - 1;
#define getchar() (++ pos == buff + SZ ? fread(pos = buff, 1, SZ, stdin), *pos : *pos)

inline ll read() {
	ll x = 0; int f = 1, c = getchar();
	for (;!isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x<<3) + (x<<1) + (c^48);
	return x * f;
}

const int N = 1005;
ll n;
ll w[N], s[N], v[N];
ll ind[N];
ll dp[N][N * 20];
ll maxw, maxs;

inline void chk(ll &a, ll b) { if (b > a) a = b; }

int main() {
	n = read();
	for (int i = 0; i < n; ++ i) {
		w[i] = read(), s[i] = read(), v[i] = read();
		chk(maxw, w[i]); chk(maxs, s[i]);
		ind[i] = i;
	}
	sort(ind, ind + n, [&](ll a, ll b) {
		return w[a] + s[a] < w[b] + s[b];
	});
	ll ans = 0;
	for (ll ii = 0; ii < n; ++ ii) {
		ll i = ind[ii];
		for (ll j = 0; j <= maxs + maxw; ++ j) {
			chk(dp[ii + 1][j], dp[ii][j]);
			if (j > s[i]) continue;
			if (j + w[i] <= maxs + maxw) chk(dp[ii + 1][j + w[i]], dp[ii][j] + v[i]);
		}
	}
	for (ll i = 0; i <= n; ++ i) {
		for (ll j = 0; j <= maxs + maxw; ++ j) {
			chk(ans, dp[i][j]);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 156928
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;

void main()
{
	while (1) {
		auto x = readln.chomp.to!int;
		if (!x) break;
		auto dp = new long[](x + 3);
		dp[0] = 1;
		foreach (i; 0..x) {
			dp[i+1..i+4] += dp[i];
		}
		writeln((dp[x] / 10.0 / 365.0).ceil);
	}
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

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

    if (abs(x-a) < abs(x-b)) {
        puts("A");
    } else {
        puts("B");
    }
}

Measured memory_bytes: 256
(defvar N (read))
(defvar M (read))
(defvar X (read))

(defparameter arr (make-array (list N (1+ M))))

(loop for i below N do
      (setf (aref arr i M) (read))
      (loop for j below M do
            (setf (aref arr i j) (read))))


(defun solve ()
  (loop for k below (expt 2 N) with result
        do
        (setf result      
              (loop for j below M
                    with lst = (loop for i below N
                                     for B across (format nil "~v,'0B~%" N k)
                                     if (eq B #\1) collect i)
                    if (> X (or (loop for i in lst sum (aref arr i j)) 0))
                    do (return nil)
                    finally (return (loop for i in lst 
                                          sum (aref arr i M)))))
        if result minimize result))


(defvar result (solve))

(if (and result (plusp result)) (princ result) (princ "-1"))

Measured memory_bytes: 27712
n = int(input())
l = []
for _ in range(n):
    a = int(input())
    l.append(a)

l2 = l
l2 = sorted(l2)
l2.reverse()
max = max(l)


ans = []
if l2[1] == max:
    for i in range(n):
        print(max)
else:
    for j in l:
        if j != max:
            print(max)
        else:
            print(l2[1])

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

# define x first    
# define y second
# define mp make_pair
// everything go according to my plan      
# define pb push_back
# define sz(a) (int)(a.size())
# define vec vector         
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
# define y1    Y_U_NO_y1
# define left  Y_U_NO_left
# define right Y_U_NO_right  

using namespace std;

typedef pair <int, int> pii; 
typedef long long ll;
typedef long double ld;

const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap () {
  ios_base :: sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}
inline void randomizer3000 () {
  unsigned int seed;
  asm ("rdtsc" : "=A"(seed));
  srand (seed);
}
void files (string problem) {   
  if (fopen ((problem + ".in").c_str(),"r")) {
    freopen ((problem + ".in").c_str(),"r",stdin);
    freopen ((problem + ".out").c_str(),"w",stdout);
  }
}
void localInput(const char in[] = "s") { 
  if (fopen (in, "r")) {
    freopen (in, "r", stdin);
  }
  else
    cerr << "Warning: Input file not found" << endl;
}
int n;

pii a[Sz];

int ans[Sz];
                    
int main()
{
  # ifdef Local
    //localInput();
  # endif
  Read_rap();
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].x;
    a[i].y = i;
  }
  sort (a + 1, a + n + 1);
  for (int i = 1; i <= n; i++) {
    ans[a[i].y] = (i <= n/2 ? a[n/2 + 1].x : a[n/2 ].x);
  }  
  for (int i = 1; i <= n; i++)
    cout << ans[i] << endl;



  return 0;
}






// Coded by Z..



Measured memory_bytes: 4992
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

def pt(s):
    sm = 0
    for i in range(q):
        if s[b[i]]-s[a[i]]==c[i]:
            sm += d[i]
    return sm

def dfs(i,s):
    if i==10:
        return pt(s)
    mx = -1
    s1 = s[-1]
    for j in range(s1,m+1):
        s.append(j)
        v = dfs(i+1,s)
        mx = max(mx,v)
        s.pop()
    return mx

n,m,q = inm()
a = []
b = []
c = []
d = []
for i in range(q):
    aa,bb,cc,dd = inm()
    a.append(aa)
    b.append(bb)
    c.append(cc)
    d.append(dd)
s = [1]
print(dfs(0,s))


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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define endl "\n"

#define k first
#define v second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()

#define ALL(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.k << ", " << p.v << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    int n, m;
    cin >> n >> m;
    pi student[n];
    for (size_t i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        student[i] = mp(a, b);
    }
    pi checkpoint[m];
    for (size_t i = 0; i < m; i++) {
        int c, d;
        cin >> c >> d;
        checkpoint[i] = mp(c, d);
    }
    for (auto &s : student) {
        int closest_i = 0;
        long double closest_dist = INT_MAX;
        for (int i = 0; i < m; i++) {
            auto c = checkpoint[i];
            if (closest_dist > (abs(s.first - c.first) + abs(s.second - c.second))) {
                closest_dist = (abs(s.first - c.first) + abs(s.second - c.second));
                closest_i = i;
            }
        }
        cout << closest_i + 1 << endl;
    }
}


Measured memory_bytes: 256
// Vivek Rai
// Blazer_007

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

#define fastio    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl      '\n'

typedef long long int ll;
const int hell = 1e9 + 7 ;

signed main() {

    fastio
   

    int h1 , m1 , h2 , m2 , k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int start = h1*60 + m1;
    int end = h2*60 + m2;
    int total = end - start;
    cout << total - k << endl; 

    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    LL n, m;
    cin >> n >> m;
    vector<LL> v(n);
    for(int i = 0; i < n; ++i) {
        cin >> v[i];

    }
    sort(all(v));

    int l, r;
    l = 0, r = 10000000;
    while(r - l > 1) {
        int mi = (l + r) / 2;
        LL c = 0;
        for(int i = 0; i < n; ++i) {
            int p = lower_bound(all(v), mi - v[i]) - v.begin();
            c += (n - p);

        }
        if(c < m) {
            r = mi;

        } else {
            l = mi;

        }
    }

    LL sum[SIZE] = {};
    for(int i = 0; i < n; ++i) {
        sum[i + 1] = sum[i] + v[i];

    }
    
    LL res = 0;
    for(int i = 0; i < n; ++i) {
        int p = upper_bound(all(v), l - v[i]) - v.begin();
        res += (n - p) * v[i] + (sum[n] - sum[p]);
        m -= n - p;

    }
    res += m * l;
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 2688
package main

import "fmt"

func main() {
	A := [3]int{}
	fmt.Scan(&A[0])
	fmt.Scan(&A[1])
	fmt.Scan(&A[2])
	if A[0]+A[1]+A[2] > 21 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1e18;

ll dp[100010];

signed main(){
    int n,m;
    cin>>n>>m;
    vector<int> a;
    rep(i,m){
        int b;cin>>b;
        a.push_back(b);
    }
    int k=0;
    dp[0]=1;
    for(int i=1;i<=n;i++){
        if(k<m&&m>0){
            if(i==a[k]){
                k++;
                continue;
            }
        }
        if(i==1) dp[i]+=dp[i-1]%mod;
        else dp[i]+=(dp[i-1]+dp[i-2])%mod;
    }
    cout<<dp[n]<<endl;
}

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

const ll inf = 1e18;

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll>a(n);
    for(int i=0;i<n;i++) cin >> a[i];

    ll ans = inf;

    for(int tmp=0;tmp<(1<<15);tmp++){
        bitset<15>s(tmp);
        int cnt = 0;
        for(int i=0;i<n;i++) if(s.test(i)) cnt++;
        if(cnt < k) continue;

        ll ma = 0;
        ll sum = 0;
        for(int i=0;i<n;i++){
            if(!s.test(i)){
                ma = max(ma, a[i]);
                continue;
            }
            if(a[i] > ma){
                ma = a[i];
                continue;
            }
            sum += ma - a[i] + 1;
            ma++;
        }
        
        ans = min(ans, sum);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define LOOP(i,x,n) for(int i=(x);i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  string s;
  cin>>s;
  vector<bool> used(26);
  REP(i,s.size())used[s[i]-'a']=true;

  if(s.size()==26){
    int p=30;
    for(int i=s.size()-1;i>0;i--){
      if(s[i-1]<s[i]){
        p=i-1;
        break;
      }
    }
    char mini=s[p+1];
    char tmp=s[p];
    for(int i=p+1;i<s.size();i++){
      if(tmp<s[i])mini=min(mini,s[i]);
    }
    if(p==30){
      cout<<-1<<endl;
    }else{
      cout<<s.substr(0,p)<<mini<<endl;
    }
  }else{
    cout<<s;
    REP(i,26){
      if(used[i]==false){
        cout<<(char)(i+'a')<<endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{

	int a, b,x,y,sum=0;

	scanf("%d %d", &a, &b);


	if (a <= b) {
		x = a;
		y = b;
	}
	else {
		x = b;
		y = a;
	}

	for (int i = 0;i < y;i++)
	sum = sum * 10 + x;
		printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 15:34-

            int a = sc.nextInt();
            int b = sc.nextInt();

            int x = 1;
            int cnt = 0;
            while (x < b) {
                x--;
                x += a;
                cnt++;
            }

            out.println(cnt);
        }
    }

}


Measured memory_bytes: 22996
# n = int(input())

# arr = list(map(int,input().split(" ")))

# arr.sort()

# print(arr)




# # k = 99999999999999

# # for i in range(n):

# # 	for j in range(i+1,n):

# # 		mini = min(arr[i],arr[j])

# # 		diff = abs(j-i)

# # 		temp = mini//diff


# # 		if(temp <= k):

# # 			k = mini//diff


# # print(k)


n = int(input())

a,b=0,0
flg = 1
ans = 0

for _ in range(n):

	s = input()

	if(s[0] == 'B' and s[-1] == 'A'):
		a += 1
		b += 1

	elif(s[0] == 'B'):
		b += 1
		flg = 0


	elif(s[-1] == 'A'):
		a += 1
		flg = 0 


	ans += s.count('AB')


if(min(a,b) > 0):
	ans += min(a,b) - flg

print(ans)

Measured memory_bytes: 3064
import itertools

n = int(input())
array = []
for i in range(n):
    t = int(input())
    array.append([])
    for j in range(t):
        tmp = list(map(int, input().split(" ")))
        array[i].append(tmp)

allcombs = list(itertools.product([0, 1], repeat=n))
max_val = 0
for comb in allcombs:

    if sum(comb) <= max_val:
        continue

    tmp = []
    for i, j in enumerate(comb):
        if j == 1:
            tmp += array[i]
            
    if all([comb[t[0]-1]==t[1] for t in tmp]):
        max_val = max(max_val, sum(comb))

print(max_val)

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

using namespace std;

int main() {
	int k, max = 1e6;
	cin >> k;
	int n = 0;
	if (!(k%2)) {
		cout << "-1";
		return 0;
	}
	for (int i = 0; i < max; i++) {
		n = (n * 10 + 7) % k;
		if (n == 0) {
			cout << i+1;
			return 0;
		}
	}
	if (n) {
		cout << -1;
	}
	return 0;
}

Measured memory_bytes: 3632
def bubbleSort(A, N):
    cnt = 0
    flag = 1
    while flag:
        flag = 0
        for j in range(N - 1, 0, -1):
            if A[j] < A[j - 1]:
                A[j], A[j - 1] = A[j - 1], A[j]
                flag = 1
                cnt += 1
    print(' '.join(map(str,A)))
    print(cnt)


x =int(input())
y = list(map(int,input().split(' ')))
bubbleSort(y,x)


Measured memory_bytes: 5600
N, A, B = gets.strip.split(" ").map(&:to_i)
sum = 0

(N+1).times do |i|
  num = i
  result = 0
  while num > 0 do
    result += (num % 10)
    num /= 10
  end
  if result >= A && result <= B
    sum += i
  end
end

puts sum

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

int main() {
  int s1s2s3;
  cin >> s1s2s3;
  int t1 = s1s2s3 / 100;
  int t2 = (s1s2s3 - s1s2s3 / 100 * 100) / 10;
  int t3 = s1s2s3 - s1s2s3 / 100 * 100 - (s1s2s3 - s1s2s3 / 100 * 100) / 10 *10;
  cout << t1 + t2 + t3 << endl;
}

Measured memory_bytes: 3632
N ,M= map(int, input().split())
memo =[1]*(N + 2)#start goal and hole
memo[N+1] = 0 #dead hole
impossible = False
back2 = 0
start_step =0
for i in range(M):
    a = int(input())
    memo[a] = 0 
  
def one_step(step):
    memo[step] = (memo[step+1] + memo[step+2])*memo[step]

for step in range(N-1 ,-1,-1):
    one_step(step)

print(memo[0]%1000000007)


Measured memory_bytes: 468472
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, s1, s2, s3;
  cin >> a;
  s1 = a / 100;
  s2 = (a - s1 * 100) / 10;
  s3 = a - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;
}


Measured memory_bytes: 256
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<utility>
#include <math.h>
#include <cmath>
#include <string.h>
#define __STDC_LIMIT_MACROS
#include <stdint.h>
#include <limits.h>

using namespace std;
typedef long long ll;

ll dp[4][1000005];
ll a[1000005];
ll b[1000005];
ll c[1000005];

ll n=0;
int prev=-1;//0-a,1-b,2,c
ll dpfun(int ij,int prev)
{
	if(dp[prev][ij]!= -1)
		return dp[prev][ij];
	ll i,max1 = INT_MIN;
	if(ij==n-1)
	{	
		if(prev==0)
		{
			max1=max(c[ij],b[ij]);
			max1=max(max1,c[ij]);
			dp[prev][ij]=max1;
			return max1;
		}	
		if(prev==1)
		{
			max1=max(max1,a[ij]);
			max1=max(max1,c[ij]);
			dp[prev][ij]=max1;
			return max1;
		}	
		if(prev==2)
		{
			max1=max(max1,b[ij]);
			max1=max(max1,a[ij]);
			dp[prev][ij]=max1;
			return max1;
		}	
	}
	if(prev==0)//a
	{
			max1= max(dpfun(ij+1,1)+ b[ij] ,dpfun(ij+1,2) + c[ij]);
		dp[prev][ij]=max1;
		return max1;
	}
	if(prev==1)//b
	{
			max1= max(dpfun(ij+1,0)+ a[ij] ,dpfun(ij+1,2) + c[ij]);
		dp[prev][ij]=max1;
		return max1;
	}
	if(prev==2)//c
	{
			max1= max(dpfun(ij+1,0)+ a[ij] ,dpfun(ij+1,1) + b[ij]);
		dp[prev][ij]=max1;
		return max1;
	}
	return 0;

}

int main()
{
	ios_base::sync_with_stdio(false); 
	cin>>n;
	if(n==0)
		return 0;
	memset(dp,-1, sizeof dp);
	ll i;
	for(i=0;i<n;i++)
		cin>>a[i]>>b[i]>>c[i];

	ll ans=INT_MIN;
		dp[0][0]=dpfun(0,0);
	// memset(dp,-1, sizeof dp);
		dp[1][0]=dpfun(0,1);
	// memset(dp,-1, sizeof dp);
		dp[2][0]=dpfun(0,2);

		ans=max(ans,dp[0][0]);
		ans=max(ans,dp[1][0]);
		ans=max(ans,dp[2][0]);
ll j;
	cout<<ans<<endl;
			// for(i=0;i<n;i++)
		// {
		// 	for(j=0;j<3;j++)
		// 		cout<<dp[j][i]<<" ";
		// 	cout<<endl;
		// }
	return 0;
}


Measured memory_bytes: 44672
H, W, K = map(int, input().split())
C = []

for _ in range(H):
    C.append(input())


def check(C, row, col):
    cnt = 0
    for i in range(H):
        for j in range(W):
            if row[i] == 0 and col[j] == 0 and C[i][j] == '#':
                cnt += 1

    return cnt
            
ans = 0
for i in range(1<<H):
    row = [0]*H
    for j in range(H):
        if 1&(i>>j):  # 右シフトして論理積（bit全探索）
            row[j] = 1

    for i in range(1<<W):
        col = [0]*W
        for j in range(W):
            if 1&(i>>j):  # 右シフトして論理積（bit全探索）
                col[j] = 1

        # print(row, col)
        if check(C, row, col) == K:
            ans += 1

print(ans)

Measured memory_bytes: 9176
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main(){


    int n;
    cin >> n;

    int sub[n], normal[n], add[n];

    map<int, int> cnt;

    for (int i = 0; i < n; i++){
        cin >> normal[i];
        sub[i] = normal[i] - 1;
        add[i] = normal[i] + 1;

        if (cnt.find(normal[i]) == cnt.end()){
            cnt[normal[i]] = 1;
        }
        else {
            cnt[normal[i]]++;
        }

        if (cnt.find(sub[i]) == cnt.end()){
            cnt[sub[i]] = 1;
        }
        else {
            cnt[sub[i]]++;
        } 

        if (cnt.find(add[i]) == cnt.end()){
            cnt[add[i]] = 1;
        }
        else {
            cnt[add[i]]++;
        } 
    }

    int ans = 0;

    for (auto it = cnt.begin(); it != cnt.end(); ++it){
        ans = max(ans, it->second);
    }

    cout << ans << endl;


    return 0;
}

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

int32_t main(){
	int n,p,tmp,sum=0;
	cin>>n>>p;
	for(int i=1;i<=n;i++){
		cin>>tmp;sum+=(tmp&1);
	}
	sum = n-sum;
	if(n==1){
		if(p!=sum){
			cout<<1;
		}
		else {
			cout<<0;
		}	
	}
	else {
		if(p==0){
			cout<<(1LL<<(n-(n!=sum)));
		}
		else {
			cout<<(sum!=n)*(1LL<<(n-1));
		}
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <numeric>
#include <vector>
#include <queue>
#include <map>
typedef unsigned long long ull;
typedef long long ll;
#define MAX 3005
using namespace std;

int main() {
  int a, b;
  string s;
  cin >> a >> b;
  if(a<=8&&b<=8) {
    s="Yay!";
  } else {
    s=":(";
  }
  cout << s <<endl;
  return 0;
}

Measured memory_bytes: 256
/*
  素数判定問題。
  とりあえずエラトステネスのふるいを利用。
  n が100,000 を超えるようならエラトステネス推奨。
*/

import java.util.*;
public class Main{
    static Scanner sc = new Scanner(System.in);
    public static void main(String[] args){
	boolean[] primeN = new boolean[1000000];
	setP(primeN);
	while(sc.hasNext()){
	    int n = sc.nextInt();
	    if(n!=0)  solve(primeN, n);
	}
    }

    static void solve(boolean[] primeN, int n){
	int i, count=0;
	for(i=n+1; i<=n*2; i++)
	    if(primeN[i]) count++;
	System.out.println(count);
    }

    static void setP(boolean[] primeN){
	Arrays.fill(primeN, true);
	primeN[0] = false;
	primeN[1] = false;
	for(int i=2; i<primeN.length; i++){
	    for(int j=i+i; j<primeN.length; j+=i){
		primeN[j] = false;
	    }
	}
    }
}

/* 
  データを全て読み込んでから答えを返却するタイプ。
  素数判定は√n 以下でごり押し。
  割と時間がかかるので、TimeLimitが少ない場合には要注意。
  この問題は時間に余裕があるため、ごり押し型でも通る。
 */
/*
  import java.util.Scanner;
  public class Main1172 {
     public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
     int i = 0;
     int[] read = new int[123456];  // データ読み込み用配列
     // データ読み込みここから
     while(sc.hasNext()) {
        read[i] = sc.nextInt();
        i++;
     }
     // 解答ここから、read[i]=今解答中の n
     i = 0;
     while(read[i] != 0) {
        System.out.println(Pcount(read[i]));
        i++;
     }
  }


  //与えられた整数に対して、n < x <= 2*n の素数を探し個数を数え返却する
  static int Pcount(int a) {
     int count = 0;
     for(int i = (a+1); i <= 2*a; i++) {
        if(isPrime(i)) count++;          //素数ならばカウントが増える
     }
     return count;	
  }

  //ある数が素数かどうか判定する
  // 
  static boolean isPrime(int n) {
     int f = (int)Math.sqrt(n);
     while((n % f)  > 0) f--;  // f = √n から, nを割り切れるfを探す
     return f == 1;            // n==1ならば、素数なのでtrueを返す
  }
 }
*/

Measured memory_bytes: 23344
n,m = map(int, input().split())
#a = list(map(int, input().split()))

class UnionFind:
    def __init__(self,n):
        self.par=[i for i in range(n)]
        self.siz=[1]*n

    def root(self,x):
        while self.par[x]!=x:
            self.par[x]=self.par[self.par[x]]
            x=self.par[x]
        return x

    def unite(self,x,y):
        x=self.root(x)
        y=self.root(y)
        if x==y:
            return False
        if self.siz[x]<self.siz[y]:
            x,y=y,x
        self.siz[x]+=self.siz[y]
        self.par[y]=x
        return True

    def is_same(self,x,y):
        return self.root(x)==self.root(y)

    def size(self,x):
        return self.siz[self.root(x)]

uni = UnionFind(n)
for i in range(m):
    a,b = map(int, input().split())
    uni.unite(a-1, b-1)

cnt = [0]*(n)
for i in range(n):
    cnt[uni.root(i)] = 1

print(sum(cnt)-1)

Measured memory_bytes: 14420
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int r, D, x[11];
	cin >> r >> D >> x[0];
	for(int i=0; i<10; i++){
		x[i+1]=r*x[i]-D;
		cout << x[i+1] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  int i,j,k;
  char s[1002],a[9002],m[6];
  char c[]={" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?"};
  char w[][9]={
    "101"     ,    "000000"  ,     "000011"  ,     "10010001",
    "010001"  ,    "000001"  ,     "100101"  ,     "10011010",
    "0101"    ,    "0001"    ,     "110"     ,     "01001"   ,
    "10011011",    "010000"  ,     "0111"    ,     "10011000",
    "0110"    ,    "00100"   ,     "10011001",     "10011110",
    "00101"   ,    "111"     ,     "10011111",     "1000"    ,
    "00110"   ,    "00111"   ,     "10011100",     "10011101",
    "000010"  ,    "10010010",     "10010011",     "10010000"
  };
  while(fgets(s,1001,stdin)){
    for(i=a[0]=0;s[i]-10;i++){
      for(j=0;s[i]-c[j+6];j++);
      for(k=m[5]=0;k<5;j/=2)m[4-k++]=j%2+'0';
      strcat(a,m);
    }
    for(i=0;a[i]-'2';i+=strlen(w[j])){
      for(j=0;j<32;j++){
	if(strncmp(a+i,w[j],strlen(w[j]))==0)break;
      }
      if(j==32)break;
      printf("%c",c[j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 524
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int N, K;
  string s;
  cin >> N >> s >> K;

  rep(i, N) { cout << (s[i] != s[K - 1] ? '*' : s[K - 1]); }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#pragma once
using namespace std;
int main() {
    int N;
    cin >> N;
    int X;
    cin >> X;
    vector<int> L(N);
    for(int i = 0; i < N; i++) cin >> L.at(i);

    int count = 1;
    int D = 0;
    for(int i = 0; i < N; i++){
        D = D + L.at(i);
        if(D <= X) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b) printf("%d\n",c);
	else{
		if(a==c) printf("%d\n",b);
		else     printf("%d\n",a);
	}
	return 0;
}

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

int main(void){
  int n, a[100];
  
  cin >> n;
  for(int i = 0; i < n; i ++) cin >> a[i];
  
  int max = 0;
  
  for(int i = 0; i < n; i ++){
    for(int j = i; j < n; j ++){
      if(abs(a[j]-a[i]) > max) max = abs(a[j]-a[i]);
    }
  }
  
  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
using namespace std;
int  main()
{     int n, sum =1;
       
      cin>>n;
      char c[n];
      for(int i = 0; i<n;i++)
      { 
           cin>>c[i];
      }
      
      for(int j=0 ; j<n-1;j++)
      { 
           
          if(c[j]!=c[j+1])
          { 
               sum++;
          }
          
      }
       cout<<sum;
       return 0;
}



Measured memory_bytes: 3656
#include<stdio.h>
int main()
{
    int n,a[10000],i,sum=0;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    printf("%d\n",sum-n);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
  vector<vector<bool>>d(5001,vector<bool>(5001));
int main(){
  ll a,b=0,ans=0,e,d;cin>>a;
  if(a>=105)b++;
  if(a>=135)b++;
  if(a>=165)b++;
  if(a>=189)b++;
  if(a>=195)b++;
  cout<<b;
}



Measured memory_bytes: 30176
#include<stdio.h>
#include<math.h>
//static const int N =10000,X=10*10*10*10*10*10*10*10;
int main()
{
  int n, x,count=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      scanf("%d",&x);
      if(1==isPrime(x))count+=1; 
    }	 
 
  printf("%d\n",count);

  return 0;
}

int isPrime(int x)
{
  int i;
  if (x == 2) return 1;

  if( x < 2 || x%2==0)return 2;
  i = 3;
  while (i*i <= x )
    {
      if (x%i==0)return 2;
      i = i + 2;
    }
  return 1;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pr pair<int,int>
#define SZ(S) int(S.size())
#define REP(i,a,b) for(int i=a;i<b;++i)
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define FORD(i,b,a) for(int i=b;i>=a;--i)
#define CLR(A,x) memset(A,x,sizeof(A))
#define ALL(S) S.begin(),S.end()

#define OUT(a,l,r) cout<<#a": ";FOR(i,l,r)cout<<a[i]<<" ";cout<<endl
#define PRT(a) cout<<"--> "#a" "<<a<<endl

using namespace std;
typedef long long ll;

const int N=100005,INF=0x3f3f3f3f;
const ll P=1e9+7;

template<typename T>
inline void read(T& x,int f=1,char s=getchar()) {
	for(x=0;s>'9'||s<'0';s=getchar()) if(s=='-') f=-1; 
	while(s<='9'&&s>='0') x=x*10+s-'0',s=getchar();x*=f;
}

char s[N];
char t[N]={'Y','A','K','I'};
int main() {
	scanf("%s",s);
	if(strlen(s)<4) {
		cout<<"No";
		return 0;
	}
	FOR(i,0,3) if(s[i]!=t[i]) {
		cout<<"No";
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

using namespace std;

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

  for(int i=0;i<t;i++){
    int n,k;
    cin >> n >> k;
    int x[100000]={};
    for(int j=0;j<n;j++) cin >> x[j];
    int d[99999]={};
    for(int j=1;j<n;j++) d[j-1]=x[j]-x[j-1];
    sort(d,d+n-1);

    int sum=0;
    for(int j=0;j<n-k;j++) sum+=d[j];
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
 
    void solve() throws IOException {
        int N = ni();
        int M = ni();
        int X= ni()-1;
        int[] a = new int[N];
        for (int i = 0; i < M; i++) {
            int at = ni()-1;
            a[at] = 1;
        }
        int right = 0;
        int left = 0;
        for (int i = X+1; i < N; i++) {
            right += a[i];
        }
        for (int i = X-1; i >=0; i--) {
            left += a[i];
        }
 
        out.println(Math.min(left, right));
    }

    final int mod = 1000000007;
    final BigInteger MOD = BigInteger.valueOf(mod);

    int mul(int x, int y){
        int val = (int)((x * 1L * y) % mod);
        return val>=0 ? val : val+mod;
    }
    int add(int x, int y) {
        x += y;
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    int sub(int x, int y){
        x = add(x,mod-y);
        if(x < 0) x += mod;
        if(x>=mod) x -= mod;
        return x;
    }
    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }
 
    int ni() throws IOException {
        return Integer.parseInt(ns());
    }
 
    long nl() throws IOException {
        return Long.parseLong(ns());
    }
 
    double nd() throws IOException {
        return Double.parseDouble(ns());
    }
 
    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }
 
    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }
 
    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }
 
    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;
 
    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}

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

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long LL;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    long long N;
    cin >> N;

    int r = floor(sqrt(N));

    REP(i, r) {
        int c = r - i;
        if (N % c == 0) {
            cout << floor(log10(N / c) + 1) << endl;
            break;
        }
    }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    long H;
    long W;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.H = sc.nextLong();
        this.W = sc.nextLong();
    }
    
    //解答処理
    private long solve() {
        long count = 1;
        
        if (H != 1 && W != 1) {
        	long area = H*W;
        	if (area % 2 == 0) {
        		count = area / 2;
        	} else {
        		count = (area+1) / 2;
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(long answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 35524
table=[True for i in range(123456*2+1)]
table[0:2]=[False,False]
for i in range(2,len(table)):
    if table[i]==True and i*i<len(table):
        j=i*i
        while j<len(table):
            table[j]=False
            j+=i
while 1:
    n=int(input())
    if n==0:
        break
    ans=0
    for i in range(n+1,2*n+1):
        if table[i]==True:
            ans+=1
    print(ans)


Measured memory_bytes: 7568
n=int(input())
from itertools import product as p
l=['7','5','3']
a=[]
for i in range(1,11):
  for j in p(l,repeat=i):
    t=''.join(j)
    if '3' in t and '5' in t and '7' in t:
      a.append(int(t))
a.sort()
from bisect import bisect_right as bi
print(bi(a,n))

Measured memory_bytes: 6424
#include <iostream>
#include <stdio.h>

using namespace std;

void solve()
{
	int sum = 0;
	int q_sum = 0;
	int count = 0;
	int unit_price, quantity;
	while(~scanf("%d,%d", &unit_price, &quantity))
	{
		sum += unit_price * quantity;
		q_sum += quantity;
		++count;
	}
	cout << sum << endl;
	cout << (int)((double)q_sum / count + 0.5) << endl;
}

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

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (1000000000)
#define linf (1000000000000000000ll)
#define mod (1000000007)

int a,b;

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b))<<endl;
	
	
	return 0;
}


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

typedef long long ll;

int n,x[15],y[15],p[15],D[15],d[15];
ll ans[16];

int main(){

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

    cin>>n;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>p[i];
    memset(ans,0x3f,sizeof(ans));
    ans[0]=0;
    for(int i=0;i<n;i++){
        D[i]=min(abs(x[i]),abs(y[i]));
        ans[0]+=(ll)p[i]*D[i];
    }
    for(int s=0;s<1<<n;s++){
        for(int t=s;t;t=(t-1)&s){
            memcpy(d,D,sizeof(d));
            for(int i=0;i<n;i++){
                if(s>>i&1){
                    if(t>>i&1){
                        for(int j=0;j<n;j++){
                            d[j]=min(d[j],abs(x[i]-x[j]));
                        }
                    }else{
                        for(int j=0;j<n;j++){
                            d[j]=min(d[j],abs(y[i]-y[j]));
                        }
                    }
                }
            }
            ll cur=0;
            for(int i=0;i<n;i++){
                cur+=(ll)d[i]*p[i];
            }
            ans[__builtin_popcount(s)]=min(ans[__builtin_popcount(s)],cur);
        }
        {
            int t=0;
            memcpy(d,D,sizeof(d));
            for(int i=0;i<n;i++){
                if(s>>i&1){
                    if(t>>i&1){
                        for(int j=0;j<n;j++){
                            d[j]=min(d[j],abs(x[i]-x[j]));
                        }
                    }else{
                        for(int j=0;j<n;j++){
                            d[j]=min(d[j],abs(y[i]-y[j]));
                        }
                    }
                }
            }
            ll cur=0;
            for(int i=0;i<n;i++){
                cur+=(ll)d[i]*p[i];
            }
            ans[__builtin_popcount(s)]=min(ans[__builtin_popcount(s)],cur);
        }
    }
    for(int i=0;i<=n;i++)cout<<ans[i]<<'\n';

    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
using namespace std;
typedef pair<int,int> P;
const int INF = ~(1<<31) / 2;

int field[15][15];
int dp[15][15];

int main(){
    while(1){
        int X,Y;
        scanf("%d %d",&X,&Y);
        if(X==0)break;
        for(int i=0;i<Y;i++){
            for(int j=0;j<X;j++){
                scanf("%d",&field[i][j]);
            }
        }

        for(int j=0;j<X;j++){
            dp[Y-1][j] = field[Y-1][j] == 1 ? 0 : 1;
        }

        for(int i=Y-2;i>=0;i--){
            for(int j=0;j<X;j++){
                if(field[i][j]==1){
                    dp[i][j] = 0;
                }else if(field[i][j]==2){
                    dp[i][j] = i+2<Y ? dp[i+2][j] : 1;
                }else{
                    dp[i][j] = 0;
                    if(j-1>=0 && field[i+1][j-1]==0){
                        dp[i][j] += dp[i+1][j-1];
                    }
                    if(j+1<X && field[i+1][j+1]==0){
                        dp[i][j] += dp[i+1][j+1];
                    }
                    if(field[i+1][j]!=1){
                        dp[i][j] += dp[i+1][j];
                    }
                }
            }
        }
        int ans = 0;
        for(int j=0;j<X;j++){
            ans += dp[0][j];
        }
        printf("%d\n",ans);
    }

    return 0;
}

Measured memory_bytes: 1188
A, B = map(int, input().split())

def is_palindrome(S):
    for i in range(len(S) // 2 ):
        if S[i] != S[len(S) - i - 1]:
            return False
    return True

ans = 0
for i in range(A, B + 1):
    if is_palindrome(str(i)):
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int frac(int n){
    int ret=1;
    while(n){
        ret*=n;
        n--;
    }
    return ret;
}
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    double ans=0;
    vector<double> x(n),y(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            double X=x[i]-x[j],Y=y[i]-y[j];
            ans+=sqrt(X*X+Y*Y);
        }
    }
    cout<<setprecision(20)<<ans*2/n;
}

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

typedef unsigned long long int ll;
typedef unsigned long int l;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll x, temp = 100;
  cin >> x;
  l year = 0;
  while (temp < x) {
    year++;
    temp += temp/100;
  }
  cout << year;
  return 0;
}

Measured memory_bytes: 3596