akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <cstdio>
#include <vector>
using namespace std;
struct edge { int to, cost; };
bool operator<(const edge& e1, const edge& e2) { return e1.cost < e2.cost; }
int N, M, C, b1, b2, e1, e2, e3, e4;
int main() {
	while (scanf("%d%d%d%d%d", &N, &M, &C, &b1, &b2), b1--, b2--, N) {
		vector<vector<vector<edge> > > G1(C, vector<vector<edge> >(N));
		for (int i = 0; i < M; i++) {
			scanf("%d%d%d%d", &e1, &e2, &e3, &e4); e1--, e2--, e4--;
			G1[e4][e1].push_back(edge{ e2, e3 });
			G1[e4][e2].push_back(edge{ e1, e3 });
		}
		vector<vector<vector<int> > > dist(C, vector<vector<int> >(N, vector<int>(N, 999999999)));
		for (int i = 0; i < C; i++) {
			for (int j = 0; j < N; j++) {
				dist[i][j][j] = 0;
				priority_queue<edge> que1; que1.push(edge{ j, 0 });
				while (!que1.empty()) {
					edge u = que1.top(); que1.pop();
					for (edge e : G1[i][u.to]) {
						if (dist[i][j][e.to] > -u.cost + e.cost) {
							dist[i][j][e.to] = -u.cost + e.cost;
							que1.push(edge{ e.to, -dist[i][j][e.to] });
						}
					}
				}
			}
		}
		vector<int> P(C);
		for (int i = 0; i < C; i++) scanf("%d", &P[i]);
		vector<vector<int> > costs(C, vector<int>(20000));
		for (int i = 0; i < C; i++) {
			vector<int> Q(P[i] + 1), R(P[i]); Q[0] = 0, Q[P[i]] = 19999;
			for (int j = 1; j < P[i]; j++) scanf("%d", &Q[j]);
			for (int j = 0; j < P[i]; j++) scanf("%d", &R[j]);
			for (int j = 0; j < P[i]; j++) {
				for (int k = Q[j] + 1; k <= Q[j + 1]; k++) {
					costs[i][k] = costs[i][k - 1] + R[j];
				}
			}
		}
		vector<vector<int> > G2(N, vector<int>(N, 999999999));
		for (int i = 0; i < C; i++) {
			for (int j = 0; j < N; j++) {
				for (int k = 0; k < N; k++) {
					if (j == k) continue;
					if (dist[i][j][k] == 999999999) continue;
					G2[j][k] = min(G2[j][k], costs[i][dist[i][j][k]]);
				}
			}
		}
		vector<vector<edge> > G3(N);
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (G2[i][j] != 999999999) G3[i].push_back(edge{ j, G2[i][j] });
			}
		}
		vector<int> dist2(N, 999999999); dist2[b1] = 0;
		priority_queue<edge> que2; que2.push(edge{ b1, 0 });
		while (!que2.empty()) {
			edge u = que2.top(); que2.pop();
			for (edge e : G3[u.to]) {
				if (dist2[e.to] > -u.cost + e.cost) {
					dist2[e.to] = -u.cost + e.cost;
					que2.push(edge{ e.to, -dist2[e.to] });
				}
			}
		}
		printf("%d\n", dist2[b2] != 999999999 ? dist2[b2] : -1);
	}
	return 0;
}

Measured memory_bytes: 5316
#include<iostream>
using namespace std;
int main()
{
	int a[100000], b[100000];
	char op[100000];
	int i,j,r,d=0;
	for (i = 0; i < 98000; i++){
		cin >> a[i] >> op[i] >> b[i];
		if (op[i] == '?'){
			j = i;
			break;
		}
	}
	for (i = 0; i < j; i++){
		if (op[i] == '+'){
			r = a[i] + b[i];
			d = 1;
		}
		else if (op[i] == '-'){
			r = a[i] - b[i];
			d = 1;
		}
		else if (op[i] == '*'){
			r = a[i] * b[i];
			d = 1;
		}
		else if (op[i] == '/'){
			r = a[i] / b[i];
			d = 1;
		}
		if (d == 1){ 
			cout << r << endl;
			d = 0;
		}
	}
	return 0;
}

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

