akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int n,a[330001],Next[330001],go[330001];
long long dp[330001],sum[330001];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	n=unique(a+1,a+1+n)-a-1;
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		dp[i]=(sum[a[i]]+dp[i-1])%mod;
		sum[a[i]]=(sum[a[i]]+dp[i-1])%mod;
	}
	cout<<dp[n]<<'\n';
}


Measured memory_bytes: 8320
#include <stdio.h>

int main(void)
{
    int a, b, sum, length;
    
    scanf("%d %d", &a, &b);
    
    sum = a * b;
    length = a * 2 + b * 2;
    printf("%d %d\n", sum, length);
    
    return 0;
    
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	long long int d,t,s;
	cin>>d>>t>>s;
	if(t*s>=d)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
	return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int sum = a + b;
    int sub = a - b;
    int mul = a * b;
    int max = sum;
    if (max < sub) max = sub;
    if (max < mul) max = mul;
    System.out.println(max);
  }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int r, g, b, k;
    cin >> r >> g >> b >> k;
    int c = 0;
    while (!(r < g)) {
        g = 2 * g;
        c += 1;
    }
    while (!(g < b)) {
        b = 2 * b;
        c += 1;
    }
    cout << (c <= k ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3616
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());

    let (a, b, c) = (scan.next::<i32>() ,scan.next::<i32>(), scan.next::<i32>());
    let mut ans = 0;
    // for i in a..=b {
    for i in a..b+1 {
        if c % i == 0 {
            ans += 1;
        }
    }
    writeln!(out, "{}", ans).ok();
}



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

int main(){
   int N;
   cin>>N;
   vector<int> A(1000000,0),count(1000001,0);
   A.at(0)=N;
   for(int i=1;i<A.size();i++){
       count.at(A.at(i-1))++;
       if(count.at(A.at(i-1))==2){
           cout<<i<<endl;
           return 0;
       }
       else if(A.at(i-1)%2==0){
           A.at(i)=A.at(i-1)/2;
       }
       else {
           A.at(i)=3*A.at(i-1)+1;
       }
   }
}    

