akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define MIN3(a,b,c) (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c))
#define MAX(a,b) (a)>(b)?(a):(b)
#define MIN2(a,b) (a)<(b)?(a):(b)
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
#define ull unsigned long long
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;
#define deb(x )     cerr << #x << " here "<< x << endl;
#define endl    "\n"
#define printCase() "Case #" << caseNum << ": "
inline bool is_palindrome(const string& s){ return std::equal(s.begin(), s.end(), s.rbegin()); }
const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
#define ff first
#define ss second
/*----------------------------------------------------------------------*/

typedef vector<vll> mat;

int n;
mat adj; 

void mult(mat &a, mat b) {
	mat tmp(n, vll(n, 0));
	FOR(i, 0, n) {
		FOR(j, 0, n) {
			FOR(k, 0, n) {
				tmp[i][j] += (a[i][k] * b[k][j]) % MOD;
				tmp[i][j] %= MOD;
			}
		}
	}
	a = tmp;
}

mat exp(mat a, ll kk) {
	mat b(n, vll(n, 0));
	FOR(i, 0, n) b[i][i] = 1LL;
	while(kk) {
		if(kk % 2) {
			mult(b, a);
		}
		mult(a, a);
		kk >>= 1LL;
	}
	return b;
}

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll k; cin>>n>>k;
    adj.resize(n, vll(n, 0));
    mat init(n, vll(n, 0));
    FOR(i, 0, n) {
    	init[i][i]=1;
    	FOR(j, 0, n) {
    		cin>>adj[i][j];
    	}
    }
    adj = exp(adj, k);
    mult(adj, init); ll ans = 0;
    FOR(i, 0, n) {
    	FOR(j, 0, n) {
    		ans += adj[i][j];
    		ans %= MOD;
    	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define trans(x) add(nxt[ d[i][x] ], cur[i])

const int N = 300054, mod = 1000000007;
const int d[8][2] = {{2, 3}, {6, 6}, {4, 5}, {6, 7}, {2, 2}, {2, 3}, {1, 3}, {7, 7}};

int dp_[2][8], *cur = *dp_, *nxt = dp_[1];
char s[N];

inline int & add(int &x, const int y) {return x += y - mod, x += x >> 31 & mod;}

int main() {
	int i, ans; char *p = s; *nxt = 1;
	for (scanf("%s", s); *p; ++p) {
		std::swap(cur, nxt), memset(nxt, 0, sizeof *dp_);
		for (i = 0; i < 8; ++i) *p == 48 || trans(1), *p == 49 || trans(0);
	}
	printf("%d\n", add(ans = nxt[3], nxt[7]));
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#include <cctype>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)

#define AAA (1000000007) 


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll powD(ll a, ll b) {
	ll ans = 1;
	a %= AAA;
	for (int i = 0; i < b; i++)
	{
		ans *= a;
		ans %= AAA;
	}
	return ans;
}


int main() {
	//int i, j, k;
	ll i, j;
	int N, M, K;
	cin >> N;
	vector<int> A;
	vector<int> B;
	rep(i, 0, N) {
		int a, b;
		cin >> a>> b;
		A.push_back(a);
		B.push_back(b);
	}
	sort(A.begin(), A.end());
	sort(B.rbegin(), B.rend());
	if (N % 2 == 1) {
		int X = N / 2;
		cout << B[X] - A[X]+1;
		return 0;
	}
	int X, Y;
	X = N / 2-1;
	Y = N / 2;

	cout << B[Y] + B[X] - A[Y] - A[X] + 1;
	return 0;
}

Measured memory_bytes: 5100
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        N: usize,
        M: usize,
        X: usize,
        CA: [(usize, [usize; M]); N],
    }

    let mut ans = INF;
    for mask in 0..(1 << N) {
        let mut Z: Vec<usize> = vec![0; M];
        let mut cost = 0;

        for (i, (C, A)) in CA.iter().enumerate() {
            if (1 << i) & mask == 0 {
                continue;
            }
            cost += C;
            for (j, a) in A.iter().enumerate() {
                Z[j] += a;
            }
        }

        if Z.iter().all(|z| *z >= X) {
            ans = min(ans, cost);
        }
    }

    if ans < INF {
        println!("{}", ans);
    } else {
        println!("-1");
    }
}


Measured memory_bytes: 2168
#include <cstdio>
#include <map>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>

using namespace std;

//const int mod = int(1e9) + 7;
const int SZ = 1010;
//const int MX = 100500;

#define pii pair<int,int>


void solve(){

};

int main(int argc, char** argv)
{
#ifdef LOCAL
    freopen("/Users/melnykroman/CLionProjects/cf/in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    string s;
    cin >> s;
    cout <<  s.substr(0, s.size() - 8) << endl;


    return 0;
}

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

int main() {
	long long N, count = 0;
	long long DP[110][4][4][4] = {};
	cin >> N;
	DP[0][3][3][3] = 1;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) {
					for (int m = 0; m < 4; m++) {
						if (!(k == 0 && l == 1 && m == 2) &&
							!(k == 0 && l == 2 && m == 1) &&
							!(k == 1 && l == 0 && m == 2) &&
							!(j == 0 && l == 1 && m == 2) &&
							!(j == 0 && k == 1 && m == 2)) {
							DP[i + 1][k][l][m] += DP[i][j][k][l];
							DP[i + 1][k][l][m] = DP[i + 1][k][l][m] % 1000000007;
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				count += DP[N][i][j][k];
				count = count % 1000000007;
			}
		}
	}
	cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vector<ll> vec;
	int n,m; cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		ll x; cin>>x; vec.pb(x);
	}
	sort(vec.begin(),vec.end());
	int ptr=0;
	vector<ii> a;
	for(int i=0;i<m;i++)
	{
		ll x,y; cin>>x>>y;
		a.pb({y,x});
	}
	sort(a.rbegin(),a.rend());
	int ptr2=0;
	while(ptr<n&&ptr2<m)
	{
		if(a[ptr2].se<=0) 
		{
			ptr2++; continue;
		}
		if(vec[ptr]>=a[ptr2].fi)
		{
			ptr++; continue;
		}
		a[ptr2].se--;
		vec[ptr]=a[ptr2].fi;
		ptr++;
	}
	ll ans=0;
	for(ll x:vec) ans+=x;
	cout<<ans<<'\n';
}


