akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

const int INF = 1e9;

int main() {
    ios::sync_with_stdio(false);
    int w, h, n;
    cin >> w >> h >> n;
    vector<int> x1,x2,x3,x4, y1,y2,y3,y4, a;
    REP(i,n) {
        int xx, yy, aa;
        cin >> xx >> yy >> aa;
        if (aa == 1) {
            x1.push_back(xx);
            y1.push_back(yy);
        }
        
        if (aa == 2) {
            x2.push_back(xx);
            y2.push_back(yy);
        }
        
        if (aa == 3) {
            x3.push_back(xx);
            y3.push_back(yy);
        }
        
        if (aa == 4) {
            x4.push_back(xx);
            y4.push_back(yy);
        }
    }
    
    sort(ALL(x1));
    sort(ALL(x2));
    sort(ALL(y3));
    sort(ALL(y4));
    
    int xmin, xmax;
    int ymin, ymax;
    if (x1.empty()) {
        xmin = 0;
    }else {
        xmin = x1.back();
    }
    
    if (x2.empty()) {
        xmax = w;
    }else {
        xmax = x2.front();
    }
    
    if (y3.empty()) {
        ymin = 0;
    }else {
        ymin = y3.back();
    }
    
    if (y4.empty()) {
        ymax = h;
    }else {
        ymax = y4.front();
    }
    
    if (xmin >= xmax || ymin >= ymax) {
        print(0);
    }else {
        print((min(xmax, w) -xmin) * (min(ymax, h) - ymin));
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 36
int judge(char x[N][2],char y[N][2],int n);
int main(){
  int i, j, n, min,k;
  char a[N][2],b[N][2],c[N][2],change[3];

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%s",a[i]);

  

  for(i=0;i<n;i++){ 
    for(j=i+1;j<n;j++){
   
    }
  }
  for(i=0;i<n;i++){
    strncpy(b[i],a[i],2);
    strncpy(c[i],a[i],2);
  }
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(b[j][1]<b[j-1][1]){
	  strncpy(change,b[j],2);
	  strncpy(b[j],b[j-1],2);
	  strncpy(b[j-1],change,2);
      }
    }
  }
  for(i=0;i<n;i++){
    if(i<n-1)printf("%c%c ",b[i][0],b[i][1]);
    else printf("%c%c\n",b[i][0],b[i][1]);
  }
		
 
  if(judge(&a[0],&b[0],n)==0)printf("Stable\n");
  else printf("Not stable\n");
  
  
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(c[j][1]<c[min][1])
	min=j;
	
      
    }
     if(min==i)continue; 
  strncpy(change,c[i],2);
  
  strncpy(c[i],c[min],2);

  strncpy(c[min],change,2);

  
  
  }
  
  for(k=0;k<n;k++){
    if(k<n-1)printf("%c%c ",c[k][0],c[k][1]);
    else printf("%c%c\n",c[k][0],c[k][1]);
  }
 if(judge(&a[0],&c[0],n)==0)printf("Stable\n");
  else printf("Not stable\n");
  
  return 0;
}
int judge(char x[N][2],char y[N][2],int n){
  int i, j, a, b;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(a=0;a<n;a++){
	for(b=a+1;b<n;b++){
	  if(x[i][1]==x[j][1] && x[i][1]==y[b][1] && x[j][1]==y[a][1] && x[i][0]==y[b][0] && x[j][0]==y[a][0])
	    return 1;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 620
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

const int Max = 10001;
bool isPrime[Max];
pair<int, int> twinPrimes[Max];
int main()
{
	fill(isPrime, isPrime+Max, true);
	int prev = -100;
	pair<int, int> twin;
	for (int i = 2; i < Max; ++i)
	{
		if (isPrime[i])
		{
			for (int j = 2*i; j < Max; j += i)
				isPrime[j] = false;
			if (i - prev == 2)
				twin = make_pair(prev, i);
			prev = i;
		}
		twinPrimes[i] = twin;
	}

	int n;
	while (scanf("%d", &n), n)
		printf("%d %d\n", twinPrimes[n].first, twinPrimes[n].second);

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i,c=0;
    cin>>n;
    int a[n+2],b[n+2];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+n);
    for(i=0; i<n; i++)
    {
        if(b[i]!=a[i])
        {
            c++;
        }
    }
    if(c<=2)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 100100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

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


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:1024000000,1024000000")
/* vim: set fdm=marker */
//{{{
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int iinf = 0x7fffffff;
const ll linf = ~(1LL<<63);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef map<ll, int> mli;
typedef map<ll, ll> mll;
template<typename T>
inline T gcd(T a, T b) {
	if(a < 0) return gcd(-a, b);
	if(b < 0) return gcd( a,-b);
	if(a < b) return gcd(b, a);
	if(b == 0) return a;
	return gcd(b, a%b);
}

ll qpow(ll a, ll n, ll mod) {
	a %= mod;
	ll ans = 1LL;
	while(n) {
		if(n & 1) ans = (ans*a % mod);
		a = (a*a % mod);
		n >>= 1;
	}
	return ans;
}

inline ll rev(ll a, ll p) {
	return qpow(a, p - 2, p);
}

#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define rep(x, st, en) for(int x = st; x < en; x++)
#define rer(x, st, en) for(int x = st; x >= en; x--)
#define pb push_back
#define mp make_pair
#define dbgm(msg, var) cerr<<#msg<<" "<<#var<<" = "<<var<<endl; 
#define dbg(var) cerr<<#var<<" = "<<var<<endl;
#define X first
#define Y second
// build prefix sum
template<typename T>
inline void BPS(T* DST, T* SRC, int N, int s = 0) {
	DST[s] = SRC[s];
	rep(i, 1, N) DST[s + i] = DST[s + i - 1] + SRC[s + i];
}
inline int in() { int x; cin>>x; return x; }
#ifdef ALNDBG
namespace alndbg {
	clock_t s, e;
}
#endif

inline void tic() {
#ifdef ALNDBG
	alndbg::s = clock();
#endif
}

inline void toc() {
#ifdef ALNDBG
	alndbg::e = clock();
	cerr<<1000.0 * (alndbg::e - alndbg::s) / CLOCKS_PER_SEC<<" ms"<<endl;
#endif
}

//}}}

// -------------------- Spliters ------------------------
const int maxn = 1010;

struct Circle {
	ll x, y;
	ll r;
} ps, pt;

vector<Circle> pts;
struct Edge {
	int to;
	double dis;
	bool operator<(const Edge& e) const {
		return dis > e.dis;
	}
};
vector<Edge> E[maxn];

double dis(Circle& u, Circle& v) {
	double d1 = sqrt((u.x - v.x) * (u.x - v.x) + (u.y - v.y) * (u.y - v.y));
	d1 -= u.r + v.r;
	return max(0.0, d1);
}

double dijkstra(int s, int t) {
	double dist[maxn];
	dist[s] = 0;
	rep(i, 1, maxn) dist[i] = 1e10;
	priority_queue<Edge> pq;
	pq.push({s, 0});
	while(!pq.empty()) {
		Edge t = pq.top(); pq.pop();
		if(t.dis > dist[t.to]) continue;
		for(auto& e : E[t.to]) {
			if(t.dis + e.dis < dist[e.to]) {
				dist[e.to] = t.dis + e.dis;
				pq.push({e.to, dist[e.to]});
			}
		}
	}
	return dist[t];
}


int main() {
	ios::sync_with_stdio(0);
	cin>>ps.x>>ps.y>>pt.x>>pt.y;
	ps.r = 0; pt.r = 0;
	pts.pb(ps);
	int N;
	cin>>N;
	rep(i, 0, N) {
		Circle c;
		cin>>c.x>>c.y>>c.r;
		pts.push_back(c);
	}
	pts.pb(pt);
	rep(i, 0, pts.size()) {
		rep(j, i + 1, pts.size()) {
			E[i].pb({j, dis(pts[i], pts[j])});
			E[j].pb({i, dis(pts[i], pts[j])});
		}
	}
	cout<<fixed<<setprecision(12)<<dijkstra(0, N + 1)<<endl;
	return 0;
}
// --USE C++11
// *-USE O2


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

long long int gcd(long long int a,long long int b){
    if(a<b){
        long long int tmp=a;
        a=b;
        b=tmp;
    }

    long long int r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

long long int lcm(long long int a,long long int b){
    long long int g = gcd(a,b);
    return (a/g)*b;
}


int main() {
    string N;
    cin >> N;

    ll ans1 = 0;
    REP(i,N.size()) ans1 += stoi(N.substr(i,1));

    ll ans2 = 0;    
    bool under = false;
    REP(i,N.size()){
        if(under || N[i]=='9') ans2 += 9;
        else if(i == 0) {
            ans2 += stoi(N.substr(i,1))-1;
            under = true;
        } else {
            ans2 -= 1;
            ans2 += 9;
            under = true;
        }
    }

    pl(max(ans1,ans2))

    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n;
map<int, int> d;
int m;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) {
        int e;
        cin >> e;
        d[e]++;
    }
    cin >> m;
    bool ok = true;
    rep(i, m) {
        int t;
        cin >> t;
        if (d[t] == 0) {
            ok = false;
            break;
        }
        d[t]--;
    }
    if (ok) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 12800
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    for(;;){
        int n;
        scanf("%d\n",&n);
        if(n==0) break;
        vector<vector<int> > cards(2);
        vector<bool> cl(n*2+1,true);
        int ins;
        for(int i=0;i<n;i++){
            scanf("%d",&ins);
            cards[0].push_back(ins);
            cl[ins]=false;
        }
        sort(cards[0].begin(),cards[0].end());
        for(int i=1;i<=2*n;i++){
            if(cl[i])cards[1].push_back(i);
        }
        int ba=0;
        for(int ix=0;;ix=(ix+1)%2){
            bool is=false;
            for(int i=0;i<n;i++){
                if(cards[ix][i]>ba){
                    is=true;
                    ba=cards[ix][i];
                    cards[ix][i]=0;
                    break;
                }
            }
            if(!is)ba=0;
            is=true;
            for(int i=0;i<n;i++){
                if(cards[ix][i]!=0)is=false;
            }
            if(is){
                int po=0;
                int ene=(ix+1)%2;
                for(int i=0;i<n;i++)if(cards[ene][i]!=0)po++;
                if(ix==0)printf("%d\n%d\n",po,0);
                else printf("%d\n%d\n",0,po);
                break;
            }
        }
    }
}

Measured memory_bytes: 0
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repr(i,a,b) for(int i=a,i > b;--i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define modi 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (ll)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <double, double> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<int> vii;

const int N= 2e5+3;
vi a;
int main(){
	int n;cin>>n;
	a.resize(n);
	rep(i,0,n) {
		int x;cin>>x; a[i]=x-i-1;
	}
	sort(a.begin(),a.end());
 
	int  b = a[n/2];
	ll ans=0;
	rep(i,0,n) ans+=abs(a[i]-b);	
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, A, B = getlist()
	ans = pow(2, N, con) - 1

	dif = 1
	var = N
	for i in range(A):
		inv = pow((1 + i) , con - 2, con)
		dif = dif * (var - i) * inv
		dif %= con
	ans -= dif
	dif = 1
	for i in range(B):
		inv = pow((1 + i) , con - 2, con)
		dif = dif * (var - i) * inv
		dif %= con
	ans -= dif

	ans %= con
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 40428
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import Data.Bool
import Data.Maybe

main :: IO ()
main = do
  d <- readDate
  print . showAnswer $ solve d

type Input  = [Int]
type Output = Bool

solve :: Input -> Output
solve [y,m,d] = y <= 2019 && m <= 4 && d <= 30

showAnswer :: Output -> Answer
showAnswer = String . bool "TBD" "Heisei"

-- utils
readDate :: IO [Int]
readDate = map (fst . fromJust . C8.readInt) . concatMap (C8.split '/') . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)    = bool "No" "Yes" b
  show (YESNO b)    = bool "NO" "YES" b
  show (AB b)       = bool "B"  "A" b
  show (Number i)   = show i
  show (String s)   = s
  show (Compare o)  = ordering "<" "=" ">" o
  show (Compare2 o) = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

Measured memory_bytes: 380
#-*-coding:utf-8*-
#0003.rb

#????´??????\????????????????????????????????????
count = 0
loop = gets.to_i #???????????????????????§??????????????°????±??????????
line = []

for input in loop.times do
  input_line = gets
  lines = input_line.split(" ")
  lines_int = lines.map(&:to_i)
  line = lines_int.sort
  #a^2 + b^2 = c^2 ????????´?§?????§???¢
  triangle_check = line[0] ** 2 + line[1] ** 2 == line[2] ** 2

  #true??????Yes???false??????No?????????
  if triangle_check == true then
    puts "YES"
  else
    puts "NO"
  end

  #??????????????°????????????
  count += 1

  #1000???????¶????????????????????????????
  if count > 1000 then
    puts "????????????1000???????¶????????????????"
    break
  end
  
end

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

#define g(a,b,c) for(int a=b;a<c;a++)
#define ff(a,b,c) for(int a=c;a>b;a--)
#define ffk(a,b,c) for(int a=b;a<=c;a++)
#define fff(a,b,c) for(int a=c;a>=b;a--)
int main (){
string s;
int dem=0;
cin>>s;
for(int i=0;i<s.length();i++){
	if(s[i]==s[i+1]){
		dem++;
	}
}
if (dem>0){
	cout<<"Bad";
}
else {
	cout<<"Good";
}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1020;
long long x[maxn], y[maxn], r[maxn];
long double distance(int i, int j){
	long long delta = (x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]);
	if(delta <= (r[i] + r[j]) * (r[i] + r[j])) return 0.0L;
	return sqrtl(delta) - r[i] - r[j];
}
long double dist[maxn];
int seen[maxn];
int main(){
	cin >> x[0] >> y[0] >> x[1] >> y[1];
	int n; cin >> n;
	for(int i = 0; i < n; i++) cin >> x[i+2] >> y[i+2] >> r[i+2];
	n += 2;
	for(int i = 0; i < n; i++) dist[i] = 1e18;
	dist[0] = 0;
	for(int i = 0; i < n; i++){
		int now = -1;
		for(int j = 0; j < n; j++) if(!seen[j] && (now == -1 || dist[j] < dist[now])) now = j;
		seen[now] = 1;
		for(int j = 0; j < n; j++) dist[j] = min(dist[j], dist[now] + distance(now, j));
	}
	cout << fixed << setprecision(12) << dist[1] << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int sins = 0;
        string s = Console.ReadLine();
        string akiba = "AKIHABARA";
        for (int i = 0; i < akiba.Length; i++)
        {
            if (i - sins < s.Length && akiba[i] == s[i - sins]) ;
            else if (akiba[i] == 'A') sins++;
            else
            {
                Console.WriteLine("NO");
                return;
            }
        }
        if (s.Length + sins == akiba.Length)
        {
            Console.WriteLine("YES");
        }
        else
        {
            Console.WriteLine("NO");
        }
    }
}

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

using namespace std;

struct coord {
	long long l;
	long long r;
	bool operator < (const coord& el) const {
		return ((r < el.r) || (r == el.r && l < el.l));
	}
};

int main() {
	ios::sync_with_stdio(false);
	long long n;
	cin>>n;
	vector < coord > v(n);
	for (long long i = 0; i < n; i++) {
		long long x, r;
		cin>>x>>r;
		v[i].l = x - r;
		v[i].r = x + r;
	}
	sort(v.begin(), v.end());
	
	//for (long long i = 0; i < n; i++)
	//	cout<<v[i].l<<" "<<v[i].r<<endl;
		
	long long bound = -(1e10), res = 0;
	for (long long i = 0; i < n; i++) {
		if (v[i].l >= bound) {
			res++;
			bound = v[i].r;
		}
	}
	cout<<res<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;

bool check(int a, int b) {
	return a > b;
}

int main() {
	char s[100];
	cin >> s;
	char t[100];
	int cnt = 0;
	rep(i, strlen(s)) {
		if (s[i] == 'B') {
			if (cnt != 0) {
				cnt--;
			}
		}
		else {
			t[cnt] = s[i];
			cnt++;
		}
	}
	rep(i, cnt) {
		cout << t[i];
	}
	cout << endl;
	return 0;
}


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

bool check(int n, vector<int> d) {
    int k = d.size();
    bool ans = true;
    while (n > 0) {
        int c = n % 10;
        for (int i = 0; i < k; i++) {
            if (c == d[i]) {
                ans = false;
                goto OUT;
            }
        }
        n /= 10;
    }

    OUT:
    return ans;
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    for (int i = 0; i < k; i++) {
        cin >> d[i];
    }

    while (check(n, d) == false) {
        n++;
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int ab[10][10];
int main() {
	int N; cin >> N;
	REP(i, N) {
		string s = to_string(i + 1);
		ab[s.front() - '0'][s.back() - '0']++;
	}
	int res = 0;
	REP(i, 10) REP(j, 10)
		res += ab[i][j] * ab[j][i];
	cout << res << '\n';
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main(){
	for(;;){
		int h,w;
		cin>>h>>w;
		if(h==0&&w==0){
			break;
		}
		for(int a=0;a<h;a++){
			if(a%2==0){
				for(int b=0;b<w;b++){
					if(b%2==0){
						cout<<"#";
					}
					else{
						cout<<".";
					}
				}
				cout<<endl;
			}
			else{
				for(int c=0;c<w;c++){
				    if(c%2==0){
						cout<<".";
					}
					else{
						cout<<"#";
					}
				}
				cout<<endl;
			}
		}
		cout<<endl;
	}
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int MAX_V=210;

vvin g(MAX_V);//グラフの隣接リスト表現
vin match(MAX_V);//マッチングのペア
vbo used(MAX_V);

void add_edge(int u,int v){
    g[u].push_back(v);
    g[v].push_back(u);
}

//増加パスをdfsで探す
bool dfs(int v){
    used[v]=true;
    for(auto u:g[v]){
        int w=match[u];
        if(w<0||(!used[w]&&dfs(w))){
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}

//二部グラフの最大マッチングを求める
int max_matching(int v){//vは頂点数
    int res=0;
    fill(all(match),-1);
    rep(i,v){
        if(match[i]<0){
            fill(all(used),false);
            if(dfs(i))res++;
        }
    }
    return res;
}

int main(){
    int X,Y,e;cin>>X>>Y>>e;
    int x,y;
    rep(i,e){
        cin>>x>>y;
        add_edge(x,y+X);
    }
    cout<<max_matching(X+Y)<<endl;
}


Measured memory_bytes: 3272
#include <bits/stdc++.h>
using namespace std;
#define ll    long long
#define ld    long double
#define F     first
#define S     second
#define pb    push_back
#define mp    make_pair
#define mod   1000000007
#define vlli  vector<ll>
#define vi    vector<ll>
#define vs    vector<string>
#define vplli vector< pair< ll, ll> >
#define plli  pair< ll, ll >
#define vps   vector< pair< string, string> >
#define vpi   vector< pair< ll, ll> >
#define all(x)          x.begin(), x.end()
#define rall(x)         x.rbegin(), x.rend()
#define fast  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define forn(i, a, n)   for (ll i = a; i < n; i++)
#define forr(i, n, a)   for (ll i = n - 1; i >= a; i--)
#define scan(arr, a, n) for (ll i = (a); i < (n); i++) cin >> (arr)[i];
#define prll(arr, a, n) for (ll i = (a); i < (n); i++) cout << (arr)[i] << " ";

const ll inf = 1e18;

ll add(ll x, ll y) {
    ll res = x + y; return (res >= mod ? res - mod : res);
}
ll mul(ll x, ll y) {
    ll res = x * y; return (res >= mod ? res % mod : res);
}
ll sub(ll x, ll y) {
    ll res = x - y; return (res < 0 ? res + mod : res);
}
ll power(ll x, ll y) {
    ll res = 1; x %= mod; while (y) {

        if (y & 1) res = mul(res, x); y >>= 1; x = mul(x, x);
    }
    return res;
}
ll mod_inv(ll x) {
    return power(x, mod - 2);
}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif
    ll n, m, q;
    cin >> n >> m >> q;
    ll x, y, i, j;
    map<ll, ll> ma[n];
    vplli a(n);
    vplli b(m);
    for (i = 0; i < n; i++) {
        a[i].F = 0;
        a[i].S = i;
    }
    for (i = 0; i < m; i++) {
        b[i].F = 0;
        b[i].S = i;
    }

    while (q--) {
        cin >> x >> y;
        a[x - 1].F++;
        b[y - 1].F++;
        ma[x - 1][y - 1]++;
    }
    ll mx = 0;
    sort(all(a));
    sort(all(b));
    for (i = n - 1; i >= 0; i--) {
        for (j = m - 1; j >= 0; j--) {
            x = b[j].F + a[i].F;
            if (x <= mx) break;
            if (ma[a[i].S][b[j].S]) x--;
            mx = max(x, mx);
        }
        if (a[i].F + b[m - 1].F <= mx) break;
    }

    cout << mx << endl;


}

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

int main() {
    int n,cnt=0,i=0,j;
    string s;
    cin >> n >> s;
    j=s.size()-1;
    while(i<j) {
        if (s[i]=='W' && s[j]=='R') {
            cnt++;
            i++;
            j--;
        }
        else if (s[i]=='W') {j--;}
        else if (s[j]=='R') {i++;}
        else {i++;j--;}
    }
    cout << cnt << endl;

}


Measured memory_bytes: 3764
#include "bits/stdc++.h"

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

int N;
int M;
vector<llvec> est;


ll sumv(int flag, llvec a){
  if(flag == 0) return a[0] + a[1] + a[2];
  if(flag == 1) return -a[0] + a[1] + a[2];
  if(flag == 2) return a[0] - a[1] + a[2];
  if(flag == 3) return a[0] + a[1] - a[2];
  if(flag == 4) return a[0] - a[1] - a[2];
  if(flag == 5) return -a[0] + a[1] - a[2];
  if(flag == 6) return -a[0] - a[1] + a[2];
  if(flag == 7) return -a[0] - a[1] - a[2];
}

/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  cin >> N >> M;
  rep(i, N){
    llvec tmp;
    ll tmp2;
    cin >> tmp2;
    tmp.push_back(tmp2);
    cin >> tmp2;
    tmp.push_back(tmp2);
    cin >> tmp2;
    tmp.push_back(tmp2);
    est.push_back(tmp);
  }
  ll ans = 0;
  rep(f, 8){
    sort(ALL(est), [f](llvec a, llvec b){return sumv(f, a)>sumv(f, b);});
    ll cand = 0;
    rep(i, M){
      cand += sumv(f, est[i]);
    }
    ans = max(ans, cand);
  }
  cout << ans;
  return 0;
}


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

#define debug(s) cout << s << endl
#define debug1(s, t) cout << s << " " << t << endl
#define debug2(s, t, u) cout << s << " " << t << " " << u << endl
#define printvec(v)       \
    for (auto &&i : v)    \
        cout << i << " "; \
    cout << endl
#define rep(n, i) for (int i = 0; i < n; i++)

using namespace std;
using i64 = long long;

using Graph = vector<vector<int>>;

bool noseen = true;
int cirnode = 0;
int prev__ = 0;
int dis = 0;

void DFS1(Graph &g, vector<bool> &seen, int p, vector<int> &d)
{
    if (noseen)
        d[p] = d[prev__] + 1;
    seen[p] = true;
    for (auto &&gi : g[p])
    {
        if (seen[gi])
        {
            if (noseen)
            {
                noseen = false;
                cirnode = gi;
                dis = d[p];
            }
            continue;
        }
        prev__ = p;
        DFS1(g, seen, gi, d);
    }
}

int main()
{
    int n;
    i64 k;
    cin >> n >> k;
    vector<int> a(n);
    Graph g(n);
    rep(n, i)
    {
        int a;
        cin >> a;
        a--;
        g[i].push_back(a);
    }

    vector<bool> seen(n, false);
    vector<int> d(n, 0);
    DFS1(g, seen, 0, d);

    vector<bool> seen1(n, false);

    DFS1(g, seen1, cirnode, d);

    int c_size = 0;
    for (auto &&s : seen1)
    {
        if (s)
        {
            c_size++;
        }
    }

    dis -= c_size;

    int node = 0;
    if (k > (i64)dis)
    {
        k -= (i64)dis;
        k %= (i64)c_size;
        node = cirnode;
    }
    while (k > 0LL)
    {
        node = g[node].front();
        k--;
    }

    cout << node + 1 << endl;

    return 0;
}

Measured memory_bytes: 31060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    REP(i, max(a, b)) {
        cout << min(a, b);
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll a[100001];
ll b[100001];
ll c[100001];
//ll dp[100001];
ll ksa(ll x,ll arr[]);
ll ksb(ll y,ll brr[]);
ll ksc(ll z,ll crr[]);
ll dpa[100001];
ll dpb[100001];
ll dpc[100001];

ll ksa(ll n,ll a[])
{
    ll ans;
    if(n==1)
    {
        ans=max(b[1],c[1]);
        return ans;
    }
    
    if(dpa[n]!=-1)
    {
        ans=dpa[n];
        return ans;
    }
    
    
    else
    {
        //ll temp1=a[n]+ks(n-1);
        ll temp2=b[n]+ksb(n-1,b);
        ll temp3=c[n]+ksc(n-1,c);
        ans=max(temp2,temp3);
        dpa[n]=ans;
    }
    
    
    return ans;
}

ll ksb(ll n,ll b[])
{
    ll ans;
    if(n==1)
    {
        ans=max(a[1],c[1]);
        return ans;
    }
    
     if(dpb[n]!=-1)
    {
        ans=dpb[n];
        return ans;
    }
    
    else
    {
        //ll temp1=a[n]+ks(n-1);
        ll temp2=a[n]+ksa(n-1,a);
        ll temp3=c[n]+ksc(n-1,c);
        ans=max(temp2,temp3);
        dpb[n]=ans;
    }
    
    return ans;
}

ll ksc(ll n,ll c[])
{
    ll ans;
    if(n==1)
    {
        ans=max(b[1],a[1]);
        return ans;
    }
    
     if(dpc[n]!=-1)
    {
        ans=dpc[n];
        return ans;
    }
    
    else
    {
        //ll temp1=a[n]+ks(n-1);
        ll temp2=b[n]+ksb(n-1,b);
        ll temp3=a[n]+ksa(n-1,a);
        ans=max(temp2,temp3);
        dpc[n]=ans;
    }
    
    return ans;
}




int main() 
{
    memset(dpa,-1,sizeof(dpa));
    memset(dpb,-1,sizeof(dpb));
    memset(dpc,-1,sizeof(dpc));
    
	ll n;
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
	    cin>>a[i]>>b[i]>>c[i];
	}
	
	ll res=max(ksa(n,a),ksb(n,b));
	ll fres=max(res,ksc(n,c));
	
	cout<<fres<<"\n";
}


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

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            var S = Console.ReadLine();
            var T = Console.ReadLine();
            if(S == T.Substring(0, T.Length - 1)) {
                Console.Write("Yes");
            } else {
                Console.Write("No");
            }
        }
    }
}

Measured memory_bytes: 25884
#include<iostream>
using namespace std;
int main()
{
	long long n,i,m=0;
	cin >> n;
	for(i=1;i<=n;i++)
	{
		if(i*i<=n && i*i>m)
		{
			m=i*i;
		}
	}
	cout << m << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
# Author: cr4zjh0bp
# Created: Tue Mar 10 14:13:53 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from math import ceil

N, K = na()
A = na()

print(ceil((N - 1) / (K - 1)))

Measured memory_bytes: 13876
local n = io.read("*n")
local d = {}
for i = 1, n do
  d[i] = io.read("*n")
end
local ret = 0
for i = 1, n - 1 do for j = i + 1, n do
  ret = ret + d[i] * d[j]
end end
print(ret)


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
#include <float.h>
using namespace std;

void A();
void B();
void C();
void D();

int main() {
	int n, a, b, sum, dig, num, sum2 = 0;
	cin >> n >> a >> b;
	for (int i = 1; i <= n; ++i) {
		num = i;
		sum = 0;
		while (num) {
			dig = num % 10;
			sum = sum + dig;
			num = num / 10;
		}
		if (sum >= a && sum <= b) {
			sum2 += i;
		}
	}
	cout << sum2 << endl;
	return 0;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
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())

l = LI()
l.sort()
if l == [5,5,7]:
    print("YES")
else:
    print("NO")


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

int main() {
  int n,k;
  string s;
  cin >> n >> k >> s;
  k--;
  if (s[k] == 'A'){
    s[k] = 'a';
  }
  else if (s[k] == 'B'){
    s[k] = 'b';
  }
  else{
    s[k] = 'c';
  }
  
  cout << s << endl;
}

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

using namespace std;
#define ll long long

#define PI 3.14159265358979323846

int main() {
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output1.txt", "w", stdout);
#endif


	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);

	for (int i = 0; i < m; ++i) {
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}


	queue<int> q;
	vector<bool> visited(n, false);
	vector<int> parent(n , -1);
	q.push(0);
	visited[0] = true;

	while (!q.empty()) {


		int curr = q.front();
		q.pop();

		for (auto a : graph[curr]) {
			if (visited[a] == false) {
				parent[a] = curr;
				visited[a]  = true;
				q.push(a);
			}
		}

	}

	bool flag = true;
	for (auto a : visited) {
		if (!a) {
			flag = false;
			break;
		}
	}

	if (!flag) {
		cout << "No\n";
	}
	else {

		cout << "Yes\n";

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

	}



	return 0;

}

Measured memory_bytes: 10276
import sys
sys.setrecursionlimit(10**6)
n=int(input())
g=[set() for _ in range(n)]
for _ in range(n-1):
  u,v,w=map(int,input().split())
  g[u-1].add((v-1,w%2))
  g[v-1].add((u-1,w%2))
l=[-1]*n
def dfs(x,p=-1,s=0):
  l[x]=s
  for c,d in g[x]:
    if p==c: continue
    dfs(c,x,s^d)
dfs(0)
print(*l,sep='\n')

Measured memory_bytes: 97064
#include<stdio.h>

int main(void){
    int n,i,x,max,min;
    long int sum=0;
    scanf("%d",&n);
    scanf("%d",&x);
    min=x;
    max=x;
    sum+=x;
    for(i=1;i<n;i++){
        scanf("%d",&x);
        if(x<min) min=x;
        if(x>max) max=x;
        sum+=x;
    }
    
    printf("%d %d %ld\n",min,max,sum);
    
    return 0;
}


Measured memory_bytes: 2100
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		List<Integer> listH = new ArrayList<Integer>();
		List<Integer> listW = new ArrayList<Integer>();
		for(;;){
			int H = scan.nextInt();
			int W = scan.nextInt();
			if((H == 0) && (W == 0)){
				break;
			}
			listH.add(H);
			listW.add(W);
		}

		for(int i = 0; i < listH.size(); i++){
			int h = listH.get(i);
			int w = listW.get(i);
			for(int j = 0; j < h; j++){
				for(int k = 0; k < w; k++){
					if(j % 2 == 0){
						if(k % 2 == 0){
							System.out.print("#");
						} else{
							System.out.print(".");
						}
					} else if(k % 2 == 0){
						System.out.print(".");
					} else{
						System.out.print("#");
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 33364
def main():
  A,B,K = input().split()
  A=int(A)
  B=int(B)
  K=int(K)
  
  if(A+B<=K):
    print("0","0")
  elif(A>=K):
    print(A-K,B)
  else:
    print("0",A+B-K)
    
if __name__=="__main__":
  main()

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

bool check(string s){
  for(int i = 0; i < s.size() - 1; i++){
    if(s[i] != s[i + 1]) return false;
  }
  return true;
}

int main(){
  int score = INT_MAX, new_score = 0;
  string s;
  cin >> s;
  if(check(s)){cout << 0 << endl; return 0;}
  for(int i = 0; i < 26; i++){
    char c = char('a' + i);
    string ss = s;
    new_score = 0;
    while(1){
      for(int j = 0; j < ss.size() - 1; j++){
	if(ss[j] == c || ss[j + 1] == c) ss[j] = c;
      }
      // cout << ss << endl;
      ss.pop_back();
      new_score++;
      if(check(ss))break;
    }
    // cout << "new_score(" << c << "): "<< new_score << endl;
    score = min(score, new_score);
  }

  cout << score << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        Map<Integer, Long> map = new HashMap<>();
        for(int i = 0; i < n; i++){
        	int number = sc.nextInt();
            num[i] = number;
            if(map.containsKey(number)){
            	map.put(number, map.get(number) + 1);
            }else{
            	map.put(number, 1L);
            }
        }
        long total = 0;
        for(int key: map.keySet()){
            total += (map.get(key) * (map.get(key) - 1)) / 2;
        }
        for(int i = 0; i < n; i++){
        	long lb = (map.get(num[i]) * (map.get(num[i]) - 1)) / 2;
            long la = ((map.get(num[i]) - 1) * (map.get(num[i]) - 2)) / 2;
            System.out.println(total - lb + la);
        }
	}
}

Measured memory_bytes: 70032
#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <algorithm>
#define fr first
#define sc second
#define INF (2 << 28)
using namespace std;

typedef pair<int, int> iP;
typedef pair<iP, iP> iiP;
typedef pair<iiP, int> iiiP;

int w, h;
iP ts, ks;
int mas[51][51], used[51][51][51][51];
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int bfs(){
  
  fill_n(***used, 51*51*51*51, INF);
  queue <iiiP> que;
  que.push(iiiP(iiP(ts, ks), 0)); used[ts.fr][ts.sc][ks.fr][ks.sc] = 0;
  while(!que.empty()){
    iiiP p = que.front(); que.pop();
    if(p.fr.fr == p.fr.sc){
      if(p.sc >= 100) return -1;
      else return p.sc;
    }
    
    int tx = p.fr.fr.fr, ty = p.fr.fr.sc, kx = p.fr.sc.fr, ky = p.fr.sc.sc;
    if(used[tx][ty][kx][ky] == INF) continue;
    for(int i = 0; i < 4; i++){
      int ntx = tx + dx[i], nty = ty + dy[i];
      int nkx = kx - dx[i], nky = ky - dy[i];
      
      if(mas[nty][ntx] == 1 || !(ntx >= 0 && ntx < w && nty >= 0 && nty < h)) ntx = tx, nty = ty;
      if(mas[nky][nkx] == 1 || !(nkx >= 0 && nkx < w && nky >= 0 && nky < h)) nkx = kx, nky = ky;

      if(used[ntx][nty][nkx][nky] > p.sc + 1){
	que.push(iiiP(iiP(iP(ntx, nty), iP(nkx, nky)), p.sc + 1));
	used[ntx][nty][nkx][nky] = p.sc + 1;
      }
    }
  }
  return -1;

}  

int main(){
  
  while(cin >> w >> h, w||h){
    cin >> ts.fr >> ts.sc;
    cin >> ks.fr >> ks.sc;
    ts.fr--, ts.sc--;
    ks.fr--, ks.sc--;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++) cin >> mas[i][j];
    }

    int ans = bfs();
    if(ans == -1) cout << "NA" << endl;
    else cout << ans << endl;
  }

}

Measured memory_bytes: 27788
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B, K;
    cin >> A >> B >> K;
    for (int i = min(A, B); i >= 1; --i)
    {
        if (A % i == 0 && B % i == 0)
        {
            --K;
            if (K == 0)
            {
                cout << i << endl;
                return 0;
            }
        }
    }
    assert(false);
}

Measured memory_bytes: 3600
def get_day(date)
  m = date[0]
  d = date[1]
  info = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
  (m - 1).times do |i|
    d += info[i]
  end
  return case d % 7
    when 0 then "Wednesday"
    when 1 then "Thursday"
    when 2 then "Friday"
    when 3 then "Saturday"
    when 4 then "Sunday"
    when 5 then "Monday"
    when 6 then "Tuesday"
    end
end

loop do
  date = gets.chomp.split(" ").map(&:to_i)
  exit if date[0] == 0
  puts get_day(date)
end

Measured memory_bytes: 8640
# include <stdio.h>
# include <string.h>
# include <stdlib.h>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <math.h>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define MAXN 100005
# define eps 1e-5
# define MAXM 500001
# define MOD 100000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
typedef long long LL;
typedef unsigned long long ULL;
int _MAX(int a, int b){return a>b?a:b;}
int _MIN(int a, int b){return a>b?b:a;}

LL dp[55][2505];
int a[55];

int main ()
{
    int n, ave;
    scanf("%d%d",&n,&ave);
    FOR(i,1,n) scanf("%d",a+i);
    dp[0][0]=1;
    FOR(i,1,n) for (int j=i-1; j>=0; --j) FOR(k,0,2500-a[i]) dp[j+1][k+a[i]]+=dp[j][k];
    LL ans=0;
    FOR(i,1,n) ans+=dp[i][i*ave];
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int l;
    cin >> l;
    cout << fixed << setprecision(10) << (double)l * l * l / 27 << endl;
    return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string N;
  cin >> N;
  cout << (N[0] == '7' || N[1] == '7' || N[2] == '7' ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3588
N = int(input())
S = input()
r = g = b = 0
L = [0] * (3*N)
for i, c in enumerate(S):
    if c=="R":
        L[i] = r
        r += 1
    elif c=="G":
        L[i] = g
        g += 1
    else:
        L[i] = b
        b += 1
LL = [[] for _ in range(N)]
for i, l in enumerate(L):
    LL[l].append(i)
idx = 0
A, B, C = list(zip(*LL))
ans = 1
mod = 998244353
for i in range(2, N+1):
    ans = ans * i % mod
idx_b = N-1
n = 0
for i, a in enumerate(A[::-1]):
    while idx_b >= 0 and a < B[idx_b]:
        idx_b -= 1
        n += 1
    ans = ans * n % mod
    #print(n)
    n -= 1
idx_b = 0
n = 0
for c in C:
    while idx_b < N and B[idx_b] < c:
        idx_b += 1
        n += 1
    ans = ans * n % mod
    #print(n)
    n -= 1
print(ans)


Measured memory_bytes: 45952