akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;


int main(){
    
    long H=0,N=0;

    cin >> H >> N;

    for(int i=1;i<=N;i++){
        int x;
        cin >> x;
        H -= x;
    }

    if(H>0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
using P = pair<int, int>;
const int INF = 1100100100;

int main(){
    int v, e, r;
    cin >> v >> e >> r;
    vector<vector<P>> graph(v);
    for(int i = 0; i < e; i++){
        int s, t, d;
        cin >> s >> t >> d;
        //graph[s][i].second は sを始点とする辺の終点t
        //graph[s][i].first は 辺の重み
        graph[s].push_back(make_pair(d, t));
    }

    vector<bool> isdone(v, false);
    vector<int> result(v, INF);
    priority_queue<P, vector<P>, greater<P>> Q;

    result[r] = 0;
    Q.push(make_pair(result[r], r));
    while(Q.size()){
        P cur = Q.top();
        int curnode = cur.second;
        Q.pop();
        if(isdone[curnode]) continue;
        isdone[curnode] = true;
        for(int i = 0; i < graph[curnode].size(); i++){
            int nextnode = graph[curnode][i].second;
            int nextcost = graph[curnode][i].first;
            if(isdone[nextnode] == false &&
            result[nextnode] > result[curnode] + nextcost){
                result[nextnode] = result[curnode] + nextcost;
                Q.push(make_pair(result[nextnode], nextnode));
            }
        }
    }

    for(int i = 0; i < v; i++){
        if(result[i] == INF) cout << "INF" << endl;
        else cout << result[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 12968
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

int main()
{
    ll a=in(),b=in(),n=in();
    ll _b=n/b*b;
    ll x=_b<=1?n:_b-1;
    cout<<std::floor(a*((double)(x)/b-x/b))<<endl;
}


Measured memory_bytes: 3780
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define FRE freopen("in.txt", "r", stdin);
#define endl "\n"
#define PI acos(-1.0)
typedef long long LL;
typedef pair<int, int> PII;
const double eps = 1e-8;
const int inf = 0x3f3f3f3f;
const int N = 110, M = 1010;

set<int> s;

void solve() {
	int n, k;
	cin >> n >> k;
	while(k--) {
		int d, num;
		cin >> d;
		while(d--) {
			cin >> num;
			s.insert(num);
		}
	}
	cout << n - s.size() << endl;
}

int main() {
	//FRE;
	int t;
	solve();
	return 0;
}


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

int main()
{
	int h, w;
	cin >> h >> w;
	auto s = vector<string>(h + 2);
	s[0] = s[h + 1] = string(w + 2, '.');
	for(auto i = 1; i < h + 1; ++i){
		string t;
		cin >> t;
		s[i] = '.' + t + '.';
	}
	bool ans = true;
	for(auto i = 1; i < h + 1; ++i){
		for(auto j = 1; j < w + 1; ++j){
			if(s[i][j] == '.') continue;
			if(s[i - 1][j] == '.'&& s[i][j + 1] == '.' && s[i + 1][j] == '.' && s[i][j - 1] == '.'){
				ans = false;
				break;
			}
		}
		if(!ans) break;
	}
	cout << (ans ? "Yes" : "No") << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(max(a,b)<=9)
        printf("%d\n",a*b);
    else
        printf("-1\n");
	return 0;
}


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

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


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

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 1e16;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 3e5;

int fact[maxN], rev[maxN];

int mod_pow(int a, int b) {
    if (!b) return 1;
    if (b % 2) return a * mod_pow(a, b - 1) % MOD;
    int q = mod_pow(a, b / 2);
    return q * q % MOD;
}

int c(int n, int k) {
    return (fact[n] * rev[k] % MOD) * rev[n - k] % MOD;
}


void solve() {
    int n, k;
    cin >> n >> k;
    int ans = 0;
    
    fact[0] = 1;
    for (int i = 1; i < maxN; i++) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    for (int i = 0; i < maxN; i++) {
        rev[i] = mod_pow(fact[i], MOD - 2);
    }

    for (int i = 0; i <= min(n - 1, k); i++) {
        int one = c(n, i);
        int two = c(n - 1, n - i - 1);
        ans = (ans + one * two % MOD) % MOD;
    }
    cout << ans;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    //cin >> t;
    int t = 1;
    //srand(time(0));
    while (t--) solve();
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);
struct edge{int to,num;};

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(){
    int N,M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    rep(i,M){
        int s,t;
        cin >> s >> t;
        --s,--t;
        G[s].push_back(t);
    }
    vector<double> dp(N);
    dp[N-1]=0;
    for (int i=N-2;i>=0;--i){
        int s=G[i].size();
        double sum=0;
        for (auto nv:G[i]){
            sum+=dp[nv];
        }
        dp[i]=(double)sum/s+1;
    }
    double ans=dp[0];
    rep(i,N-1){
        if (G[i].size()<=1) continue;
        int t=-1;
        double M=-1;
        for (auto nv:G[i]){
            if (chmax(M,dp[nv])) t=nv;
        }
        vector<double> dp2(N);
        for (int j=N-2;j>=0;--j){
            int s=G[j].size();
            if (j==i) --s;
            double sum=0;
            for (auto nv:G[j]){
                if (j==i&&nv==t) continue;
                sum+=dp2[nv];
            }
            dp2[j]=(double)sum/s+1;
        }
        chmin(ans,dp2[0]);
    }
    cout << fixed << setprecision(10) << ans << endl;
}

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

int main(){
  int n;
  scanf("%d",&n);
 char s[1000],t[1000];
  scanf("%s%s",&s,&t);
  
  char ans[1000];
  for(int i=0;i<n;i++){
    printf("%c%c",s[i],t[i]);
  }
  

  return 0;
}

Measured memory_bytes: 128
console.log((args=>{
  const [a,b,c] = args.trim().split`\n`.map(r=>r.split``.reverse());
  const S = {a,b,c};
  let p = 'a';
  while ( S[p].length ) p = S[p].pop();
  return p.toUpperCase();
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 30544
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  int n;
  cin>>n;
  if(n/10==9||n%10==9)ou("Yes");
  else ou("No");
}

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


void solve(std::string T){
  long long N = T.size();
  for(long long i = 0; i < N; i++){
    if(T[i] == '?' && i == 0) T[i] = 'D';
    else if(T[i] == '?' && T[i-1] == 'P') T[i] = 'D';
    else if(T[i] == '?' && (i+1) < N && (T[i+1] == '?' || T[i+1] == 'D')) T[i] = 'P';
    else if(T[i] == '?') T[i] = 'D';
  }

  cout << T << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string T;
  std::cin >> T;
    solve(T);
    return 0;
}


Measured memory_bytes: 3924
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>

using namespace std;

template <class T>
using gp_queue=priority_queue<T, deque<T>, less<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

pair<Weight, Edges> minimum_spanning_tree(const Graph &g, size_t s=0) {
    /* Prim */
    size_t V=g.size();
    Edges T;
    Weight total=0;

    vector<bool> visited(V);
    gp_queue<Edge> q; q.push(Edge(-1, s, 0));
    while (!q.empty()) {
        Edge e=q.top(); q.pop();
        if (visited[e.dst]) continue;

        T.push_back(e);
        total += e.weight;
        visited[e.dst] = true;
        for (const Edge &f: g[e.dst])
            if (!visited[f.dst])
                q.push(f);
    }

    return make_pair(total, T);
}

int main() {
    size_t V, E;
    scanf("%zu %zu", &V, &E);

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t;
        Weight w;
        scanf("%zu %zu %lld", &s, &t, &w);

        join(g, s, t, w);
    }

    printf("%lld\n", minimum_spanning_tree(g).first);
    return 0;
}

Measured memory_bytes: 12576
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }
    
    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        char c[]=sc.getCharSet();
        int r=0;
        for (int i = 0; i+2 < c.length; i++) {
			if(c[i]=='A' && c[i+1]=='B' && c[i+2]=='C')r++;
		}

    	out.println(r);
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}

//
//class P implements Comparable<P>{
//    int id,ds,p;
//    P(int id, int ds, int p) {
//    	this.id=id;
//    	this.ds=ds;
//    	this.p=p;
//    }
//
//    public int compareTo(P p){
//        return ds-p.ds;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include<algorithm>

using namespace std;

int main()
{
	int n, k, i;
	long long res = 1;
	cin >> n >> k;

	for (i = 0; i < n-1; i++) {
		res *= k- 1;
	}

	cout << res*k << endl;
	return 0;
}

Measured memory_bytes: 256
// parameter "input" gets all data
function Main(input) {
 // the first line is assigned to input[0], the second line is assigned to input[1] similarly.
 input = input.split("\n");
 // convert string from integer using "parseInt"
 var s = parseInt(input[0], 10);
 var k = input[1] 
 var ans
  if (s>=k.length){
    ans=k
  } else {
    ans=k.substr(0,s)+'...'
  }
 //output
 console.log(ans)
}
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29636
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let x = read::<usize>();
    let mut ls = vec![0; n];
    let mut d = 0;
    let mut ans = 1;
    for i in 0..n {
        ls[i] = read::<usize>();
        d += ls[i];
        if d <= x {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [[0]*M]*N
for i in range(N):
  A[i] = list(map(int, input().split()))
  

count = 0
for i in range(N):
  total = 0
  for j in range(M):
    total += B[j] * A[i][j]
  total += C
  if total > 0:
    count += 1
print(count)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		int[] w = new int[N];

		for(int i=0;i<N;i++) {
			w[i] = sc.nextInt();

		}

		int s = 0;
		int r =0;

		int ans =500;
		for(int j=0;j<N-1;j++) {
			for(int i=0;i<=j;i++) {
				s = s + w[i];
			}

			for(int i=j+1;i<N;i++) {
				r = r + w[i];
			}

			ans = Math.min(Math.abs(s-r),ans);
			s=0; r=0;
		}

		System.out.print(ans);
	}

}


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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

const ll INF = 1e9+7;


int main(){
	//ios_base::sync_with_stdio(false);
	int N, ans=0;
	string S;

	cin >> S;

	ans = S.length() / 2;

	if( S.length() % 2 == 0 ){
		S = S.substr(0, ans) + S[ans] + S.substr(ans);
		//cout << S << endl;
		ans--;
	}

	rep(i, S.length()/2+1){
		int mid = S.length()/2;
		int p1 = mid - i;
		int p2 = mid + i + (S.length()%2==0);
		if( S[p1] == S[mid] && S[p2] == S[mid] ) ans++;
		else break;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#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 pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll W,a,b;
  cin>>W>>a>>b;
  if(a<b&&b-(a+W)>0) cout<<b-(a+W)<<endl;
  else if(a>b&&a-(b+W)>0) cout<<a-(b+W)<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 3584
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <queue>
#include <sstream>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
#define fi first
#define se second
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<string> vs;
typedef vector<vi> vvi;
int n,a;
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a;
		if(a%2){
			cout<<"first"<<endl;
			return 0;
		}
	}
	cout<<"second"<<endl;
    return 0;
}

Measured memory_bytes: 256
/*
	?????¨????????????FX??????????????§??????????±???????
*/

#include <stdio.h>

int main(void)
{
	long int n, i, min, mp, R;

	scanf("%d", &n);			//??????(????´???°)???????????????

	for (i = 0; i < n; i++) {
		scanf("%d", &R);		//?????¨????????????????????????

		if (i == 1||(i>1&&mp<R-min)){	//?????¨?????§????????§??????
			mp = R - min;
		}

		if (i==0||R<min) min = R;	//?????¨?????§???????°???????
	}

	printf("%d\n", mp);			//?????????????????§???????????????

	return 0;
}

Measured memory_bytes: 596
N = int(input())
num_list = list(map(int, input().split()))

def change_height(list, n):
    for i in range(n-1):
        if list[i] > list[i+1]:
            diff = list[i] - list[i+1]
            list[i+1] += diff
    return list

c_num_list = []
for i in range(N):
    c_num_list.append(num_list[i])
changed_list = change_height(num_list, N)
total_step = 0
for j in range(N):
    total_step += changed_list[j] - c_num_list[j]

print(total_step)


Measured memory_bytes: 32384
#include<stdio.h>
#include<algorithm>
#include<cstdlib>
#include<set>
#define pli pair<long long, int>
using namespace std;
struct point{
    int x, y;
}w[101000];
int n, s1, s2, L;
bool v[101000];
set<pli>Set1, Set2;
long long p1[101000], p2[101000], Res;
long long Get(int a, int b){
    if(b == 1)return w[a].x*(1ll<<31) + w[a].y;
    else return w[a].y*(1ll<<31) + w[a].x;
}
void DFS(int a){
    v[a]=true;
    long long t1 = Get(a,1), t2 = Get(a,2);
    Set1.erase(pli(t1,a));
    Set2.erase(pli(t2,a));
    long long tt = L*(1ll<<31);
    set<pli>::iterator it;
    while(1){
        it = Set1.lower_bound(pli(t1+tt-L, 0));
        if(it!=Set1.end() && it->first <= t1+tt+L){
            DFS(it->second);
        }
        else break;
    }
    while(1){
        it = Set1.lower_bound(pli(t1-tt-L, 0));
        if(it!=Set1.end() && it->first <= t1-tt+L){
            DFS(it->second);
        }
        else break;
    }
    while(1){
        it = Set2.lower_bound(pli(t2+tt-L, 0));
        if(it!=Set2.end() && it->first <= t2+tt+L){
            DFS(it->second);
        }
        else break;
    }
    while(1){
        it = Set2.lower_bound(pli(t2-tt-L, 0));
        if(it!=Set2.end() && it->first <= t2-tt+L){
            DFS(it->second);
        }
        else break;
    }
}
int main(){
    int i;
    scanf("%d%d%d",&n,&s1,&s2);
    for(i=1;i<=n;i++){
        scanf("%d%d",&w[i].x,&w[i].y);
    }
    L = abs(w[s1].x-w[s2].x) + abs(w[s1].y-w[s2].y);
    for(i=1;i<=n;i++){
        int t = w[i].x-w[i].y;
        w[i].x = w[i].x+w[i].y;
        w[i].y = t;
        p1[i] = Get(i,1);
        p2[i] = Get(i,2);
        Set1.insert(pli(Get(i,1),i));
        Set2.insert(pli(Get(i,2),i));
    }
    DFS(s1);
    sort(p1+1,p1+n+1);
    sort(p2+1,p2+n+1);
    for(i=1;i<=n;i++){
        if(!v[i])continue;
        long long tt = L* (1ll<<31), t1 = Get(i,1), t2 = Get(i,2);
        Res += upper_bound(p1+1,p1+n+1,t1+tt+L) - lower_bound(p1+1,p1+n+1,t1+tt-L);
        Res += upper_bound(p1+1,p1+n+1,t1-tt+L) - lower_bound(p1+1,p1+n+1,t1-tt-L);
        Res += upper_bound(p2+1,p2+n+1,t2+tt+L-1) - lower_bound(p2+1,p2+n+1,t2+tt-L+1);
        Res += upper_bound(p2+1,p2+n+1,t2-tt+L-1) - lower_bound(p2+1,p2+n+1,t2-tt-L+1);
    }
    printf("%lld\n",Res/2);
}

Measured memory_bytes: 21376
#include<iostream>
#include<deque>
#include<queue>
#include<math.h>
#include<string>
#include<string.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<iomanip>
#include<map>
#include<unordered_map>
 
#include<unordered_map>
#include<algorithm>
#define inf 0x3f3f3f3f
#define sup_inf 2e18
#define pb push_back
 
#define ii pair<int,int>
#define f first		
#define s second
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define iii pair<int, ii >
#define in freopen("entrada","r",stdin);
#define out freopen("myfile.txt", "w", stdout);
#define eps 1e-9
#define id pair<int ,double > 
#define di pair<double, int>
 
#define pi 3.14159265359
#define nl (no<<1)
#define nr ( (no<<1)|1)
#define mid l + ( (r-l)>>1)
 
using namespace std;
 
const int maxn = 4e5 + 10;
const int MAX = 2e4 + 10;

typedef long long ll;
typedef vector< int> vi;
//~ https://codeforces.com/contest/645/problem/D


int a, b, c;
int main (){
	//~ in
	
	cin >> a >> b >> c;
	if ( ( a+b+c) >= 22)
		cout << "bust\n";
	else
		cout << "win\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>

int main() {
	int n; long long int a, b; std::cin >> n >> a >> b;
	std::vector<int> monsters(n); for (auto& m : monsters) std::cin >> m;
	std::sort(monsters.begin(), monsters.end());
	int min = 1, max = 1000000000;
	while (min < max) {
		const auto mid = (min + max) >> 1;
		const auto can_defeat = std::distance(monsters.begin(), std::upper_bound(monsters.begin(), monsters.end(), mid * b));
		long long int count = 0;
		for (auto i = can_defeat; i < n; ++i) {
			count += (monsters[i] - mid * b + (a - b) - 1) / (a - b);
		}
		if (count > mid) {
			min = mid + 1;
		}
		else {
			max = mid;
		}
	}
	std::cout << min << std::endl;
}


Measured memory_bytes: 640
N,M=map(int, input().split())
P=list(map(int, input().split()))
class UnionFind():
  # 作りたい要素数nで初期化
  # 使用するインスタンス変数の初期化
  def __init__(self, n):
    self.n = n
    # root[x]<0ならそのノードが根かつその値が木の要素数
    # rootノードでその木の要素数を記録する
    self.root = [-1]*(n+1)
    # 木をくっつける時にアンバランスにならないように調整する
    self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
  def Find_Root(self, x):
    if(self.root[x] < 0):
      return x
    else:
    # ここで代入しておくことで、後の繰り返しを避ける
      self.root[x] = self.Find_Root(self.root[x])
      return self.root[x]

    # 木の併合、入力は併合したい各ノード
  def Unite(self, x, y):
    # 入力ノードのrootノードを見つける
    x = self.Find_Root(x)
    y = self.Find_Root(y)
    # すでに同じ木に属していた場合
    if (x == y):
      return 
      # 違う木に属していた場合rnkを見てくっつける方を決める
      #rnkが大きい方に結合
    elif (self.rnk[x] > self.rnk[y]):
      self.root[x] += self.root[y]
      self.root[y] = x

    else:
      self.root[y] += self.root[x]
      self.root[x] = y
      # rnkが同じ（深さに差がない場合）は1増やす
      if(self.rnk[x] == self.rnk[y]):
        self.rnk[y] += 1

  # xとyが同じグループに属するか判断
  def isSameGroup(self, x, y):
    return self.Find_Root(x) == self.Find_Root(y)

  # ノードxが属する木のサイズを返す
  def Count(self, x):
    return -self.root[self.Find_Root(x)]
uni=UnionFind(N)
for i in range(M):
  x,y=map(int, input().split())
  uni.Unite(x,y)
  
ans=0 
for i, p in enumerate(P):
  if uni.isSameGroup(p,i+1):
    ans+=1
print(ans)


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

int main()
{
	string s;
	cin>>s;
	int i=0;
	long long ans=0;
	int ca=0;
	while(i<s.size())
	{
		//cout<<i<<"!";
		int c1=0,c2=0;
		bool b=0;
		while(i<s.size()-1)
		{
			if(s[i]=='A' && s[i+1]=='A')
			{
				b=1;
		//		cout<<i<<"@";
				ca++;
				i++;
			}
			else break;
		}
		while(i<s.size()-2)
		{
			if(s.substr(i,3)=="ABC")
			{
				b=1;
		//		cout<<i<<"*";
				c1++;
				i=i+3;
			}
			else break;
		}
		
		while(i<s.size()-1)
		{
			if(s.substr(i,2)=="BC")
			{
				b=1;
				//cout<<i<<"$";
				c2++;
				i=i+2;
			}
			else break;
		}
		ans=ans+(c2+1)*(long long)c1;
		ans=ans+ (long long)(c1*(c1-1))/2;
		ans= ans+ (long long)(ca)*(c1+c2);
		//cout<<ans<<" ";
		
		if(b==0){
			i++;
			ca=0;
		}
		else ca=ca+c1;
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdint.h>
#include <iostream>
#include <fstream>
#include <cassert>
using namespace std;

#define DEBUG (0)

#if DEBUG
#define DPRINTF(...)  printf("D(L%d) %s: ", __LINE__, __func__); printf(__VA_ARGS__)
#else
#define DPRINTF(...)
#endif // DEBUG

bool solve(const int i, const int max_i, const int array[], const int val)
{
  if (val == 0)
    return true;
  else if (i > max_i || val < 0)
    return false;

  bool left = solve(i + 1, max_i, array, val);
  if (left == true)
    return true;

  return solve(i + 1, max_i, array, val - array[i]);
}


int main()
{
  int numOfArrayA;
  cin >> numOfArrayA; cin.ignore();

  int arrayA[numOfArrayA];
  for (int i = 0; i < numOfArrayA; i++) cin >> arrayA[i];

  int numOfArrayQ;
  cin >> numOfArrayQ; cin.ignore();

  int arrayQ[numOfArrayQ];
  for (int i = 0; i < numOfArrayQ; i++) cin >> arrayQ[i];

#if DEBUG
  for (int i = 0; i < numOfArrayA; i++)
  {
    if (i == 0) { DPRINTF("Array A: %d", arrayA[i]); }
    else        { printf(" %d", arrayA[i]); }
  }
  cout << endl;

  for (int i = 0; i < numOfArrayQ; i++)
  {
    if (i == 0) { DPRINTF("Array Q: %d", arrayQ[i]); }
    else        { printf(" %d", arrayQ[i]); }
  }
  cout << endl;
#endif

  for (int i = 0; i < numOfArrayQ; i++)
  {
    const int val = arrayQ[i];

    if (solve(0, numOfArrayA - 1, arrayA, val))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }

  return 0;
}



Measured memory_bytes: 3084
def read():
    N = input().strip()
    return N,


def solve(N, INF=1000000):
    L = len(N)
    N = list(reversed("0" + N))
    dp0 = [0 for i in range(L + 1)]
    dp1 = [0 for i in range(L + 1)]
    dp1[0] = INF
    for i in range(L):
        x = int(N[i])
        dp0[i + 1] = min(dp0[i] + x, dp1[i] + x)
        dp1[i + 1] = min(dp0[i] + 1 + (10 - x), dp1[i] + 1 + (10 - x) - 2)
    return min(dp0[-1], dp1[-1])


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 92624
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

bool check[2][1000010];
int sum[2][1000010];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, N) {
        int A; cin >> A;
        if (check[0][A]) {cout << 0 << endl; return 0;}
        check[0][A] = true;
        sum[0][A]++;
    }
    rep(i, M) {
        int B; cin >> B;
        if (check[1][B]) {cout << 0 << endl; return 0;}
        check[1][B] = true;
        sum[1][B]++;
    }
    RREP(i, N * M, 1) {
        rep(j, 2) {
            sum[j][i] += sum[j][i + 1];
        }
    }
    ll ans = 1;
    //RREP(i, N * M, 1) cout << i << " " << sum[0][i] << " " << sum[1][i] << endl;
    RREP(x, N * M, 1) {
        if (check[0][x] && check[1][x]) continue;
        ll K = sum[1][x];
        ll T = sum[0][x];
        if (check[0][x]) {
            ans *= K;
        } else if (check[1][x]) {
            ans *= T;
        } else {
            ans *= max(0LL, K * T - (N * M - x));
        }
        ans %= mod;
        //cout << x << " " << K << " " << T << " " << N * M - x << " " << ans << endl;
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 8448
S = input()
import itertools
for ptn in itertools.product("+-", repeat=3):
    if eval(S[0] + ptn[0] + S[1] + ptn[1] + S[2] + ptn[2] + S[3]) == 7:
        print(S[0] + ptn[0] + S[1] + ptn[1] + S[2] + ptn[2] + S[3] + "=7")
        exit()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
	
	int N,a[110];
	cin >> N ;
	for(int i=0;i<N;i++){
		cin >> a[i];
	}
	
	sort(a, a + N, greater<int>());
	
	int Alice=0;
	int Bob=0;
	
	for(int i=0;i<N;i++){
		if(i%2 == 0){
			Alice += a[i];
		}
		else{
			Bob += a[i];
		}
	}
	
	cout << Alice - Bob << endl;
	
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define MOD 1000000007
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=50010;
//ll fact[N];

void solve()
{
    int h,w;
    cin>>h>>w;

    vector<string> s(h+1,"");

    srep(i,1,h) cin>>s[i];
    

    ll dp[h+1][w+1];

    set0(dp);
    dp[1][1] = 1ll;

    srep(j,2,w) 
    {
        if(s[1][j-1]=='#') break;
        else dp[1][j] = 1ll;
    }

    srep(i,2,h)
    {
        if(s[i][0]=='#') break;
        else dp[i][1] = 1ll;
    }
    
    srep(i,2,h)
    {
        srep(j,2,w)
        {
            if(s[i][j-1]=='#') continue;
            dp[i][j] = (dp[i][j-1] + dp[i-1][j])%MOD;
        }
    }

    
    cout<<dp[h][w];
}

int main()
{
    fastio;
    
    int t=1;
    //cin>>t;
    
    srep(i,1,t)
    {
        solve();
        cout<<"\n";
    }
    return 0;
}

ll add(ll a, ll b){
    a+=b;
    while(a>=MOD) a-=MOD;
    while(a<0) a+=MOD;
    return a;
}

ll mult(ll a, ll b){
    return (a * 1ll * b) % MOD;
}


ll binpow(ll a, ll b){
    ll c = 1;
    while(b > 0)
    {
        if(b % 2 == 1)
            c = mult(c, a);
        a = mult(a, a);
        b /= 2;
    }
    return c;   
}

ll inv(ll a){
    return binpow(a, MOD-2);
}

ll division(ll a, ll b){
    return mult(a, inv(b));
}

/*ll nCr(ll n, ll r){
    if(r > n) return 0;
    return division(fact[n], mult(fact[n-r], fact[r]));
}

void calc(){
    fact[0] = 1;
    srep(i,1,N-1)
        fact[i] = (i*1ll*fac[i-1])%MOD;

}*/

Measured memory_bytes: 12436
M,D=map(int,input().split())
W=M+1
if D<=21:
  print(0)
if 29>=D>=22:
  d1=D%10
  d10=D//10
  q=[x*y for x in range(2,d1+1) for y in range(2,d10+1)]
  DDD=([q.count(i) for i in range(1,M+1)])
  RR=sum(DDD)
  print(RR)
if 30<=D:
    d1=D%10
    d10=D//10
    qq=[x*y for x in range(2,d10) for y in range(2,10)]
    qqq=[d10*w for w in range(2,d1+1)]
    Q=[qq.count(j)for j in range(1,M+1)]+[qqq.count(j)for j in range(1,M+1)]
    DD=sum(Q)
    print(DD)
    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  ll n, k;
  cin >> n >> k;
  vi l(n);
  rep(i,n){
    cin >> l[i];
  }
  sort(all(l));
  ll total = 0;
  for (ll i = n - 1; i >= n - k;i--){
    total += l[i];
  }
  print(total);
}

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

using namespace std;
typedef long long ll;
const int N = 110;
int mod = 1e9 + 7;
#define INF 0x3f3f3f3f
int num[N];
typedef pair<int, int> pii;

int main()
{
#ifndef ONLINE_JUDGE  
   // freopen("in.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
#endif 
   // ios::sync_with_stdio(0);
    int n, x;
    while (~scanf("%d%d", &n, &x))
    {
 		for (int i = 0; i < n; i++)
 		{
 			scanf("%d", num + i);
 		}
 		sort(num, num + n);
 		int sum = 0;
 		for (int i = 0; i < n; i++)
 			if (x >= num[i])
 			{
 				sum++;
 				x -= num[i];
 			}
 		if (x)
 		{
 			if (sum == n)
 				sum--;
 		}
 		printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

int main() {
    int n;
    cin >> n;
    long a[n], b[n];
    bool done[n];
    int dcnt=0;
    fill(done, done+n, false);
    for (auto &ai:a)
        cin >> ai;
    for (int i=0; i<n; i++) {
        cin >> b[i];
        if (b[i] == a[i]) {
            done[i] = true;
            dcnt++;
        } else if (b[i] < a[i]) {
            cout << -1 << '\n';
            return 0;
        }
    }
    long cnt=0;
    while (dcnt < n) {
        bool no = true;
        for (int i=0; i<n; i++) {
            if (done[i]) continue;
            int ip = (i + n - 1) % n,
                in = (i + 1) % n;
            long q = (b[i] - a[i]) / (b[ip] + b[in]);
            if (q > 0) no = false;
            else continue;
            cnt += q;
            b[i] -= (b[ip] + b[in]) * q;
            if (b[i] == a[i]) {
                done[i] = true;
                dcnt++;
            }
        }
        if (no) {
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int n, k;
long long h[200005], res;
int main() {
    DAU
    cin >> n >> k;
    for (int i = 1; i <= n; ++i)
        cin >> h[i];
    sort(h + 1, h + n + 1);
    for (int i = 1; i <= n - k; ++i)
        res += h[i];
    cout << res;
    PLEC
}


Measured memory_bytes: 1792
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

const int MAX_S = 2000 * 2000 + 1;
bitset<MAX_S> B;
 
signed main() {
    int N, sum = 0; cin >> N;
    B[0] = 1;
    rep(i,0,N) {
        int val; cin >> val;
        B |= (B << val);
        sum += val;
    }

    int ans = (sum + 1) / 2;
    while(!B[ans]) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)



int main(){
    double w,h,x,y;
    cin>>w>>h>>x>>y;
    bool ok=false;
    if(x*2==w && y*2==h) ok=true;
    cout<<ketasuu(10)<<(w/2*h)<<" ";
    cout<<(ok? 1: 0)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
int main(){
    ll A,B,C;
    cin >> A >> B >> C;
    if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0)cout << 0 << endl;
    else{
        cout << min(min(A * B,B * C),A * C);
    }
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a_filterd = [x-(i+1) for i,x in enumerate(a)]
a_filterd.sort()
if n%2==1:
    med = n//2 +1
else:
    med = n//2
x = a_filterd[med -1]
ans = 0
for i in a_filterd:
    ans += abs(i-x)
print(ans)

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b;
  while (cin >> a >> b) {
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
    else cout << "Impossible"  << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
N = int(input().strip())
xyh = []
for _ in range(N):
  x, y, h = map(int, input().strip().split())
  xyh.append((x, y, h))

for i in range(101):
  for j in range(101):
    for k in range(N):
      if xyh[k][2] != 0:
        H = xyh[k][2] + abs(i-xyh[k][0]) + abs(j-xyh[k][1])
        break
    is_h = True
    for k in range(N):
      if max(0, H-abs(i-xyh[k][0])-abs(j-xyh[k][1])) != xyh[k][2]:
        is_h = False
        break
    if is_h:
      print(i, j, H)


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

namespace ProgramingStudying2
{
    class Program
    {

        static void Main(string[] args)
        {
            double ans = 0.0;
            var n = int.Parse(Console.ReadLine());
            if(n % 2 == 0)
            {
                ans = (double)(0.5);
            }
            else if(n == 1)
            {
                ans = 1;
            }
            else
            {
                ans = (double)(n + 1) / (2 * n);
            }

            Console.WriteLine(ans);
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
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 (b<a) { a=b; return 1; } return 0; }

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

  ll n, m=100, count=0, ans=0;
  string s;
 
  cin >> n;

  while(m<n){
    m+=m/100;
    count++;
  }



  cout << count << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
        //#define endl '\n'
        #define modulo 1000000007
        #define int long long
        #pragma GCC optimize("-Ofast")
        #define float double
        #define PI 3.141592653589793238462643383279502884
        #define sinDegrees(x) sin((x) * PI / 180.0)
        #define tanDegrees(x) tan((x) * PI / 180.0)
        #define atanDegrees(x) atan(x)* 180.0 / PI
        #define f first
       // #define s second
        using namespace std;
        int power(int x,int y,int m)
        {
        int temp;
        if(y == 0)
        return 1;
        temp = (power(x, y/2,m))%m;
        if (y%2 == 0)
        return ((temp%m)*temp);
        else
        return ((x*temp%m)*temp%m)%m;
        }
        int inv(int x)
        {
        return (power(x,modulo-2,modulo))%modulo;
        }
        bool comp(int a,int b)
        {
            return a>b;
        }
        ///Solution created by:Ahmadsm2005
        int32_t main()
        {
            //freopen("output.txt","w", stdout);
            //freopen("input0.txt","r", stdin);
            iostream::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
            vector<bool>lolz;
            string s;
            cin>>s;
            for(int i=0;i<s.size();i++){
            if(s[i]=='0')
            lolz.push_back(0);
            else if(s[i]=='1')
            lolz.push_back(1);
            else if(s[i]=='B'&&lolz.size())
            lolz.pop_back();
            }
            for(int i=0;i<lolz.size();i++){
            cout<<lolz[i];
            }
            return 0;
        }


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
p = LIST()

acc = [0]*N
for i in range(N):
	acc[i] = (p[i]+1)/2

acc = list(accumulate([0]+acc))
ans = 0
for i in range(N-K+1):
	ans = max(ans, acc[i+K]-acc[i])
print(ans)


Measured memory_bytes: 27912
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<queue>
#include<utility>
#include<climits>
#include<algorithm>
using namespace std;

#define BLACK '#'
#define WHITE '.'

int main(void)
{
	int H, W;
	cin >> H >> W;

	int cnt = 0;
	vector<string> s(H+2, string(W+2, BLACK));
	for(int i=1; i<=H; i++)
		for(int j=1; j<=W; j++){
			cin >> s[i][j];
			if(s[i][j] == WHITE)
				cnt++;
		}

	const int dx[4] = {0, 1, 0, -1};
	const int dy[4] = {1, 0, -1, 0};
	vector<vector<int>> stage(H+2, vector<int>(W+2, INT_MAX));
	queue<pair<int, int>> task;
	
	task.emplace(1, 1);
	stage[1][1] = 1;
	while(task.empty() != true){
		auto p = task.front();
		task.pop();

		int x = p.first;
		int y = p.second;

		for(int i=0; i<4; i++){
			int xx = x + dx[i];
			int yy = y + dy[i];

			if(s[yy][xx] == BLACK)
				continue;
			if(stage[yy][xx] != INT_MAX)
				continue;

			stage[yy][xx] = stage[y][x] + 1;
			task.emplace(xx, yy);
		}
	}

	if(stage[H][W] == INT_MAX){
		cout << -1 << endl;
		return 0;
	}

	//int cnt = 0;
	//for(int i=1; i<=H; i++)
	//	cnt += count(s[i].begin(), s[i].end(), WHITE);
	
	cout << cnt - stage[H][W] << endl;

	return 0;
}


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

int main() {
 string s;
  cin >> s;
  
  if ( s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int long long i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

const i64 MAXN = 300005;

i64 n;
i64 a[MAXN];

i64 res(i64 i) {
    if (i == 1) {
        return 300000;
    }
    if (i == 2) {
        return 200000;
    }
    if (i == 3) {
        return 100000;
    }
    return 0;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    i64 x, y;
    cin >> x >> y;
    i64 R = 0;
    if (x == 1 && y == 1) {
        R = 400000;
    }

    R += res(x);
    R += res(y);

    cout << R << endl;

    return 0;
}

Measured memory_bytes: 256