int main() {
  int A, B, M;
  cin >> A >> B >> M;
  int a[A], b[B], x, y, c, sum, min, mina = INT_MAX, minb = INT_MAX;
  REP(i, A) {
    cin >> a[i];
    if (a[i] < mina) mina = a[i];
  }
  REP(i, B) {
    cin >> b[i];
    if (b[i] < minb) minb = b[i];
  }

  sum = mina + minb;
  min = sum;

  REP(i, M) {
    cin >> x >> y >> c;
    sum = a[x - 1] + b[y - 1] - c;
    if (sum < min) min = sum;
  }


  cout << min << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int n;
  int t,x,y;
  int r;

  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d%d%d",&t,&x,&y);
    if(t-(x+y)>=0&&(t-(x+y))%2==0)r++;
    else{
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}
  


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

int main(){
		int n, x;

	while(cin >> n >> x){

		if(n==0 && x==0) break;

		int count=0;
		for(int i=1; i<=n; i++){
			for(int j=i+1; j<=n; j++){
				for(int k=j+1; k<=n; k++){
					if(i+j+k==x) count++;
				}
			}
		}
		cout << count << endl;
	}
}

Measured memory_bytes: 1160
import sys

sys.setrecursionlimit(int(1e7))

n = int(input())

graph = {}

for i in range(n-1):
    s, t, w = map(int, input().split())
    if s not in graph:
        graph[s] = {}
    graph[s][t] = w
    if t not in graph:
        graph[t] = {}
    graph[t][s] = w

visited = set()


def visit(v):
    visited.add(v)
    if v not in graph:
        return (0, v)

    costs = []
    for t, w in graph[v].items():
        if t in visited:
            continue
        cost, d = visit(t)
        costs.append((cost + w, d))

    return max(costs) if len(costs) > 0 else (0, v)


_, u = visit(0)
visited.clear()
cost, _ = visit(u)

print(cost)



Measured memory_bytes: 169040
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

bool check(VI a, int x){
    int n = a.size();
    int d = 8200;
    VVI dp(n+1, VI(2*d));
    dp[0][d] = 1;
    REP(i,n) REP(j,2*d){
        if (dp[i][j]){
            dp[i+1][j+a[i]] = dp[i+1][j-a[i]] = 1;
        }
    }
    if (x <= -d || x >= d) return false;
    return dp[n][x+d];
}

int main() {
    string s;
    int x, y;
    cin >> s >> x >> y;
    int n = s.length();

    VI a, b;
    int p = 0, d = 0, f = 1;
    for (char c : s){
        if (c == 'T'){
            if (f){
                x -= p;
                f = 0;
            }else if (d == 0){
                if (p) a.push_back(p); 
            }else{
                if (p) b.push_back(p);
            }
            p = 0;
            d ^= 1;
        }else{
            p++;
        }
    }
    if (p){
        if (f) x -= p;
        else if (d == 0) a.push_back(p);
        else b.push_back(p);
    }

    // for (int x : a) cout << x << " ";
    // cout << endl;
    // for (int x : b) cout << x << " ";
    // cout << endl;

    if (check(a, x) && check(b, y)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }


    return 0;
}





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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 2e5 + 5;
int arr[MAX];

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

	int n;
	cin >> n;

	fori(i, 1, n + 1) {
		cin >> arr[i];
	}

	if(arr[1] != 0) {
		cout << -1 << '\n';
		return 0;
	}
	
	ll ans = 0, value = 0;
	ford(i, n, 2) {
		value--;
		if(value > arr[i]) {
			cout << -1 << '\n';
			return 0;
		}
		else if(arr[i] - 1 == arr[i - 1]) {
			ans++;
		}
		else if(arr[i] > i - 1) {
			cout << -1 << '\n';
			return 0;
		}
		else {
			ans += arr[i];
		}
		value = max(value, 1LL * arr[i]);
	}

	cout << ans << '\n';


	return 0;
}


Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    if v[0] < 10 && v[1] < 10 {
        println!("{}", v[0] * v[1]);
    } else {
        println!("-1");
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define pb push_back 
#define lb lower_bound 
#define lowbit(x) (x)&(-x)   
#define forup(i,a,b) for(int i=(a);i<=(b);i++)  
#define fordown(i,a,b) for(int i=(a);i>=(b);i--)  
#define maxn 1000005
#define INF 107000000 
#define mod 997
using namespace std;  
typedef long long ll;  
typedef unsigned long long ull;  
    
template<class T> inline  void read(T& num){   num = 0; bool f = true;char ch = getchar();   while(ch < '0' || ch > '9') { if(ch == '-') f = false;ch = getchar();}   while(ch >= '0' && ch <= '9') {num = num * 10 + ch - '0';ch = getchar();}   num = f ? num: -num;  } 
int out[100]; 
template<class T> inline
void write(T x,char ch){  if (x==0) {putchar('0'); putchar(ch); return;}  if (x<0) {putchar('-'); x=-x;} int num=0; while (x){ out[num++]=(x%10); x=x/10;} fordown(i,num-1,0) putchar(out[i]+'0'); putchar(ch); } 
/*========================================================*/
ll a,b,c;
int main()
{ cin>>a>>b>>c;
int cnt=0;
  while(1)
  { if((a%2==0)&&(b%2==0)&&(c%2==0))
    {cnt++;
	ll x=a,y=b,z=c;
     a=(y+z)/2;b=(x+z)/2;c=(x+y)/2;
     if(a==b&&b==c)  {puts("-1");return 0;}
	}
    else  break;	
  }
cout<<cnt<<endl;	
	
return 0;	
} 

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==b) printf("%d\n",c);
  if(a==c) printf("%d\n",b);
  if(b==c) printf("%d\n",a);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

void solve() {
    string s;
    cin >> s;
    int cnt = 0, ans = 0;
    for(int i = 0; i < s.sz; ++i) {
        if(s[i] == 'R') cnt++;
        else ans = max(ans, cnt), cnt = 0;
    }
    cout << max(ans, cnt);
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);

    ll n;
    cin >> n;
    vll a(n);
    rep(i,n) cin >> a[i];

    ll ans = 0;
    rep(i,n) if(i % 2 == 0 && a[i] % 2 == 1) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#define ll long long
using namespace std;

int main(){
  int n,q; ll k; cin >> n >> k >> q;
  int a[q]; for(int i=0; i<q; i++){cin >> a[i];}
  ll p[n]; for(int i=0; i<n; i++){p[i]=k-q;}
  
  for(int i=0; i<q; i++){
    p[a[i]-1]++;
  }
  
  for(int i=0; i<n; i++){
    if(p[i]<=0){cout << "No";}
    else{cout << "Yes";}
    if(i!=n-1){cout << endl;}
  }
  return 0;
}