Measured memory_bytes: 8064
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    int digits = 0;
    int temp   = n;
    while (temp != 0) {
        digits++;
        temp /= 10;
    }
    set<string> s;
    s.insert("");
    for (int i = 0; i < digits; ++i) {
        set<string> ns = s;
        for (auto &ss : s) {
            ns.insert(ss + "3");
            ns.insert(ss + "5");
            ns.insert(ss + "7");
        }
        swap(s, ns);
    }
    vector<string> ns;
    for (auto &ss : s) {
        vi cnt(3, 0);
        for (int i = 0; i < ss.size(); ++i) {
            if (ss[i] == '3')
                cnt[0]++;
            else if (ss[i] == '5')
                cnt[1]++;
            else if (ss[i] == '7')
                cnt[2]++;
        }
        if (cnt[0] == 0 || cnt[1] == 0 || cnt[2] == 0)
            continue;
        ns.push_back(ss);
    }
    int ret = 0;
    for (auto &ss : ns) {
        if (stoi(ss) <= n)
            ret++;
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 4160
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <climits>
#include <sstream>
 
using namespace std;

typedef long long ll;

int main(){
    int c[110][110];

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    for(int i = 0; i < 3; i++){
        while( (c[i][0] != 0 && c[i][1] != 0) && c[i][2] != 0){
            c[i][0]--;
            c[i][1]--;
            c[i][2]--;
        }
    }

    bool flag = true;
    if( c[0][0] != c[1][0] || c[0][0] != c[2][0] ) flag = false;
    if( c[0][1] != c[1][1] || c[0][1] != c[2][1] ) flag = false;
    if( c[0][2] != c[1][2] || c[0][2] != c[2][2] ) flag = false;

    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

    unsigned long l_havingCookieCountOfTakahashi;
    unsigned long l_havingCookieCountOfAoki;
    unsigned long l_repeatCount;

    scanf("%ld%ld%ld", &l_havingCookieCountOfTakahashi, &l_havingCookieCountOfAoki, &l_repeatCount);

    if (l_havingCookieCountOfTakahashi > l_repeatCount)
    {
        l_havingCookieCountOfTakahashi -= l_repeatCount;
    }
    else if (l_havingCookieCountOfTakahashi == l_repeatCount)
    {
        l_havingCookieCountOfTakahashi = 0;
    }
    else
    {
        l_repeatCount -= l_havingCookieCountOfTakahashi;
        l_havingCookieCountOfTakahashi = 0;
        if (l_repeatCount <= l_havingCookieCountOfAoki)
        {
            l_havingCookieCountOfAoki -= l_repeatCount;
        }
        else
        {
            l_havingCookieCountOfAoki = 0;
        }
    }

    printf("%ld %ld", l_havingCookieCountOfTakahashi, l_havingCookieCountOfAoki);

}

Measured memory_bytes: 128
/*      Chill raho be kuch nhi rakha sadness me. 
               Author: Maskman_lucifer                   */
               
#include <bits/stdc++.h>   
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
ll dp[110][200005];;

ll knapsack(ll index,ll size,ll weights[],ll values[])
{
    ll take,dontTake;
    take = dontTake = 0;
    
    if (dp[index][size]!=-1)
    {
        return dp[index][size];
    }

    if (index==0)
    {
        if (weights[0]<=size)
        {
            dp[index][size] = values[0];
            return values[0];
        }
        else
        {
            dp[index][size] = 0;
            return 0;
        }
    }
    
    dontTake = knapsack(index-1, size, weights, values);
    
    if (weights[index]<=size)
    {
        take = values[index] + knapsack(index-1, size-weights[index], weights, values);
    }
   
    
    dp[index][size] = max (take, dontTake);
    
    return dp[index][size];

}
int main()
{
    IO
    memset(dp,-1,sizeof(dp));
    ll n;
    cin>>n;
    ll knapsackSize;
    cin>>knapsackSize;
    ll weights[n+1];
    ll values[n+1];
    for(ll i=0;i<n;i++)
    {
        cin>>weights[i]>>values[i];
    }
    cout<<knapsack(n-1,knapsackSize,weights,values)<<lc;
    return 0;
}


Measured memory_bytes: 175524
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<int> a(N);
        REP(i, N) cin >> a[i];
        stack<int> stk;
        int ans = 0;
        REP(i, N){
            while(!stk.empty() && stk.top() > a[i]) stk.pop();
            if(stk.empty() || stk.top() < a[i]) {
                stk.push(a[i]);
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 2580
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]C - いっしょ / Be Together
            int n = int.Parse(Console.ReadLine());
            var a = ReadLine();

            int min = int.MaxValue;

            for(int i = a.Min(); i <= a.Max(); i++)
            {
                int sum = 0;

                for(int j = 0; j < n; j++)
                {
                    sum += (int)Math.Pow(a[j] - i, 2);
                }

                if (sum < min)
                {
                    min = sum;
                }
            }

            Console.WriteLine(min);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define ll long long

using namespace std;

const int INF = 2*1e05+1;
vector< vector<int> > g(INF);
vector<int> visited(INF);
int cnt;

void dfs(int now) {
  visited[now] = 1;
  for (int next: g[now]) {
    if (visited[next]) continue;
    cnt++;
    dfs(next);
  }
}

int main() {
  int N, M;
  cin >> N >> M;
  
  int A, B;
  for (int m = 0; m < M; m++) {
    cin >> A >> B;
    g[A].push_back(B);
    g[B].push_back(A);
  }
  
  int ans = 1;
  for (int n = 1; n < N+1; n++) {
    if(visited[n]) continue;
    cnt = 1;
    dfs(n);
    ans = max(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 21152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main(){
  int N,M,sum = 0,dif;
  cin >> N;
  vector<int> T(N);
  rep(i,0,N){cin >> T[i]; sum += T[i];}
  cin >> M;
  vector<int> P(M),X(M);
  rep(i,0,M){
    dif = 0;
    cin >> P[i] >> X[i];
    dif = T[P[i] - 1] - X[i];
    co(sum - dif);
  }
}

Measured memory_bytes: 256
s = input()
n = len(s)

dp = [0] * (n + 1)
dp[1] = 1
dp[2] = dp[1] + (1 if s[0] != s[1] else 0)

for i in range(2, n):
    if s[i] != s[i-1]:
        dp[i+1] = dp[i] + 1
    else:
        dp[i+1] = dp[i-2] + 2
    

print(dp[n])

Measured memory_bytes: 11144
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using int64 = int64_t;

constexpr int64 MOD = 1000000007;

int64 fact(int64 x) {
    int64 ans = 1;
    for (int j = 2; j <= x; ++j) {
        ans *= j;
    }
    return ans;
}

int N, A, B;
int64 v[50];

int main() {
    cin >> N >> A >> B;
    for (int j = 0; j < N; ++j) { cin >> v[j]; }

    sort(v, v+N);

    double avr = 0;
    for (int j = N-A; j < N; ++j) {
        avr += v[j];
    }
    avr /= A;

    int li = lower_bound(v,v+N,v[N-A]) - v;
    int ui = upper_bound(v,v+N,v[N-A]) - v;

    int m = ui - li;

    int low =  ui - (N-A);
    int high = v[N-A] == v[N-1] ? min(B, N - li + 1) : low;

    int64 ans = 0;
    int64 acc = 1;
    for (int j = 1; j <= high; ++j) {
        acc *= (m-j+1);
        acc /= j;
        if (j >= low) {
            ans += acc;
        }
    }

    printf("%.12f\n", avr);
    printf("%lld\n", ans);
    return 0;
}


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


int main()
{
    int n,k;
    cin>>n>>k;
    int *x=new int [n];
    for(int i=0;i<n;i++)
        cin>>x[i];
    sort(x,x+n);
    int i=0,s=0;
    while(i<k){
        s+=x[i];
        i++;
    }
    cout<<s;
}

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

using namespace std;

typedef long long ll;
ll n, a, b;
vector<ll> h;

bool enough(ll t) {
    ll tt = t;
    for (ll i = 0; i < n; i++) {
        if (h[i] - b * t > 0)
            tt -= (h[i] - b * t + a - b - 1) / (a - b);
    }
    return tt >= 0;
}

int main() {
    cin >> n >> a >> b;
    h.resize(n);
    ll mx = 0;
    for (ll i = 0; i < n; i++) {
        cin >> h[i];
        mx = max(h[i], mx);
    }

    ll l = 0, r = (mx + b - 1) / b;
    while (l < r) {
        ll m = (l + r) / 2;
        if (enough(m)) {
            r = m;
        } else {
            l = m + 1;
        }
    }

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 1024
a, b = map(int, input().split())

Aa = 0
i = 0
for i in range (b):
    A = (10**i)*a
    Aa = A + Aa
    i=i+1

Bb = 0
j = 0
for j in range (a):
    B = (10**j)*b
    Bb = B + Bb
    j=j+1
    
list = [Aa, Bb]
sorted = sorted(list)

print (sorted [1])

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,K; cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    vector<int> B(K+1);
    set<int> dic;
    int ans = 1e9;
    int right = 0;
    rep(left,N) {
        while (right < N && dic.size() < K) {
            if (A[right] <= K) {
                B[A[right]]++;
                dic.emplace(A[right]);
            }
            right++;
        }
        if (dic.size() == K) chmin(ans,right-left);
        if (left == right) right++;
        if (A[left] <= K) {
            B[A[left]]--;
            if (B[A[left]] == 0) dic.erase(A[left]);
        }
    }

    cout << (ans==1e9 ? 0 : ans) << endl;
}


Measured memory_bytes: 8292
#include<cmath>
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int i;
	while(n/2)
	{
		n/=2;
		i++;	
	}	
	i=pow(2,i);
	cout<<i<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define pf(x) cout << (x) << endl

ll f(ll n){
    if(n == 0)return 1;
    return f(n % bitset<20>(n).count()) + 1;
}

//modの値の確認をすること
int main(){
    ll n,c = 0;
    string s;
    cin >> n >> s;
    rep0(i, n)if(s[i] == '1')++c;
    ll k1 = 0,k2 = 0,r1 = 1,r2 = 1;
    rrep0(i, n){
        if(s[i] == '1'){
          	if(c > 1){
            	k1 += r1;
            	k1 %= (c - 1);
         	}
            k2 += r2;
            k2 %= (c + 1);
        }
        if(c > 1)r1 = 2 * r1 % (c - 1);
        r2 = 2 * r2 % (c + 1);
    }
    r1 = 1;
    r2 = 1;
    vector<ll> ans(n);
    rrep0(i, n){
        if(s[i] == '1'){
          	if(c > 1){
            	k1 -= r1;
            	k1 += (c - 1) * 2;
            	k1 %= (c - 1);
          
            	ans[i] = f(k1);
              	k1 += r1;
            }else ans[i] == 0;
        }else{
            k2 += r2;
            k2 %= (c + 1);
          
            ans[i] = f(k2);
          
            k2 -= r2;
            k2 += (c + 1) * 2;
            k2 %= (c + 1);
        }
        if(c > 1)r1 = 2 * r1 % (c - 1);
        r2 = 2 * r2 % (c + 1);
    }
    rep0(i, n)pf(ans[i]);
    return 0;
}



Measured memory_bytes: 5252
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;

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

    int N;
    cin >> N;
    
    while(N != 0){
        vector<P> w;
        REP(i, N){
            int x, y;
            cin >> x >> y;
            w.pb(mp(y, x));
        }
        w.pb(w[0]);
        int xu = -20000, xd = 20000, yu = -20000, yd = 20000;
        REP(i, 4){
            int x, y;
            cin >> x >> y;
            chmax(yu, y);
            chmin(yd, y);
            chmax(xu, x);
            chmin(xd, x);
        }

        LL ans = 0;
        REP(i, N){
            int x1 = w[i].se;
            int x2 = w[i+1].se;
            int y = w[i].fi;
            ans += (x1 - x2) * y;
            x1 = max(xd, min(xu, x1));
            x2 = max(xd, min(xu, x2));
            y = max(yd, min(yu, y));
            ans -= (x1 - x2) * y;

        }
        cout << ans << endl;

        cin >> N;
    }

    return 0;
}


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

int main() {
    int N;
    cin >> N;
    int cake = 0;
    int donut = 0;
    bool can = false;
    for(int i = 0; i < 25; ++i) {
        cake = 4*i;
        for(int j = 0; j < 15; ++j) {
            donut = 7*j;
            if(cake + donut == N) {
                can = true;
                break;
            }
        }
    }
    if(can) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

import static java.lang.Integer.parseInt;

/**
 * The Shortest Path on A Rhombic Path
 */
public class Main {

	public static int MAX = 100;
	public static int[] H = {0, 1};
	public static int[] V = {1, 0};

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int[][] dp = new int[MAX][MAX];

		int prevLen = 0, maxLen = 0;
		while ((line = br.readLine()) != null && !line.isEmpty()) {

			String[] words = line.split(",");

			if (words.length > prevLen) {
				for (int i = 0, c = 0, r = words.length - 1; i < words.length; i++, c++, r--) {
					dp[r][c] = parseInt(words[i]);
				}
			} else {
				for (int i = 0, c = maxLen - words.length, r = maxLen - 1; i < words.length; i++, c++, r--) {
					dp[r][c] = parseInt(words[i]);
				}
			}

			prevLen = words.length;
			maxLen = Math.max(maxLen, words.length);

		}

		for (int i = 0; i < maxLen; i++) {
			for (int j = 0; j < maxLen; j++) {
				if (i == 0 && j != 0) {
					dp[i][j] += dp[i][j - 1];
				} else if (i != 0 && j == 0) {
					dp[i][j] += dp[i - 1][j];
				} else if (i != 0 && j != 0) {
					dp[i][j] += Math.max(dp[i][j - 1], dp[i - 1][j]);
				}
			}
		}
		System.out.println(dp[maxLen - 1][maxLen - 1]);

	}

}

Measured memory_bytes: 25100
#include<iostream>

using namespace std;

int main(){
  int W , H , N;

  cin >> W >> H >> N ;
  
  int WWL = 0 , WWR = W , WHU = 0 , WHO = H;
  for(int i = 0 ; i < N ; i++){
    int x , y , a;
    cin >> x >> y >> a;
    switch(a){
      case(1):
        if(WWL < x)
          WWL = x;
        break;
      
      case(2):
        if(WWR > x)
          WWR = x;
        break;
      
      case(3):
        if(WHU < y)
          WHU = y;
        break;
      
      case(4):
        if(WHO > y)
          WHO = y;
        break;
    }
    //cout << "xa=" << WWL << " xb=" << WWR << " ya=" << WHU << " yb =" << WHO << endl; 
  }
  
  int men = (WWR - WWL) *  (WHO - WHU);
  if ((WWR - WWL) < 0 || (WHO - WHU)<0)
    men = 0;
  cout << men << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vec;
typedef vector<vec> mat;
const double EPS=1E-9;
bool gauss_jordan(const mat& A,const vec& b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)B[i][j]=A[i][j];
  
  for(int i=0;i<n;i++)B[i][n]=b[i];
  
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++)if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    swap(B[i],B[pivot]);

    for(int j=0;j<n;j++)
      if(i!=j)
	for(int k=i+1;k<=n;k++)B[j][k]=(B[j][k]+B[j][i]*B[i][k])%2;
  }
  vec x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  for(int i=0;i<n;i++)if(B[i][i]==0&&x[i]==1) return 0;
  return 1;
}

int h,w,d,mp[25][25];

int main(){
  while(1){
    cin>>w>>h>>d;
    if(!w&&!h&&!d)break;
    mat A(h*w,vec(h*w));
    vec B(h*w);
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)cin>>mp[i][j];
    
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	int idx=w*i+j;
	B[idx] = mp[i][j];
	for(int y=0;y<h;y++)
	  for(int x=0;x<w;x++){
	    int t = abs(i-y)+abs(j-x);
	    if(t==d||t==0)A[idx][w*y+x]=1;				
	  }
      }
    cout<<gauss_jordan(A,B)<<endl;
  }
  return 0;
}

