akhauriyash/Code-Regression huggingface dataset:
n,m = (int(x) for x in input().split())
swi = []
for i in range(m):
  l = [int(x) for x in input().split()]
  t = 0
  for i in range(1,len(l)):
    t += 1 << (l[i]-1)
  swi.append(t)
ppp = [int(x) for x in input().split()]

ans = 0
for i in range(1 << n):
  for s, p in zip(swi,ppp):
    t = i & s
    c = bin(t).count("1") % 2
    if c != p:
      break
  else:
    ans += 1
print(ans)

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

using namespace std;


long long dp[3000][3000][2];


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

    int n;
    cin>>n;
    vector<long long> A(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }

    
    // for(int i=0;i<3000;i++){
    //     for(int k=0;k<3000;k++){
    //         dp[i][k][0]=dp[i][k][1]=0;
    //     }
    // }

    for(int i=0;i<n;i++){
        dp[i][i][1]=A[i];
        dp[i][i][0]=-A[i];
    }

    for(int i=n-1;i>=0;i--){
        for(int j=i+1;j<n;j++){
            if(i>=j){
                continue;
            }
            dp[i][j][0]=min(dp[i][j-1][1]-A[j], dp[i+1][j][1]-A[i]);
            dp[i][j][1]=max(dp[i][j-1][0]+A[j], dp[i+1][j][0]+A[i]);
        }
    }

    // for(int i=0;i<n;i++){
    //     for(int j=0;j<n;j++){
    //         cout<<dp[i][j][0]<<" ";
    //     }
    //     cout<<endl;
    // }
    // cout<<endl;

    // for(int i=0;i<n;i++){
    //     for(int j=0;j<n;j++){
    //         cout<<dp[i][j][1]<<" ";
    //     }
    //     cout<<endl;
    // }

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

Measured memory_bytes: 85340
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

template <class T> void vecout(T V) {
    auto t = V.begin();
    while(t != V.end()) {
        // cout << " " << *t++;
        cout << *t++ << "\n";
        // cout << *t++;
        // if(t != V.end()) cout << " ";
    }
    // cout << endl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    int c = 0;
    const int t = T.size();
    vector<int> A;
    rep(i, S.size() - T.size() + 1) {
        c = 0;
        rep(j, T.size()) {
            if(S.at(i + j) == T.at(j))
                c++;
            else
                break;
        }
        if(c == T.size()) A.push_back(i);
    }
    vecout(A);
}



Measured memory_bytes: 3208
row = []
matrix = []

n = gets.chomp.to_i
[*0...n].each { |i| row[i] = 0 }
[*0...n].each { |i| matrix[i] = row.clone }

n.times {
    xs = gets.chomp.split.map(&:to_i)
    num = xs.shift; num -= 1; xs.shift
    xs.each { |x|
        matrix[num][x - 1] = 1
    }
}

[*0...n].each { |i|
    if matrix[i] != nil
        puts matrix[i].join(" ")
    end
}


Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a,b,c,d;
  cin >> a >> b >>c >> d;
  
  long long A = max(a*c,b*d);

  long long B = max(A,a*d);

  long long C = max(B, b*c);

  cout << C <<endl;

}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main()
{
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  cout << (s == "abc" ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
s = list(input())
#print(s)
x = []
for i in s:
    if i in ('A' 'C' 'G' 'T'):
        x.append(1)
    else:
        x.append(0)
#print(x)

z = len(x)
y = [0]
a = 1
if z == 1:
    if x[0] == 1:
        y.append(a)
else:
    for j in range(1,z):
        if x[j] == 1:
            if x[j-1] == 1:
                a += 1
                if j == z-1:
                    y.append(a)
            else:
                y.append(a)
                a = 1
        else:
            if x[j-1] == 1:
                y.append(a)
                a = 1
#print(y)
print(max(y))
        




Measured memory_bytes: 3064
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

void Main()
{
	int x, a, b;
  	cin >> x >> a >> b;
 	if(abs(a-x) > abs(b-x)) cout << "B" << endl;
	else cout << "A" << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
long long N, A, B, C, D;
long long Bmax,Bmin,Bwid;
int i;

int main(void){

scanf("%ld %ld %ld %ld %ld",&N, &A, &B, &C, &D);
Bwid = (N-1)*(D-C)+1;

for(i=0;i<N-1;i++){
Bmax = A + (N-1-i)*D-i*C;
Bmin = Bmax - Bwid+1;
if( Bmin <= B && B <= Bmax){
printf("YES");
return 0;
}
}
printf("NO");
return 0;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int a,b,c,d;cin>>a>>b>>c>>d;
  while(1){
    c-=b;
    if(c<=0){
      cout<<"Yes"<<endl;
      return 0;
    }
    a-=d;
    if(a<=0){
      cout<<"No"<<endl;
      return 0;
      
    }
  }
  
  return 0;
}


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

using namespace std;

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

int main() {
  int N, Ma, Mb;
  cin >> N >> Ma >> Mb;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i] >> C[i];
  }
  const int inf = 1e9 + 5;
  vector<vector<int>> D(450, vector<int>(450, inf));
  D[0][0] = 0;
  for (int i = 0; i < N; i++) {
    for (int a = 400; a >= 0; a--) {
      for (int b = 400; b >= 0; b--) {
        if (D[a][b] == inf) continue;
        chmin(D[a + A[i]][b + B[i]], D[a][b] + C[i]);
      }
    }
  }
  int ans = inf;
  for (int a = 1; a <= 400; a++) {
    for (int b = 1; b <= 400; b++) {
      if (a * Mb == b * Ma) chmin(ans, D[a][b]);
    }
  }
  if (ans == inf) ans = -1;
  cout << ans << endl;

  return 0;
}
/* vim:set fdm=marker: */


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

int main() {
  ll x,y;cin>>x>>y;
  int ans=0;
  while(x<=y){
    x*=2;
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> dp(n, INF);
    dp[0] = 0, dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < n; i++) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n - 1] << endl;
}

Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  VI a(n); for (int i = 0; i < n; i++) cin >> a[i];
  
  lint res = 0;
  int p = 1;
  for (int i = 0; i < n; i++) {
    if (a[i] == p) {
      p++;
    } else {
      res += (a[i] - 1) / p;
    }
    p = max(2, p);
  }
  cout << res << '\n';
  return 0;
}

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