Measured memory_bytes: 6092
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <random>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define REP(i, n) for(int i=0; i<(n); i++)
#define LLREP(i,n) for(LL i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define SORT(x) sort(ALL(x))
#define REVE(x) reverse(ALL(x))
#define MP make_pair
#define PB push_back
#define INF INT_MAX

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef vector<vector<bool>> VVB;
typedef pair<int, int> PII;
typedef vector<pair<int, int>> VPII;
typedef queue<int> QI;
typedef long long LL;

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
const int MOD=1e9+7;



int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n),b(3);
    rep(i,n) {
        int in;
        cin >> in;
        while (in%2==0) {
            in/=2;
            ++a[i];
        }
        if (a[i]>1) ++b[2];
        else ++b[a[i]];
    }
    bool flag;
    if (b[1]>0) flag=(b[2]>=b[0]);
    else flag=(b[2]>=max(1,b[0]-1));

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

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

int main(){
 int A, B, C, D;
  cin >> A >> B >> C >> D;
  if( (A+B)>(C+D) ){
    cout << "Left" << endl;
  }
  else if ((A+B)==(C+D)){
    cout << "Balanced" << endl;
  }
  else if ((A+B)<(C+D)){
    cout << "Right" <<endl;
  }
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    input()
    aa=LI()
    if len(aa)%2:
        print(*aa[::-2],end=" ")
        print(*aa[1::2])
    else:
        print(*aa[::-2],end=" ")
        print(*aa[::2])
main()

Measured memory_bytes: 25168
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
const int maxn = 5e5+5;
int a[maxn],ans[maxn],cnt[maxn],res=0;
struct node{
	int l,r,id;
	int block;
}e[maxn]; 

bool cmp(const node &a,const node &b){
	if(a.block==b.block){
		if(a.block&1) return a.r<b.r;
		return a.r>b.r;
	}
	return a.l<b.l;
}

inline void del(int x){
	--cnt[a[x]];
	if(cnt[a[x]]==0)--res;
}
inline void add(int x){
	if(cnt[a[x]]==0)++res;
	++cnt[a[x]];
}

int main() {
	int n,q;
	scanf("%d%d",&n,&q);
	int bl=n/sqrt(q*2/3);
	for(int i=1;i<=n;++i)scanf("%d",&a[i]);
	for(int i=1;i<=q;++i){
		scanf("%d%d",&e[i].l,&e[i].r);
		e[i].id=i;
		e[i].block=e[i].l/bl;
	}
	sort(e+1,e+1+q,cmp);
	int l=e[1].l,r=e[1].l-1;
	for(int i=1;i<=q;++i){
		int stdl=e[i].l,stdr=e[i].r;
		while(l<stdl)del(l++);
		while(l>stdl)add(--l);
		while(r<stdr)add(++r);
		while(r>stdr)del(r--);
		ans[e[i].id]=res;
	}
	for(int i=1;i<=q;++i)printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 17440
#include"bits/stdc++.h"
using namespace std;
long long flag1[3000000],flag2[3000000];
int main(){
	long long n,k,num[3000];
	cin>>n>>k;
	for(int i=0;i<n;i++){
		scanf("%d",&num[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(num[j]>num[i])flag2[i]++;
			if(j<i&&num[j]>num[i])flag1[i]++;
		}
	}
	long long ans=0,temp=0;
	for(int i=0;i<n;i++){
		temp+=flag1[i]%(1000000007);
		ans+=flag2[i]%1000000007;
	}

	cout<<(ans%1000000007*(((1+k-1)*(k-1)/2)%1000000007)%1000000007+temp*k%1000000007)%1000000007<<endl;
}
//10 998
//10 9 8 7 5 6 3 4 2 1

Measured memory_bytes: 2304
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli a = 0ll, b = 0ll, c = 0ll, d = 0ll, res = -(lli)1e18;
	cin >> a >> b >> c >> d;
	if (a < 0ll && c < 0ll)
		res = max(res, 1ll * a * c);
	if (b > 0ll && d > 0ll)
		res = max(res, 1ll * b * d);
	res = max({res, 1ll * a * d, 1ll * b * c});
	cout << res << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
struct fast_ios {
    fast_ios() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    };
} fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end)                                                     \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end)                                                    \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &v : vec)
        is >> v;
    return is;
}

