akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int blank_row(vector<vector<char>>& mat){
    for(int i = 0; i < mat.size(); i++){
	bool f = true;
	for(int j = 0; j < mat.at(i).size(); j++){
	    if(mat.at(i).at(j) != '.'){
		f = false;
	    }
	}
	if(f) return i;
    }
    return -1;
}

int blank_col(vector<vector<char>>& mat){
    for(int j = 0; j < mat.at(0).size(); j++){
	bool f = true;
	for(int i = 0; i < mat.size(); i++){
	    if(mat.at(i).at(j) != '.' && mat.at(i).at(j) != '*'){
		f = false;
	    }
	}
	if(f) return j;
    }
    return -1;
}

int main()
{

    int H, W;

    cin >> H >> W;

    vector<vector<char>> mat(H, vector<char>(W));

    for(int i = 0; i < H; i++){
	for(int j = 0; j < W; j++){
	    cin >> mat.at(i).at(j);
	}
    }

    int r;
    while((r = blank_row(mat)) >= 0){
	for(int i = 0; i < mat.at(r).size(); i++){
	    mat.at(r).at(i) = '*';
	}
    }
    while((r = blank_col(mat)) >= 0){
	for(int i = 0; i < mat.size(); i++){
	    mat.at(i).at(r) = '+';
	}
    }
    for(int i = 0; i < H; i++){
	bool f = false;
	for(int j = 0; j < W; j++){
	    if(mat.at(i).at(j) != '*' && mat.at(i).at(j) != '+'){
		f = true;
		cout << mat.at(i).at(j);
	    }
	}
	if(f) cout << endl;
    }
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, x, y int
	fmt.Scan(&a, &b, &c, &x, &y)

	ans := int(1e18)
	n := max(x, y)
	for i := 0; i <= n; i++ {
		ans = min(ans, c*2*i+max(0, (x-i)*a)+max(0, (y-i)*b))
	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

Measured memory_bytes: 512
// Author: HarshKumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll x, t = 0, a = 100;
    cin >> x;
    while (a < x)
        a *= (101.0 / 100), t++;
    cout << t;
}

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

// 誤差, 浮動小数点
int main() {
  long long A;
  string B;
  cin >> A >> B;

  long long BB = (B[0] - '0') * 100 + (B[2] - '0') * 10 + (B[3] - '0');

  cout << (A * BB / 100) << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
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; }
const long long INF = 1LL << 60;

int main() {
	long long N;
	cin >> N;
	vector<long long>P(N);

	for (long long i = 0; i < N; i++) {
		cin >> P.at(i);
	}
	long long min = P.at(0);
	long long res = 0;
	for (long long i = 0; i < N; ++i) {
		if (min >= P.at(i)) {
			min = P.at(i);
			++res;
		}
		else {
			continue;
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline int read()
{
	int x=0;char ch=getchar();
	while(ch<'0' || '9'<ch)ch=getchar();
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x;
}

#define mid ((l+r)>>1)
const int N=1e4+9;
const int Inf=1e9+7;

struct node
{
	int x,y;
}p[N];

struct pts
{
	int x,id;
	bool operator < (pts o)const
	{
		return x<o.x;
	}
}pt[N<<1];

int n,ans=0;
vector<int> g[N<<3];
int low[N<<1],pre[N<<1],scc[N<<1],scccnt,dfn;
int rp[N<<1],stk[N<<1],top,ptop;

inline void chkmin(int &a,int b){if(a>b)a=b;}
inline void chkmax(int &a,int b){if(a<b)a=b;}

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

inline void dfs(int u)
{
	low[u]=pre[u]=++dfn;
	stk[++top]=u;
	for(int i=0,e=g[u].size(),v;i<e;i++)
		if(!low[(v=g[u][i])])
		{
			dfs(v);
			chkmin(low[u],low[v]);
		}
		else if(!scc[v])
			chkmin(low[u],pre[v]);
	if(low[u]==pre[u])
	{
		scccnt++;
		do
			scc[stk[top]]=scccnt;
		while(stk[top--]!=u);
	}
}	

inline void build(int x,int l,int r)
{
	if(l==r)
		return;
	build(x<<1,l,mid);
	build(x<<1|1,mid+1,r);
	add((x<<1)+ptop,x+ptop);
	add((x<<1|1)+ptop,x+ptop);
}

inline void adds(int x,int l,int r,int dl,int dr,int id)
{
	if(dl==l && r==dr)
	{
		add(id,x+ptop);
		return;
	}
	if(dr<=mid)
		adds(x<<1,l,mid,dl,dr,id);
	else if(mid<dl)
		adds(x<<1|1,mid+1,r,dl,dr,id);
	else
	{
		adds(x<<1,l,mid,dl,mid,id);
		adds(x<<1|1,mid+1,r,mid+1,dr,id);
	}
}

inline bool judge(int k)
{
	dfn=scccnt=0;
	for(int i=0;i<ptop;i++)
		g[i].clear();
	memset(low,0,sizeof(low));
	memset(scc,0,sizeof(scc));

	//build(1,1,ptop);
	//for(int i=0;i<ptop;i++)
	//	adds(1,1,ptop,pt[i].x-k,pt[i].x,pt[i].id);

	
	for(int i=0;i<ptop;i++)
	{
		for(int j=i-1,cnt=1;~j && pt[j].x+k>pt[i].x && cnt<=25;j--,cnt++)
		{
			add(pt[i].id,pt[j].id^1);
			add(pt[j].id,pt[i].id^1);
		}
	}
	

	for(int i=0;i<ptop;i++)
		if(!low[i])
			dfs(i);
	for(int i=0;i<n;i++)
		if(scc[i<<1]==scc[i<<1|1])
			return false;
	return true;
}

int main()
{
	n=read();
	int l=0,r=0,mids,ans=0;
	for(int i=0;i<n;i++)
	{
		p[i].x=read();
		p[i].y=read();
		if(p[i].x>p[i].y)swap(p[i].x,p[i].y);
		chkmax(r,p[i].y);
		pt[i<<1].x=p[i].x;pt[i<<1].id=i<<1;
		pt[i<<1|1].x=p[i].y;pt[i<<1|1].id=i<<1|1;
	}
	ptop=n*2;
	sort(pt,pt+ptop);
	while(l<=r)
	{
		mids=l+r>>1;
		if(judge(mids))
			ans=mids,l=mids+1;
		else
			r=mids-1;
	}

	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 8704
N = int(input())
A = sorted(list(map(int,input().split())),reverse=True)
if A[0]==A[-1] and (A[0]==1 or A[0]==N-1):
    print("Yes")
else:
    k = A[0]
    cnt = A.count(k-1)
    n = N-cnt
    k -= cnt
    if k<=0:
        print("No")
    else:
        n -= 2*k
        if n>=0:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 52292
#include <iostream>
#include <vector>
#include <algorithm>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;

ll get_group(vector<ll> &uni, ll g) {
	if(uni[g]==0LL) return g;
	ll _g = get_group(uni,uni[g]);
	uni[g] = _g;
	return _g;
}

ll get_count(vector<ll> &uni, vector<ll> &count, ll g) {
	if(uni[g]==0LL) return count[g];
	return get_count(uni,count,uni[g]);
}

ll merge(vector<ll> &uni, vector<ll> &count, ll a, ll b) {
	ll ag = get_group(uni,a);
	ll bg = get_group(uni,b);
	if(ag==bg) return 0LL;
	ll ac = get_count(uni,count,a);
	ll bc = get_count(uni,count,b);
	uni[ag] = bg;
	count[bg] = (ac+bc);
	return ac*bc;
}

int main() {
	ll n,m;
	cin >> n >> m;
	vector<pair<ll,ll> > brs(m);
	for(int i = 0; i < m; i++) {
		cin >> brs[i].first >> brs[i].second;
	}

	vector<ll> uni(n+1);
	vector<ll> count(n+1,1);

	vector<ll> ans(m);
	ans[m-1] = n*(n-1)/2;

	for(int i = m-1; i >= 1; i--) {
		ll a = brs[i].first;
		ll b = brs[i].second;
		ll add = merge(uni,count,a,b);
		ans[i-1] = ans[i] - add;
/*
			for(int i = 0; i < n+1; i++) {
				cout << uni[i] << "," << count[i] << endl;
			}
			cout << endl;
*/
	}

	for(int i = 0; i < m; i++) {
		cout << ans[i] << endl;
	}
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int main(){

    int N;cin>>N;
    int mx;
    int sum=0;
    for(int i=1;;i++){
        sum+=i;
        if(sum>=N){
            mx=i;
            break;
        }
    }
    for(int j=mx;N>0;j--){
        if(N-mx<0){
            cout<<N<<endl;
            break;
        }
        cout<<mx<<endl;
        N-=mx;
        mx--;
    }

    return 0;
}

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

using namespace std;

long long st[MAXN + 1];
int r[MAXN + 1];
int sol[MAXN + 1];

int main() {
  //  ifstream cin("A.in");
  //  ofstream cout("A.out");
    int i, n, l;
    long long len;
    ios::sync_with_stdio(false);
    cin >> n >> l;
    int sz = -1;
    int cnt = 0;
    for(i = 1; i <= n; i++) {
        cin >> len;
        while(sz >= 0 && st[sz] + len >= l) {
            len += st[sz];
            sol[++cnt] = r[sz];
            sz--;
        }
        st[++sz] = len;
        r[sz] = i;
    }
    if(sz == 0) {
        cout << "Possible" << endl;
        for(i = n - 1; i >= 1; i--)
            cout << sol[i] << endl;
    }
    else
        cout << "Impossible" << endl;
   // cin.close();
   // cout.close();
    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int x, a; cin >> x >> a;

	if (x < a) cout << 0 << endl;
	else       cout << 10 << endl;

	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

template<class T>
void remove_duplication(vector<T> &v){
    sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
}

void Main(){
    int N,K,Q; cin >> N >> K >> Q;
    VI A(N); REP(i,N) cin >> A[i];
    VI B(A); remove_duplication(B);

    int ans = INF;
    REP(i,(int)B.size()){
        int ptr = 0;
        VI q;
        while(ptr<N-K+1){
            if(A[ptr] < B[i]){
                ptr++;
                continue;
            }

            int l = ptr, r = l+1;
            while(r<N && A[r]>=B[i]) r++;

            if(r-l < K){
                ptr = r;
                continue;
            }

            VI cand;
            FOR(j,ptr,r) cand.push_back(A[j]);
            SORT(cand);
            REP(j,r-l-K+1) q.push_back(cand[j]);

            ptr = r;
        }

        if(q.size() < Q) break;
        SORT(q);
        chmin(ans, q[Q-1] - q[0]);
    }

    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		double r = scanner.nextDouble();
		System.out.println(String.format("%.5f", Math.pow(r, (double) 2) * Math.PI) + " " + String.format("%.5f", r * (double) 2 * Math.PI));
	}
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, T;
  cin >> N >> T;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  vector<int> X(N, -1);
  X[N - 1] = A[N - 1];
  for (int i = N - 2; i > -1; i--) {
    X[i] = max(X[i + 1], A[i]);
  }
  int mn = 0;
  for (int i = 0; i < N; i++) {
    mn = max(mn, X[i] - A[i]);
  }
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (mn == X[i] - A[i]) res++;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	

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

		int cnt = 0;

		int b = 0;
		int w = 0;
		for (int i = N-1; i>=0; i--) {
			if (S.charAt(i) == '#') {
				b++;
			}
			else
				w++;
			if (b >= w) {
				cnt += w;
				w = 0;
				b = 0;
				
			}
		}
		cnt += b;

		System.out.println(cnt);
	}
}	

Measured memory_bytes: 28336
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
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;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int n;

int main(){
    ll a,b,k;
    cin>>a>>b>>k;
    if(a+b<=k)
    cout<<"0 0"<<endl;
    else
        cout<<max(0LL,a-k)<<" "<<min(max({0LL,b-k+a}),b)<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> a(q), b(q);
    for (int i = 0; i < q; ++i) {
        scanf("%d %d", &a[i], &b[i]);
        a[i]--; b[i]--;
    }
    set<int> s;
    vector<int> v(n);
    iota(v.begin(),v.end(), 0);
    int cur = 0;
    s.emplace(0); s.emplace(1);
    for (int i = 0; i < q; ++i) {
        swap(v[a[i]], v[b[i]]);
        if(a[i] == cur || b[i] == cur) cur ^= a[i]^b[i];
        if(cur) s.emplace(v[cur-1]);
        if(cur != n-1) s.emplace(v[cur+1]);
    }
    cout << s.size() << "\n";
    return 0;
}

Measured memory_bytes: 1408
/* 計数ソート */
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int main()
{
  unsigned short *A, *B;
  int C[VMAX+1] = {0};
  int n, i;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for( i = 1; i<=n; i++ )
    scanf("%u", &A[i]);

  /* 計数ソートを用いて昇順にソート */
  
  for( i = 1; i<=n; i++ )        /* C[i]に i の出現数を記録 */
    C[ A[i] ]++;

  for( i = 1; i<=VMAX; i++ )
    C[i] += C[i-1];             /* C[i]に i 以下の数の出現数を記録 */

  for( i = n; i>=1; i-- )
    {
      B[ C[ A[i] ] ] = A[i];
      C[ A[i] ]--;
    }

  /* 結果を出力 */
  for( i = 1; i<=n; i++ )
    {
      printf("%u", B[i]);
      if( i != n )
	printf(" ");
    }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 9620
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n;
	int d, min, max;
	long long sum;

	scanf("%d%d", &n, &d);
	sum = min = max = d;
	while (--n > 0) {
		scanf("%d", &d);
		if (d < min) min = d;
		if (d > max) max = d;
		sum += d;
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}



Measured memory_bytes: 2104
module mod_union_find
  implicit none
  type union_find
    integer :: n = 0
    integer, pointer :: par(:), rnk(:), siz(:) => null()
  contains
    procedure :: init => inituf
    procedure :: release => releaseuf
    procedure :: find => find
    procedure :: same => same
    procedure :: unite => unite
    procedure :: size => size_of
  end type
  interface union_find
    module procedure :: newuf
  end interface union_find
contains
  function newuf(n) result(ret)
    integer, intent(in) :: n
    type(union_find) :: ret
    integer :: i
    ret%n = n
    allocate(ret%par(n),ret%rnk(n),ret%siz(n))
    ret%rnk = 0
    ret%siz = 1
    ret%par = [(i,i=1,n)]
  end
  subroutine inituf(this,n)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: n
    integer :: i
    if (this%n /= n) then
      if (this%n /= 0) deallocate(this%par,this%rnk,this%siz)
      allocate(this%par(n),this%rnk(n),this%siz(n))
    end if
    this%n = n
    this%rnk = 0
    this%siz = 1
    this%par = [(i,i=1,n)]
  end
  subroutine releaseuf(this)
    class(union_find), intent(inout) :: this
    if (this%n /= 0) deallocate(this%par,this%rnk,this%siz)
    this%n = 0
  end
  recursive function find(this,i) result(ret)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i
    integer :: ret
    if (this%par(i) /= i) this%par(i) = find(this,this%par(i))
    ret = this%par(i)
  end
  logical function same(this,i,j)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i, j
    same = find(this,i) == find(this,j)
  end
  subroutine unite(this,i,j)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i, j
    integer :: x, y
    x = find(this,i)
    y = find(this,j)
    if (x == y) return
    if (this%rnk(x) < this%rnk(y)) then
      this%par(x) = y
      this%siz(y) = this%siz(y)+this%siz(x)
    else
      this%par(y) = x
      this%siz(x) = this%siz(x)+this%siz(y)
      if (this%rnk(x) == this%rnk(y)) this%rnk(x) = this%rnk(x)+1
    end if
  end
  integer function size_of(this,i)
    class(union_find), intent(inout) :: this
    integer, intent(in) :: i
    size_of = this%siz(find(this,i))
  end
end module mod_union_find
program friends
  use mod_union_find
  implicit none
  integer :: n, m, a, b, x = 0, i
  type(union_find) :: uf
  read(*,*) n, m
  uf = union_find(n)
  do i = 1, m
    read(*,*) a, b
    call uf%unite(a, b)
  end do
  do i = 1, n
    x = max(x, uf%size(i))
  end do
  write(*,'(i0)') x
end program friends

Measured memory_bytes: 5656
#include <cstdio>
#include <iostream>
int SG(int a,int k)
{
	int x=a/k,b=a%k;
	if(!b) return x;
	int t=(b+x)/(x+1);
	return SG(a-t*(x+1),k);
}
int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int a,k;
		scanf("%d%d",&a,&k);
		ans^=SG(a,k);
	}
	puts(ans?"Takahashi":"Aoki");
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;

const int MAXN=1e5+5,MAXM=1e7+5;
int n,m,ans,s;
int he[MAXN],col[MAXN];
bool cannt[MAXN],vis[MAXN],flag;
struct line{int to,nex;}ed[MAXM<<1];

inline void addE(int u,int v)
{
	static int cnt=0;
	ed[++cnt]=(line){v,he[u]};
	he[u]=cnt;
}

void DFS(int u,int c)
{
	for(int i=he[u],v;i;i=ed[i].nex)
	{
		v=ed[i].to;
		if(!col[v]) col[v]=c,DFS(v,c^1);
		else
			if(col[v]!=col[u]) continue;
			else flag=true;
	}
}


int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;++i)
	{
		scanf("%d%d",&u,&v);
		addE(u,v),addE(v,u);
	}
	col[1]=1;
	DFS(1,0);
	if(flag) printf("%lld",(long long)n*(n-1)/2-m);
	else
	{
		long long cnt=0;
		for(int i=1;i<=n;++i)
			if(col[i]) ++cnt;
		printf("%lld",(long long)cnt*(n-cnt)-m);
	}
	return 0;
}

Measured memory_bytes: 8448
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

typedef pair<int,int> P;

bool cmp(P x,P y){
  if(x.first!=y.first)return x.first>y.first;
  return x.second < y.second;
}

int main(void){

  int n,m,in,p[101];
  
  while(cin >> n >> m,n|m){
    
    fill(p,p+m+1,0);
    
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
	cin >> in;
	p[j+1]+=in;
      }
    }

    vector<P>res;
    for(int i=1;i<=m;i++){
      res.push_back(make_pair(p[i],i));
    }

    sort(res.begin(),res.end(),cmp);

    for(int i=0;i<res.size();i++){
      cout << res[i].second;
      if(i<res.size()-1)cout <<" ";
      else cout << endl;
    }

  }
  
  return 0;
}

Measured memory_bytes: 1196
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <queue>
#include <stdarg.h>
#include <map>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#include <numeric>
#include <set>

#define ll long long

using namespace std;

void
solve() {
  ll x, n;
  cin>>x>>n;
  map<ll, bool> have;

  ll current;
  for (int i=0; i<n; i++) {
    cin>>current;
    have[current] = true;
  }

  for (int i=0; i<1000; i++) {
    if (!have[x-i]) {
      cout<<x-i<<endl;
      break;
    }
    else if (!have[x+i]) {
      cout<<x+i<<endl;
      break;
    }
  }
}

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

  int t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;
 
// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())
 
// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
 
// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);
 
// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl
 
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N; cin >> N;
    ll ans = 1;
    for(int i = 1; i <= N; i++) {
        ans = ans * i % MOD;
    }
    cout << ans << "\n";
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  cin >> s;
  if (s.size() == 1) {
    cout << 1 << '\n';
    return 0;
  }

  int ans = s.size(), n = s.size();
  for (int i = 0; i < s.size() - 1; ++i) {
    if (s[i] != s[i + 1]) {
      ans = min(ans, max(i + 1, n - i - 1));
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 512
function f(P,K,D)
	Q=Pair{Int,Int}[]
	while !isempty(P)
		(u,d)=pop!(P)
		if D[(u+1)%K+1]>d+1
			D[(u+1)%K+1]=d+1
			push!(Q,(u+1)%K=>d+1)
		end
		if D[u*10%K+1]>d
			D[u*10%K+1]=d
			push!(P,u*10%K=>d)
		end
	end
	Q
end
function main()
	K=parse(Int,readline())
	P=Pair{Int,Int}[1=>1]
	D=Int[1145141919 for _=0:K]
	D[2]=1
	while !isempty(P)
		P=f(P,K,D)
	end
	println(D[1])
end
main()


Measured memory_bytes: 115196
#include<stdio.h>
int main(void)
{
 
    int a,b,c;
    int d=0;
    int ans=0;
    scanf("%d",&a);
//    if(a<105)
//    {
//       printf("0");return 0;
//    }

    for(b=105; b<=a; b+=2)
    {
        for(c=1;c<=b;c++)
        {
            if(b%c==0)
               { d++;}
        }

        if(d==8)
           { ans++;}
        d=0;
    }
    printf("%d",ans);
return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    char c;
    while(cin>>a>>c>>b)
    {
        if(c=='+') cout<<a+b<<endl;
        else if(c=='-') cout<<a-b<<endl;
        else if(c=='*') cout<<a*b<<endl;
        else if(c=='/') cout<<a/b<<endl;
        else if(c=='?') continue;
    }
    return 0;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
main()
{
    long long  a,b,c,x,y,z,d,m1,m2,m3;
    cin>>a>>b>>c>>x>>y;
    z=min(x,y);
    if(x>y)d=(x-y)*a;
    else d=(y-x)*b;
    m2=d+(z*2*c);
    m3=max(x,y)*2*c;

    m1=a*x + b*y;
    m1=min(m1,m2);
    m1=min(m1,m3);
    cout<<m1<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int 			long long int
#define ld 				long double
#define ff 				first
#define ss 				second
#define P 				pair<int,int>
#define pb 				push_back
#define mod             1000000007
#define inf             1e18
#define endl			'\n'
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
const int N = 105;//change it when needed
const int K = 1e5 + 5; //change it when needed
int n, k;
int a[N];
int dp[N][K];
int f(int i, int krem) {
	if (i == 0) {
		return (a[i] >= krem ? 1 : 0);
	}

	int &ans = dp[i][krem];
	if (ans != -1)return ans;
	ans = f(i - 1, krem);
	if (krem != 0) {
		ans = (ans + f(i, krem - 1)) % mod;
		if (krem - a[i] - 1 >= 0) {
			ans = (mod + ans - f(i - 1, krem - a[i] - 1)) % mod;
		}
	}
	return (ans);
}
void solve() {
	cin >> n >> k;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	if (sum < k) {
		cout << 0 << endl;
	}
	else {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < K; j++) {
				dp[i][j] = -1;
			}
		}
		cout << f(n - 1, k) << endl;
	}
}

int32_t main()
{
	ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	// int t; cin >> t; while (t--)
	solve();
	return 0;
}

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

int main ()
{
    int n, m;
    while (cin >> n >> m, n || m) {
        int MAX = 0;
        int d = 0;
        vector<int> v((int)(100 / m) + 1, 0);
        for (int i = 0; i < n; i++) {
            int num = 0;
            cin >> num;
            v[num / m]++;
            MAX = max(MAX, num / m);
            d = max(d, v[num / m]);
        }

        double res = 0;
        for (int i = 0; i < MAX; i++) {
            res += ((double)(v[i]) / d) * ((double)(MAX - i) / MAX);
        }

        res += 0.01;

        printf("%.8f\n", res);
    }

    return 0;
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{

    ll i,j,k,c,d,a,b,e,f,p,q,n,t,m,r,u,x,y;
    vector<ll > vv,ss,v,s;
    string st,et;
    map<ll,ll > pa,ea,ma;
    cin>>a;
    long double bb;
    bb  = 1;
    f  = 0;
    for(i=1;i<=a;i++){
        cin>>c;
        v.push_back(c);

    }
    sort(v.begin(),v.end());
    for(i=0;i<a;i++){
        bb = bb*v[i];
        if(bb>1000000000000000000){f=1;break;}
    }
    if(f==0){
        c = bb/1;
        cout<<c<<endl;
    }
    else cout<<-1<<endl;
}


Measured memory_bytes: 4320
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	s, _ := r.ReadString('\n')
	s = strings.TrimRight(s, " \t\n")
	slice := strings.Split(s, " ")
	a := string(slice[0])
	b := string(slice[1])
	A, _ := strconv.Atoi(a)
	B, _ := strconv.Atoi(b)

	if A > B {
		fmt.Println(A + A - 1)
	} else if A < B {
		fmt.Println(B + B - 1)
	} else {
		fmt.Println(A + B)
	}

}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int lPow2[202020], rPow2[202020];

int main(){
    
    // 1. 入力情報.
    int N;
    char X[202020];
    scanf("%d %s", &N, X);
    
    // 2. 1 の 個数 を カウント.
    int one = 0;
    rep(i, N) if(X[i] == '1') one++;
    
    // 3. 2 の べき乗 を popcount(X) - 1, popcount(X) + 1 で割った余り を 取得.
    int l = one - 1, r = one + 1;
    if(l > 0){
        lPow2[N - 1] = 1;
        repr(i, N - 2, 0) lPow2[i] = lPow2[i + 1] * 2 % l;
    }
    rPow2[N - 1] = 1;
    repr(i, N - 2, 0) rPow2[i] = rPow2[i + 1] * 2 % r;
    // printf("one=%d l=%d r=%d\n", one, l, r);
    
    // 4. X mod(popcount(X) - 1), X mod(popcount(X) + 1) を 計算.
    int lX = 0, rX = 0;
    repr(i, N - 1, 0){
        if(X[i] == '1'){
            if(l) lX = (lX + lPow2[i]) % l;
            rX = (rX + rPow2[i]) % r;
        }
    }
    // printf("lX=%d rX=%d\n", lX, rX);
    // rep(i, N) printf("%d ", lPow2[i]);
    // puts("");
    // rep(i, N) printf("%d ", rPow2[i]);
    // puts("");
    
    // 5. f(X[i]) を 出力.
    rep(i, N){
        if(X[i] == '1'){
            // X mod(popcount(X) - 1) で 考える.
            // 2 の (N - 1 - i)乗 を 減算.
            int x = lX, ans = 1;
            if(one > 2){
                // 初回.
                x -= lPow2[i];
                if(x < 0) x += l;
                // printf("5-1. x=%d ans=%d\n", x, ans);
                
                // 2回目以降.
                int nPopcount = 0;
                while(1){
                    if(x > 0){
                        nPopcount = __builtin_popcount(x);
                        x %= nPopcount;
                        ans++;
                        // printf("5-2. x=%d nPopcount=%d ans=%d\n", x, nPopcount, ans);
                    }else{
                        break;
                    }
                }
                printf("%d\n", ans);
            }else if(one == 2){
                puts("1");
            }else{
                puts("0");
            }
        }else{
            // X mod(popcount(X) + 1) で 考える.
            // 2 の (N - 1 - i)乗 を 加算.
            int x = rX, ans = 1;
            
            // 初回.
            x += rPow2[i];
            x %= r;
            // printf("5-3. x=%d ans=%d\n", x, ans);
            
            // 2回目以降.
            int nPopcount = 0;
            while(1){
                if(x > 0){
                    nPopcount = __builtin_popcount(x);
                    x %= nPopcount;
                    ans++;
                    // printf("5-4. x=%d nPopcount=%d ans=%d\n", x, nPopcount, ans);
                }else{
                    break;
                }
            }
            printf("%d\n", ans);
        }
    }
    return 0;
    
}

Measured memory_bytes: 5428
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
#include <climits>
#include <cstdio>
#include <list>
#include <iomanip>
using namespace std;

#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define si second
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define AS 200001
#define mod 1000000007
vector<int>graph[100001];
int dp[100001]; //dp[i] =len of longest path starting at node i
int solve(int src) {
	if (dp[src] != -1) {
		return dp[src];
	}
	bool leaf = 1;
	int bestChild = 0;
	for (int child : graph[src]) {
		leaf = 0;
		bestChild = max(solve(child), bestChild);
	}
	return dp[src] = leaf ? 0 : 1 + bestChild;
}
int main() {
	fastIO
	int n, m;
	cin >> n >> m;
	memset(dp, -1, sizeof dp);
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		graph[u].push_back(v);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++ ) {
		ans = max(ans, solve(i));
	}
	cout << ans << endl;
}

Measured memory_bytes: 8192
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Project1
{
    class Class1
    {
        static bool[] used;
        static int[,] dp;
        static void Main()
        {
            String input;
            dp = new int[331, 11];
            used = new bool[10];
            permutation(10, 0, 0);
            while ((input = Console.ReadLine()) != null)
            {
                String[] tmp = input.Split(' ');
                int n = int.Parse(tmp[0]);
                int s = int.Parse(tmp[1]);
                if (s > 330 || n>10)
                {
                     Console.WriteLine(0);
                }
                else
                {
                    Console.WriteLine(dp[s, n]);
                }
            }
        }
        static void permutation(int n, int pos, int sum)
        {

            dp[sum, pos]++;
            if (n == pos)
            {
                return;
            }
            for (int i = 0; i < 10; i++)
            {
                if (used[i]) continue;
                used[i] = true;
                permutation(n, pos + 1, sum + (pos + 1) * i);
                used[i] = false;
            }
            return;
        }
    }
}

Measured memory_bytes: 5648
#include<iostream>
#include<vector>
#include<string>
#define rep(i,n) for (int i=0;i<n;i++)
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;


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





Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1

print(ans)

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

#define loop(i, n) for(int i = 0; i < n; i++)
#define sloop(i, s, n) for (int i = s; i < n; i++)
#define rloop(i, n) for (int i = n - 1; i >= 0; i--)

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    int mx = INT_MIN;
    loop(mid, n) {
        int count = 0;
        set<char> s1, s2;
        loop(i, mid) {
            s1.insert(s[i]);
        }
        sloop(i, mid, n) {
            if(s1.find(s[i]) != s1.end() && s2.find(s[i]) == s2.end()) {
                count++;
                s2.insert(s[i]);
            }
        }
        mx = max(mx, count);
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 3616
def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    T = int(buflist[1])
    buf = input()
    buflist = buf.split()
    A = list(map(int, buflist))
    min_price = A[0]
    max_price_diff = 0
    max_diff_count = 0
    for i in range(1, N):
        if A[i] < min_price:
            min_price = A[i]
        elif A[i] - min_price > max_price_diff:
            max_price_diff = A[i] - min_price
            max_diff_count = 1
        elif A[i] - min_price == max_price_diff:
            max_diff_count += 1
    print(max_diff_count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15196
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
at=0
bt=0
al=[0]*(n+1)
bl=[0]*(m+1)
for i in range(n):
  at=at+a[i]
  al[i+1]=at
for j in range(m):
  bt=bt+b[j]
  bl[j+1]=bt
ans=0
t=m
i=0
while i<n+1:
  if al[i]+bl[t]<=k:
    ans=max(ans,i+t)
    i=i+1
  else:
    t=t-1
  if i==n+1 or t==-1:
    break
print(ans)
    


Measured memory_bytes: 47696
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1e9 + 7, N = 2e5 + 100;
int p[N], s[N], ans;
int find_set(int x) {
    return x == p[x] ? x : p[x] = find_set(p[x]);
}
void union_sets(int x, int y) {
    x = find_set(x);
    y = find_set(y);
    if(x == y) return;
    s[y] += s[x];
    s[x] = 0;
    p[x] = y;
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); 
    int n, m;
    cin >> n >> m;
    for(int i = 1; i <= n; ++i) p[i] = i, s[i] = 1;
    for(int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        union_sets(u, v);
    }
    for(int i = 1; i <= n; ++i) {
        ans = max(ans, s[i]);
    }
    cout << ans << endl;
}

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

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

int main(){
  int n;
  cin >> n;
  int ans;
  cin >> ans;
  for(int i=1;i<n;i++){
    int a;
    cin >> a;
    ans=gcd(ans,a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3588
using System;
namespace Sample
{
	class test
    {
    	static void Main()
        {
          	int ans = 0;
        	string[] a = Console.ReadLine().Split(' ');
        	int A = int.Parse(a[0]);
          	int B = int.Parse(a[1]);
          while(true)
          {
          		if(A>B)
              	{
					ans += A;
                  	A--;
                      if(A>B)
                      {
                          ans += A;
                       	  break;
                      }
                      if(A==B)
                      {
                          ans += A;
                      	  break;
                      }
              	}
              	if(B>A)
                {
					ans += B;
                  	B--;
                      if(A<B)
                      {
                          ans += B;
                      	  break;
                      }
                      if(A==B)
                      {
                          ans += B;
                      	  break;
                      }
                }
              	if(A==B)
                {
                	ans = A + B;
                  	break;
                }
      	  }
          Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<iostream>
using namespace std;
long long p[100][21]={0};
int a[100];
int main(){
int i,j,n;
cin>>n;
for(i=0;i<n;i++)cin>>a[i];
p[0][a[0]]=1;
for(i=0;i<n-1;i++){
for(j=0;j<=20;j++){
if(p[i][j]>0){
if(j+a[i+1]<=20)p[i+1][j+a[i+1]]=p[i+1][j+a[i+1]]+p[i][j];
if(j-a[i+1]>=0)p[i+1][j-a[i+1]]=p[i+1][j-a[i+1]]+p[i][j];
}
}
}
cout<<p[n-2][a[n-1]]<<endl;
return 0;
}

Measured memory_bytes: 3112
a,b=input().split()
c=int(a)
d=int(b)
e=[]
for i in range(c):
    e.append(i+1)
for j in range(d):
    f=int(input())
    g=input().split()
    h=[int(s) for s in g]
    for n in range(len(h)):
        if h[n] in e:
            e.remove(h[n])
print(len(e))

Measured memory_bytes: 9144
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <tuple>

//....................................................................................................................//

using std::cin;
using std::cout;
using std::vector;
using std::list;
using std::unordered_set;
using std::set;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::swap;
using std::stack;
using std::deque;
using std::queue;
using std::ios_base;
using std::ifstream;
using std::ofstream;
using std::string;
using std::tuple;
using std::make_tuple;
using std::get;
using std::upper_bound;
using std::lower_bound;
using std::max_element;
using std::min_element;
using std::multiset;
using std::greater;
using std::priority_queue;
using std::less;

//....................................................................................................................//

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

[[maybe_unused]] const string endl = "\n";
[[maybe_unused]] const string sep = " ";
[[maybe_unused]] const string yes = "YES\n";
[[maybe_unused]] const string no = "NO\n";
[[maybe_unused]] const string ng = "NG\n";
[[maybe_unused]] const string ok = "OK\n";
[[maybe_unused]] const double pi = acos(-1);
[[maybe_unused]] const ull modular = 998244353;

//....................................................................................................................//


int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout.precision(15);
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) {
        cout << s;
    } else {
        cout << s.substr(0, k) << "...";
    }
}


Measured memory_bytes: 3132
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
  
int main(){
 int A,B,C;
 cin>>A>>B>>C;
 if(A+B>=C){
     cout<<"Yes"<<endl;
 }
 else{
     cout<<"No"<<endl;
 }
}

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

int main(){
  int K,X,a,b;
  cin >> K >> X; 
  if(K != 1){
  	for(int i = 1;i <= K;i++){
    	a = X - K + i;
    	cout << a << " ";
  	}
  	for(int j = 1;j < K;j++){
    	b = X + j ;
    	cout << b << " ";
  	}
  }
  else
    cout << X;
  return 0;
}
  

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

typedef int32_t i32;
typedef int64_t i64;

static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

int cmp (const void *a, const void *b) {
  i32 d = *(i32 *)a - *(i32 *)b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

void run (void) {
  i32 n = read_int();
  i32 *a = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    a[i] = read_int() - i - 1;
  }
  qsort (a, n, sizeof (i32), cmp);
  i32 val = a[n / 2];
  i64 ans = 0;
  for (i32 i = 0; i < n; ++i) {
    i32 d = a[i] - val;
    ans += d > 0 ? d : -d;
  }
  printf ("%" PRIi64 "\n", ans);
}

int main (void) {
  run ();
  return 0;
}


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int INF = 1e9;
const int MOD = INF+7;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.rbegin(),v.rend()
#define MP make_pair
#define pb push_back
using P = pair<int,int>;
//c

int gcd(int n,int m){return m?gcd(m,n%m):n;}
int lcm(int n,int m){return n*m/gcd(n,m);} 

signed main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    cout << (B - B/C - B/D + B/lcm(C,D)) - (A - A/C - A/D + A/lcm(C,D)) + (!!(A%C) && !!(A%D)) << endl;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
a = [[0]*2 for i in range(N)]
for i in range(N):
    a[i][0],a[i][1] =  map(int,input().split())

a.sort()

s = 0
for i in range(N):
    s += a[i][1]
    if s >= K:
        print(a[i][0])
        break

Measured memory_bytes: 55172
/*
 * Write a program that reads one integer x, computes the cube of x, and outputs the result.
 */

using System;

namespace XCubic
{
    class XCubic
    {
        public void Run()
        {
            ReadX();
            Calc();
            ShowCubic();
        }

        private void ReadX()
        {
            string s = string.Empty;

            s = System.Console.ReadLine();

            x = int.Parse(s);
        }

        private void Calc()
        {
            cubic =  x * x * x;
        }

        private void ShowCubic()
        {
            System.Console.WriteLine(cubic);
        }

        // field
        private int x;
        private int cubic;
    }

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

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

using namespace std;

int calc_gcd(int a, int b) { return b == 0 ? a : calc_gcd(b, a % b); }

long long calc_lcm(int a, int b) { return (long long)a * b / calc_gcd(a, b); }

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  for (auto &a : A) {
    cin >> a;
    a /= 2;
  }
  long long lcm = A[0];
  for (int i = 1; i < N; i++) {
    lcm = calc_lcm(lcm, A[i]);
  }
  for (auto a : A) {
    if ((lcm / a) % 2 == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  int x = M / lcm;
  int ans = (x + 1) / 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        
        int ans=0;
        ans+=(int)(n/5) + (int)(n/25) + (int)(n/125) + (int)(n/625) + (int)(n/3125) + (int)(n/15625);
        cout<<ans<<endl;
    }

    return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-07-30 02:44:47 +0900
# LastModified: 2020-07-30 13:58:47 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, m = map(int, input().split())
    switch_list = []
    for _ in range(m):
        command = list(map(int, input().split()))
        _ = command[0]
        switch_list.append(command[1:])
    p = list(map(int, input().split()))
    ans = 0
    for i in range(1 << n):
        flag = 1
        for j, switch in enumerate(switch_list):
            cnt = 0
            for s in switch:
                if 1 & i >> (s-1):
                    cnt += 1
            if cnt % 2 != p[j]:
                flag = 0
                break
        if flag == 1:
            ans += 1

    print(ans)






if __name__ == "__main__":
    main()


Measured memory_bytes: 9116
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

internal static class CR
{
    public static string Get() { return Console.ReadLine(); }
    public static int GetInteger() { return int.Parse(Console.ReadLine()); }
    public static IEnumerable<int> GetIntegers() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)); }
}

namespace A
{
    internal class Program
    {
        public static int A { get; private set; }
        public static int B { get; private set; }

        private static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.WriteLine(r); }

        private static object GetResult()
        {
            A = CR.GetInteger();
            B = CR.GetInteger();
            
            return new int[] { 1, 2, 3 }.Where(x => x != A).Where(x => x != B).First();
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int N;
int A[1010][1010];
int nex[1010];


int main(){
  cin>>N;
  rep(i,N) rep(j,N-1){
    cin>>A[i][j];
    A[i][j]--;
  }
  
  int ans=0,fin=0;
  int par[N]; rep(i,N) par[i]=-1;
  queue<int> que; rep(i,N) que.push(i);
  while(fin<N){
    int siz=que.size();
    if(siz==0){
      cout<<-1<<endl;
      return 0;
    }
    while(siz--){
      int i=que.front(); que.pop();
      par[i]=A[i][nex[i]];
      int j=par[i];
      if(i==par[j]){
        nex[i]++,nex[j]++;
        if(nex[i]==N-1) fin++;
        else que.push(i);
        if(nex[j]==N-1) fin++;
        else que.push(j);
      }
    }
    ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4224
K,N = map(int,input().split())
A1 = list(map(int,input().split()))

D = [0] * (N)

A2 = [A1[i]+K for i in range(len(A1)-1)]
A1 = A1+A2

for i in range(N):
    D[i] = A1[i+N-1] - A1[i]
    #print(A1[i],A1[i+N-1])
print(min(D))

Measured memory_bytes: 36436
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){

   int a, b;
   cin >> a >> b;
   if(a % b == 0 || b % a == 0){cout<<a+b<<endl;}
   else{cout <<b - a<<endl;}

   return 0;
}

Measured memory_bytes: 256