akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  vector<string> s(n);
  map<string, ll> cnt;
  REP(i, n) {
    cin >> s[i];
    cnt[s[i]]++;
  }

  ll maxi = 0;
  FOREACH(x, cnt) { maxi = max(maxi, x.second); }
  vector<string> ans;
  FOREACH(x, cnt) {
    if (x.second == maxi) {
      ans.push_back(x.first);
    }
  }
  sort(ALL(ans));
  REP(i, SZ(ans)) { cout << ans[i] << endl; }
}

Measured memory_bytes: 28788
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    long H, W;
    scan(H, W);
    auto t = new char[][](H, W);
    foreach (i; 0 .. H)
        t[i] = sread().to!(char[]);

    foreach (size_t y; 0 .. H)
        foreach (size_t x; 0 .. W)
        {
            if (t[y][x] == '.')
            {
                long cnt;
                foreach (j; -1 .. 2)
                    foreach (k; -1 .. 2)
                        if (0 <= (y + j) && (y + j) < H && 0 <= (x + k) && (x + k) < W)
                        {
                            cnt += (t[y + j][x + k] == '#') ? 1 : 0;
                        }
                t[y][x] = cnt.text[0];
            }
        }

    foreach (row; t)
        row.text.writeln();
}


Measured memory_bytes: 380
#include <cstdio>
#include <cstdint>
#include <algorithm>

intmax_t gcd(intmax_t m, intmax_t n) {
  while (n) std::swap(m %= n, n);
  return m;
}

intmax_t lcm(intmax_t m, intmax_t n) {
  return m / gcd(m, n) * n;
}

int main() {
  int N;
  scanf("%d", &N);

  intmax_t res = 1;
  for (int i = 0; i < N; ++i) {
    intmax_t T;
    scanf("%jd", &T);
    res = lcm(res, T);
  }
  printf("%jd\n", res);
}

Measured memory_bytes: 256
#include <stdio.h>
#define LIMIT_NUM 1000000000000000000ULL

int main(void) {
    int N;
    unsigned long long result = 1;

    scanf("%d", &N);
    unsigned long long A[N];

    for (int i = 0; i < N; i++) {
        scanf("%llu", &A[i]);
    }

    // 0が存在する場合
    for (int i = 0; i < N; i++) {
        if (A[i] == 0) {
            printf("0\n");
            return 0;
        }
    }

    for (int i = 0; i < N; i++) {
        // A*result>10^18 -> A>10^18/result
        if (A[i] > LIMIT_NUM / result) {
            printf("-1\n");
            return 0;
        }
        result *= A[i];
    }

    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 2912
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    int h,w;
    cin>>h>>w;
    int sc=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            char c;
            cin>>c;
            if(c=='#'){
                sc++;
            }
        }
    }
    if(sc==h+w-1){
        cout<<"Possible"<<endl;
    }else{
        cout<<"Impossible"<<endl;
    }
}

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