Measured memory_bytes: 5868
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
int a,b,c;
inline int read(){
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9') {x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int main(){
	a=read();b=read();c=read();
	if(a==b) {cout<<c<<endl;return 0;}
	if(c==b) {cout<<a<<endl;return 0;}
	if(a==c) {cout<<b<<endl;return 0;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    int h,w,n,point=0;
    in(h,w,n);
    vector<int> vec(n);
    in(vec);
    vector2d(int,color,h,w,0);
    rep(y,h){
        if(y%2==0){
            for(int x=0;x<w;x++){
                color[y][x]=point+1;
                vec[point]--;
                if(vec[point]==0)point++;
            }
        }else{
            for(int x=w-1;x>=0;x--){
                color[y][x]=point+1;
                vec[point]--;
                if(vec[point]==0)point++;
            }
        }
    }
    rep(i,h)out(color[i]);
}

Measured memory_bytes: 3836
A,V= map(int,input().split())
B,W= map(int,input().split())
T = int(input())
if A < B and A + T* V >=B+ T* W:
    ans = "YES"
elif B < A and A -T* V <=B- T* W:
    ans = "YES"
else:
    ans ="NO"
print(ans)


Measured memory_bytes: 9172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int r = fs.nextInt();
		
		System.out.println((double)(2*r) * Math.PI);
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}


}