Measured memory_bytes: 1792
"use strict";

const main = (arg) => {
  const array = arg.trim().split(" ");
  const A = parseInt(array[0], 10);
  const B = parseInt(array[1], 10);
  const answer = A * B;
  console.log(answer);
};
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29600
n=int(input())
l,r=0,n
print(0,flush=True)
s=input()
sl,sr=s,s
while True:
  m=(l+r)//2
  print(m,flush=True)
  sm=input()
  if (sm==sl)+((m-l)%2)==1:
    l=m
    sl=sm
  else:
    r=m
    sr=sm

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allg(v) v.begin(), v.end(), greater<int>()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, T;
  cin >> n >> T;
  
  int ans = 1001;
  
  rep(i, 0, n) {
    int c, t;
    cin >> c >> t;
    if(t <= T)
      ans = min(c, ans);
  }
  
  if(ans == 1001)
    cout << "TLE" << "\n";
  else
    cout << ans << "\n";

}


Measured memory_bytes: 256
package main

import "fmt"

func getGcd(a, b int) (g int) {
	if a < b {
		g = getGcd(b, a)
	} else {
		if a%b == 0 {
			g = b
		} else {
			g = getGcd(b, a%b)
		}
	}
	return
}

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	l := make([]int, n)
	r := make([]int, n)
	for i := 0; i < n; i++ {
		if i == 0 {
			l[i] = a[i]
		} else {
			l[i] = getGcd(l[i-1], a[i])
		}
	}
	for i := 0; i < n; i++ {
		if i == 0 {
			r[i] = a[n-1-i]
		} else {
			r[i] = getGcd(r[i-1], a[n-1-i])
		}
	}
	var max int
	if n == 2 {
		if r[n-2] > l[n-2] {
			max = r[n-2]
		} else {
			max = l[n-2]
		}
	} else {
		if r[n-2] > l[n-2] {
			max = r[n-2]
		} else {
			max = l[n-2]
		}
		for i := 1; i < n-1; i++ {
			if tmp := getGcd(l[i-1], r[n-i-2]); tmp > max {
				max = tmp
			}
		}
	}
	fmt.Println(max)
}


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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

string C(string s) {
    return string(s.begin()+1, s.end()) + string(s.begin(), s.begin()+1);
}

string J(string s) {
    return string(s.end()-1, s.end()) + string(s.begin(), s.end()-1);
}

string E(string s) {
    int n = s.length();
    if (n % 2 == 0) {
        return string(s.begin()+n/2, s.end()) + string(s.begin(), s.begin()+n/2);
    } else {
        return string(s.begin()+n/2+1, s.end()) + s[n/2] + string(s.begin(), s.begin()+n/2);
    }
}

string A(string s) {
    return string(RALL(s));
}

string M(string s) {
    string str(s);
    REP(i, s.length()) {
        if (isdigit(s[i])) {
            str[i] = '0' + ((s[i] - '0' + 1) % 10);
        }
    }
    return str;
}

string P(string s) {
    string str(s);
    REP(i, s.length()) {
        if (isdigit(s[i])) {
            str[i] = '0' + ((s[i] - '0' - 1 + 10) % 10);
        }
    }
    return str;
}