int main() {
    int N;
    cin >> N;
    vector<ll> P(N);
    cin >> P;
    map<int, int> Pinv;

    REP(i, N) Pinv[P[i]] = i;
    multiset<int> shown;
    shown.insert(-1);
    shown.insert(-1);
    shown.insert(N);
    shown.insert(N);
    ll ret = 0;
    IFOR(i, 1, N + 1) {
        ll now = Pinv[i];
        ll r = *shown.lower_bound(now);
        ll rr = *next(shown.lower_bound(now));
        ll l = *prev(shown.lower_bound(now));
        ll ll = *prev(shown.lower_bound(now), 2);
        ret += ((rr - r) * (now - l) + (l - ll) * (r - now)) * i;
        // dbg((vector<ll>{ll, l, r, rr}));
        shown.insert(now);
    }
    cout << ret << endl;
}


Measured memory_bytes: 10368
#include <iostream>
#include <vector>
#include<iomanip>
#include <algorithm>

#include <sstream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
static const int MAX = 101;

int N;
int F[MAX][11];
int P[MAX][11];

int main(int argc, const char * argv[]) {
    int i,j;
    
    cin >> N;
    for(i = 1; i <= N; i++) {
        for (j = 1; j <= 10 ; j++) {
            cin >> F[i][j];
        }
    }
    
    for(i = 1; i <= N; i++) {
        for (j = 0; j <= 10; j++) {
            cin >> P[i][j];
        }
    }
    int ans = -(1<<30);
    for (int b = 1; b < (1<<10); b++) {
        int sum = 0;
        for (i = 1; i <= N; i++) {
            int cnt = 0;
            for (j = 0; j <= 9; j++) {
                if ((b>>j & 1) && F[i][j+1]) {
                    cnt++;
                }
            }
            sum += P[i][cnt];
        }
        ans = max(ans, sum);
    }
    
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
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;
}
///////////////////////////////////////////////
int main(){
    ll N; cin >> N;
    ll ans = 0;
    ll a[51] = {};
    REP(i,N){
        cin >> a[i];
    }

    while(true){
        bool chk = false;
        REP(i,N){
            if (a[i] >= N) chk = true;
        }

        if (!chk) break;
        ll S = 0;
        REP(i,N){
            S += (a[i] / N);
        }

        REP(i,N){
            a[i] = a[i] + (S - (a[i] / N)) - ((a[i] / N) * N);
        }

        ans += S;

    }

    cout << ans << endl;

}






Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
using namespace std;
typedef complex<double> P;

static const double EPS = 1e-8;
static const double PI = acos(-1.0);

struct circle/*{{{*/
{
  P o;
  double r;
  circle() {}
  circle(const P& p, double x) : o(p), r(x) {}

  // POJ 1418 Viva Confetti
  // POJ 2149 Inherit the Spheres
  inline bool intersects(const circle& c) const
  {
    return !contains(c) && !c.contains(*this) && abs(o - c.o) <= r + c.r;
  }

  pair<P,P> intersection(const circle& c) const
  {
    // assert(intersects(c))
    const double d = abs(o - c.o);
    const double cos_ = (d*d + r*r - c.r*c.r) / (2*d);
    const double sin_ = sqrt(r*r - cos_*cos_);
    const P e = (c.o - o) / d;
    return make_pair(o + e*P(cos_, sin_), o + e*P(cos_, -sin_));
  }