int main(){
    int N,A,B,sum=0,num,add=0,i;
    cin >> N >> A >> B;
    for(i=1;i<=N;i++){
        num = i;
        while(num>0){
            add += num % 10;
            num /= 10;
        }
        if(A<=add&&add<=B){
            sum += i;
        }
        add = 0;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P,L;
string S,T;
ll ans;
ll x[101010];
ll y[101010];
ll a[101010];
ll b[101010];
ll c[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
ll tmp[101010];
int main() {
	cin>>N;
	string A,B,C;
	cin>>A>>B>>C;
	ans=0;
	rep(i,0,N){
		if(A[i]==B[i] && A[i]==C[i]){

		}
		else if(A[i]==B[i] || A[i]==C[i] || B[i]==C[i]){
			ans+=1;
		}else{
			ans+=2;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
  int N ;
  cin >> N ;
  int t = N ;
  int c = 0 ;
  while(t > 0){
    c += t%10 ;
    t /= 10 ;
  }
  if(N % c == 0)
    cout << "Yes" << endl ;
  else
    cout << "No" <<endl ;
}

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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
ll k;
cin>>n>>k;
vector<int> a(n);
ll log_k=floor(log2f64x(k));
rep(i,n){
    cin>>a[i];
    a[i]--;
}
//ダブリング初期化
vector<vector<ll>> next(log_k+1,vector<ll>(n));
rep(i,n){
    next[0][i]=a[i];
}
rep(j,log_k){
    rep(i,n){
        next[j+1][i]=next[j][next[j][i]];
    }
}
ll p=0;
rep(b,log_k+1){
    if((k>>b)&1){
        p = next[b][p];
    }
}
cout<<p+1<<endl;
return 0;
}

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

using namespace std;

int main(){
    int n;
    double ans=0;
    cin>>n;
    rep(i,n){
        double a;
        string s;
        cin>>a>>s;
        if(s=="JPY"){
            ans+=a;
        }
        else{
            ans+=a*380000.0;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = 1+(int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n; cin >> n;
	ll ans = 0;
	int mn = inf;
	vi a(n), b(n);
	rep(i, n){
		cin >> a[i] >> b[i];
		if(a[i] > b[i]) mn = min(mn, b[i]);
		ans += a[i];
	}
	ans -= mn;
	if(mn == inf) ans = 0;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){  
  ll n, k;
  cin >> n >> k;
  vector<ll> a = vector<ll>(n);
  REP(i, n) cin >> a[i];

  //SORT(a, a+n);
  sort(a.begin(), a.end(), greater<ll>());

  ll t = 0LL;
  ll ans = n;
  REP(i, n){
    if(t+a[i]<k){
      t+=a[i];
    }
    else{
      ans=min(ans, n-i-1);
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    static long MOD = 1000000007;

    public static void main(String[] args) {

        //int ans=Integer.MAX_VALUE;
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long[] fact = new long[n+1];
        fact[0]=1;
        for(int i=1;i<n+1;i++){
            fact[i]=i*fact[i-1]%MOD;
        }
        System.out.println(fact[n]);
    }
}




Measured memory_bytes: 21716
/* author   : mpily :-()
title : Competing.cpp
time :Fri Aug 23 13:20:23 2019

*/
#include<bits/stdc++.h>
using namespace std;
class rational{
	public:
	unsigned long long numerator ,denominator;
	rational(unsigned long long a, unsigned long long b){
		numerator = a;
		denominator = b;
		while(__gcd(numerator,denominator) != 1){
			long long temp = __gcd(numerator,denominator);
			numerator/=temp;
			denominator/=temp;
		}
	}
	//double toDecimal() return numerator/denominator;
	rational operator -(rational b){
		rational c(this-> numerator * b.denominator - this -> denominator * b. numerator, this-> denominator * b.denominator);
		return c;
	}
	rational operator +(rational b){
		rational c(this-> numerator * b.denominator + this -> denominator * b. numerator, this-> denominator * b.denominator);
		return c;
	}
	rational reciporocal(){
		rational d(this-> denominator,this->numerator);
		return d;
	}
	
};
int main(){
	 int n;
	cin>>n;
	double sum = 0;	
	for(int i= 0; i < n; i++){
		double a; cin>>a;
		sum+=1/a;
	}
	sum = 1/sum;
	cout<<fixed;
	cout<<setprecision(12);
	cout<<sum;
}

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

int gcd(int m,int n) {
    if(n==0) {
        return m;
    }else{
        return gcd(n,m %n);
    }
}
int main() {
    int a,b,c;
    cin>>a>>b>>c;
    cout << (gcd(c,gcd(a,b))==gcd(a,b)? "YES":"NO") <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>

#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORN(i, a, b) for (int i = a; i <= b; i++)
#define P(s) cout << s << endl
#define PC(condition, _true, _false) if (condition) _true; else _false;
#define toInt(_char) _char - '0'

using namespace std;
//
// Created by karayuu on 2018-12-18.
//

int main() {
    while (true) {
        int n = 0;
        cin >> n;

        if (n == 0) break;

        int a[1001];
        FOR(i, 0, n) {
            cin >> a[i];
        }

        int dif = 999999999;

        FOR(i, 0, n) {
            FOR(j, i + 1, n) {
                dif = min(dif, abs(a[i] - a[j]));
            }
        }

        P(dif);
    }
}


Measured memory_bytes: 3068
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
signed main() {
	cin >> Q;
	int B = 0, c = 0, L = 0, R = 0, m = -1, Lc = 0, Rc = 0;
	multiset< int > s;
	multiset< int >::iterator it;
	while (Q--) {
		int q;
		cin >> q;
		if (q == 1) {
			int a, b;
			cin >> a >> b;
			B += b;
			s.insert(a);
			if (m == -1) {
				it = s.begin();
				m = a;
				L += a;
				Lc++;
			} else {
				if (m < a) {
					R += a;
					Rc++;
					if ((c & 1) == 0) {
						++it;
						m = *it;
						L += *it;
						Lc++;
						R -= *it;
						Rc--;
					}
				} else if (m > a) {
					L += a;
					Lc++;
					if ((c & 1) == 1) {
						R += *it;
						Rc++;
						L -= *it;
						Lc--;
						--it;
						m = *it;
					}
				} else {
					if ((c & 1) == 1) {
						R += a;
						Rc++;
					} else {
						L += a;
						Lc++;
						++it;
					}
				}
			}
			++c;
		} else {
			int ans = B;
			ans += m * Lc - L;
			ans += R - m * Rc;
			//cout << L << " " << Lc << " " << R << " " << Rc << endl;
			cout << m << " " << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>

// nが素数であれば1を、そうでなければ0を返す
int isprime(int n) {
	if(n < 2)
		return 0;
	int i;
	for(i = 2; i*i < n; i++)
		if(n%i == 0)
			return 0;
	return 1;
}

int main(void) {
	int x;
	scanf("%d", &x);
	while(1) {
		if(isprime(x)) {
			printf("%d\n", x);
			return 0;
		}
		x++;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)

double gain1(int y, int r){
	return 1.0+(double)y*(double)r/100.0;
}

double gain2(int y, int r){
	return pow(1.0+(double)r/100.0, (double)y);
}

int main(){
	int n;
	while( cin >> n, n ){
		double maxGain = 0.0;
		int y, maxNum = 0;
		cin >> y;
		rep(i,n){
			int b,t,r;
			cin >> b >> r >> t;
			double gain = (t==1 ? gain1(y,r) : gain2(y,r));
			if( maxGain < gain ){
				maxGain = gain;
				maxNum = b;
			}
		}
		cout << maxNum << endl;
	}
	return 0;
}

Measured memory_bytes: 1248
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

int main(void){
    int N;
    scanf("%d",&N);

    int* X;
    NEW(X,N);
    for(int i=0;i<N;i++){
        scanf("%d",&X[i]);
    }

    int* Y;
    NEW(Y,N);
    for(int i=0;i<N;i++) Y[i]=X[i];
    qsort(Y,N,sizeof(int),asc);

    for(int i=0;i<N;i++){
        if(X[i]>=Y[N/2]) printf("%d\n",Y[N/2-1]);
        else printf("%d\n",Y[N/2]);
    }

    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

ll N;

std::vector<ll> divisors(ll n){
    std::vector<ll> res;

    for(ll i=1;i*i<=n;++i){
        if(n % i == 0){
            res.emplace_back(i);
            if(i * i != n){
                res.emplace_back(n / i);
            }
        }
    }

    return res;
}

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

  std::cin >> N;

  if(N == 2){
      std::cout << 1 << std::endl;
      return 0;
  }

  std::vector<ll> v1 = std::move(divisors(N)), v2 = std::move(divisors(N - 1));
  int res = v2.size() - 1;

  for(ll n : v1){
      if(n == 1){
          continue;
      }

      ll m = N;
      
      while(m % n == 0){
          m /= n;
      }

      m %= n;

      if(m == 1){
          res += 1;
      }
  }

  std::cout << res << std::endl;
}


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

ll c[505], s[505], f[505];

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n; read(n);

  rep(i, 1, n) read(c[i], s[i], f[i]);

  rep(i, 1, n + 1) {
    ll ct = 0;
    rep(j, i, n) {
      chmax(ct, s[j]);
      if (ct % f[j]) ct += f[j] - ct % f[j];
      ct += c[j];
    }
    write(ct);
  }
}


Measured memory_bytes: 3648
h, w, s = gets.chomp.split(' ').map(&:to_i)
field = []
rows = []
black_count = 0
h.times do
  row = gets.chomp.split('')
  count_row = row.count('#')
  rows << count_row
  black_count += count_row
  field << row
end

cols = []
w.times do |i|
  count = 0
  h.times do |j|
    count += 1 if field[j][i] == '#'
  end
  cols << count
end

count = 0
(0...(1 << h)).each do |i|
  count_h = 0
  selected_h = []
  h.times do |j|
    if (i >> j) & 1 == 1
      count_h += rows[j]
      selected_h << j
    end
  end

  (0...(1 << w)).each do |k|
    count_w = 0
    selected_w = []
    w.times do |l|
      if (k >> l) & 1 == 1
        count_w += cols[l]
        selected_w << l
      end
    end
    overlap = 0
    selected_h.each do |hh|
      selected_w.each do |ww|
        overlap += 1 if field[hh][ww] == '#'
      end
    end
    count += 1 if black_count - (count_h + count_w - overlap) == s
  end
end
puts count

Measured memory_bytes: 14368
H, W = map(int,input().split())
A = [list(input()) for _ in range(H)]

dp = [[0] * (W+1) for _ in range(H+1)]

for i in range(1,H+1):
    for j in range(1,W+1):
        if i == 1 and j == 1:
            dp[i][j] = 1
        else:
            if A[i-1][j-1] == '.':
                dp[i][j] = dp[i-1][j] + dp[i][j-1]
            elif A[i-1][j-1] == '#':
                dp[i][j] = 0

print((dp[-1][-1])%(10**9+7))


Measured memory_bytes: 245340
#include <bits/stdc++.h>
#define uint unsigned long long
#define ll long long
#define db double
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-8
#define lb(x) x & -x
#define INF 0x3f3f3f3f
#define sz(x) (x).size()
using namespace std;
inline int read()
{
    int x = 0, f = 1; char ch = getchar();
    while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
    while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
    return x * f;
}
inline ll read1()
{
	ll x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
using namespace std;
int n, m;
int ch[110][110];
int a, b;
int main()
{
	a = read();
	b = read();
	rep(i, 1, 50)
		rep(j, 1, 100)
			ch[i][j] = 1, ch[i + 50][j] = 2;
	for(int i = 1; i <= 50; i += 2)
		for(int j = 1; j <= 100; j += 2)
			if(a > 1) a --, ch[i][j] = 2;

	for(int i = 52; i <= 100; i += 2)
		for(int j = 1; j <= 100; j += 2)
			if(b > 1) b --, ch[i][j] = 1;
    cout << 100 << " " << 100 << endl;
	rep(i, 1, 100)
	{
		rep(j, 1, 100)
			if(ch[i][j] == 2) putchar('.');
			else putchar('#');
		puts("");
	}


	return 0;
}


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

// 素数列を作る
// N: 上限
// v: 出力先
void GetPrimes(int N, vector<int> &v) {
	v = vector<int>();
    int c = 1;
    while (c < N) {
            c++;
            bool flag = true;
            int d = (int)sqrt(c);
            for(int i = 0; i < v.size(); i++) {
            	if(c % v[i] == 0) {
            		flag = false;
            		break;
            	}
            	if (d < v[i]) break;
            }
            if(flag) v.push_back(c);
    }
}

// 素因数分解を行う
// N: 対象
// p: 素数セット(GetPrimesで取得)
// v: 導かれた指数部
// [return]: 割り切れない場合の残り, 失敗すると-1を返す
int64_t Factorize(int64_t N, const vector<int> &p, vector<int> &v) {
	if(p.back() < sqrt(N)) return -1;
	for(int i = 0; N != 1 && i < p.size(); i++) {
		v.push_back(0);
		while(N % p[i] == 0) {
			N /= p[i];
			v[i]++;
		}
	}
	return N;
}

int64_t N, M, L, ans = 0;
vector<int> P;
vector<int> F;

void recursive(int k, int64_t n) {
    if(M < n * N) return;
    if(k == -1) {
        ans = max(n, ans);
        return;
    }
    int64_t tmp = 1;
    for(int i = 0; i <= F[k]; i++) {
        recursive(k - 1, n * tmp);
        tmp *= P[k];
    }
}

int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    cin >> N >> M;
    GetPrimes(100000, P);
    Factorize(M, P, F);
    L = F.size();
    recursive(L - 1, 1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<cmath>
#include<bitset>
#include<cassert>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast_io;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

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

    int res = ((n - 1) / x + 1) * t;
    cout << res << endl;

    return 0;
}

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

int main()
{
	int bor_money = 100000, n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		bor_money *= 1.05;

		if (0 < (bor_money % 1000)) {
			bor_money /= 1000;
			bor_money += 1;
			bor_money *= 1000;
		}
	}
	cout << bor_money << endl;
    return 0;
}

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

#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT_ON(bit, i) (((bit >> i) & 1) > 0)

typedef long long LL;
template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);}
template<typename T,typename... Ts> auto make_v(size_t a, Ts... ts){ return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}    // C++14
template<typename T,typename V> typename std::enable_if<std::is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename std::enable_if<std::is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
template<class T> inline T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> inline void print(T x) { std::cout << x << std::endl; }
template<class T> inline void print_vec(const std::vector<T> &v) { for (int i = 0; i < v.size(); ++i) {  if (i != 0) {std::cout << " ";} std::cout << v[i];} std::cout << "\n"; }
template<class T> inline bool inside(T y, T x, T H, T W) {return 0 <= y and y < H and 0 <= x and x < W; }
template<class T> inline double euclidean_distance(T y1, T x1, T y2, T x2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); }
template<class T> inline double manhattan_distance(T y1, T x1, T y2, T x2) { return abs(x1 - x2) + abs(y1 - y2); }
template<typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }

template<class T> inline std::vector<T> unique(std::vector<T> v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v;
}
// 初項s, 交差dのn個の数列の和
long long sum_of_arithmetic_progression(long long s, long long d, long long n) {
    return n * (2 * s + (n - 1) * d) / 2;
}

// 2のべき乗数かどうか
bool is_power_of_two(long long x) {
    return !(x & (x - 1));
}

const int INF = 1 << 30;
const double EPS = 1e-9;
const long double PI = acos(-1.0);
const std::vector<int> dy2 = {0, 1}, dx2 = {1, 0};  // 右，下
const std::vector<int> dy4 = {0, -1, 0, 1}, dx4 = {1, 0, -1, 0};    // 右，上，左，下
const std::vector<int> dy8 = { 0, -1, 0, 1, 1, -1, -1, 1 }, dx8 = { 1, 0, -1, 0, 1, 1, -1, -1 };


using namespace std;

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

    int N;
    cin >> N;
    LL total = 0;
    int p = 0, n = 0;
    LL mini = INF;
    FOR(i, 0, N) {
        LL a;
        cin >> a;

        if (a > 0) {
            p++;
        }
        if (a < 0) {
            n++;
        }
        total += abs(a);
        chmin(mini, abs(a));
    }

    if (n % 2 == 0) {
        print(total);
    }
    else {
        print(total - 2 * mini);
    }

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
vector<int> h;
long long t[10000001];
long long maxquery(int index,int lb,int rb,int lq,int rq)
{
    if((lb==lq&&rb==rq)||lb==rb)
    {
	return t[index];
    }
    int mid=(lb+rb)/2;
    long long ret=0;
    if(rq<=mid)
    {
	ret=max(ret,maxquery(index*2,lb,mid,lq,rq));
    }
    else if(lq>mid)
    {
	ret=max(ret,maxquery(index*2+1,mid+1,rb,lq,rq));
    }
    else
    {
	ret=max(ret,maxquery(index*2,lb,mid,lq,mid));
	ret=max(ret,maxquery(index*2+1,mid+1,rb,mid+1,rq));
    }
    return ret;
}
void update(int index,int lb,int rb,int leaf,long long value)
{
    if(lb==rb&&lb==leaf)
    {
	t[index]=max(t[index],value);
	return;
    }
    int mid=(lb+rb)/2;
    if(leaf<=mid)
    {
	update(index*2,lb,mid,leaf,value);
	t[index]=max(t[index],t[index*2]);
    }
    else
    {
	update(index*2+1,mid+1,rb,leaf,value);
	t[index]=max(t[index],t[index*2+1]);
    }
}
int main()
{
    int n;
    int i,a;
    long long tmp;
    scanf("%d",&n);
    h.resize(n+1);
    for(i=1;i<=n;i++)
    {
	scanf("%d",&h[i]);
    }
    for(i=1;i<=n;i++)
    {
	scanf("%d",&a);
	tmp=maxquery(1,1,n,1,h[i]-1);
     	update(1,1,n,h[i],tmp+a);
    }
    printf("%lld\n",t[1]);
    return 0;
}

Measured memory_bytes: 7296
/**
 *   
 *   Date: 22 December 2019
 *   Time: 17:56:47
**/
#pragma GCC optimize("O3")
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cmath>
#include <cstring>
#include<queue>
#include<stack>
#include<climits>
#include<iomanip>
#define endl "\n"
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pi;
typedef vector<ll> vec;
typedef vector<vector<ll> > matrix;
ll const mod=1000000007;

int main(){
	ios_base::sync_with_stdio(false); 
	cin.tie(NULL);
	ll a,b,d,d1;
	cin>>a>>b;
	d=__gcd(a,b);
	d1=(a*b)/d;
	cout<<d1<<endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    while(true) {
        // input
        int n, x;
        cin >> n >> x;
        if(n == 0 && x == 0) {
            break;
        }

        // calc
        int count = 0;
        int i, ii, iii = 0;
        for(i=1; i <= n; i++) {
            //cout << "i: " << i << endl;
            for(ii = i + 1; (ii > i && ii <= n); ii++) {
                //cout << "ii: " << ii << endl;
                for(iii = ii + 1; (iii > ii && iii <= n); iii++) {
                    //cout << "iii: " << iii << endl;
                    if( i + ii + iii == x ) {
                        count += 1;
                    }
                }
            }
        }

        // output
        cout << count << endl;
    }
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n;
    cin >> n;
    int p = 1;
    int a;
    int ans = 0;
    REP(i, n) {
        cin >> a;
        if (a == p) {
            p++;
        } else {
            ans++;
        }
    }
    cout << (n == ans ? -1 : ans) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,tes,t;
string s,h;
char ch;
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>ch;
	if(ch>='a'&&ch<='z'){
		cout<<"a";
	}else{
		cout<<"A";
	}
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  int a, b, ans;
  cin >> a >> b;
  if (a==1 && b==1) {
    ans=1;
  }
  else {
    if (a>=b) {
      ans=b;
      for (int i=1; i<a; i++) {
        ans=ans*10+b;
      }
    }
    else {
      ans=a;
      for (int j=1; j<b; j++) {
        ans=ans*10+a;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;

struct R{
    int s , e , x;
};
const int N = 2e5 + 4;
int n , q;
multiset<int> in[N] , out[N];
int f[N];


int main(){

    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    cin >> n >> q;
    vector<R> a(n);
    for(int i = 0 ; i < n ; ++i){
        cin >> a[i].s >> a[i].e >> a[i].x;
    }

    vector<int> p(q);
    for(int &x : p)
        cin >> x;

    for(int i = 0 ; i < n ; ++i){
        int f1 = a[i].s - a[i].x;
        int f2 = a[i].e - a[i].x;

        auto it1 = lower_bound(all(p) , f1);
        auto it2 = lower_bound(all(p) , f2);

        if(it1 == it2)continue;
        in[it1 - p.begin()].insert(a[i].x);
        out[it2 - p.begin()].insert(a[i].x);
    }

    multiset<int> s;
    for(int i = 0 ; i < q ; ++i){
        for(int x : out[i])
            s.erase(s.find(x));
        for(int x : in[i])
            s.insert(x);

        f[i] = (s.empty() ? -1 : *s.begin());
    }

    for(int i = 0 ; i < q ; ++i)
        cout << f[i] << "\n";
}


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

#define mp make_pair
#define pb push_back

using namespace std;

int n, k, a[345678], m;

int main(){
	scanf("%d%d",&k,&n);
	if (k % 2 == 0){
		printf("%d", (k + 1) / 2);
		for(int i = 1; i < n; ++i) printf(" %d", k);
	}
	else{
		for(int i = 1; i <= n; ++i) a[i] = (k + 1) / 2;
		m = n;
		for(int i = 1; i <= n / 2; ++i){
			--a[m];
			if (a[m] == 0) --m;
			else while (m < n) a[++m] = k;
		}
		for(int i = 1; i <= m; ++i) printf("%d ", a[i]);
	}
	return 0;
}

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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9
#define LINF (ll)4e18
#define MOD (ll)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

int main() {
    int n;
    cin >> n;

    bool same[n + 1] = {};

    int cnt = 0;

    rep2(i, n) {
        int a;
        cin >> a;
        if (a == i) {
            same[i] = true;
            cnt++;
        }
    }

    rep2(i, n - 1) {
        if (same[i] && same[i + 1]) {
            cnt--;
            same[i] = false;
            same[i + 1] = false;
        }
    }

    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 384
n = int(input())
value = [[0] * 3 for i in range(n)]
for j in range(n):
    value[j] = list(map(int,input().split()))

dp = [[0] * 3 for i in range(n + 1)]
for i in range(n):
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i + 1][j] = max(dp[i][k] + value[i][j], dp[i + 1][j])
print(max(dp[n]))


Measured memory_bytes: 50024
S1 = gets.chomp
T = gets.chomp
a = []
b = 0
i = 0

while b == 0 && i <= S1.size-T.size

    a[i] = 0

    for j in 0..T.size-1

        if S1[S1.size-T.size-i+j] != T[j] && S1[S1.size-T.size-i+j] != '?'

            a[i] += 1

        end

    end

    if a[i] == 0

        b += 1

    end

    i += 1

end

if b > 0

    for k in 0..S1.size-1

        if (k <= S1.size-T.size-i || S1.size-i+1 <= k) && S1[k] == '?'

            S1[k] = 'a'

        elsif S1.size-T.size-i < k && k < S1.size-i+1

            S1[k] = T[k-S1.size+T.size+i-1] 

        end

    end

    puts S1

else

    puts 'UNRESTORABLE'

end

Measured memory_bytes: 3836
#include <cstdio>
#include <algorithm>
using namespace std;

const int maxn = 25;
int a[maxn];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool flag = false;
        for (int j = i - 1; j >= 0; j--) {
            if (a[i] < a[j]) {
                flag = true;
                break;
            }
        }
        if (!flag) ans++;
    }
    printf("%d\n", ans);
    return 0;
}

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

int main() {
  int N ;
  cin >> N ;
  int a = N/2 ;
  int b = (N+1)/2 ;
  if(N%2==0){
  cout << a << endl;
}
  else{
    cout << b << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

struct UnionFind
{
    vector<int> par, size;
    UnionFind(int x)
    {
        par.resize(x);
        size.resize(x, 1);
        for (int i = 0; i < x; i++)
        {
            par[i] = i;
        }
    }
    int find(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    int consize(int x)
    {
        return size[find(x)];
    }
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y])
        {
            par[x] = y;
            size[y] += size[x];
        }
        else
        {
            par[y] = x;
            size[x] += size[y];
        }
    }
};

int main(){
    int n,m,k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    map <int,int>mp;

    rep(i,m){
        int a,b;
        cin >> a >> b;a--;b--;
        uf.unite(a,b);
        mp[a]++;
        mp[b]++;
    }

    map<int,int>mmp;

    rep(i,k){
        int c,d;
        cin >> c >> d;c--;d--;
        if(uf.same(c,d)){
            mmp[c]++;
            mmp[d]++;
        }
    }

    for(int i = 0; i < n; i++){
        int ans = uf.consize(i);
      //  cout << "uf.consize:" << ans << endl;
      //  cout << "mp[" << i << "]:" << mp[i] << endl;
        ans -= 1 + mp[i]; //自分自身を減らす
        //ここからどうブロック関係の人を減らすか(ブロック関係 && 同じグループに属している必要)
        ans -= mmp[i];
        cout << ans << " ";


    }



}

Measured memory_bytes: 13528
n = int(input())

l = [[0 for i in range(10)] for j in range(10)]
for i in range(1,n+1):
    a = str(i)
    l[int(a[:1])][int(a[-1:])] += 1

ans = 0
for i in range(1,10):
    for j in range(i,10):
        if i==j:    
            ans += l[i][j] * l[j][i]
        else:
            ans += 2 * l[i][j] * l[j][i]
print(ans)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main(){
	int a[5], k;
	for (int i = 0; i < 5; i++){
		cin >> a[i];
	}
	cin >> k;

	for (int i = 0; i < 5; i++){
		for (int j = i + 1; j < 5; j++){
			if(a[j] - a[i] > k){
				cout << ":(" << endl;
				return 0;
			}
		}
	}

	cout << "Yay!" << endl;
	return 0;
}


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

class Hello{

    public static void Main(){
    
        long[] h;
        long n;
        long k;
        
        var inpts = Console.ReadLine().Split(' ');
        n = long.Parse(inpts[0]);
        k = long.Parse(inpts[1]);
        //もし敵の数以上必殺技を使える場合は、すべてゼロ
        if(n <= k){
            Console.WriteLine("0");
            return;
        }
        h = new long[n];
        var second = Console.ReadLine().Split(' ');
        
        for(long i = 0;i < n;i++)
            h[i] = long.Parse(second[i]);
        
        List<Enemy> enemies = new List<Enemy>();
        
        for(long i = 0;i < n;i++){
            enemies.Add(new Enemy(i,h[i]));
        }
        var bigs = enemies.OrderByDescending(x=>x.hp).ToArray();
        for(long i = 0;i < k;i++){
            if(i >= n)
                break;
            h[bigs[i].index] = 0;
            
        }
        Console.WriteLine(h.Sum());
    }
    
    public class Enemy{
        public long index;
        public long hp;
        public Enemy(long index,long hp){
            this.index =index;
            this.hp = hp;
        }
        
    }
}

Measured memory_bytes: 48092
#include<bits/stdc++.h>
using namespace std;
/*-----------------------*/
#define FAST        ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define endl        "\n"
#define ff          first
#define ss          second
#define cc(x)       cout<<#x<<"="<<x<<" ";
#define CC(x)       for(auto xx: x) cout<<xx<<" ";
#define ee          cout<<"\n";
#define ll          long long
#define ull         unsigned long long
#define pii         pair<ll,ll>
#define mp          make_pair
#define all(x)      x.begin(),x.end()
#define ps(x)       push(x)
#define psb(x)      push_back(x)
#define psf(x)      push_front(x)
#define pp          pop()
#define ppb         pop_back()
#define ppf         pop_front()
#define OK          cout<<"Ok"<<"\n";
#define TESTS       ll test;cin>>test;for(ll   tcase=1;tcase<=test;tcase++)
/*------------------------*/
#define MAX int(1e5)
int dp[2][10000+9];
int value[1000+9],weight[1000+9];


int main()
{
    FAST
    int h,n;
    cin>>h>>n;
    int s=0;
    int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        s+=x;

    }
    if(s>=h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}


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

void run(void){
  char *s=(char *)calloc(100000+1,sizeof(char));
  scanf("%s",s);
  int n=strlen(s);
  if(n&1){
    puts("No");
    return;
  }
  for(int i=0;i<n-1-i;i++){
    int a=s[i];
    int b=s[n-1-i];
    int c=a^b;
    if(c!=('b'^'d') && c!=('p'^'q')){
      puts("No");
      return;
    }
  }
  puts("Yes");
}

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


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

int main()
{
	int X;
	cin >> X;

	auto IsPrime = []( int num )
	{
		if (num < 2) return false;
		else if (num == 2) return true;
		else if (num % 2 == 0) return false;
		for ( int i = 3; i * i <= num; i += 2 ) {
			if (num % i == 0) return false;
		}
		return true;
	};

	for( int x = X; ; x++ ) {
		if( IsPrime( x ) ) {
			cout << x << endl;
			break;
		}
	}
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

const int32_t inf = 1001001001;
const int64_t infll = 1001001001001001001ll;
const int dx[] = {0, -1, 1, 0, -1, 1, -1, 1}, dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

template <typename T> using vector2d = vector<vector<T>>;

// clang-format off
template <typename T> void sort(vector<T> &v) { sort(all(v)); }
ostream &operator<<(ostream &os, __int128_t value) { if (ostream::sentry(os)) { __uint128_t tmp = value < 0 ? -value : value; char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[tmp % 10]; tmp /= 10; } while (tmp != 0); if (value < 0) { --d; *d = '-'; } int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __int128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } if (in[0] == '-') value *= -1; return is; }
ostream &operator<<(ostream &os, __uint128_t value) { if (ostream::sentry(os)) { char buffer[64]; char *d = end(buffer); do { --d; *d = "0123456789"[value % 10]; value /= 10; } while (value != 0); int len = end(buffer) - d; if (os.rdbuf()->sputn(d, len) != len) { os.setstate(ios_base::badbit); }} return os; }
istream &operator>>(istream &is, __uint128_t &value) { string in; is >> in; value = 0; for (const char &c : in) { if ('0' <= c && c <= '9') value = 10 * value + (c - '0'); } return is; }
template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { os << v[0]; for (int i = 1; i < v.size(); ++i) os << " " << v[i]; return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.fs << " " << p.sc; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.fs >> p.sc; return is; }

struct IoSetup { IoSetup(){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); } } iosetup;

inline int64_t in() { int64_t x = 0; cin >> x; return x; }
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

signed main(int argc, char *argv[]) {
  int n = in();
  int ans = inf;
  for (int i = 0; i < n; ++i) {
    int a = in();
    int cnt = 0;
    while (a % 2 == 0) {
      a /= 2;
      cnt++;
    }

    chmin(ans, cnt);
  }

  cout << ans << endl;
}


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

int main()
{
	 string input;
 while(cin && getline(cin, input)){
  int a, b, c, d, e;
  istringstream is(input);
  is>>a>>b>>c>>d>>e;
  vector<int> buf;
  buf.push_back(a);
  buf.push_back(b);
  buf.push_back(c);
  buf.push_back(d);
  buf.push_back(e);
  sort(buf.begin(),buf.end());
  reverse(buf.begin(),buf.end());
  for(int i=0; i<buf.size(); i++){
   if(i!=0) cout<<" ";
   cout<<buf[i];
  }
  cout<<endl;
  break;
 }
}

Measured memory_bytes: 0