akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PLL = pair<ll, ll>;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repn(i,n) for(int i = 0; i <= (int)(n); i++)
#define srep(i,l,n) for(int i = l; i < (int)(n); i++)
#define srepn(i,l,n) for(int i = l; i <= (int)(n); i++)
#define drep(i,n) for(int i = (int)(n-1); i >= 0; i--)
#define drepn(i,n) for(int i = (int)(n); i >= 0; i--)
#define size(s) (int)s.size()
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<typename T> inline istream& operator>>(istream &i, vector<T> &v) {rep(j, size(v)) i >> v[j]; return i;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> T gcd(T a, T b) {if(b==0)return a; else return gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return a/gcd(a,b)*b;}
template<class T = int> using V = vector<T>;
template<class T = int> using VV = vector<V<T>>;
bool isIn(int i, int j, int h, int w) {return i >= 0 && i < h && j >= 0 && j < w;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define ep emplace_back

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n+1, 2);
    ll ans = 1;
    srepn(i, 2, n) {
        ans += (ll)i * a[i];
        for(int j = i + i; j <= n; j+=i) {
            a[j] += 1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 42248
#include <bits/stdc++.h>
using namespace std;
using lint=long long;
static const lint MAX=1000000000000000000;
static const string s="unfair";

int main(){
  lint t,n,h,k;
  lint t1,t2,t3;
  lint ans=0;
  cin >> t >> n >> h >> k;
  if(k==0) ans=t-n;
  else if(k==1) ans=n-t;
  else if(k%2==0) ans=(t-n);
  else ans=(t-n)*-1;

  if(ans>MAX) cout << s << endl;
  else cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}/*swap 交換*/
ll max2(ll a,ll b){return a>=b?a:b;}/*2つのうち大きい数を返す*/ 
ll min2(ll a,ll b){return a>=b?b:a;}/*2つのうち小さい数を返す*/ 
ll ABS(ll a){return a>=0?a:(-a);}/*絶対値*/ 
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

/*-------------------------------------------------------------*/
// Weighted Union Find
typedef struct{
    ll num; //number
    ll par; //parent
    ll hei; //height
    ll wdif;
    ll wei;
}WUF;
void WUFmake(ll n, WUF b[n]){for(ll i=0;i<n;i++){
    b[i].par = i;
    b[i].num = i;
    b[i].hei = 1;
    b[i].wdif = 0;
    b[i].wei = 0;
    }
}
ll WUFroot(ll n, ll a, WUF b[n]){
    ll c= a==b[a].par ? a : WUFroot(n,b[a].par,b) ;
    b[a].wei = b[b[a].par].wei + b[a].wdif;
    return c;
}
// b[x]+z=b[y]
void WUFunite(ll n, ll x, ll y, ll z, WUF b[n]){
    ll xr = WUFroot(n,x,b), yr = WUFroot(n,y,b);
    if(b[xr].hei > b[yr].hei){ b[yr].par = xr;  b[yr].wdif = b[x].wei+z-b[y].wei;
    }else{ b[xr].par = yr;  b[yr].hei = max2(b[yr].hei,b[xr].hei+1);  b[xr].wdif = b[y].wei-b[x].wei-z;}
}
ll WUFsame(ll n, ll x, ll y, WUF b[n]){ return WUFroot(n,x,b) == WUFroot(n,y,b) ? 1 : 0; }



int main(void){
    ll n,m;
    scanf("%lld%lld",&n,&m);
    // if(m==0){
    //     printf("Yes\n");
    //     return 0;
    // }
    ll l[m],r[m],d[m];
    WUF tree[n];
    WUFmake(n,tree);
    rep(i,0,m){
        scanf("%lld%lld%lld",&l[i],&r[i],&d[i]);
    }
    rep(i,0,m){
        if(WUFsame(n,l[i]-1,r[i]-1,tree)){
            if(tree[r[i]-1].wei - tree[l[i]-1].wei != d[i]){
                printf("No\n");
                return 0;
            }
        }else{
            WUFunite(n,l[i]-1,r[i]-1,d[i],tree);
        }
    }
    printf("Yes\n");
    return 0;
}

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

int main(){
    int N,R;
    cin >> N >> R;
    if(N>=10) cout << R << endl;
    else{
        R = R + 100*(10 - N);
        cout << R << endl;
    }
}

Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]


x = int(input())
ps = primes(10**6)
ind = bisect_left(ps, x)
val = ps[ind]
print(val)

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

int main(){

  int N; cin >> N;
  vector<int> A(N);
  
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  int max = 0; int second = 0;
  
  for(int i=0; i<N; i++){
    
    if(A.at(i) >= max){
      second = max;
      max = A.at(i);
      continue;
    }
    
    if(A.at(i) > second)
      second = A.at(i);
  }
  
  for(int i=0; i<N; i++){
    
    if(A.at(i) == max)
      cout << second << endl;
    else
      cout << max << endl;
    
  }
  
}

Measured memory_bytes: 2432
#include <iostream>
using namespace std;
int main(){
  int a,b,c,k;
  int ans = 0;
  cin >> a >> b >> c >> k;
  if (a >= k) ans = k;
  if(a <= k && k<= (a+b)) ans = a;
  if(k >= a+b) ans = 2*a - k + b;
  cout << ans <<endl;
}
    

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
const long double PI =(acos(-1));

int main(){
    int a,b;
    char op;
    int n=1;
    while(n){
        cin >> a >> op >> b;
        switch(op){
            case '+': cout << a+b << endl;
                      break;
            case '-': cout << a-b << endl;
                      break;
            case '*': cout << a*b << endl;
                      break;
            case '/': cout << a/b << endl;
                      break;
            case '?': n=0;
                      break;
        }
    }

    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <stdio.h>
#include <string.h>

#define rep(i, n) for (int i = 0; i < n; ++i)
typedef unsigned long long ll;

using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    ll left = 4 * a * b;
    ll right = (c - a - b) * (c - a - b);
    if (c-a-b < 0){
        cout << "No" << endl;
    }
    else if (left < right){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main(void){
    //?¬??????¨????????????\?????????????????§?¶???????
    int ans[1000];
    int cnt=0;
    while(1){

        int num[2];
        char op;
        //??°???????¬?????????°????????????
        scanf("%d %c %d",&num[0],&op,&num[1]);
        //?¬??????¨??????????????????
        switch(op){
            case '+':
                ans[cnt]=num[0]+num[1];
                break;
            case '-':
                ans[cnt]=num[0]-num[1];
                break;
            case '*':
                ans[cnt]=num[0]*num[1];
                break;
            case '/':
                ans[cnt]=floor(num[0]/num[1]);
                break;
        }
        //??????\????????????
        if(op=='?')break;
        cnt++;

    }
    int i;
    //??¨??????????????????
    for (i=0;i<cnt;i++){
        printf("%d\n",ans[i]);
    }
    
return 0;
}

Measured memory_bytes: 604
fn main() {
    let v = read_vec::<u32>();
    let n = 100 * v[0] + 10 * v[1] + v[2];

    if n % 4 == 0 {
        println!("YES");
        return
    }
    println!("NO");
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
n = int(input())
a = list(map(int, input().split()))

mod = 10**9+7
resl = [0] * 60
for i in a:
    for j in range(60):
        if i & 1 > 0:
            resl[j]+=1
        i = i >> 1
        if i == 0:
            break

result = 0
for i in range(60):
    result = (result + 2**i * resl[i] * (n-resl[i])) % mod
print(result)


Measured memory_bytes: 122932
// Problem : C - 2D Plane 2N Points
// Contest : AtCoder Regular Contest 092
// URL : https://atcoder.jp/contests/arc092/tasks/arc092_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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

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

struct point {
	int x, y;
} r[N], b[N];

int n, ans = 0;
bool kil[N], del[N];

int main() { cin.tie(0)->sync_with_stdio(0);
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> r[i].x >> r[i].y;
	}
	for (int i = 1; i <= n; i++) {
		cin >> b[i].x >> b[i].y;
	}
	sort(r + 1, r + n + 1, [](point a, point b) {
		return a.x > b.x;
	});
	sort(b + 1, b + n + 1, [](point a, point b) {
		return a.y < b.y;
	});
	for (int j = 1; j <= n; j++) {
		for (int i = 1; i <= n; i++) {
			if (!kil[i] && !del[j] && r[i].x < b[j].x && r[i].y < b[j].y) {
				kil[i] = 1;
				del[j] = 1;
				ans++;
			}
		}
	}
	cout << ans;
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
using namespace std;
using ll = long long;



int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n, t; cin >> n;
    map<ll, int> m;
    ll ans = 0, sum = 0;

    ++m[0];
    for(int i=0; i < n; ++i) {
        cin >> t;
        sum += t;
        ans += m[sum];
        ++m[sum];
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 12800
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll N;
vector<ll> a,b,c;

int main(){
    ll ans = 0;
    cin >> N;
    a.resize(N);
    b.resize(N);
    c.resize(N);
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=0;i<N;i++) cin >> b[i];
    for(int i=0;i<N;i++) cin >> c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll an,cn;
    for(int i=0;i<N;i++){
        an = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
        cn = c.end() - upper_bound(c.begin(),c.end(),b[i]);
        ans += an * cn;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
int M,N,j,b,max,k,an,a;
  j=0;
  an=0;
  a=0;
  cin>>N>>M;
  int d[10][10];
  int pi[M];
    for(int i=0;i<10;i++){
    for(int u=0;u<10;u++){
     d[i][u]=0;
    }
  }
  for(int i=0;i<M;i++){
    cin>>k;
    for(int u=0;u<k;u++){
      cin>>d[i][u];
    }
  }
      for(int u=0;u<M;u++){
      cin>>pi[u];
    }
    int ans[11];
  ans[0]=0;
  for(int i=0;i<pow(2,N);i++){
ans[1]=i%2;
    ans[2]=(i/2)%2;
    ans[3]=(i/4)%2;
      ans[4]=(i/8)%2;
      ans[5]=(i/16)%2;
    ans[6]=(i/32)%2;
    ans[7]=(i/64)%2;
      ans[8]=(i/128)%2;
      ans[9]=(i/256)%2;
    ans[10]=(i/512)%2;

    for(int p=0;p<M;p++){
      for(int u=0;u<10;u++){
        an+=ans[d[p][u]];
      }
    if(an%2==pi[p]){
      if(p!=M-1){
        an=0;
      continue;
      }
      else{
        an=0;
    	a++;
        break;
      }
    }
    else{
      an=0;
      break;
    } 
  
    }
  }
              cout<<a<<endl;
}


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

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll N, M;
ll S[20050], T[20050];
ll dp[20050];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= N; i++) cin >> S[i];
    for(int i = 1; i <= M; i++) cin >> T[i];
    dp[0] = 1;
    for(int s = 1; s <= N; s++) {
        ll now = 1;
        for(int t = 1; t <= M; t++) {
            ll newnow = (now + dp[t]) % mod;
            if(S[s] == T[t]) {
                dp[t] = (dp[t] + now) % mod;
            }
            now = newnow;
        }
    }
    ll ans = 0;
    for(int t = 0; t <= M; t++) {
        ans = (ans + dp[t]) % mod;
    }
    cout << ans << endl;
    return 0;
}


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

long long int n,x[110],y[110],dp[110][100100],i,j,w;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>w;
	for (i=1;i<n+1;i++) cin>>x[i]>>y[i];
	for (i=1;i<w+1;i++) dp[0][i]=0;
	for (i=1;i<n+1;i++)
	for (j=1;j<w+1;j++)
	{
		if (x[i]>j) dp[i][j]=dp[i-1][j];
		else dp[i][j]=max(dp[i-1][j],dp[i-1][j-x[i]]+y[i]);
	}
	cout<<dp[n][w];
}

Measured memory_bytes: 80128
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#pragma region atcoder
/*#include <atcoder/dsu>
using namespace atcoder;*/
//using mint = modint998244353;
//These are for segment tree
/*int op(int a, int b){return max(a, b);}
int e(){return -1;}
bool f(int v){ return v < target;}
*/
#pragma endregion
#pragma region macros
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vl = vector<ll>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n - 1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#pragma endregion
#pragma region debug for var, v, vv
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){cout << endl;int cnt = 0;for(const auto& v : vv){cout << cnt << "th : "; view(v); cnt++;} cout << endl;}
#pragma endregion

const ll mod = 1000000007;
const int inf = 1001001001;
const ll INF = 1001001001001001001;

template<class T>bool chmax(T &a, const T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T b) { if (b<a) { a=b; return 1; } return 0; }
ll modpow(ll a, ll p){ll ret = 1; while(p){if(p & 1){ret = ret * a % mod;} a = a * a % mod; p >>= 1;} return ret;}

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

/*-----------------------------------------------------------------------------------------------------*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m, k; cin >> m >> k;
	if(k >= pow(2, m)) cout << -1 << endl;
	else if(m == 1){
		if(k == 0) cout << "1 1 0 0" << endl;
		else cout << -1 << endl;
	}
	else{
		vi b(1 << m);
		rep(i, 1<<m) b[i] = i;
		vi c = b;
		reverse(all(c));
		rep(i,sz(b)){
			if(i == k) continue;
			cout << i << " ";
		}
		cout << k << " ";
		rep(i,sz(c)){
			if(c[i] == k) continue;
			cout << c[i] << " ";
		}
		cout << k << endl;
	}
}

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

int main() {
	long long N, M, X; cin >> N >> M >> X;
	vector<int>C(N);
	vector<vector<int>>A(N, vector<int>(M));
	for (long long i = 0; i < N; i++) {
		cin >> C.at(i);
		rep(j, M) cin >> A.at(i).at(j);
	}
	long long ans = 1e9;
	rep(i, (1 << N)) {
		vector<int>B;
		rep(j, N) {
			if (i & (1 << j)) B.push_back(j);
		}
		if (!B.empty()) {
			vector<int>Algo(M, 0);
			long long num = 0;
			rep(j, B.size()) {
				num += C.at(B.at(j));
				rep(k, M) {
					Algo.at(k) += A.at(B.at(j)).at(k);
				}
			}
			bool check = true;
			rep(j, M) {
				if (Algo.at(j) < X) check = false;
			}
			if (check) {
				ans = min(ans, num);
			}
		}
	}
	if (ans == 1e9) cout << -1 << endl;
	else cout << ans << endl;
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(2000000)

def comb(n,k):
    if n==k or k==0:
        return 1
    elif lis[n][k]>0:
        return lis[n][k]
    else:
        lis[n][k]=comb(n-1,k)+comb(n-1,k-1)%1000000007
        return lis[n][k]
    
    

def divide(k,i):
    return comb(k-1,i-1)
n,k = map(int,input().split())
lis = [[0]*i for i in range(1,n+1)]

for i in range(1,k+1):
    if i-1 <= n-k:
        print(divide(k,i)*comb(n-k+1,i)%1000000007)
    else:
        print(0)

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

int main() {
	int N, M, a, b, c[50] = { 0 };
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		c[a-1]++;
		c[b-1]++;
	}
	for (int i = 0; i < N; i++) {
		cout << c[i] << endl;
	}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

ld memo[1001][1001];
ld getans(const int know, const int notknow) {
	assert(know <= notknow);
	if (memo[know][notknow] < -0.1) {
		if (notknow == 0) {
			memo[know][notknow] = 0.;
		}else{
			ld ans = 0;


			//??\??£????????????
			{
				ld per = ld(know) / notknow;
				if (know) {

					ans += per*(getans(know - 1, notknow - 1));
				}
			}

			if (notknow != know) {
				//??\???????????????
				{
					ld per = ld(notknow - know) / notknow;

					//??£?§£
					{
						ld per2 = 1. / (notknow - 1.);
						ans += per*per2*(getans(know, notknow -2));
					}
					//??\???????????????
					{
						ld per2 = (notknow - know - 2.) / (notknow - 1.);
						if (know + 2 != notknow) {

							ans += per*per2*(1 + getans(know + 2, notknow - 2));
						}
					}
					//??\??£????????????
					{
						ld per2 = ld(know) / (notknow - 1.);
						ans += per*per2*(1 + getans(know, notknow - 2));
					}
				}
			}
			memo[know][notknow] = ans;
		}
	}
	return memo[know][notknow];
}
int main() {
	cout << setprecision(22) << fixed;
	for (int i = 0; i < 1001; ++i) {
		for (int j = 0; j < 1001; ++j) {
			memo[i][j] = -1;
		}
	}
	while (1) {
		int N; cin >> N;
		if (!N)break;
		ld ans = getans(0, N);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 18844
#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
long long modpow(long long a, long long b){
	a %= MOD;
	long long res = 1;
	while (b > 0){
		if (b % 2 == 1) res = res * a % MOD;
		a = a * a % MOD;
		b = b / 2;
	}
	return res;
}
long long modinv(long long a){
	return modpow(a, MOD - 2);
}
vector<long long> mf;
vector<long long> mfinv;
long long modfact(long long n){
	if (n < mf.size()){
		return mf[n];
	} else {
		if (mf.empty()) mf.push_back(1);
		long long res = mf.back();
		for (int i = mf.size(); i <= n; i++){
			res = res * i % MOD;
			mf.push_back(res);
		}
      	
		return res;
	}
}
long long modbinom1(long long n, long long r){
	long long res;
	res = modfact(n);
	res = res * modinv(modfact(r)) % MOD;
	res = res * modinv(modfact(n - r)) % MOD ;
	return res;
}
int main(){
  int H, W, A, B;
  cin >> H >> W >> A >> B;
  H--;
  W--;
  long long ans = 0;
  for (int i = 0; i <= H - A; i++){
    ans += (modbinom1(B + i - 1, B - 1) * modbinom1(W - B + H - i, W - B) % MOD);
    ans %= MOD;
  }
  cout << ans;
}

Measured memory_bytes: 2420
import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }




void main() {
  try {
    for (; ; ) {
      const S = readToken();
      const N = cast(int)(S.length);
      
      int[] xs;
      foreach (i; 0 .. N + 1) {
        if ((i == 0 || S[i - 1] == '>') && (i == N || S[i] == '<')) {
          xs ~= i;
        }
      }
      const xsLen = cast(int)(xs.length);
      debug {
        writeln("xs = ", xs);
      }
      
      auto ans = new long[N + 1];
      foreach (i; 0 .. xs[0] + 1) {
        ans[i] = xs[0] - i;
      }
      foreach (i; xs[xsLen - 1] .. N + 1) {
        ans[i] = i - xs[xsLen - 1];
      }
      
      foreach (j; 0 .. xsLen - 1) {
        const a = xs[j];
        const b = xs[j + 1];
        int c;
        for (c = a; c < b && S[c] == '<'; ++c) {}
        debug {
          writeln(a, " ", c, " ", b);
        }
        foreach (i; a .. c) {
          ans[i] = i - a;
        }
        ans[c] = max(c - a, b - c);
        foreach (i; c + 1 .. b) {
          ans[i] = b - i;
        }
      }
      
      debug {
        writeln(ans);
      }
      writeln(ans.sum);
    }
  } catch (EOFException e) {
  }
}


Measured memory_bytes: 8208
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define eb emplace_back
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <class T>
void chmin(T &a, T b) { a = min(a, b); }
template <class T>
void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll x;
    cin >> x;
    ll res = 1000LL * (x / 500);
    x %= 500;
    res += 5 * (x / 5);
    cout << res << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
n, m = map(int, input().split())

friend = [set() for i in range(n)]

for i in range(m):
  a = list(map(int, input().split()))
  a.sort()
  x, y = a[0]-1,a[1]-1
  friend[x].add(y)
  friend[y].add(x)

def dfs(s):
  if vis[s] == False:
    vis[s] = True
    ary.append(s)
    for j in friend[s]:
      dfs(j)
vis = [False for i in range(n)]
ans = 0
for i in range(n):
  ary = []
  dfs(i)
  ans = max(ans,len(ary))
print (ans)




Measured memory_bytes: 708352
using System;

class AtCoder
{
  	static int abs(int x)
    {
      if( x >= 0 ) return x;
      else return -x;
    }
  
    static void Main(string[] args)
    {
      Console.ReadLine();
        string s;
      	var cx = 0;
      	var cy = 0;
      	var ct = 0;
      	while((s=Console.ReadLine()) != null ){
        	var n = s.Split(' ');     
          	var t = int.Parse(n[0]);
          var t2 = t-ct;
          	var x = int.Parse(n[1]);
          	var y = int.Parse(n[2]);
          
           var m = abs(cx-x) + abs(cy-y);
          	if( t2 < m ) {
              Console.Write("No");
              return ;
            }
            if( m != t2 ){
              if( ((t2-m) & 0x00000001) == 1 ){
              Console.Write("No");
              return ;                
              }
            }
          
          cx = x;
          cy = y;
          ct = t;
      	}      	
      
                    Console.Write("Yes");
    }
}

Measured memory_bytes: 15184
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = list(input())
    n = len(s)
    alp = list("abcdefghijklmnopqrstuvwxyz")
    f = {}
    for i in range(26):
        f[alp[i]] = i
    if n == 26:
        if s == alp[::-1]:
            print(-1)
        else:
            d = [1]*26
            m = f[s[-1]]
            d[m] = 0
            for i in range(n-1)[::-1]:
                if m > f[s[i]]:
                    break
                m = f[s[i]]
                d[m] = 0
            k = f[s[i]]
            for j in range(k+1,n):
                if not d[j]:
                    break
            s = s[:i]+[alp[j]]
            print(*s,sep = "")
    else:
        d = [1]*26
        for i in s:
            d[f[i]] = 0
        for i in range(26):
            if d[i]:
                break
        s += [alp[i]]
        print(*s,sep = "")
    return
#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

ll gcd(ll a,ll b){return b ? gcd(b,a%b) :a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}

ll n;



    vector<pair<ll,ll>>p;
void fs(ll a){
    for(ll i=2;i*i<=n;i++){
        ll cnt=0;
        while(n%i==0){
            n/=i;
            cnt++;
        }
        p.emplace_back(i,cnt);
    }
    return;
}


ll di[]={1,0,-1,0};
ll dj[]={0,-1,0,1};
int main()
{
 const ll m=1000000007;
 ll n;
 cin>>n;
 vector<ll>a(n);
 rep(i,n)cin>>a[i];
 vector<ll>v(n);
 v[0]=a[0];
 Rep(i,n)v[i]=v[i-1]+a[i];
 ll sum=0;
 ll ans=0;
 rep(i,n){
     ll sum=(v[n-1]-v[i])%m;
     ans+=a[i]*sum;
     ans%=m;
 }
 cout<<ans<<endl;
 
}
 




Measured memory_bytes: 6420
#include<iostream>
#include<vector>
#include<string>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

#define inf INT_MAX/3
#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define MP make_pair
#define mp make_pair
#define ALL(a) (a).begin(),(a).end()
#define all(a) (a).begin(),(a).end()
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define PII pair<int,int>
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define VS vector<string>
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define pi 2*acos(0.0)
#define INFILE() freopen("in0.txt","r",stdin)
#define OUTFILE()freopen("out0.txt","w",stdout)
#define in scanf
#define out printf
#define LL long long
#define ll long long
#define ULL unsigned long long
#define ull unsigned long long
#define eps 1e-14
#define FST first
#define SEC second

int N,A,B;
VI X;

int main(){

	cin >> N >> A >> B;
	X.resize(N);
	REP(i,N){
		cin >> X[i];
	}
	long long ans;
	REP(i,N-1){
		if((long long)A*(X[i+1]-X[i]) > B)
			ans += B;
		else
			ans += (long long)A*(X[i+1]-X[i]);
	}
	cout << ans;

}

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

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

    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }

    vector<pair<int, string>> A;
    int maxi = 0;
    for(auto x : mp){
        A.push_back({x.second, x.first});
        maxi = max(maxi, x.second);
    }

    sort(A.begin(), A.end());

    // cout << "#" << endl;
    vector<string> Ans;
    for(int i = (int)A.size() - 1; i >= 0; i--){
        if(maxi == A[i].first) Ans.push_back(A[i].second);
    }

    sort(Ans.begin(), Ans.end());

    // cout << "@" << endl;
    for(auto x : Ans){
        cout << x << endl;
    }

    return 0;
}

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

int main(){
    std::string s;

    std::cin >> s;

    if (s == "ABC")
    {
        std::cout << "ARC" << std::endl;
    }
    else
    {
        std::cout << "ABC" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int main()
{
  string S;
  cin >> S;
  int K;
  cin >> K;
  set<string> st;
  REP(i,S.size()){
    FOR(j,1,6){
      st.insert(S.substr(i,min(j,(int)S.size()-i)));
    }
  }

  auto itr = st.begin();
  REP(i,K-1){
    itr++;
  }
  cout << *itr << endl;
}

Measured memory_bytes: 1664
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
const int N=100005;

void solve()
{
    int n;
    cin>>n;
    string s;map<string,int>mp;map<string,int>::iterator it;int mx=0;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        mp[s]++;
    }
    it=mp.begin();
    while(it!=mp.end())
    {
        mx=max(mx,it->second);
        it++;
    }
    it=mp.begin();
    while(it!=mp.end())
    {
        if(it->second==mx)
            cout<<it->first<<endl;
        it++;
    }
}
int32_t main()
{
    IOS;
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main(){
    string s;
    cin>>s;
    int n=s.size();
    string t="";
    rep(i,n){
        if(i%2==0) t+='g';
        else t+='p';
    }

    int ans=0;
    rep(i,n){
        if(s[i]=='g' && t[i]=='p') ans++;
        else if(s[i]=='p' && t[i]=='g') ans--;
    }

    cout<<ans<<endl;
}




Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <numeric>
#include <algorithm>
#include <iomanip>
#include <queue>
using namespace std;
#define INF 1000000007
#define ll long long
#define rep(i, start, end) for(ll i=(ll)start; i<(ll)end; i++)
#define print(a) cout << a << endl;
#define printarray(a, len) rep(ii,0,len) cout << a[ii] << " ";

int main(){
  ll h, w, count=0, last=0, ans=0;
  cin >> h >> w;
  ll grid[2001][2001] = {};
  string s;
  
  rep(i, 0, h){
    cin >> s;
    rep(j, 0, w){
      if (s[j] == '.') {
        grid[i][j]++;
      }
    }
  }
  
  rep(i, 0, h){
    rep(j, 0, w+1){
      if (grid[i][j] > 0 && last > 0){
        count++;
      }
      else if (grid[i][j] == 0 && count > 0){
        rep(k, 0, count+1){
          grid[i][j-k-1] += count;
        }
        count = 0;
      }
      last = grid[i][j];
    }
    last = 0;
    count = 0;
  }
  
  rep(j, 0, w){
    rep(i, 0, h+1){
      if (grid[i][j] > 0 && last > 0){
        count++;
      }
      else if (grid[i][j] == 0 && count > 0){
        rep(k, 0, count+1){
          grid[i-k-1][j] += count;
        }
        count = 0;
      }
      last = grid[i][j];
    }
    last = 0;
    count = 0;
  }
 
  rep(i, 0, h){
    rep(j, 0, w){
      ans = max(ans, grid[i][j]); 
    }
  }
  print(ans);
  
  return 0;
}

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

if((A%2 == 0)or(B%2 == 0)or(C%2 == 0)):
  ans = 0
else:
  max_num = max(A,B,C) 
  if(max_num == A): 
    ans = 1*B*C
  elif(max_num == B):
    ans = 1*A*C
  else:
    ans = 1*A*B

print(ans)    

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
char s[4];
int main(){
    for(int i=0;i<4;i++){
        cin >> s[i];
    }
    if(s[0] == s[1] && s[1] == s[2] && s[2] ==s[3] ){
        cout << "No" << endl;
    }
    else if(
        (s[0] == s[1] && s[2] == s[3])||
        (s[0] == s[2] && s[1] == s[3])||
        (s[0] == s[3] && s[1] == s[2])
    ){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;



int main(int argc, char *args[]) {
	int n, m, x;
	int a[100];
	cin >> n >> m >> x;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	int left = 0, right = 0;
	for (int i = 0; i < m; i++) {
		if (a[i] < x)left++;
		if (a[i] > x)right++;
	}
	cout << min(left, right) << endl;

	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define INF 1e9

int digit_sum(int x){
    int res = 0;
    while(x>0){
        res += x%10;
        x /= 10;
    }
    return res;
}

int main(void){
    int n;
    cin>>n;
    int res = INF;
    rep1(a,n-1){
        res = min(res,digit_sum(a)+digit_sum(n-a));
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    Int ans[11] = {};
    Int s = (1 + 2 + 3 + 8 + 9 + 10 + 15 + 16 + 17) % 11;
    for (int i = 0; i < 5; i++) {
        Int cnt = max(0, N - 2);
        for (int j = 0; j < 11; j++) {
            ans[j] += cnt / 11;
        }
        Int t = s;
        for (int j = 0; j < cnt % 11; j++) {
            ans[t] += 1;
            t = (t + 3 * 3 * 7) % 11;
        }
        s = (s + 3 * 3) % 11;
    }
    cout << ans[K] << endl;
    return 0;
}


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

using ll = long long;
using ull = unsigned long long;

using namespace std;

int main(int argc, char const *argv[]) {
	int n,k;
	std::cin >> n >> k;
	std::vector<int> v(n);
	int where = 0;
	for (size_t i = 0; i < n; i++) {
		std::cin >> v[i];
		if (v[i] == 1) {
			where = i;
		}
	}
	n--;
	k--;
	std::cout << n/k + !!(n%k) << '\n';
	int left = where - 0;
	int right = n - where - 1;

	return 0;
}


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

int n,m,h[MAXN],tot,vis[MAXN],cnt,ans;

struct node{
	int from,to,next;
}e[MAXN << 1];

void add(int x , int y){
	tot++;
	e[tot].from = x;
	e[tot].to = y;
	e[tot].next = h[x];
	h[x] = tot;
}

void dfs(int now , int fa){
	if(vis[now])return;
	cnt++;
	vis[now] = 1;
	for(int i = h[now] ; i != (-1) ; i = e[i].next){
		if(e[i].to == fa)continue;
		dfs(e[i].to , now);
	}
}

int main(){
	memset(h , -1 , sizeof(h));
	cin>>n>>m;int x,y;
	for(int i  = 1 ; i <= m ; i++){
		cin>>x>>y;
		add(x , y) , add(y , x);
	}
	for(int i = 1 ; i <= n ; i++){
		if(!vis[i])cnt = 0 , dfs(i , i) , ans = max(ans , cnt);
	}
	cout<<ans<<endl;
}

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

int main(){
  ll N, X, M;
  cin >> N >> X >> M;
  
  vector<ll> next(M, -1);
  
  ll pos = X, ans = 0, kaisu = 0;
  while (next.at(pos) == -1){
    ll num = (pos * pos) % M;
    next.at(pos) = num;
    ans += pos;
    pos = num;
    kaisu++;
    if (kaisu == N){
      cout << ans << endl;
      exit(0);
    }
  }
  
  ll loopbegin = pos, loopsum = pos, loopnow = pos, loopsize = 1;
  while (next.at(loopnow) != loopbegin){
    loopsum += next.at(loopnow);
    loopnow = next.at(loopnow);
    loopsize++;
  }
  
  ll loopnum = (N - kaisu) / loopsize;
  ans += loopnum * loopsum;
  
  ll nokori = N - kaisu - loopsize * loopnum;
  loopnow = loopbegin;
  for (ll i = 0; i < nokori; i++){
    ans += loopnow;
    loopnow = next.at(loopnow);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4280
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;

int main() {
    long a,b ,k;
    cin >> a >> b >> k;
    for (int i = a; i <=b ; ++i) {
        if(i-a <k || b- i <k) cout << i << endl;
        
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  map<string,int> mp;
  int n; cin>>n;
  rep(i,n){
    string s; cin>>s;
    mp[s]++;
  }
  int m; cin>>m;
  rep(i,m){
    string t; cin>>t;
    mp[t]--;
  }
  int ans=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
    ans=max(ans,itr->second);
  }
  cout<<ans<<endl;

  return 0;

}


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


int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    vector<set<int>> indexes(10, set<int>());
    for(int i = 0; i < N; i++)
    {
        int num = S[i] - '0';
        indexes.at(num).insert(i);
    }
    int answer = 0;
    for(int i = 0; i <= 9; i++){
        if(indexes.at(i).empty()){
            continue;
        }
        int firstIndex = *begin(indexes.at(i));
        for(int j = 0; j <= 9; j++){
            if(indexes.at(j).empty()){
                continue;
            }
            auto secondIte = indexes.at(j).upper_bound(firstIndex);
            if(secondIte == indexes.at(j).end()){
                continue;
            }
            int secondIndex = *secondIte;
            for(int k = 0; k <= 9; k++){
                if(indexes.at(k).empty()){
                    continue;
                }
                auto thirdIte = indexes.at(k).upper_bound(secondIndex);
                if(thirdIte != indexes.at(k).end()){
                    answer++;
                }
            }
        }
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 1792
gets
m=[*$<]

def get(m, x, y)
  if m[y]
    if m[y][x].chr == '#'
      true
    else
      false
    end
  else
    false
  end
end

def q(m)
  x = 0
  y = 0
  w = m[0].size - 1
  h = m.size
  trace = m.map{|l|l.gsub('#', '.')}
  while true
    trace[y][x] = '#'
    if !get(m, x, y)
      return false
    end
    if x == w - 1 && y == h - 1
      return m == trace
    end

    r = get(m, x+1, y)
    d = get(m, x, y+1)
    if r == d
      return false
    end

    if r
      x += 1
    else
      y += 1
    end
  end
end

if q(m)
  puts "Possible"
else
  puts "Impossible"
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
char a[100005];
int b[26][26];
char c[100005];
int d[26][26];
int main(){
int i,j;

for(i=0;i<26;i++)
    for(j=0;j<26;j++)
            {
    b[i][j]=(i+j)%26;
          d[i][b[i][j]]=j;             }

int k;
cin>>a;
cin>>k;
int x=strlen(a)-1;

for(i=0;i<strlen(a);i++)
{



int y=a[i]-'a';
if(x==i){

    k=k%26;

   c[i]=(char)('a'+b[y][k]);
}
else{

    int o=d[y][0];
    if(k>=o){
        k=k-o;
        c[i]='a';

    }
    else
        c[i]=a[i];



}



}


c[x+1]='\0';
cout<<c<<endl;


return 0;
           }


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,i,j,sum=0;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(i=0;i<k;i++)
	{
		sum=sum+a[i];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int64_t x; cin >> x;
	int64_t a = x / 500;
	int64_t b = (x % 500) / 5;
	cout << 1000 * a + 5 * b << '\n';
	return 0;
}

Measured memory_bytes: 256
// 2018/07/10 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	const int INF = 1000000001;

	int N, W;
	cin >> N >> W;

	int v[100];
	int w[100];
	for(int i=0; i<N; i++){
		cin >> v[i] >> w[i];
	}

	int DP[101][10001];

	DP[0][0] = 0;
	for(int j=1; j<=10000; j++){
		DP[0][j] = INF;
	}

	for(int i=1; i<=N; i++){
		for(int j=0; j<=10000; j++){
			if(j<v[i-1]){
				DP[i][j] = DP[i-1][j];
			}
			else{
				DP[i][j] = min(DP[i-1][j], DP[i-1][j-v[i-1]]+w[i-1]);
			}
		}
	}
/*
	for(int i=0; i<=N; i++){
		for(int j=0; j<=19; j++){
			if(DP[i][j]==INF){
				cout << "INF ";
			}
			else{
				cout << DP[i][j] << ' ';
			}
		}
		cout << endl;
	}
*/
	for(int j=10000; j>=0; j--){
		if(DP[N][j]<=W){
			cout << j << endl;
			break;
		}
	}

	return 0;
}



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

using namespace std;

typedef long long ll;
typedef long double ld;

const int V = 2 * 101;
const int T = 2 * 20001;
const int BIG = 1e9;

ld dp[V][T];
int n, v[V], t[V], ts, mx[T];

int main()
{   /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); /**/
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> t[i];
    for (int i = 0; i < n; i++)
        cin >> v[i];
    ts = 0;
    for (int i = 0; i < n; i++)
        ts += t[i];
    ts *= 2;
    for (int i = 0; i < V; i++)
        dp[i][0] = -BIG;
    int r = 0;
    for (int i = 0; i < n; i++)
    {
        mx[r] = min(mx[r], 2 * v[i]);
        for (int j = 0; j < 2 * t[i]; j++)
            mx[r + j + 1] = 2 * v[i];
        r += 2 * t[i];
    }
    dp[0][0] = 0;
    for (int i = 0; i < ts; i++)
    {
        for (int j = 0; j < V; j++)
        {
            if (j > mx[i + 1])
            {
                dp[j][i + 1] = -BIG;
                continue;
            }
            if (dp[j][i] == -BIG)
                dp[j][i + 1] = -BIG;
            else
                dp[j][i + 1] = dp[j][i] + j;
            if (j + 1 != V && dp[j + 1][i] != -BIG)
                dp[j][i + 1] = max(dp[j][i + 1], dp[j + 1][i] + j + 1 / 2);
            if (j - 1 != -1 && dp[j - 1][i] != -BIG)
                dp[j][i + 1] = max(dp[j][i + 1], dp[j - 1][i] + j + 1 / 2);
            //cerr << i + 1 << " " << j << " " << dp[j][i + 1] << "\n";
        }
    }
    cout << fixed << setprecision(20);
    cout << dp[0][ts] / 4;
    return 0;
}