  inline bool contains(const circle& c) const
  {
    return abs(o - c.o)+c.r <= r;
  }
};/*}}}*/

int main()
{
  int N;
  while (scanf("%d", &N) != EOF && N != 0) {
    vector<circle> cs;
    for (int i = 0; i < N; i++) {
      double x, y, r;
      scanf("%lf %lf %lf", &x, &y, &r);
      cs.push_back(circle(P(x, y), r));
    }

    for (vector<circle>::iterator it = cs.begin(); it != cs.end();) {
      bool contained = false;
      for (vector<circle>::const_iterator jt = cs.begin(); jt != cs.end(); ++jt) {
        if (it != jt && jt->contains(*it)) {
          contained = true;
          break;
        }
      }
      if (contained) {
        it = cs.erase(it);
      } else {
        ++it;
      }
    }

    N = cs.size();
    vector<vector<pair<double,double> > > spans(N);
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        if (i == j) {
          continue;
        }
        const circle& c1 = cs[i];
        const circle& c2 = cs[j];
        if (c1.intersects(c2)) {
          const pair<P, P> r = c1.intersection(c2);
          if (abs(r.first - r.second) < EPS) {
            continue;
          }
          const pair<double, double> p = make_pair(arg(r.second - c1.o), arg(r.first - c1.o));
          if (p.first < p.second) {
            spans[i].push_back(p);
          } else {
            spans[i].push_back(make_pair(p.first, PI));
            spans[i].push_back(make_pair(-PI, p.second));
          }
        }
      }
    }

    double ans = 0;
    for (int i = 0; i < N; i++) {
      sort(spans[i].begin(), spans[i].end());
      for (vector<pair<double, double> >::iterator it = spans[i].begin(); it != spans[i].end() && it+1 != spans[i].end();) {
        pair<double, double>& p1 = *it;
        const pair<double, double>& p2 = *(it+1);
        if (p1.second > p2.first) {
          p1.second = max(p1.second, p2.second);
          spans[i].erase(it+1);
        } else {
          ++it;
        }
      }

      double ang = 2*PI;
      for (vector<pair<double, double> >::const_iterator it = spans[i].begin(); it != spans[i].end(); ++it) {
        ang -= (it->second - it->first);
      }
      ans += cs[i].r * ang;
    }
    printf("%.8f\n", ans);
  }
  return 0;
}

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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, k, s;
    cin >> n >> k >> s;
    vec rui(n);

    rep (i, k)
        rui[i] = s;
    int val = s == 1 ? 2 : 1;
    if (s == 1000000000) val = -1;
    For(i, k, n - 1) rui[i] = s + val;

    print(rui);

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    string a = "ABC";
    string b = "ARC";
    if (s == a) {
        cout << b << endl;
    }
    else {
        cout << a << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0; i < (n); i++)

const int MAX_W = 23;
bool visited[MAX_W][MAX_W];
char map[MAX_W][MAX_W] = {};
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};

int dfs(int x, int y) {
  if (map[y][x] != '.') return 0;
  int ret = 1;
  map[y][x] = '#';
  rep(i,4) {
    ret += dfs(x + dx[i], y + dy[i]);
  }
  return ret;
}

void solve(int w, int h) {
  int sx, sy;
  rep(i, MAX_W) rep(j, MAX_W) map[i][j] = 0;
  rep(i,h) {
    string s;
    cin >> s;
    rep(j,w) {
      if (s[j] == '@') {
        sx = j+1;
        sy = i+1;
        s[j] = '.';
      }
      map[i+1][j+1] = s[j];
    }
  }
  cout << dfs(sx, sy) << endl;
}

int main() {
  int w, h;
  while(true) {
    cin >> w >> h;
    if (w == 0) return 0;
    solve(w, h);
  }
}

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

using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(c) c.begin(), c.end()
#define rall(c) c.end(), c.begin()
#define INF (int)1e9
#define MOD 1000000007
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef map<int, int> MPII;
typedef set<int> SETI;

const int mxN = 2e5;
int a[mxN];

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

    string a, b;
    cin >> a >> b;

    int cnt = 0;
    for (int i = 0; i < a.length(); ++i)
    {
        if (a[i] != b[i])
        {
            cnt++;
        }
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 3796
import java.io.*;

class Main{
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int sum;
		while(true){
			sum=0;
			String str = br.readLine();
			char[] cr = str.toCharArray();
			int[] in = parseInts(cr);
			for(int i=0;i<in.length;i++){
				sum += in[i];
			}
			if(sum==0) break;
			System.out.println(sum);
		}
	}
	static int[] parseInts(char[] c){
		int[] x = new int[c.length];
		for(int i=0;i<c.length;i++){
			x[i] = Character.getNumericValue(c[i]);
		}
		return x;
	}
}

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