Measured memory_bytes: 33280
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
ll digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}
ll countpow(ll a, ll b) {
	int ans = 0;
	if (b == 0)return -1;
	while (1) {
		if (a % b == 0) {
			a /= b;
			ans++;
		}
		else break;
	}
	return ans;
}
int to_num(char c) {
	if (c >= '0' && c <= '9')return (c - '0');
	else return -1;
}

string to_time(int x) {
	string ans;
	if (x < 10)ans = '0' + to_string(x);
	else ans = to_string(x);
	return ans;
}

int main() {
	IOS;
	string s;
	cin >> s;
	if (s.size() == 26) {
		if (s == "zyxwvutsrqponmlkjihgfedcba") {
			cout << -1 << endl;
			return 0;
		}
		string t = s;
		reverse(ALL(t));
		int j;
		char min;
		REP(i, 25) {
			if (t[i + 1] > t[i])continue;
			else {
				j = i + 1;
				min = t[i + 1];
				break;
			}
		}
		int k;
		REP(i, j) {
			if (t[i] > min) {
				k = i;
				break;
			}
		}
		
		string ans = s.substr(0,26 - j - 1) + t[k];
		cout << ans << endl;
		return 0;
	}
	else {
		bool used[26];
		MEM(used, false);
		REP(i, s.size()) {
			used[s[i] - 'a'] = true;
		}
		REP(i, 26) {
			if (used[i])continue;
			else {
				char unko = 'a' + i;
				s = s + unko;
				break;
			}
		}
		cout << s << endl;
	}
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))