int main() {
	int K, A, B;
	bool hve = false;
	cin>>K;
	cin>>A>>B;
	for(int i = A; i<=B; i++) {
	    if(i%K==0) {
	        hve = true;
	        break;
	    }
	}
	if(hve) {
	    cout<<"OK"<<endl;
	} else {
	    cout<<"NG"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n, ans = 0;
    cin >> n;
    vector<int> a(n);
    for (int i; i < n; i++)
        cin >> a.at(i);
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) ans += a.at(i);
        else ans -= a.at(i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
// cout << "\t" << endl;

int main() {
  int x, y, z;
  cin >> x >> y >> z;
  swap(x, y);
  swap(x, z);
  cout << x << " " << y << " " << z << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	ll N, A, B, c;
	cin >> N >> A >> B;
	if( A == 0) cout << 0;
	else if(B == 0) cout << N;
	else{
		c = (N % (A + B));
		cout << (N/(A+B))*A + (c>A? A:c);
	}
			
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a[101][101], b[101][101];
	long long c[101][101], s;
	int i, j, k;
	int n, m, l;

	scanf("%d%d%d", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) scanf("%d", &a[i][j]);
	}
	for (i = 0; i < m; i++) {
		for (j = 0; j < l; j++) scanf("%d", &b[i][j]);
	}

	for (i = 0; i < n; i++) {
		for (j = 0; j < l; j++) {
			s = 0;
			for (k = 0; k < m; k++) {
				s += a[i][k] * b[k][j];
			}
			c[i][j] = s;
		}
	}

	for (i = 0; i < n; i++) {
		printf("%lld", c[i][0]);
		for (j = 1; j < l; j++) printf(" %lld", c[i][j]);
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

class SegmentTree {
  vector<long long> dat;
  int n = 1;
  long long def;
public:
  SegmentTree(int num, long long d) : def(d) {
    while (n < num)
      n <<= 1;
    dat.resize(2 * n - 1, def);
  }
  void update(int i, long long x) {
    i += (n - 1);
    dat[i] += x;
    while (i > 0) {
      i = (i - 1) / 2;
      dat[i] = dat[2 * i + 1] + dat[2 * i + 2];
    }
  }
  long long query(int a, int b, int i = 0, int li = 0, int ri = -1) {
    if (!i) ri = n;
    if (ri <= a || li >= b) return def;
    if (li >= a && ri <= b) return dat[i];
    long long vl = query(a, b, 2 * i + 1, li, (li + ri) / 2);
    long long vr = query(a, b, 2 * i + 2, (li + ri) / 2, ri);
    return vl + vr;
  }
};

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, q;
  cin >> n >> q;
  SegmentTree st(n, 0);
  rep(i, n) {
    int a;
    cin >> a;
    st.update(i, a);
  }
  rep(_, q) {
    int que;
    cin >> que;
    if (que) {
      int l, r;
      cin >> l >> r;
      cout << st.query(l, r) << '\n';
    } else {
      int p;
      ll x;
      cin >> p >> x;
      st.update(p, x);
    }
  }
  return 0;
}

Measured memory_bytes: 12552
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function lower_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)/2]<e?a=c:b=c;return d[a]<e?b:a};