using namespace std;

int main() {
  int32_t h, w;
  cin >> h >> w;
  vector<string> t(h, "");
  for (int32_t i = 0; i < h; ++i) {
    cin >> t[i];
  }

  vector<vector<int32_t>> dp(h, vector<int32_t>(w, 0));
  dp[0][0] = 1;

  for (int32_t j = 1; j < w; ++j) {
    if (t[0][j] == '#') {
      dp[0][j] = 0;
    } else {
      dp[0][j] = dp[0][j-1];
    }
  }
  for (int32_t i = 1; i < h; ++i) {
    if (t[i][0] == '#') {
      dp[i][0] = 0;
    } else {
      dp[i][0] = dp[i-1][0];
    }
  }

  int32_t mod = 1'000'000'007;
  for (int32_t i = 1; i < h; ++i) {
    for (int32_t j = 1; j < w; ++j) {
      if (t[i][j] == '#') {
        dp[i][j] = 0;
      } else {
        dp[i][j] = (dp[i][j-1] + dp[i-1][j]) % mod;
      }
    }
  }

  cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 5760
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    A = I()
    B = I()
    for i in range(1, 4):
        if i == A or i == B:
            continue
        print(i)

main()



Measured memory_bytes: 6068
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

vector<vector<ll>> tree(1e5+1);

void f(ll k, vector<ll>& d){
    queue<ll> q;
    q.push(k);
    while(!q.empty()){
        ll t=q.front();q.pop();
        for(auto x:tree[t]){
            if(x!=k && d[x]==0){
                d[x] = d[t]+1;
                q.push(x);
            }
        }
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;cin>>n;
    REP(i,n-1){
        ll a,b;cin>>a>>b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    vector<ll> df(n+1),ds(n+1);
        f(1,df);
        f(n,ds);
        ll sum=0;
        for(int i=1;i<=n;i++){
            sum += df[i] <= ds[i] ? 1:-1;
        }
        if(sum>0) cout<<"Fennec";
        else cout<<"Snuke";
}

Measured memory_bytes: 8064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
const int MAX_N = 55;
int N;
string board[2];
int dp[MAX_N][4][4];

int memo(int pos, int pre1, int pre2){
  if (pos >= N){
    return 1;
  }
  int &res = dp[pos][pre1][pre2];
  if (res >= 0){
    return res;
  }
  res = 0;
  if (board[0][pos] == board[1][pos]){//tate
    for (int i = 1; i <= 3; i++){
      if (i != pre1 and i != pre2){
        res += memo(pos + 1, i, i);
        res %= MOD;
      }
    }
  }else{
    for (int i = 1; i <= 3; i++){
      for (int j = 1; j <= 3; j++){
        if (i == j)continue;
        if (i == pre1 or j == pre2)continue;
        res += memo(pos + 2, i, j);
        res %= MOD;
      }
    }
  }


  return res;
}

int main() {
  cin >> N;
  cin >> board[0];
  cin >> board[1];
  memset(dp, -1, sizeof(dp));

  cout << memo(0, 0, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define f first
#define s second
#define MOD 998244353
 
using namespace std;


void solve(){
	int n; cin>>n;
	string s;
	cin>>s;
	ll r=0,g=0,b=0;
	for(int i=0; i<n; i++){
		if(s[i] =='R') r++;
		else if(s[i] == 'G') g++;
		else b++;
	}
	ll ans = 0;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			if((i+j)%2 == 0 && s[i] != s[j]){
				int k = (i+j)/2;
				if(s[k] != s[i] && s[k] != s[j]){
					ans++;
				}
			}
		}
	}
	cout<<r*b*g - ans;


}


int main()
{ 
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//cout<<fixed<<setprecision(12);
	//memset(dp,-1,sizeof(dp));
	
	int t =1; 
	//cin>>t;

	//int x = t;


	while(t--){
		solve();
		//cout<<"\n";
	}




	return 0;

	}




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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for (int i = 0; i < n; i++){
    cin >> s[i] >> t[i];
  }
  string x;
  cin >> x;
  int k = 0;
  while(s[k] != x){
    k++;
  }
  int ans = 0;
  for (int i = k + 1; i < n; i++){
    ans += t[i];
  }
  cout << ans << endl;
  return 0;
}

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

return 0;
}

Measured memory_bytes: 596
import math
i = int(input())
answer = 0
for _ in range(i):
    n = int(input())
    if n <= 1:
        continue
    elif n == 2:
        answer += 1
    else:
        if 0 == n % 2:
            continue
        else:
            x = 3
            answer += 1
            while x <= math.sqrt(n):
                if 0 == n % x:
                    answer -= 1
                    break
                x = x + 2
print(answer)


Measured memory_bytes: 5672
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTA(a,n) sort(a,a+n)
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int x,y,z;
    cin >> x >> y >> z;
    //処理
    //出力
    cout << (x-z)/(y+z) << ENT;
    return 0;
}

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