color = [0]*8
free_color = 0
for a in A:
  if a < 400:
    color[0] = 1
  elif a < 800:
    color[1] = 1
  elif a < 1200:
    color[2] = 1
  elif a < 1600:
    color[3] = 1
  elif a < 2000:
    color[4] = 1
  elif a < 2400:
    color[5] = 1
  elif a < 2800:
    color[6] = 1
  elif a < 3200:
    color[7] = 1
  else:
    free_color += 1
sum_c = sum(color)

if sum_c == 0:
  print(1, free_color)
else:
  print(sum_c, sum_c + free_color)


Measured memory_bytes: 3064
import itertools

count = 0
N, M = map(int, input().split())
listN = [i for i in range(2, N + 1, 1)]
listM = []
for j in range(M):
    new_keiro = list(map(int, input().split()))
    listM.append(new_keiro)
    listM.append(new_keiro[::-1])

all_listN = list(itertools.permutations(listN))

for now_listN in all_listN:
    judge = True
    if [1 ,now_listN[0]] in listM:
        x = 0
    else:
        judge = False
    for k in range(len(now_listN) - 1):
        if [now_listN[k],now_listN[k + 1]] in listM:
            x = 0
        else:
            judge = False
    count += judge

print(count)

Measured memory_bytes: 3572
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp = input[0].split(" ");
    var N = Number(tmp[0])
    A = input[1].split(" ").map(Number)

    var ansinv=0
    for(var i=0; i<N; i++)
    {
        ansinv += 1/A[i]
    }
    console.log(1/ansinv)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


Measured memory_bytes: 2044
N,T=map(int,input().split())
t=list(map(int,input().split()))
t.append(10**10)
ans=0
flg=0
temp=0

for i in range(N):
  if t[i]+T > t[i+1]:
    if flg==0:
      temp=t[i]
      flg=1
    continue
  else:
    if flg==0:
      ans+=T
    else:
      ans+=t[i]-temp+T
    flg=0
print(ans)

Measured memory_bytes: 30896
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;

typedef vector< vector<int> > Graph;
bool dfs(Graph &g, vector<int> &color, int u, int c){
    color[u] = c;
    for(int v : g[u]){
        if(color[v] == c) return false;
        if(!color[v] && !dfs(g, color, v, -c)) return false;
    }
    return true;
}

int isBipartite(Graph &g){
    int n = g.size();
    vector<int> color(n);
    REP(i, n) if(!color[i] && !dfs(g, color, i, 1)) return 0;
    int c = 0;
    REP(i, n) c += color[i] == 1;
    return c;
}

int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin >> n >> m;
    Graph g(n);
    REP(i, m) {
        int u, v;
        cin >> u >> v; u--; v--;
        g[u].pb(v); g[v].pb(u);
    }
    ll sum;
    int c = isBipartite(g);
    if (!c) {
        sum = (ll)n * (n-1) / 2;
    } else {
        sum = (ll)c * (n - c);
    }
    cout << sum - m << endl;
    return 0;
}


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