int main() {
    assert(C("aB23d") == "B23da");
    assert(J("aB23d") == "daB23");
    assert(E("e3ac") == "ace3");
    assert(E("aB23d") == "3d2aB");
    assert(A("aB23d") == "d32Ba");
    assert(M("aB23d") == "aB34d");
    assert(M("e9ac") == "e0ac");
    assert(P("aB23d") == "aB12d");
    assert(P("e0ac") == "e9ac");

    int n;
    cin >> n;
    REP(i, n) {
        string order, s;
        cin >> order >> s;
        RREP(j, order.length()) {
            switch (order[j]) {
            case 'J':
                s = J(s);
                break;
            case 'C':
                s = C(s);
                break;
            case 'E':
                s = E(s);
                break;
            case 'A':
                s = A(s);
                break;
            case 'P':
                s = P(s);
                break;
            case 'M':
                s = M(s);
                break;
            }
        }
        cout << s << endl;
    }
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Cnter(ll x,int n){
  int k = 0;
  while(x%n == 0){
    k++;
    x /= n; 
  }
  return k;
}

int main(){
  int n; cin >> n;
  vector<pair<ll,int>> v(n);
  for(int i = 0; i < n; ++i){
    string s; cin >> s;
    string t;
    int k = -1;    
    for(const auto e:s){
      if(k != -1)k++;
      if(e != '.')t.push_back(e);
      else k = 0;
    }
    if(k == -1)k = 0;
    v[i] = {stoll(t),k};
  }
  map<int,map<int,int>> mp;
  for(auto e:v){
    // debug(e.first);
    // debug(e.second);
    // debug(Cnter(e.first,2)-e.second);
    // debug(Cnter(e.first,5)-e.second);
    // cerr << endl;
    mp[Cnter(e.first,2)-e.second][Cnter(e.first,5)-e.second]++;
  }
  for(int i = 50; i > -50; --i){
    for(int j = 50; j > -50; --j){
      // mp[i][j] += max(mp[i+1][j],mp[i][j+1]);
      mp[i][j] += mp[i][j+1];
    }
  }
  
  for(int j = 50; j > -50; --j){
    for(int i = 50; i > -50; --i){
      // mp[i][j] += max(mp[i+1][j],mp[i][j+1]);
      mp[i][j] += mp[i+1][j];
    }
  }


  ll ans = 0;
  for(auto e:v){
    int two = -(Cnter(e.first,2)-e.second);
    int fiv = -(Cnter(e.first,5)-e.second);
    // debug(e.first);
    // debug(e.second);
    // debug(two);
    // debug(fiv);
    // debug(mp[two][fiv]);
    ans += mp[two][fiv];
    if(two <= 0 && fiv <= 0)ans--;
    // cerr << endl;
  }
  cout << (ans)/2 << endl;
  return 0;
}


Measured memory_bytes: 6956
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define rep(i, j, k) for (auto i = j; i < k; i++)
#define rrep(i, j, k) for (auto i = j; i > k; i--)
using namespace std;

map<int, int> idx;
int a[201][201], b[201][201];
int dy[] = {0, 1, 1, 0, -1, -1, 0};
int dx[] = {1, 1, 0, -1, -1, 0, 0};

void solve(int &t, int &n) {
  rep(i, 0, n) {
    int x, y; cin >> x >> y;
    a[idx[y]][idx[x]] = -1;
  }
  int sx, sy; cin >> sx >> sy;
  a[idx[sy]][idx[sx]] = 1;
  rep(cnt, 0, t) {
    rep(i, 0, 201) {
      rep(j, 0, 201) {
        if (a[i][j] == 0) continue;
        if (a[i][j] == -1) {b[i][j] = -1; continue;}
        rep(d, 0, 7) {
          if (a[i + dy[d]][j + dx[d]] != -1) b[i + dy[d]][j + dx[d]] = 1;
        }
      }
    }
    rep(i, 0, 201) rep(j, 0, 201) {
      a[i][j] = b[i][j];
      b[i][j] = 0;
    }
  }
  int ans = 0;
  rep(i, 0, 201) rep(j, 0, 201) if (a[i][j] == 1) ans++;
  cout << ans << endl;
}
int main() {
  rep(i, -100, 101) idx[i] = i + 100;
  int n, t;
  while (true) {
    cin >> t >> n;
    if (n == 0 && t == 0) break;
    rep(i, 0, 201) rep(j, 0, 201) {a[i][j] = 0; b[i][j] = 0;}
    solve(t, n);
  }
}



Measured memory_bytes: 3392
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>(b);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,n-1,-1)

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m, a, b;
	cin >> n >> m;
	vector<P> v;
	vector<int> cnt(n);
	vector<vector<int>> gr(n);
	REP(i, m) {
		cin >> a >> b;
		a--;
		b--;
		v.push_back(P(a, b));
		gr[a].push_back(b);
		cnt[a]++;
	}
	vector<double> es(n);
	RREP(i, n - 1) {
		for (auto j : gr[i]) es[i] += 1 + es[j];
		es[i] /= cnt[i];
	}
	vector<double> maxval(n);
	vector<int> cand(n);
	REP(i, n) cand[i] = -1;
	REP(i, m) {
		a = v[i].first;
		b = v[i].second;
		if (maxval[a] < es[b]) {
			maxval[a] = es[b];
			cand[a] = i;
		}
	}
	double res = es[0];
	vector<double> es2(n);
	for (int skip : cand) {
		if (skip == -1) continue;
		a = v[skip].first;
		b = v[skip].second;
		if (cnt[a] == 1) continue;
		cnt[a]--;
		FOR(i, a + 1, n) es2[i] = es[i];
		RFOR(i, a, -1) {
			es2[i] = 0;
			for (auto j : gr[i]){
				if (i!=a or j!=b) es2[i] += 1 + es2[j];
			}
			es2[i] /= cnt[i];
		}
		res = min(res, es2[0]);
		cnt[a]++;
	}
	cout << fixed << setprecision(10) << res;
	return 0;
}

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