Measured memory_bytes: 256
# coding: utf-8
while 1:
    data=[]
    n,m=map(int,input().split())
    if n==m==0:
        break
    for i in range(n):
        d,p=map(int,input().split())
        data.append((d,p))
    data=sorted(data,key=lambda x:(-x[1],-x[0]))
    for i in range(n):
        if data[i][0]<=m:
            m-=data[i][0]
            data[i]=(0,data[i][1])
        else:
            data[i]=(data[i][0]-m,data[i][1])
            m=0
            break
    ans=0
    for i in range(n):
        ans+=data[i][0]*data[i][1]
    print(ans)


Measured memory_bytes: 7960
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
typedef pair<int,int> pii;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b) { 
   if (b == 0) 
      return a; 
   return gcd(b, a % b);  
} 

void solve(){
	
  	string s;
  	cin >> s;
  	
  	if(s[0]=='S')cout << "Cloudy" << endl;
 	else if(s[0] =='C') cout <<"Rainy" <<endl;
  	else cout << "Sunny" << endl;
 

} 

signed main() 
{   
    IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec[i];
  }
  int res = 0;
  for (int i = 1; i < n - 1; i++) {
    if (vec[i] > vec[i - 1] && vec[i] < vec[i + 1]) {
      ++res;
    } else if (vec[i] > vec[i + 1] && vec[i] < vec[i - 1]) {
      ++res;
    }
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
import sys
n = int(input())
x = [list(map(int, x.split())) for x in sys.stdin.readlines() ]
x.reverse()
ans = 0
for i in x:
    a, b = map(int, i)
    if (a+ans)%b != 0:
        ans += b - (a+ans)%b
print(ans)

Measured memory_bytes: 35320
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1<<30
const int mod = 1e9+7;

int main(){
    ll a,b,c; cin >> a >> b >> c;
    if(a+b+c>21) puts("bust");
    else puts("win");
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> x(n + 1); for (int i = 0; i < n; i++) cin >> x[i];
  x[n] = 2e9 + 1;
  int l; cin >> l;
  VV<> dp; assign(dp, n + 1, __lg(n) + 2);
  for (int i = 0; i < n; i++) {
    int ok = i + 1, ng = n;
    while (ng - ok > 1) {
      int m = (ok + ng) / 2;
      if (x[m] - x[i] <= l) ok = m;
      else ng = m;
    }
    dp[i][0] = ok;
  }
  fill(dp[n].begin(), dp[n].end(), n);
  for (int j = 0; j < __lg(n) + 1; j++) for (int i = 0; i < n; i++) dp[i][j + 1] = dp[dp[i][j]][j];
  int q; cin >> q;
  for (int iq = 0; iq < q; iq++) {
    int a, b; cin >> a >> b, a--, b--;
    if (a > b) swap(a, b);
    int res = 0;
    while (true) {
      int i = 0;
      while (dp[a][i] < b) i++;
      i--;
      if (i < 0) break;
      a = dp[a][i];
      res += 1 << i;
    }
    cout << res + 1 << '\n';
  }
}

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

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define dbg(x) cerr<<#x" = "<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef long long ll;
typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;
inline int rd() {
    int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
    while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
const int N=811,dr[]={0,0,1,-1},dc[]={1,-1,0,0};
char s[N][N];
int H,W,K,qx[N*N],qy[N*N],f[N][N];
inline void bfs(int Sx,int Sy){
	memset(f,-1,sizeof f);
	int h=0,t=1,x,y;
	qx[h]=Sx,qy[h]=Sy;
	f[Sx][Sy]=0;
	while(h<t){
		x=qx[h],y=qy[h],++h;
		if(f[x][y]>=K)continue;
		For(i,0,4){
			int nx=x+dr[i],ny=y+dc[i];
			if(nx<1||nx>H||ny<1||ny>W||s[nx][ny]=='#'||~f[nx][ny])continue;
			f[nx][ny]=f[x][y]+1;
			qx[t]=nx,qy[t]=ny,++t;
		}
	}
	int ans=inf;
	rep(i,1,H)rep(j,1,W)if(~f[i][j]){
		int p=min(min(i-1,j-1),min(H-i,W-j));
		ans=min(ans,1+p/K+(p%K!=0));
	}
	cout<<ans<<endl;
}
int main(){
	H=rd(),W=rd(),K=rd();
	rep(i,1,H)scanf("%s",s[i]+1);
	rep(i,1,H)rep(j,1,W)if(s[i][j]=='S'){
		bfs(i,j);
		break;
	}
}

Measured memory_bytes: 8576
# N = map(int,input().split())
# HRR = list(map(int,input().split()))

# N, K = 3,1
# HRR = [10, 20, 10]
#
# N,K = 10, 4
# HRR = [40, 10, 20, 70, 80, 10, 20, 70, 80, 60]

N,K = map(int,input().split())
HRR = list(map(int,input().split()))

def calculate(n, k, hrr):
    result = []
    for index, value in enumerate(hrr):
        srr = []
        for j in range(1, k + 1):
            if index - j >= 0:
                srr.append(result[index - j] + abs(hrr[index] - hrr[index - j]))

        if len(srr) == 0:
            result.append(0)
        else:
            result.append(min(srr))

    print(result[-1])

calculate(N, K, HRR)


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

vector<long long> F, RF, R;
long long MOD = 1000000007;

void init(long long N) {
	F.resize(N + 1), RF.resize(N + 1), R.resize(N + 1);
	F[0] = F[1] = RF[0] = RF[1] = R[0] = R[1] = 1;
	for (int i = 2; i <= N; i++) {
		F[i] = (F[i - 1] * i) % MOD;
		R[i] = MOD - (R[MOD % i] * (MOD / i)) % MOD;
		RF[i] = (RF[i - 1] * R[i]) % MOD;
	}
}

int main() {
	long long N;
	cin >> N;
	init(N);
	long long COUNT = 0;
	for (int i = (N + 1) / 2; i < N; i++) {
		long long X = F[i] * F[i - 1];
		X %= MOD;
		X *= RF[i * 2 - N];
		X %= MOD;
		COUNT = (COUNT + X) % MOD;
	}
	cout << (F[N] - COUNT + MOD) % MOD << endl;
}

Measured memory_bytes: 23680
S = input()
f = int(S[:2])
l = int(S[2:])

if 1 <= f <= 12:
    if 1 <= l <= 12:
        print("AMBIGUOUS")
    else:
        print("MMYY")
elif 1 <= l <= 12:
    print("YYMM")
else:
    print("NA")

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

int max(int a, int b, int c) {

    int ans = a*10+b+c;
    if(a*10+b+c <= b*10+c+a) ans = b * 10+c+a;
    
    if(ans <= c*10+a+b) ans = c*10+a+b;
    return ans;
}
int main(int argc, char **argv) {
    int a, b, c, ans;
    cin >> a >> b >> c;
    
    cout << max(a, b, c) << endl;
    return 0; 
}


Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    a = list(map(int, input().rstrip('\n').split()))
    ts = sum(a[1::2]) * 2
    ls = [0] * n
    ls[0] = sum(a) - ts
    for i in range(1, n):
        ls[i] = (a[i-1] - ls[i-1] // 2) * 2
    print(*ls)


if __name__ == '__main__':
    slove()


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

int main() {
    vector<int> table = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << table[k-1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = (a), i_len = (b); i < i_len; ++i)

const int MAX_N = 110;
int graph[MAX_N][MAX_N];
bool used[MAX_N][MAX_N];
int N, M;
typedef pair<int, int> P;
typedef pair<int, P> Q;
int d[MAX_N];
const int INF = 1e9 + 7;

void dijkstra(int s) {
    priority_queue<Q, vector<Q>, greater<Q>> que;
    fill(d, d + N, INF);
    que.push(Q(0, P(s, s)));
    d[s] = 0;

    while(!que.empty()) {
        Q p = que.top(); que.pop();
        int v = p.second.first;
        int v_prev = p.second.second;
        if(d[v] < p.first) continue;
        used[v_prev][v] = false;
        REP(to, 0, N) {
            if(d[to] > d[v] + graph[v][to]) {
                d[to] = d[v] + graph[v][to];
                que.push(Q(d[to], P(to, v)));
            }
        }
    }
}

int main()
{
    scanf("%d %d", &N, &M);
    REP(i, 0, N) REP(j, 0, N) if(i != j) graph[i][j] = INF;
    REP(i, 0, N) REP(j, 0, N) used[i][j] = false;
    REP(i, 0, M) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        --a, --b;
        graph[a][b] = graph[b][a] = c;
        used[a][b] = used[b][a] = true;
    }
    REP(i, 0, N) dijkstra(i);
    int res = 0;
    REP(i, 0, N) REP(j, 0, N) if(used[i][j]) ++res;
    printf("%d\n", res/2);
    return 0;
}

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

using namespace std;

#define sp << " " <<

vector <int> p[100001];
bool d[100001]={0};
vector <int> s;

void t(int n)
{
    d[n]=1;
    for(int i=0;i<p[n].size();i++)
    {
        if(d[p[n][i]]==0)
        {
            t(p[n][i]);
        }
    }
    s.push_back(n);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,m;
    cin >> n >> m;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin >> u >> v;
        p[u].push_back(v);
    }
    for(int i=1;i<=n;i++)
        if(d[i]==0)
            t(i);
    reverse(s.begin(),s.end());
    int dp[n+1];
    for(int i=0;i<=n;i++)
        dp[i]=-1;
    for(int i=n-1;i>=0;i--)
    {
        int h=-1;
        for(int j=0;j<p[s[i]].size();j++)
        {
            h=max(h,dp[p[s[i]][j]]);
        }
        dp[s[i]]=h+1;
    }
    int a=-1;
    for(int i=0;i<=n;i++)
        a=max(a,dp[i]);
    cout << a;
    return 0;
}


Measured memory_bytes: 7804
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>


#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj) (obj).begin(), (obj).end()
#define DOUT(obj,n) cout << fixed << setprecision(n) << obj << endl

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	string tmp;
	int q;
	cin >> tmp >> q;
	deque<char> s;
	REP(i, tmp.size())s.push_back(tmp[i]);
	int rev = 0;
	REP(i, q) {
		int x;
		cin >> x;
		if (x == 1)rev = 1 - rev;
		else {
			int y;
			char c;
			cin >> y >> c;
			y--;
			if (rev) y = 1 - y;
			if (y == 0) s.push_front(c);
			else s.push_back(c);
		}
	}
	if(!rev)REP(i, s.size())cout << s[i];
	else REP(i, s.size())cout << s[s.size() - i - 1];

	return 0;
}

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

int main(){
  string s;
  cin>>s;
  int i,n,ima=0,k;
  int a[3],keta[3];
  a[0]=0;
  a[1]=0;
  a[2]=0;
  keta[0]=1;
  keta[1]=1;
  keta[2]=1;
  long long int kotae=0;
  cin>>k;
  n=s.length();
  if(n<k){
    cout<<0;
    return 0;
  }
  for(i=0;i<n;i++){
    if(s[i]!='0'){
      a[ima]=s[i]-'0';
      keta[ima]=n-i;
      ima++;
    }
    if(ima==3){
      break;
    }
  }
  if(k==3){
    kotae+=(((keta[0]-1)*(keta[0]-2)*(keta[0]-3))/6)*729;
    kotae+=(((keta[0]-1)*(keta[0]-2))/2)*81*(a[0]-1);
    kotae+=(((keta[1]-1)*(keta[1]-2))/2)*81;
    kotae+=(keta[1]-1)*9*(a[1]-1);
    kotae+=(keta[2]-1)*9;
    kotae+=a[2];
  }
  if(k==2){
    kotae+=(((keta[0]-1)*(keta[0]-2))/2)*81;
    kotae+=(keta[0]-1)*9*(a[0]-1);
    kotae+=(keta[1]-1)*9;
    kotae+=a[1];
  }
  if(k==1){
    kotae+=(keta[0]-1)*9;
    kotae+=a[0];
  }
  cout<<kotae;
}

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

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; }
#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__)