int main(){
  int a, b;
  cin >> a >> b;
  
  if(a == b){
    cout << "Draw" << endl;
    return 0;
  }
  
  if((a == 1 || a > b) && b != 1){
    cout << "Alice" << endl;
  }else if(b == 1 || b > a){
    cout << "Bob" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int A,B;
    cin>>A>>B;

    if(A==B)
    {
     cout<<"Draw";
    }
    else if(A>B)
    {
      if(B==1)
      cout<<"Bob";
     else
            cout<<"Alice";
    }


   else if(B>A)
    {
      if(A==1)
     cout<<"Alice";

      else
        cout<<"Bob";
    }


    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    
    if(a<=c && b>=c){
        if(b<=d){
            cout<<b-c<<endl;
        }else{
            cout<<d-c<<endl;
        }
    }
    else if(a>=c && a<=d){
        if(b<=d){
            cout<<b-a<<endl;
        }else{
            cout<<d-a<<endl;
        }
    }
    else{
        cout<<"0"<<endl;
    }
        
        
    
   
    return 0;
}








Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// 参考 https://ei1333.github.io/luzhiled/snippets/structure/segment-tree.html
template <typename T>
struct SegTree {
    using F = function<T(T,T)>;
    
    int size;
    vector<T> dat;

    const F f;
    const T INIT;
    
    SegTree(int n, const F func, const T &init) : f(func), INIT(init) {
        size = 1;
        while(size < n) size <<= 1;
        dat.assign(2*size, INIT);
    }

    void update(int k, const T &x) {
        k += size;
        dat[k] = x;
        while(k >>= 1) {
            dat[k] = f(dat[2*k],dat[2*k+1]);
        }
    }

    T query(int a,int b) {
        T l = INIT, r = INIT;
        for(a += size, b += size+1; a < b; a >>= 1, b >>= 1) {
            if (a & 1) l = f(l,dat[a++]);
            if (b & 1) r = f(r,dat[--b]);
        }
        return f(l,r);
    }

    // 未使用機能
    private:
    void set(int k, const T &x) {
        dat[k+size] = x;
    }

    void build() {
        for(int k = size - 1; k > 0; k--) {
            dat[k] = f(dat[2*k],dat[2*k+1]);
        }
    }

    T operator[](const int &k) const {
        return dat[k+size];
    }

};


int main(void)
{
    IOS
    int N, Q;
    cin >> N >> Q;

    SegTree<int> seg(N,[](int a,int b){return a+b;}, 0);

    REP(i,Q) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) seg.update(x,seg.query(x,x) + y);
        else OUT(seg.query(x,y))
    }

    return 0;
}


Measured memory_bytes: 3796
from collections import deque
n, queries = map(int, input().split())
Q = []
for i in range(n):
    Q.append(deque())
for i in range(queries):
    q, t, *x = map(int, input().split())
    if q == 0:
        Q[t].append(x[0])
    elif q == 1:
        if Q[t]:print(Q[t][0])
    elif q == 2:
        if Q[t]:Q[t].popleft()


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

#define ran 202202

int n, q;
vector<int> e[ran];
int v[ran];

void dfs(int cur, int par, int det) {
	v[cur] += det;
	
	for(int i=0;i<e[cur].size();i++) {
		int nxt = e[cur][i];
		if (nxt==par) continue;
		
		dfs(nxt, cur, v[cur]);
	}
}

int main() {
	scanf("%d%d", &n, &q);
	for(int i=1;i<n;i++) {
		int x, y; scanf("%d%d", &x, &y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	for(int i=0;i<q;i++) {
		int id, det;
		scanf("%d%d", &id, &det);
		v[id] += det;
	}
	
	dfs(1, -1, 0);
	
	for(int i=1;i<=n;i++)
		printf("%d%c", v[i], i<n ? ' ' : '\n');
	
	return 0;
}

Measured memory_bytes: 26624
#include<stdio.h>
#include<string.h>

int tri(int a,int b,int c);
int main(void){
  int n;
  scanf("%d",&n);
  int l[n];
  int i,j,k;
  int ans=0;
  int checker=1;
  int tmp;
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
    }

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(l[i]<l[j]){
        tmp=l[i];
        l[i]=l[j];
        l[j]=tmp;
      }
    }
  }

  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(k=j+1;k<n;k++){
        checker=tri(l[i],l[j],l[k]);
        if(checker==1)
        ans++;
        else
        break;
      }
    }
  }

printf("%d",ans);

    return 0;
}

int tri(int a,int b,int c){
  if(a<b+c&&b<c+a&&c<a+b){
    return 1;

  }
  else
  return 0;
}