int main()
{
  int64_t N, K, R, S, P, ans = 0;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  vector<char> A(N);
  map<char, char> mp = {{'r', 'p'}, {'s', 'r'}, {'p', 's'}};
  map<char, int> score = {{'r', R}, {'p', P}, {'s', S}};
  for (int i = 0; i < N; i++)
  {
    if (i >= K && A[i - K] == mp[T[i]])
    {
      A[i] = '?';
      continue;
    }
    A[i] = mp[T[i]];
    ans += score[A[i]];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i+=1)
using namespace std;
int main() {
  vector<int>A(3);
  rep(i,3) cin>>A[i];
  int count =0;
  rep(i,3) count+=A[i];
  if(count>=22)
    cout<<"bust"<<endl;
  if(count<22)
    cout<<"win"<<endl;
}

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

int gcd( int m, int n )
{
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}

int lcmfunction(int m, int n )
{
	return ((m / gcd(m, n)) * n);
}

int main() {
	bitset<8368800> flgs;

	while(1){
		flgs.reset();
		int m,n;
		// ?????????????????£????????°
		int loop = 0;
		cin >> m >> n;
		if(m == 0 && n == 0) break;
	  int lcm = lcmfunction(n, m);

		if(m > n){
				cout << m + n << "\n";
		}else{
			int i;
	  	for(i = m ; loop <= n ; i++){
				if(flgs.test(i)){
				}else{
					loop++;
					for(int j = 1 ; i * j < 7368792 ; j++){
						flgs.set(i * j);
					}
		//			cout << "i = " << i << " loop = " << loop << "\n";
				}
			}

			cout << i - 1 << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 4100
#include<bits/stdc++.h>
#define int long long
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int m, a[10], b[10], n, g, ans[1010];
void f(int sum, int i) {
	if (sum > 1000)return;
	if (i == m) {
		ans[sum]++; return;
	}
	for0(p, b[i] + 1) f(sum + a[i] * p, i + 1);
}
int get() { int r; cin >> r; return r; }
signed main() {
	while (cin >> m, m) {
		for0(i, m)cin >> a[i] >> b[i];
		for0(i, 1001)ans[i] = 0;
		f(0, 0);
		cin >> g;
		while (g--)cout << ans[get()] << endl;
	}
}


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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb(x)	cout << #x << " " << x << endl;

typedef long long int ll;

int main() {

	IOS

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

	int lm = (a / k) * k;
	
	if (lm < a)
		lm += k;

	cout << (lm >= a && lm <= b ? "OK" : "NG") << endl;

	return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int n,flg,i,j,p1,q1,fllg,ii;
	while(1){
		cin>>n;
		if(n==0)break;
		for(i=n;i>1;i--){
			flg=1;
			if(i!=2&&i%2!=0){
				for(j=2;j<i;j++){
					if(i%j==0){
						flg=0;
						break;
					}
				}
				if(flg==1){
					ii=i-2;
					for(j=2;j<ii;j++){
						if(ii%j==0){
							flg=0;
							break;
						}
					}
				}
				if(flg==1) flg=2;
			}
			if(flg==2){
				p1=ii;
				q1=i;
				break;
			}
		}
		cout<<p1<<' '<<q1<<endl;
		p1=0; q1=0;
	}
	return 0;
}

Measured memory_bytes: 3036
#include<bits/stdc++.h>
using namespace std;
const long long md=1e9+7;
long long powd(long long x,long long y){
	long long res=1;
	while(y){
		if(y&1) res=res*x%md;
		x=x*x%md;
		y>>=1;
	}
	return res;
}
void Add(long long &x,long long y){
	x=(x+y)%md;
}
long long dp[25100][410];
long long dq[25100][410];
int a[25100];
bool vis[410];
int n,k,m;
long long fac[25100],inv[25100];
void solve1(int p1,int p2){
	cerr<<p1<<" "<<p2<<endl;
	long long ans=0,s1,s2,sum=0;
	for(int i=1;i<=n-m+1;i++){
		s1=0;
		for(int j=p1;j<=k;j++)
			Add(s1,dp[i-1+p1][j]*inv[k]%md*fac[k-p1]);
		s2=0;
		for(int j=p2;j<=k;j++)
			Add(s2,dp[n-(i+m-1)+p2][j]*inv[k]%md*fac[k-p2]);
		Add(ans,s1*s2);
	}
	sum=powd(k,n-m)*(n-m+1)%md;
	Add(sum,md-ans);
	printf("%lld\n",sum);
}
long long pf(long long x){
	x%=md;
	return x*x%md;
}
long long sss[25100][410];
void solve2(){
	for(int i=1;i<=n;i++)
		for(int j=1;j<=k;j++)
			sss[i][j]=(sss[i][j-1]+dp[i][j])%md;
	long long ans=0,sum;
	for(int i=m;i<=n;i++){
		for(int j=m;j<k&&j<=i;j++)
			Add(ans,dp[i][j]*(sss[n-(i-j)][k]-sss[n-(i-j)][j-1]+md)%md*fac[k-m]%md*inv[k]%md*fac[k-j]%md*inv[k]%md);
	}
	sum=powd(k,n-m)*(n-m+1)%md;
	Add(sum,md-ans);
	printf("%lld\n",sum);
}
void get_dp(){
	dp[0][0]=1;
	long long sum=0;
	for(int i=1;i<=n+1;i++){
		for(int j=1;j<k;j++)
			Add(dp[i][j],dp[i-1][j-1]*(k-(j-1))%md);
		sum=0;
		for(int j=k-1;j>=1;j--){
			Add(sum,dp[i-1][j]);
			Add(dp[i][j],sum);
			dq[i][j]=sum;
		}
	}
}
void get_fac(){
	fac[0]=1;
	for(int i=1;i<=25000;i++)
		fac[i]=fac[i-1]*i%md;
	inv[25000]=powd(fac[25000],md-2);
	for(int i=25000;i>=1;i--)
		inv[i-1]=inv[i]*i%md;
}
bool test(){
	for(int i=1;i<=m-k+1;i++){
		for(int j=1;j<=k;j++)
			vis[j]=0;
		for(int j=1;j<=k;j++)
			vis[a[i+j-1]]=1;
		bool bo=1;
		for(int j=1;j<=k;j++)
			if(!vis[j])
				bo=0;
		if(bo) return 1;
	}
	return 0;
}
int main(){
//	freopen("F.in","r",stdin);
	scanf("%d%d%d",&n,&k,&m);
	for(int i=1;i<=m;i++)
		scanf("%d",&a[i]);
	int p1,p2;
	for(p1=1;p1<=m;p1++){
		if(vis[a[p1]]) break;
		vis[a[p1]]=1;
	}
	memset(vis,0,sizeof(vis));
	for(p2=m;p2>=1;p2--){
		if(vis[a[p2]]) break;
		vis[a[p2]]=1;
	}
	if(test()){
		printf("%lld\n",powd(k,n-m)*(n-m+1)%md);
		return 0;
	}
	get_dp();
	get_fac();
	if(p1!=m+1)
		solve1(p1-1,m-p2);
	else
		solve2();
	return 0;
}


Measured memory_bytes: 241920
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int ans = (1900 * m + 100 * (n-m));
    cout << ans * pow(2, m) << endl;
}

Measured memory_bytes: 4128
x, y, z, o = [int(_) for _ in input().split()]
a = sorted([int(_) for _ in input().split()])[::-1]
b = sorted([int(_) for _ in input().split()])[::-1]
c = sorted([int(_) for _ in input().split()])[::-1]
s = []
for i in range(x):
    for j in range(y):
        for k in range(z):
            if (i+1)*(j+1)*(k+1) <= o:
                s.append(a[i]+b[j]+c[k])
            else:
                break
for ans in sorted(s)[::-1][:o]:
    print(ans)

Measured memory_bytes: 48984
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,a,b;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
    if(i%k==0){
      cout<<"OK"<<endl;
      return 0;
    }
  cout<<"NG"<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if ( a==b && b!=c || b==c && a!=b || a==c && b!=c ) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	return 0;
}

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

using namespace std;


void trace(int A[], int N)
{
    int i;
    for (i = 0; i < N; i++) {
        if(i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

int selectionSort(int A[], int N){
    int minj, cnt = 0;
    for (int i = 0; i < N; i++) {
        minj = i;
        for (int j = i; j < N; j++){
          if (A[j] < A[minj]) minj = j;
        }
        if (i != minj) {
            swap(A[i], A[minj]);
            cnt += 1;
        }
    }
    trace(A, N);
    return cnt;
}


int main() {
    int n, num_sec[101]={}, cnt=0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> num_sec[i];
    cnt=selectionSort(num_sec, n);
    cout << cnt << endl;
}


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

#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation;
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define puf push_front
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double pi=3.14159265358979323846;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){ll c; while(b!=0){c=a%b; a=b; b=c;} return a;}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a * c%mod;} a=a * a%mod; b>>=1;} return c;}
vi calc(ll x){vi res; while(x>0){res.pb(x%10); x/=10;} reverse(all(res)); return res;}

void solve() {
  int s; cin>>s;
  if(s==111) out(3);
  else out(s%3);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


Measured memory_bytes: 256
N=int(input())
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
x=0
ans=0
for i in range(N):
    x+=A1[i]
    y=x
    for j in range(i,N):
        y+=A2[j]

    if ans<=y:
        ans=y
print(ans)

Measured memory_bytes: 3316
#include <string>
#include <iostream>
using namespace std;
int n; string s, t;
int main() {
	cin >> n >> s >> t;
	for(int i = 0; i <= n; i++) {
		string res = s.substr(0, i) + t;
		if(res.substr(0, n) == s) {
			cout << res.size() << endl;
			break;
		}
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  int minx = 252521;
  int sum = 0;
  REP(i,n){
    int x; 
    cin>>x;
    sum += x;
    if(x%10 != 0)CHMIN(minx,x);
  }
  if(sum%10==0)sum=max(0,sum-minx);
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine();
        var values = input.Split(' ');
        int x = int.Parse(values[0]);
        int y = int.Parse(values[1]);

        Console.WriteLine("{0} {1} {2:f8}", x / y, x % y, (double)x / (double)y);
    }
}

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

signed main() {
  string S;
  cin >> S;
  int N = (int)S.size();
  
  string A = "abcdefghijklmnopqrstuvwxyz";
  vector<bool> use(26, false);
  
  for( int i = 0; i < N; i++ ){
    for( int j = 0; j < 26; j++ ){
      if( S.at(i) == A.at(j) ) use.at(j) = true;
    }
  }
  
  if( N < 26 ){
    for( int i = 0; i < 26; i++ ){
      if( use.at(i) == false ){
        cout << S << A.at(i) << endl;
        return 0;
      }
    }
  }
  
  reverse( A.begin(), A.end() );
  if( S == A ){
    cout << -1 << endl;
    return 0;
  }else{
    string T = S;
    next_permutation(S.begin(), S.end());
    for( int i = 0; i < N; i++ ){
      cout << S.at(i);
      if( S.at(i) > T.at(i) ) break;
    }
    cout << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,w,i,j;
    cin>>n>>w;
    ll weight[n],value[n];
    for(i=0;i<n;i++){
        cin>>weight[i]>>value[i];
    }
    ll dp[n+1][w+1];
    for(i=0;i<n;i++){
        dp[i][0]=0;
    }
    for(i=0;i<n;i++){
        for(j=1;j<=w;j++){
            if(i==0){
                if(j>=weight[i]){
                    dp[i][j]=value[i];
                }
                else{
                    dp[i][j]=0;
                }
            }
            else{
                if(j>=weight[i]){
                    dp[i][j]=max({dp[i-1][j],dp[i-1][j-weight[i]]+value[i]});
                    if(i!=0){
                        dp[i][j]=max(dp[i][j],dp[i][j-1]);
                    }
                }
                else{
                    dp[i][j]=dp[i-1][j];
                }
            }
        }
    }
    // for(i=0;i<n;i++){
    //     for(j=0;j<=w;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    cout<<dp[n-1][w];
}

Measured memory_bytes: 78592
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    S = input()
    T = input()
    s = len(S)
    t = len(T)
    if (S == T[:s]) and s+1 == t:
        print('Yes') 
    else:
        print('No')
if __name__ == '__main__':
    main()


Measured memory_bytes: 61692
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		ArrayList<Integer> list = new ArrayList<>();
		for(int i = 0; i< N; i++) {
			list.add(Integer.parseInt(sc.next()));
		}
		sc.close();

		int ans = 0;
		for(int i = list.size() - 1; i >= 0; i--) {
			int tmp = list.get(i);
			boolean check = true;
			for(int j = i - 1; j >= 0; j--) {
				if(list.get(j) <= tmp) {
					continue;
				}else {
					check = false;
					break;
				}
			}
			if(check) ans++;
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
const int mo=998244353,N=2e5+5; 
typedef long long LL; 
void Inverse(int p,int a[],int n){//线性求<=n的数%p意义下的逆元 
	a[1]=1;
	for(int i=2;i<=n;i++){
		a[i]=1ll*(p-p/i)*a[p%i]%p;
	}
}
int inv[N],fac[N];
void init(int n){
	fac[0]=inv[0]=1;Inverse(mo,inv,n);
	for(int i=1;i<=n;i++)inv[i]=1ll*inv[i-1]*inv[i]%mo,fac[i]=1ll*i*fac[i-1]%mo;
}
int C(int n,int m){return 1ll*fac[n]*inv[m]%mo*inv[n-m]%mo;}
int main(){
	int n,m,k;scanf("%d%d%d",&n,&m,&k);
	init(n);
	LL w=1,ans=0;
	for(int i=0;i<n-1-k;i++)(w*=m-1)%=mo;
	for(int i=k;i>=0;i--)
		ans+=w*C(n-1,i)%mo*m%mo,(w*=m-1)%=mo;
	printf("%d",ans%mo);
	return 0;
}

Measured memory_bytes: 5356
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int hist[12];

int main()
{
	ios_base::sync_with_stdio(0);
	int n, w;
	while (cin >> n >> w, n ){
		memset (hist, 0, sizeof (hist ) );
		int maxv = 0;
		rep (i, n ){
			int v; cin >> v;
			hist[v/w]++;
			maxv = max (maxv, v );
		} // end rep
		int cnt = maxv/w, highest = 0;
		rep (i, cnt+1 ){
			highest = max (highest, hist[i] );
		} // end for
		double ink = 0.;
		rep (i, cnt ){
			int b = hist[i];
			ink += (double)(cnt - i)/(double)cnt*(double)b/(double)highest;
		} // end for
		ink += 0.01;
		printf ("%.9lf\n", ink );
	} // end while
		
	return 0;
}

Measured memory_bytes: 1240
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"

using namespace std;

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//{akari : 1D, yukari : 2D, maki : 3D} vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//{akane : ascending order, aoi : decending order} priority queue
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Libraries ---------------------------------//

//------------------------------- Dubug Functions ---------------------------//

inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}

//------------------------------- Solver ------------------------------------//

void solve()
{
    i64 x;
    cin >> x;
    for (int i = x;; i++)
    {
        bool ok = 1;
        for (int f = 2; f * f <= i; f++)
        {
            if (i % f == 0)
            {
                ok = 0;
            }
        }
        if (ok)
        {
            cout << i << endl;
            return;
        }
    }
}

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


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		const long MOD = 1000000007;
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int r = cin.Int();
			Console.WriteLine(3 * r * r);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
using ipair = pair<int,int>;
#define INF 10000000

int main(){
    char a;
    cin >> a;
    if (isupper(a)) cout << "A" << endl;
   else cout << "a" << endl;
}

Measured memory_bytes: 3632
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;



int main(void) {
   ll N;
   vector<ll> dp;
   vector<ll> A;
   cin>>N;
   dp.resize(N);
   rep(i,0,N) dp[i] = 0;
   A.resize(N);
   rep(i,0,N) cin>>A[i];
   dp[0] = A[0];
   rep(i,0,N-1) dp[i+1] = dp[i] + A[i+1];

   A.clear();
   A.resize(N);
   rep(i,0,N) cin>>A[i];

   rep(i,0,N) {
      chmax(dp[i],dp[i]+A[i]);
      if (i!=0) chmax(dp[i],dp[i-1]+A[i]);
   }
   cout<<dp[N-1]<<endl;


   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
using namespace std;

#define MAX 10000
#define NULL -1

typedef struct node {
	int left = NULL;
	int right = NULL;
	int parent = NULL;
} node;
int n;
int rootId;
int degree[MAX];
int depth[MAX];
int height[MAX];
int type[MAX];
int sibling[MAX];
node nodes[MAX];




void setDegree() {
	for (int i = 0; i < n; i++) {
		if (nodes[i].left == NULL && nodes[i].right == NULL) degree[i] = 0;
		else if (nodes[i].left == NULL || nodes[i].right == NULL) degree[i] = 1;
		else degree[i] = 2;
	}
}

void setDepth(int id, int dep = 0) {

	if (id == NULL) {
		return;
	}
	depth[id] = dep;
	setDepth(nodes[id].left, dep+1);
	setDepth(nodes[id].right, dep+1);

}

int setHeight(int id, int hei = 0) {
	int h1=0, h2=0;

	
	if(nodes[id].left != NULL) h1 = setHeight(nodes[id].left, hei++) +1;
	if(nodes[id].right!= NULL) h2 = setHeight(nodes[id].right, hei++) +1;

	return max(h1, h2);
}

void setType() {
	for (int i = 0; i < n; i++) {
		if (nodes[i].parent == NULL) {
			type[i] = 0;
		}
		else if (nodes[i].left == NULL && nodes[i].right == NULL) {
			type[i] = 2;
		}
		else {
			type[i] = 1;
		}
	}
}

void show() {
	for (int i = 0; i < n; i++) {
		cout << "node " << i << ": parent = " << nodes[i].parent << ", sibling = " << sibling[i] << ", degree = " << degree[i] << ", depth = " << depth[i] << ", height = " << height[i];
		if (type[i] == 0) { cout << ", root" << endl; }
		if (type[i] == 1) { cout << ", internal node" << endl; }
		if (type[i] == 2) { cout << ", leaf" << endl; }
	}
}

int main() {
	int id, l, r;
	cin >> n;
	for (int i = 0; i < n; i++) {
		nodes[i].parent = NULL;
		sibling[i] = NULL;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d %d %d", &id, &l, &r);
		nodes[id].left = l;
		nodes[id].right = r;

		if (l != NULL) nodes[l].parent = id;
		if (r != NULL) nodes[r].parent = id;
		if (l != NULL && r != NULL) {
			sibling[l] = r;
			sibling[r] = l;
		}
	}

	for (int i = 0; i < n; i++) {
		if (nodes[i].parent == NULL) rootId = i;
	}

	setDepth(rootId);
	for (int i = 0; i < n; i++) {
		height[i] = setHeight(i);
	}

	setDegree();
	setType();
	

	show();
}


Measured memory_bytes: 3344
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();
		sc.close();
		
		if(W >= S) {
			System.out.println("unsafe");
		}else {
			System.out.println("safe");
		}
	}

}

Measured memory_bytes: 27080
#include <cstring>
#include <cstdio>

typedef long long LL;
const int N=100005;

int cnt[N][26],fail[N],n,t;
char s[N*2];

LL calc(LL pos,int c){
	if (pos<=n) return cnt[pos][c];
	LL s1=cnt[n][c],s2=cnt[t][c],len1=n,len2=t;
	for (;len1+len2<=pos;){
		LL tmp=s1;s1+=s2;s2=tmp;
		tmp=len1;len1+=len2;len2=tmp;
	}
	return s1+calc(pos-len1,c);
}

int main(){
	scanf("%s",s+1);
	n=strlen(s+1)/2;
	fail[0]=-1;
	for (int i=1,j=-1;i<=n;fail[i++]=++j)
		for (;j>=0 && s[j+1]!=s[i];j=fail[j]);
	LL l,r;
	scanf("%lld%lld",&l,&r);
	t=n-fail[n];
	for (int i=1;i<=n;i++){
		for (int j=0;j<26;j++) cnt[i][j]=cnt[i-1][j];
		cnt[i][s[i]-'a']++;
	}
	for (int i=0;i<26;i++)
		printf("%lld ",calc(r,i)-calc(l-1,i));
}

Measured memory_bytes: 10880
#pragma GCC optimize("O3", "unroll-loops")
#pragma GCC target("avx2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define pii pair<int,int>
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define inf 1000000000 // 1e9
#define M   1000000007 // 1e9 + 7
using namespace std;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
int32_t main(){
    fastio;
    int a,b;
    cin >> a >> b;
    if(a > b) swap(a,b);
    b-= a;
    if(b%2){
        cout << "IMPOSSIBLE\n";
    }
    else{
        cout << b/2 + a << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
  
int main(void){
  	int* dig= new int[32];
	long long v_;
	cin >> v_;
  	//cout << v_ << endl;
    
  	long long v;
    v = (v_>0)?v_:-v_;
  	long long r=1;
    
    for(int i=0;i<32;i++){
      dig[i]=(v/r)%2;
      if (v_<0){dig[i]*=-1;}
      r<<=1;
    }
    for(int i=0;i<32;i++){
      //cout << dig[i];
    }
    //cout << endl;
  	
  	int flag=false;
	for (int i=0;i<1000;i++){
        int np = 1;
		for(int j=0;j<31;j++){
          if (np==-1 & dig[j]>0){
            dig[j+1]++;
            dig[j]-=2;
          }
          if (np==1 & dig[j]>1){
            dig[j+1]++;
            dig[j]-=2;
          }
          if (np==1 & dig[j]<0){
            dig[j+1]--;
            dig[j]+=2;
          }
          if (np==-1 & dig[j]<-1){
            dig[j+1]--;
            dig[j]+=2;
          }        
          np*=-1;
        }
    }
    int np=1;
  	for(int j=0;j<32;j++){
      dig[j]*=np;
      np*=-1;
    }
    int outflag=false;
    for(int i=31;i>=0;i--){
      if (dig[i]>0){outflag=true;}
      if (outflag){cout << dig[i];}
    }
    if (v==0){
      cout << 0;
    }
    cout << endl;
}

Measured memory_bytes: 256