int main(){
    int n,m;
    cin>>n>>m;
    P ba[m];
    rep(i,m){
        int a,b;
        cin>>a>>b;
        ba[i]=make_pair(b,a);
    }
    int ctr=0;
    int prevb=0;
    sort(ba,ba+m);
    rep(i,m){
        if(ba[i].second<prevb)continue;
        prevb=ba[i].first;
        ++ctr;
    }
    cout<<ctr<<endl;
}


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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define fWrite          freopen ("out.txt","w",stdout);
#define TC              int t;cin >> t;FOR(tc,1,t)
#define LL              long long
#define ULL             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define MEM(a,x)        memset(a,x,sizeof(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

#define Make(x,p)       (x  (1<<p))
#define DeMake(x,p)     (x & ~(1<<p))
#define Check(x,p)      (x & (1<<p))
#define popcount(x)     __builtin_popcount(x)

int main()
{
    Fast
    int k,n;
    cin >> k >> n;
    int arr[n];
    REP(i,n) cin >> arr[i];
    sort(arr,arr+n);
    int diff=arr[n-1]-arr[0];
    if(arr[n-1]>=k/2) diff=k+arr[0]-arr[n-1];
    REP(i,n-1) diff=max(diff,arr[i+1]-arr[i]);
    cout << k-diff;
}


Measured memory_bytes: 1024