Measured memory_bytes: 128
// cities to vapori-
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz // math is your friend
#include <bits/stdc++.h>
#define pb push_back
#define fst first
#define snd second
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define REP(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
const int N = 2e5+20;

int ans[N];
vector<int> mod[3];
vector<int> adj[N];
vector<int> color[2];

void dfs(int u, int p = -1, int c = 0){
	color[c].pb(u);
	for(int v : adj[u]) if(v != p){
		dfs(v,u,1-c);
	}
}

int main(){
	
	fastio;
	int n,a,b;
	cin >> n;
	for(int i = 1; i < n; ++i){
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	dfs(1);

	for(int i = 1; i <= n; ++i){
		mod[i%3].pb(i);
	}

	if(sz(color[0]) > sz(color[1])) swap(color[0],color[1]);

	if(sz(color[0]) <= sz(mod[0])){
		for(int u : color[0]){
			ans[u] = mod[0].back();
			mod[0].pop_back();
		}
		for(int v : color[1]){
			if(sz(mod[0])){
				ans[v] = mod[0].back();
				mod[0].pop_back();
			}else if(sz(mod[1])){
				ans[v] = mod[1].back();
				mod[1].pop_back();
			}else if(sz(mod[2])){
				ans[v] = mod[2].back();
				mod[2].pop_back();
			}
		}
	}else{
		for(int c : mod[1]){
			ans[color[0].back()] = c;
			color[0].pop_back();
		}
		for(int c : mod[2]){
			ans[color[1].back()] = c;
			color[1].pop_back();
		}
		for(int c : mod[0]){
			if(sz(color[0])){
				ans[color[0].back()] = c;
				color[0].pop_back();
			}else{
				ans[color[1].back()] = c;
				color[1].pop_back();
			}
		}
	}

	for(int i = 1; i <= n; ++i){
		cout << ans[i] << " \n"[i == n];
	}

	return 0;
}


Measured memory_bytes: 22388
//by Judge
#include<bits/stdc++.h>
#define Rg register
#define fp(i,a,b) for(Rg int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(Rg int i=(a),I=(b)-1;i>I;--i)
#define ll long long
using namespace std;
const int M=2e5+3;
#ifndef Judge
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
#endif
char buf[1<<21],*p1=buf,*p2=buf;
inline int read(){ int x=0,f=1; char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0'; return x*f;
} int n,m,ans,t[M<<2],Tag[M<<2]; vector<int> val[M];
#define ls k<<1
#define rs k<<1|1
#define mid ((l+r)>>1)
#define lson ls,l,mid
#define rson rs,mid+1,r
inline int Max(int x,int y){ return x>y?x:y; }
inline void pushup(int k){ t[k]=Max(t[ls],t[rs]); }
inline void pushdown(int k){ if(!Tag[k]) return ;
	Tag[ls]+=Tag[k],Tag[rs]+=Tag[k];
	t[ls]+=Tag[k],t[rs]+=Tag[k],Tag[k]=0;
}
void build(int k,int l,int r){
	if(l==r) return t[k]=l,void();
	build(lson),build(rson),pushup(k);
}
void update(int k,int l,int r,int L,int R){
	if(L<=l&&r<=R) return ++Tag[k],++t[k],void(); if(l>R||L>r) return ;
	pushdown(k),update(lson,L,R),update(rson,L,R),pushup(k);
}
int query(int k,int l,int r,int L,int R){
	if(L<=l&&r<=R) return t[k]; if(l>R||L>r) return 0;
	return pushdown(k),Max(query(lson,L,R),query(rson,L,R));
}
int main(){ int l,r; n=read(),m=read()+1,ans=n-m+1;
	fp(i,1,n) l=read(),r=read(),val[l].push_back(r);
	build(1,0,m);
	fp(L,0,m-1){
		fp(j,0,val[L].size()-1) update(1,0,m,0,val[L][j]);
		ans=Max(ans,query(1,0,m,L+1,m)-m-L);
	} return !printf("%d\n",ans);
}

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

int main()
{
    int n,k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    int dp[n + 2];
    memset(dp,-1,sizeof(dp));
    dp[0] = 0;
    dp[1] = (abs(a[1] - a[0]));
    for(int i = 2; i <= n; i++)
    {
        for(int j = max(0,i - k); j < i; j++){
            if(dp[i] == -1)
                dp[i] = dp[j] + abs(a[i] - a[j]);
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]) );
        }
    }
    cout << dp[n - 1] << '\n' ;
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)

	h := make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	dp := make([]float64, n)
	dp[0] = 0
	for i := 1; i < n; i++ {
		var min float64
		for j := 1; j <= k; j++ {
			if i-j < 0 {
				break
			}
			cost := dp[i-j] + math.Abs(h[i]-h[i-j])
			if j == 1 || cost < min {
				min = cost
			}
		}
		dp[i] = min
	}
	fmt.Println(int64(dp[n-1]))
}


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

using namespace std;

const int maxn = 1e5 +  5;

int a[maxn];

int cnt = 0;