Measured memory_bytes: 126720
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}

#define l first
#define r second


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N, L;
	int x, y;
	int conl = 0, conr = 0, conm = 0, conb = 0;
	vector<pair<int,int>> interval;
	priority_queue<pair<int,int>, vector<pair<int,int>>,greater<pair<int,int>>  > Q;
	
	cin>>N>>L;
	
	interval.assign(N,{});
	
	for(int i = 0; i < N; i++){
		cin>>interval[i].l>>interval[i].r;
		if(interval[i].l == 0 && interval[i].r == L) conb++;
		else if(interval[i].l == 0) conl++;
		else if(interval[i].r == L) conr++;
		else conm++;
	}
	
	Q.push(make_pair(0,0));
	
	sort(interval.begin(), interval.end());
	
	for(int i = 0; i < N; i++){
		int minimum = INF;
		int x = Q.top().first;
		
		// cout<<interval[i].l<<" <> "<<interval[i].r<<endl;
		// cout<<Q.top().first<<" "<<Q.top().second<<" em "<<Q.empty()<<endl;
		while(!Q.empty() && Q.top().second < interval[i].l){
			Q.pop();
			x = Q.top().first;
		}
		
		if(Q.empty()){
		}
		// cout<<"i = "<<i<<" "<<x<<" "<<endl;
		Q.push(make_pair(x+1,interval[i].r));
		
	}
	
	x = Q.top().first;
		
	while(!Q.empty() && Q.top().second < L){
		Q.pop();
		x = Q.top().first;
	}
	
	
	y = conm + max(conl, conr) + 1;
	
	cout<<x<<" "<<y<<endl;
	// cout<<x<<endl;
	
	return 0;
}


Measured memory_bytes: 9864