console.log(main());
function main(){
  var s = o.a(1);
  var t = o.a(1);
  var sl = s.length;
  var tl = t.length;
  var dp = [[-1,""]];
  var u = Array(26).fill(0).map(a=>[]);
  for(var i = 0; i < sl; i++){
    u[s[i].charCodeAt()-97].push(i);
  }
  for(i = 0; i < tl; i++){
    var sn = u[t[i].charCodeAt()-97];
    for(var j = dp.length-1; j >= 0; j--){
      var v = lower_bound(sn,0,sn.length,dp[j][0]+1);
      if(v !== sn.length){
        if(dp[j+1] === undefined)dp[j+1] = [sn[v], dp[j][1]+t[i]];
        else if(sn[v] < dp[j+1][0])dp[j+1] = [sn[v], dp[j][1]+t[i]];
      }
    }
  }
  return dp[dp.length-1][1];
}

Measured memory_bytes: 25932
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define INF 1e8
typedef long long int ll;
const double PI = acos(-1);

using Graph = vector<vector<int>>;
int main()
{
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> ans(n, 0);
  for (int i = 1; i < n; ++i)
  {
    for (int j = i + 1; j <= n; j++)
    {
      int dist = min(j - i, abs(i - x) + abs(j - y) + 1);
      ans[dist]++;
    }
  }
  for (int i = 1; i < n; i++)
    cout << ans[i] << endl;
}


Measured memory_bytes: 3620
#include <stdio.h>
 
int
main(int argc, char *argv[])
{
  int n, a[100000]; int max = 0, min = 100000; int cnt[100001] = {};
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    scanf("%d", &a[i]);
    max = (max > a[i] ? max : a[i]);
    min = (min > a[i] ? a[i] : min);
    cnt[a[i]]++; cnt[a[i] + 1]++;
    if(a[i] >= 1) cnt[a[i] - 1]++;
  }
 
  int ans = 0;
 
  for(int i = min; i <= max; i++){
    ans = (ans > cnt[i] ? ans : cnt[i]);
  }
 
  printf("%d\n", ans);
 
  return 0;
}

Measured memory_bytes: 896
import sys
from collections import defaultdict as dd
sys.setrecursionlimit(4100000)

def dfs(node):
  visited[node-1] = True
  
  for next_node in tree[node]:
    if visited[next_node-1]:
      continue
    counter[next_node-1] += counter[node-1]
    dfs(next_node)

N, Q = map(int, input().split())
tree = dd(list)
visited = [False] * N
counter = [0] * N
operation = []
for _ in range(N-1):
  a, b = map(int, input().split())
  tree[a].append(b) 
  tree[b].append(a) 
for _ in range(Q):
  operation.append(tuple(map(int, input().split())))
  
for p, x in operation:
  counter[p-1] += x
dfs(1)
print(*counter)

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

int main(){
    int n, w, d;
    while(cin >> n >> w >> d, n+w+d){
        vector<pair<int,int>> v;
        v.push_back({w,d});
        int p, s;
        while(n-- > 0){
            cin >> p >> s;
            p--;
            pair<int,int> c = v[p];
            w = c.first, d = c.second;
            v.erase(v.begin()+p);
            int i, j, k, l;
            s %= (w+d+w+d);
            if(s < w)           i = s, j = d, k = w-s, l = d;
            else if(s < w+d)    i = w, j = w+d-s, k = w, l = s-w;
            else if(s < w+d+w)  i = w+d+w-s, j = d, k = s-(w+d), l = d;
            else                i = w, j = w+d+w+d-s, k = w, l = s-(w+d+w);
            if(i*j > k*l)   swap(i, k), swap(j, l);
            v.push_back({i,j});
            v.push_back({k,l});
        }
        vector<int> ans;
        for(int i = 0; i < v.size(); i++)   ans.push_back(v[i].first*v[i].second);
        sort(ans.begin(), ans.end());
        for(int i = 0; i < ans.size(); i++){
            cout << ans[i] << " \n"[i+1==ans.size()];
        }
    }
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int A = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == 'a') {
      A++;
    }
  }
  int B = 0;
  for (int j = 0; j < S.size(); j++) {
    if (S.at(j) == 'b') {
      B++;
    }
  }
  int C = 0;
  for (int k = 0; k < S.size(); k++) {
    if (S.at(k) == 'c') {
     C++; 
    }
  }
  if (A == 1 && B == 1 && C == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#![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::<i64>();
    let (l, r) = (v[0], v[1]);
    if r - l >= 2019 {
        println!("0");
        return;
    }

    let mut ans = 2018;
    for i in l..r {
        for j in i + 1..r + 1 {
            ans = min(ans, (i * j) % 2019);
        }
    }
    println!("{}", ans);
}

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: 2104
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,i,j,a[100005],ans;
bool cmp(int u,int v){
	return u>v;
}
int main(){
	n=read();
	for(i=1;i<=n;i++)
		a[i]=read();
	sort(a+1,a+n+1,cmp);
	for(i=1;i<=n;i++)
		if(i+1>a[i+1]){
			for(j=i+1;a[j]==i;j++)
				ans^=1;
			if((a[i]-i)&1)
				ans=1;
			if(ans==1)
				printf("First\n");
			else
				printf("Second\n");
			return 0;
		}
    return 0;
}