int main()
{
   for(int i=0;i<3;i++)
       cin >> a[i];
   stable_sort(a, a+3);
   while(a[0] != a[2] || a[1] != a[2] || a[0] != a[1])
   {
       cnt++;
       if(a[1] == a[2] || a[2] - a[0] > 1)
           a[0] += 2;
       else
       {
           a[0]++;
           a[1]++;
       }
       stable_sort(a, a+3);
   }
    cout << cnt << endl;
}

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

int main() {
  int a, b; cin >> a >> b;
  int ans = -1;
  int al = a*100+4, bl = b*100+5;
  if (max(al/8, bl/10) < min((al+100)/8,(bl+100)/10)) ans = max(al/8,bl/10);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
#include <string.h>

int main(void) {
  int n,r;
  int p,c;
  int i,j,k;
  char buf[1000];
  while(1) {
    fgets(buf, sizeof(buf), stdin);
    sscanf(buf, "%d%d", &n, &r);
    if(n == 0 && r == 0)
      break;
    int a[n],pt[n],ct[n];
    for(i = 0; i < n; i++)
      a[i] = i + 1;
    for(i = 0; i < r; i++) {
      memset(pt, 0, sizeof(pt));
      memset(ct, 0, sizeof(ct));
      fgets(buf, sizeof(buf), stdin);
      sscanf(buf, "%d%d", &p, &c);
      p -= 1;
      for(j = n - 1, k = 0; j > n - p - 1; j--, k++) {
        pt[k] = a[j];
      }
      for(j = n - p - 1, k = 0; j > n - p - 1 - c; j--, k++) {
        ct[k] = a[j];
      }
      for(j = n - 1, k = 0; j > n - c - 1; j--, k++) {
        a[j] = ct[k];
      }
      for(j = n - c - 1, k = 0; j > n - p - 1 - c; j--, k++) {
        a[j] = pt[k];
      }
    }
    printf("%d\n", a[n - 1]);
  }
  return 0;
}

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

int main()
{
	ll K, A, B;
	cin >> K >> A >> B;
	if (B <= A + 2) {
		cout << 1 + K << endl;
	}
	else if (K <= A - 1) {
		cout << 1 + K << endl;
	}
	else {
		K -= A - 1;
		cout << (A + (B - A) * (K / 2) + (K & 1)) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	double w;

	while(scanf("%lf", &w) != EOF){
		if(w <= 48.00){
			printf("light fly\n");
		}else if(w > 48.00 && w <= 51.00){
			puts("fly");
		}else if(w > 51.00 && w <= 54.00){
			puts("bantam");
		}else if(w > 54.00 && w <= 57.00){
			puts("feather");
		}else if(w > 57.00 && w <= 60.00){
			puts("light");
		}else if(w > 60.00 && w <= 64.00){
			puts("light welter");
		}else if(w > 64.00 && w <= 69.00){
			puts("welter");
		}else if(w > 69.00 && w <= 75.00){
			puts("light middle");
		}else if(w > 75.00 && w <= 81.00){
			puts("middle");
		}else if(w > 81.00 && w <= 91.00){
			puts("light heavy");
		}else{
			puts("heavy");
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define LF '\n'
#define ALL(x) x.begin(), x.end()
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;
template<class Itr> void dump(Itr begin, Itr end) { for (;begin != end; ++begin) clog << *begin << LF; }

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

  int x, t;
  cin >> x >> t;

  x -= min(x,t);
  cout << x << LF;

  return 0;
}



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

using namespace std;

int main(){
	static double table[100][100];
	double memo[100],next[100];
	for(int n,m;scanf("%d%d",&n,&m),n;){
		for(int i=0;i<n;i++)for(int j=0;j<n;j++)	scanf("%lf",table[i]+j);

		for(int i=0;i<n;i++)	memo[i]=1,next[i]=0;
		for(int t=1;t<m;t++){
			for(int i=0;i<n;i++)for(int j=0;j<n;j++){
				next[j]=max(next[j],table[i][j]*memo[i]);
			}
			for(int i=0;i<n;i++)	memo[i]=next[i];
		}

		double ans=0;
		for(int i=0;i<n;i++)	ans=max(ans,memo[i]);
		printf("%.2f\n",ans);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s[200001];
	map<string,int> mp;
	for (int i=0;i<n;i++){
		cin>>s[i];
		mp[s[i]]++;
	}
	int mx=0;
	vector<string> ss;
	for (int i=0;i<n;i++){
		mx=max(mx,mp[s[i]]);
	}
	for (int i=0;i<n;i++){
		if (mp[s[i]]==mx){
			ss.push_back(s[i]);
			mp[s[i]]--;
		}
	}
	sort(ss.begin(),ss.end());
	for (int i=0;i<ss.size();i++) cout<<ss[i]<<endl;
	return 0;
}

Measured memory_bytes: 28404