Measured memory_bytes: 640
def main():
    num = int(input())
    aka_data = [list(map(int, input().split())) for i in range(num)]
    ao_data = [list(map(int, input().split())) for i in range(num)]

    aka_data.sort(key=lambda x:-x[1])
    ao_data.sort(key=lambda x: x[0])

    ans = 0
    for j in range(num):
        for i in range(len(aka_data)):
            if aka_data[i][0] < ao_data[j][0] and aka_data[i][1] < ao_data[j][1]:
                aka_data.pop(i)
                ans += 1
                break

    print(ans)


if __name__ == '__main__':
    main()



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


int main(){
    double ans;
    double n, k;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    rep(i,n) p[i]++;
    queue <int> q;
    int s = 0, mx = 0;
    rep(i,n) {
        s += p[i];
        q.push(p[i]);
        if(k < q.size()) {
            s -= q.front();
            q.pop();
        }
        if(k == q.size()){
            mx = max(mx, s);
        }
    }
    ans = mx;
    ans /= 2;
    printf("%.10f", ans);
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <stack>
#include <math.h>
#include <stdio.h>
#define ll long long
#define anf 0x3f3f3f3f
using namespace std;
int f[8][2]= {0,1,0,-1,1,0,-1,0,1,1,1,-1,-1,1,-1,-1};
int main()
{
    int book[60][60];
    char mp[60][60];
    int w,h;
    cin>>w>>h;
    memset(book,0,sizeof(book));
    for(int i=0; i<w; i++)
    {
        scanf("%s",mp[i]);
    }
    for(int i=0; i<w; i++)
        for(int k=0; k<h; k++)
        {
            if(mp[i][k]=='#')
            {
                book[i][k]=-1;
                continue;
            }
            for(int j=0; j<8; j++)
            {
                int ni=i+f[j][0];
                int nk=k+f[j][1];
                if(mp[ni][nk]=='#')
                    book[i][k]++;

            }

        }
    for(int i=0; i<w; i++)
    {
        for(int k=0; k<h; k++)
        {
            if(book[i][k]==-1)
                printf("#");
             else
                printf("%d",book[i][k]);
        }
        printf("\n");
    }
    return 0;
}


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

using std::cin;
using std::cout;

int main(int argc, char* argv[]) {
  int a, b;
  cin >> a >> b;

  int count = 0;
  int s = 1;
  while (s < b) {
    s += a - 1;
    ++count;
  }
  cout << count;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <functional>
#include <list>
#include <iomanip>
#include <cctype>
#include <math.h>

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

using namespace std;


int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int c = 0;
    string S;
    cin >> S;
    
    rep(i,0,S.length()){
        if (S[i] == '0' && S[i+1] == '0'){
            S[i+1] = '1';
            c += 1;
            
        }
        else if (S[i] == '0' && S[i+1] == '1'){
            continue;
        }
        else if (S[i] == '1' && S[i+1] == '0'){
            continue;
        }
        else if (S[i] == '1' && S[i+1] == '1'){
            S[i+1] = '0';
            c += 1;
            
        }
    }
    
    cout << c <<endl;
    
}
    




Measured memory_bytes: 512
Q, H, S, D = map(int, input().split())
N = int(input())

H = min(2 * Q, H)
S = min(2 * H, S)
D = min(2 * S, D)

m = 0
m += (N // 2) * D
N = N % 2

m += N * S

print(int(m))

Measured memory_bytes: 3060
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,cardta[1000],cardha[1000];
int i,j,h,flg,flg1,flg2,ta,ha,temp;
int ba,cntta,cntha;
int main(void){
	scanf("%d",&n);
	while(n!=0){
		h=0;
		ta=0;
		ha=0;
		for(i=0;i<n;i++){
			scanf("%d",&cardta[i]);
		}
		for(i=1;i<=n*2;i++){	//花子が持っているカード抽出
			flg=0;
			for(j=0;j<n;j++){
				if(cardta[j]==i){
					flg=1;
					break;
				}
			}
			if(flg==0){
				cardha[h]=i;
				h++;
			}
		}
		sort(cardta,cardta+n);
		flg1=0;
		flg2=0;
		flg=1;
		while(flg1!=1 && flg2!=1){
				ba=0;
				flg1=1;
				flg2=1;
				//flg=1;
				while(1){//カードゲーム処理
					if(flg==1){
						for(i=0;i<n;i++){
							if(ba<cardta[i]){
								ba=cardta[i];
								//	printf("bata=%d\n",ba);
								cardta[i]=-1000;
								//printf("flga=%d\n",flg);
								flg=2;
								break;
							}
						}
					}
					for(i=0;i<n;i++){	//太郎花子のカード　すべて上書き（-1000）してたら終了
						if(cardta[i]!=-1000)flg1=0;
						if(cardha[i]!=-1000)flg2=0;
					}
					if(flg1==1 || flg2==1){
						break;
					}
					if(flg==1){
						flg=2;
						break;
					}
					if(flg==2){
						for(j=0;j<n;j++){
							if(ba<cardha[j]){
								ba=cardha[j];
								//printf("baha=%d\n",ba);
								cardha[j]=-1000;
								//printf("flgb=%d\n",flg);
								flg=1;
								break;
							}
						}
					}
					flg1=1;
					flg2=1;
					for(i=0;i<n;i++){	//太郎花子のカード　すべて上書き（-1000）してたら終了
						if(cardta[i]!=-1000)flg1=0;
						if(cardha[i]!=-1000)flg2=0;
					}
					if(flg1==1 || flg2==1){
						break;
					}
					if(flg==2){
						flg=1;
						break;
					}
				}
				flg1=1;
				flg2=1;
				for(i=0;i<n;i++){	//太郎花子のカード　すべて上書き（-1000）してたら終了
					if(cardta[i]!=-1000)flg1=0;
					if(cardha[i]!=-1000)flg2=0;
				}
				if(flg1==1 || flg2==1){
					break;
				}
				//printf("\n");
		}
		//printf("%d\n%d\n",ta,ha);
		cntta=0;
		cntha=0;
		/*for(i=0;i<n;i++){
			printf("ta%d,ha%d\n",cardta[i],cardha[i]);
		}*/
		for(i=0;i<n;i++){
			if(cardta[i]!=-1000)cntta++;
			if(cardha[i]!=-1000)cntha++;
			
		}
		printf("%d\n%d\n",cntha,cntta);
		scanf("%d",&n);
	}
	return 0;
}

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

int main() {
  int64_t K,Q=1000000007,Z=0;
  string S;
  cin>>K>>S;
  int64_t M=S.size();
  vector<int64_t> R(K+1);
  vector<int64_t> G(K+1);
  R.at(0)=1;
  G.at(0)=1;
  for(int i=0;i<K;i++){
    R.at(i+1)=(R.at(i)*26)%Q;
    G.at(i+1)=(G.at(i)*25)%Q;
  }
  if(M==1){
    for(int i=0;i<=K;i++){
      Z+=(R.at(i)*G.at(K-i))%Q;
      Z%=Q;
    }
    cout<<Z<<endl;
  }
  else{
    int64_t W=1;
    for(int64_t i=1;i<M;i++){
      W*=i;
      W%=Q;
    }
    int64_t N=Q-2; //ここから
       int64_t a=1,b=0,c=1;
       while(N>0){
         a*=2;
         if(N%a!=0){
           N-=a/2;
           int64_t d=W;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           c=c*d;
          c=c%Q;
         }
        b++;
      } //ここまで
    int64_t Y=1;
    for(int i=0;i<=K;i++){
      Z+=(((R.at(K-i)*G.at(i))%Q)*((((c*W)%Q)*Y)%Q))%Q;
      Z%=Q;
      W*=(M+i);
      W%=Q;
      
      int64_t N=Q-2; //ここから
       int64_t a=1,b=0,h=1;
       while(N>0){
         a*=2;
         if(N%a!=0){
           N-=a/2;
           int64_t d=i+1;
           for(int j=0;j<b;j++){
            d=d*d;
             d=d%Q;
          }
           h=h*d;
          h=h%Q;
         }
        b++;
      } //ここまで
      Y*=h;
      Y%=Q;
    }
    cout<<Z<<endl;
  }
}

Measured memory_bytes: 20072
package main

import (
	"fmt"
)

var debug = false

func main() {
	var a, b, c, x int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	fmt.Scanf("%d", &c)
	fmt.Scanf("%d", &x)
	res := GetAnswer(a, b, c, x)
	fmt.Printf("%v\n", res)
}

// GetAnswer ...
func GetAnswer(a, b, c, x int) int {
	prt("inputs: a:%d, b:%d, c:%d, x:%d\n", a, b, c, x)
	result := 0
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {
				total := (500 * i) + (100 * j) + (50 * k)
				prt("loop count a:%d b:%d c:%d total:%d\n", i, j, k, total)
				if total == x {
					result++
				}
			}
		}
	}
	prt("%v\n", result)
	return result
}

func prt(format string, inputs ...interface{}) {
	if debug {
		fmt.Printf(format, inputs...)
	}
}

Measured memory_bytes: 4864
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int k = sc.nextInt();
		int score = 0;
		
		if(a >= k) {
			System.out.println(k);
			return;
		}else {
			k -= a;
			score += a;
		}
		
		if(b >= k) {
			System.out.println(score);
			return;
		}else {
			k -= b;
		}
		
		score -= (k >= c) ? c : k;
		System.out.println(score);
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

int n,a[100005];
int f[100005];

int main()
{
	cin>>n;
	for(int i=1;i<=n;cin>>a[i++]);
	f[1] = 0;
	f[2] = abs(a[1]-a[2]);
	for(int i=3;i<=n;i++)
		f[i] = min(f[i-2]+abs(a[i-2]-a[i]),f[i-1]+abs(a[i-1]-a[i]));
	cout<<f[n]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;

    map<string, int> cnt;
    int nax = 0;
    rep(i, N) {
        string S;
        cin >> S;
        if (cnt.count(S) == 0) {
            cnt[S] = 1;
        }
        else {
            cnt[S]++;
        }
        chmax(nax, cnt[S]);
    }

    for (auto itr = cnt.begin(); itr != cnt.end(); itr++) {
        if (itr->second == nax) {
            cout << itr->first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<utility>
#include<queue>
#include<algorithm>
#include<map>
using namespace std;
int c[10][10];
int w,h,a,ans,b;
int dp[10];

int main(){
  cin>>w>>h;
  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++){
      cin>>c[i][j];
    }
  int minc=100000,mins,now=1;
  for(int i=0;i<10;i++)dp[i]=c[i][1];
  for(int j=0;j<10;j++)
    for(int k=0;k<10;k++){
      for(int i=0;i<10;i++){
	
	dp[i]=min(c[i][k]+dp[k],dp[i]);
	
      }
    }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a;
      if(a>=2 || a==0)ans+=dp[a];
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    void Calc()
    {
        cin = new Scanner();

        int r = cin.nextInt();

        if (r < 1200)
        {
            Console.WriteLine("ABC");
            return;
        }
        if (r < 2800)
        {
            Console.WriteLine("ARC");
            return;
        }
        Console.WriteLine("AGC");
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        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] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        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] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        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] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13140
// Contest: AtCoder Beginner Contest 156 (https://atcoder.jp/contests/abc156)
// Problem: C: Rally (https://atcoder.jp/contests/abc156/tasks/abc156_c)


// region {{{ boilerplate
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <chrono>
#include <cstdint>
#include <deque>
#include <exception>
#include <forward_list>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#if __cplusplus >= 201703L
#   include <optional>
#   include <string_view>
#   include <variant>
#endif

using namespace std;

#if __cplusplus >= 201703L
#   define all(a)      begin(a),end(a)
#   define sz(x)       ((int)size(x))
#else
#   define all(a)      (a).begin(),(a).end()
#   define sz(x)       ((int)(x).size())
#endif

#define rep(a, b)      for(int a = 0; a < (b); ++a)
#define reps(a, b, c)  for(int a = (b); a < (c); ++a)
#define trav(a, b)     for(auto& a : b)

using ll = long long;
using ld = long double;
using u64 = uint64_t;
using u32 = uint32_t;

using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vpi = vector<pi>;

#if __cplusplus >= 201703L
#   define MAYBE_UNUSED [[maybe_unused]]
#else
#   define MAYBE_UNUSED
#endif

MAYBE_UNUSED static constexpr int INF = (int)1e9 + 5;
MAYBE_UNUSED static constexpr ll INFL = (ll)1e18 + 5;
MAYBE_UNUSED static mt19937 rng((u32)chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
//endregion }}}

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

    int n; cin >> n;
    vi x(n);
    trav(xi, x) cin >> xi;
    int mn = INF;
    for (int m = 1; m <= 100; ++m) {
        int d = 0;
        trav(xi, x)
            d += abs(xi - m) * abs(xi - m);
        mn = min(mn, d);
    }

    cout << mn << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<vector<pair<int, int>>> cities(n + 1);
    for(int i = 0; i < m; i++) {
        int p, y;
        cin >> p >> y;
        cities[p].push_back({y, i});
    }
    vector<pair<int, int>> ans(m);
    for(int p = 1; p <= n; p++) {
        sort(cities[p].begin(), cities[p].end());
        for(int i = 0; i < cities[p].size(); i++) {
            ans[cities[p][i].second] = {p, i + 1};
        }
    }
    for(auto& p : ans) {
        cout << setfill('0') << setw(6) << p.first << setw(6) << p.second << endl;
    }
    return 0;
}


Measured memory_bytes: 7808
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;



int main() {
	
	int a, b;
	cin >> a >> b;
	int ans = -INF;

	ans = max(ans, a - b);
	ans = max(ans, a + b);
	ans = max(ans, a * b);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <unordered_map>
#include <queue>
// g++ -std=c++11 -o2 -Wall filename.cpp -o filename
#define hell 1000000009
#define bug1(x) cout<<"$ "<<x<<" $"<<endl
#define bug2(x) cout<<"% "<<x<<" %"<<endl
#define bug3(x) cout<<"# "<<x<<" #"<<endl
#define ll long long
#define pb push_back
#define mp make_pair
#define tr(z) for(auto it=z.begin(); it!=z.end(); it++)
#define rloop(i,a,b) for(long long i=a; i>=b;i--)
#define loop(i,a,b) for(long long i=a; i<b; i++)
#define vbool vector< bool >
#define vvbool  vector< vector<bool> >
#define vchar vector<char>
#define vi vector<int>
#define vvi vector< vector<int> >
#define pll pair<long long, long long>
#define vll vector<long long>
#define vvl vector< vector<long long> >
#define ninf numeric_limits<long long>::min()
#define pinf numeric_limits<long long>::max()
#define comp(a,b) (abs(a-b)<1e-9) // to compare doubles
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N;
    cin >> N;
    vi stones(N);
    loop(i, 0, N) {
        int n;
        cin >> stones[i];
    }

    vector<int> dp(N);
    dp[0] = 0;
    dp[1] = abs(stones[1] - stones[0]);
    loop (i, 2, N) {
        dp[i] = min(dp[i - 1] + abs(stones[i] - stones[i - 1]), dp[i - 2] + abs(stones[i] - stones[i - 2]));
    }
    cout << dp[N-1] << "\n";
    return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

class BipartiteMatching
{
private:
  int MAX_V;
  vector<int>* G;
  int* match;
  int* used;

  bool dfs(int v)
  {
    used[v] = true;
    rep(i, G[v].size()){
      int u = G[v][i], w = match[u];
      if(w < 0 || !used[w] && dfs(w)){
        match[v] = u;
        match[u] = v;
        return true;
      }
    }
    return false;
  }

public:
  BipartiteMatching(int MAX_V) : MAX_V(MAX_V)
  {
    G = new vector<int>[MAX_V];
    match = new int[MAX_V];
    used = new int[MAX_V];
  }

  void addEdge(int u, int v)
  {
    G[u].pb(v);
    G[v].pb(u);
  }

  int matching()
  {
    int res = 0;
    rep(i, MAX_V) match[i] = -1;
    rep(v, MAX_V){
      if(match[v] < 0){
        rep(i, MAX_V) used[i] = 0;
        if(dfs(v)) res += 1;
      }
    }
    return res;
  }
};

int N, M, L;
int u, v, dd;
int d[111][111];
int p[1111];
int t[1111];

int main(int argc, char *argv[])
{
  while(cin >> N >> M >> L, N){
    BipartiteMatching bm = BipartiteMatching(2 * L);
    rep(i, N) rep(j, N) d[i][j] = INF;
    rep(i, N) d[i][i] = 0;
    rep(i, M){
      cin >> u >> v >> dd;
      d[u][v] = dd;
      d[v][u] = dd;
    }
    rep(k, N) rep(i, N) rep(j, N) minup(d[i][j], d[i][k] + d[k][j]);
    rep(i, L) cin >> p[i] >> t[i];
    rep(i, L) rep(j, L) if(i != j && t[i] + d[p[i]][p[j]] <= t[j]) bm.addEdge(i, j + L);
    cout << L - bm.matching() << endl;
  }
  
  return 0;
}

Measured memory_bytes: 52484
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

int main()
{
	int n,k;
    scanf("%d %d", &k, &n);
    if(k%2==0){
      printf("%d ", k/2);
      for(int i=1; i<n; i++){
        printf("%d ", k);
      }
      printf("\n");
    }else if(k==1){
      if(n%2==0){
        for(int i=0; i<n/2; i++){
          printf("%d ", 1);
        }
      }else{
        for(int i=0; i<(n+1)/2; i++){
          printf("%d ", 1);
        }
      }
    }else if(n%2==0){
      if(k-n>=1){
        for(int i=0; i<n-1; i++){
          printf("%d ", (k+1)/2);
        }
        printf("%d ", (k-n+1)/2);
        printf("\n");
      }else{
        int a[300001];
        for(int i=0; i<n-1; i++){
          a[i]=(k+1)/2;
        }
        a[n-1]=0;
        for(int j=1; j<=(n-k-1)/2; j++){
          int t=0;
          while(a[n-1-t]==0){
            t++;
          }
          if(a[n-1-t]==1){
            a[n-1-t]=0;
          }else{
            a[n-1-t]--;
            for(int i=n-t; i<n; i++){
              a[i]=k;
            }
          }
        }
        for(int i=0; i<n; i++){
          if(a[i]>0) printf("%d ", a[i]);
        }
        printf("\n");
      }
    }else{
      if(k-n>=0){
        for(int i=0; i<n-1; i++){
          printf("%d ", (k+1)/2);
        }
        printf("%d ", (k-n+2)/2);
        printf("\n");
      }else{
        int a[300001];
        for(int i=0; i<n-1; i++){
          a[i]=(k+1)/2;
        }
        a[n-1]=0;
        for(int j=1; j<=(n-k-2)/2; j++){
          int t=0;
          while(a[n-1-t]==0){
            t++;
          }
          if(a[n-1-t]==1){
            a[n-1-t]=0;
          }else{
            a[n-1-t]--;
            for(int i=n-t; i<n; i++){
              a[i]=k;
            }
          }
        }
        for(int i=0; i<n; i++){
          if(a[i]>0) printf("%d ", a[i]);
        }
        printf("\n");
      }
    }  
	return 0;
}


Measured memory_bytes: 3328
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
using namespace std;
#include <bits/stdc++.h>
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb(X) push_back(X)
#define x first
#define y second
#define all(x) (x).begin(), (x).end()
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
typedef long long ll;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef pair<int, int> pii;
//ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const double p = 6.283185307179586232;
const int INF = 1e9 + 7;
double n;

int main() {
	scanf("%lf", &n);
	double ans = n * p;
	printf("%.3lf", ans);

	return 0;
}

Measured memory_bytes: 3828
n = int(input())
G = [[-1 for i in range(n)] for j in range(n)]
d = [999999 for i in range(n)]
  
for i in range(n):
    v = input().split()
    for j in range(int(v[1])):
        G[int(v[0])][int(v[2+2*j])] = int(v[3+2*j])

flag = [0] * n
tn = [0]
d[0] = 0
for k in range(n):
    for i in range(n):
        if i in tn:
            for j in range(n):
                if G[i][j] != -1:
                    if d[j] > d[i] + G[i][j]:
                        d[j] = d[i] + G[i][j]
                    if j not in tn:
                        tn.append(j)
  
for i in range(n):
    print(str(i) + " " + str(d[i]))

Measured memory_bytes: 8004
import sys

input = sys.stdin.readline
 
n, k =  map(int, input().split())

if k % 2 == 1:
    ans = (n // k) ** 3
else:
    a, b = 0, 0
    for i in range(1, n+1):
        if i % k == 0:
            a += 1
        if i % k == k // 2:
            b += 1
    ans = a**3 + b**3
print(ans)


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

int main(void) {
	string S, T;
	cin >> S >> T;

	vector <int> charpos[26];
	for(unsigned int i = 0; i < T.length(); i++) {
		charpos[(int)(T[i]-'a')].push_back(i);
	}
	
	bool ans = true;
	bool usedchar[26] = {false};

	for(int i = 0; i < 26; i++) {
		int TcharNum = charpos[i].size();
		if (TcharNum==0) continue;

		char schar = S[charpos[i].at(0)];
		if (usedchar[(int)(schar-'a')]) ans = false;
		usedchar[(int)(schar-'a')] = true;
		for (int j = 0; j <	TcharNum; j++) {
			if (S[charpos[i].at(j)] != schar) ans = false;
		}
	}
	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 1800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

double square_pow(double a, ll b) {
    if (b == 0) return 1;
    if (b & 1) return (a * square_pow(a, b - 1));
    double t = square_pow(a, b / 2);
    return (t * t);
}

int main() {
    double n, k;
    cin >> n >> k;
    double ans = 0.0;
    for (int i = 1; i <= n; i++) {
        ll t = i, cnt = 0;
        while (k > t) {
            cnt++;
            t *= 2;
        }
        ans += (1.0 / n) * (cnt ? square_pow(1.0 / 2, cnt) : 1);
    }
    cout << fixed << setprecision(12) << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		boolean[] count = {false,false,false,false};
		for(int i = 0; i < S.length(); i++) {
			char let = S.charAt(i);
			switch(let) {
			case 'N':
				count[0]=true;
				break;
			case 'S':
				count[1]=true;
				break;
			case 'E':
				count[2]=true;
				break;
			case 'W':
				count[3]=true;
				break;
			}
		}

		if(!(count[0]^count[1]) && !(count[2]^count[3])) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


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


static const int MAX_NUM = 10001;

int FindRoot(int elem[], int target)
{
    int parent;

    parent = target;
    for (;;) {
        if (parent == elem[parent]) {
            break;
        }
        else {
            parent = elem[parent];
        }
    }

    return parent;
}

void Unite(int elem[], int t1, int t2)
{
    int p1, p2;

    p1 = FindRoot(elem, t1);
    p2 = FindRoot(elem, t2);

    elem[p2] = p1;

    return;
}

bool Same(int elem[], int t1, int t2)
{
    bool ret;
    int p1, p2;

    p1 = FindRoot(elem, t1);
    p2 = FindRoot(elem, t2);

    if (p1 == p2) {
        ret = true;
    }
    else {
        ret = false;
    }

    return ret;
}

int main(void)
{
    int i;
    int num, qnum;
    int q;
    int t1, t2;
    int elem[MAX_NUM] = {0};

    scanf("%d %d", &num, &qnum);
    for (i = 1; i <= num; i++) {
        elem[i] = i;
    }

    for (i = 0; i < qnum; i++) {
        scanf("%d %d %d", &q, &t1, &t2);
        switch (q) {
        case 0 :
            Unite(elem, t1, t2);
            break;
        case 1 :
            if (Same(elem, t1, t2) == true) {
                printf("1\n");
            }
            else {
                printf("0\n");
            }
            break;
        default :
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 1216