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

#define INF 100000000
#define MOD9(a) (a%1000000009)
#define MOD7(a) (a%1000000007)
#define ABS(a) (a<0?-(a):a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define REP(i,a) for(int i=0;i<a;i++) 

using namespace std;
int main(){
  int K,S;
  cin >> K >> S;
  int count = 0;
  REP(i, K+1){
    for(int j = i; j < K+1; j++){
      for(int k = j;k < K+1; k++){
        if(i+j+k == S){
          if(i == j && j == k && i == k){
            count ++ ;
          }else if(i == j || j == k || i == k){
            count += 3;
          }else{
            count += 6;
          }
        }
      }
    }
  }
  cout << count << endl;

}



Measured memory_bytes: 256
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    N = int(inputs[0])
    S = inputs[1]
    half_1 = S[:N//2]
    half_2 = S[N//2:]
    if half_1 == half_2:
        return 'Yes'
    return 'No'


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)


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

int main(){
  int D,N;
  cin>>D>>N;
  if (D==0&&N==100){
    cout<<101<<endl;
  }else if(D==1&&N==100){
    cout<<10100<<endl;
  }else if(D==2&&N==100){
    cout<<1010000<<endl;
  }else{
    cout<<pow(100,D)*N<<endl;
  }
}


Measured memory_bytes: 3932
s=int(input())
a=[s]
i=0

def f(n):
  if n%2==0:
    return n//2
  else:
    return 3*n+1

while True:
  if f(a[i]) in a:
    print(i+2)
    break
  a.append(f(a[i]))
  i+=1

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

using namespace std;

static const int N = 100;

int main() {
    int n, p[N + 1], m[N + 1][N + 1];
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> p[i - 1] >> p[i];
    }

    for (int i = 1; i <= n; ++i) {
        m[i][i] = 0;
    }

    for (int l = 2; l <= n; ++l) {
        for (int i = 1; i <= n - l + 1; ++i) {
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for (int k = i; k <= j - 1; ++k) {
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}

Measured memory_bytes: 3120
/************
< 주소 >      :
*************
< 해결방안 >   :


*************
< 오답노트 >   :

*************/

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL_BOOKNU
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// ........................macro.......................... //
#define FOR(i, f, n) for(int (i) = (f); (i) < (int)(n); ++(i))
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (int)(n); --(i))
#define pb push_back
#define emb emplace_back
#define fi first
#define se second
#define ENDL '\n'
#define sz(A) (int)(A).size()
#define ALL(A) A.begin(), A.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())
#define next next9876
#define prev prev1234
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef long long i64;
typedef unsigned long long ui64;
// inline i64 GCD(i64 a, i64 b) { if(b == 0) return a; return GCD(b, a % b); }
inline int getidx(const vi& ar, int x) { return lower_bound(ALL(ar), x) - ar.begin(); } // 좌표 압축에 사용: 정렬된 ar에서 x의 idx를 찾음
inline i64 GCD(i64 a, i64 b) { i64 n; if(a < b) swap(a, b); while(b != 0) { n = a % b; a = b; b = n; } return a; }
inline i64 LCM(i64 a, i64 b) { if(a == 0 || b == 0) return GCD(a, b); return a / GCD(a, b) * b; }
inline i64 CEIL(i64 n, i64 d) { return n / d + (i64)(n % d != 0); } // 음수일 때 이상하게 작동할 수 있음.
inline i64 ROUND(i64 n, i64 d) { return n / d + (i64)((n % d) * 2 >= d); }
inline i64 POW(i64 a, i64 n) {
	assert(0 <= n);
	i64 ret;
	for(ret = 1; n; a = a*a, n /= 2) { if(n%2) ret *= a; }
	return ret;
}
template <class T> ostream& operator<<(ostream& os, vector<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class T> ostream& operator<<(ostream& os, set<T> v) {
	os << "[";
	int cnt = 0;
	for(auto vv : v) { os << vv; if(++cnt < v.size()) os << ","; }
	return os << "]";
}
template <class L, class R> ostream& operator<<(ostream& os, pair<L, R> p) { return os << "(" << p.fi << "," << p.se << ")"; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H, debug_out(T...); }
// ....................................................... //

i64 n, a, b, cur = 1;
void input() {
	cin >> n >> a >> b;
}

int solve() {
	// 일단 최소 n개는 맞추자
	i64 dis = min(n, a-1);
	n -= dis, cur += dis;
	// 홀수개 남으면 1개는 걍 올리자
	if(n%2) --n, ++cur;
	// 짝수개 남으면 바꿔서 이득이면 바꾸자
	if(n) {
		if(b-a > 2) {
			cur += (b-a) * (n/2);
		} else cur += n;
	}
	cout << cur << ENDL;
	return 0;
}

// ................. main .................. //
void execute() {
	input(), solve();
}

int main(void) {
#ifdef LOCAL_BOOKNU
	freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
#endif
	cin.tie(0), ios_base::sync_with_stdio(false);
	execute();
	return 0;
}
// ......................................... //

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
	int n,i,j,k,r=0,m[7000];
	scanf("%d",&n);
	for(i=3;i<=n;i++){
		if(i%3==0){m[r]=i;++r;}
		else{
			for(j=1;j<n;j*=10){
				k=i%(j*10);
				k/=j;
				if(k==3){
					m[r]=i;
					++r;
					break;
				}
			}
		}
	}
	for(i=0;i<r;i++)printf(" %d",m[i]);
	puts("");
	return 0;
}


Measured memory_bytes: 2024
#include <iostream>

using namespace std;

int main(){
	int a,b;
	cin>>a>>b;

	if(a<0&&b>0){
		cout<<"Zero"<<endl;
	}else if(a==0||b==0){
		cout<<"Zero"<<endl;
	}
	else if(a>0){
		cout<<"Positive"<<endl;
	}else{
		if((b-a)%2==0){
			cout<<"Negative"<<endl;
		}else{
			cout<<"Positive"<<endl;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll N,M,H,W,K,Q,A,B;

int main(){
    cin>>N; 
    vec x(N), ans(0), ord(N), oinv(N); 
    rep(i,N) cin>>x[i], --x[i], ord[i] = i; 
    sort(ALL(ord), [&](ll a, ll b){ 
      return x[a] < x[b]; 
    }); 
  rep(i,N) oinv[ord[i]] = i;
    rep(i,N) rep(j,ord[i]) ans.push_back(ord[i]);
    rep(i,N) { 
        ll num= ord[i], nx = x[num]; 
        if(nx > ans.size()){ 
          cout<<"No"<<endl; 
          return 0; 
        }else if(nx < ans.size()){
          ll tar = ans[nx]; 
          if(oinv[tar] <= i && nx < N*(N-1)/2 + i){ 
            cout<<"No"<<endl; 
            return 0; 
          }
      } 
      ans.insert(ans.begin() + nx, num); 
      rep(j, N-num-1) ans.push_back(num);
    } 
  cout<<"Yes"<<endl; 
  rep(i,N*N){ 
    cout<<ans[i] + 1; 
    i == N*N - 1 ? cout<<endl : cout<<' ';
  } 
}

Measured memory_bytes: 3448
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long n;
  cin >> n;
  for(int i=1;i<=n;i++){
    double is=(double)i;
    double jud=pow(is,2);
    if(jud>n){
      long long ans=(long long)pow(is-1,2);
      cout << ans << endl;
      break;
    }else if(jud==n){
      cout << n << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a>b){
        int t=a;a=b;b=t;
    }
    if(a>c){
        int t=a;a=c;c=t;
    }
    if(b>c){
        int t=b;b=c;c=t;
    }
    if(a+b==c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int n,k; cin >> n >> k;
	string s; cin >> s;
	int ans=0;
	for(int i=0;i<s.size()-1;i++){
		if(s[i]==s[i+1])ans++;
	}
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R'){
			while(i<s.size()&&s[i]=='R'){
				i++;
			}
			cnt++;
			i--;
		}
	}
	ans+=2*min(cnt,k);
	cout << min(n-1,ans) << endl;
}

Measured memory_bytes: 512
using System;
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int W, H, x, y, r;
            W = int.Parse(s[0]);
            H = int.Parse(s[1]);
            x = int.Parse(s[2]);
            y = int.Parse(s[3]);
            r = int.Parse(s[4]);
            if (W >= x + r && 0 <= x - r && H >= y + r && 0 <= y - r)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
    }

Measured memory_bytes: 19616
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<map>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;
typedef long long ll;

int main(){
   string s;
   int ans1 = 0, ans2 = 0;
   cin >> s;
   rep(i,s.size()){
      if(i % 2 == 0){
         if(s[i] != '0') ans1++;
         if(s[i] != '1') ans2++;
      }
      if(i % 2 == 1){
         if(s[i] != '1') ans1++;
         if(s[i] != '0') ans2++; 
      }
   }
   cout << min(ans1, ans2) << endl;
}

Measured memory_bytes: 512
S = gets.chomp

f = S[0..1].to_i
s = S[2..3].to_i

def isMonth(m)
  0 < m && m < 13
end

r = [isMonth(f), isMonth(s)]

ans = ""
case r
when [true, true] then
  ans = "AMBIGUOUS"
when [false, true] then
  ans = "YYMM"
when [true, false] then
  ans = "MMYY"
else
  ans = "NA"
end

printf("#{ans}") 


Measured memory_bytes: 1788
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author iavanish
 */
public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BHomework solver = new BHomework();
        solver.solve(1, in, out);
        out.close();
    }

    static class BHomework {

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();

            for (int i = 0; i < m; i++) {
                n -= in.nextInt();
            }

            out.println(0 <= n ? n : -1);
        }

    }

    static class FastReader {

        private final int BUFFER_SIZE = 1 << 16;
        private final InputStream inputStream;
        private final byte[] buffer;
        private int bufferPointer;
        private int bytesRead;

        public FastReader() {
            this.inputStream = new DataInputStream(System.in);
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(InputStream inputStream) {
            this.inputStream = inputStream;
            this.buffer = new byte[BUFFER_SIZE];
            this.bufferPointer = bytesRead = 0;
        }

        public FastReader(String fileName) {
            try {
                this.inputStream = new DataInputStream(new FileInputStream(fileName));
                this.buffer = new byte[BUFFER_SIZE];
                this.bufferPointer = bytesRead = 0;
            } catch (FileNotFoundException e) {
                throw new RuntimeException(e);
            }
        }

        public int nextInt() {
            int nextInt = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean negative = (c == '-');
            if (negative) {
                c = read();
            }
            do {
                nextInt = nextInt * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (negative) {
                return -nextInt;
            }
            return nextInt;
        }

        private void fillBuffer() {
            try {
                bytesRead = inputStream.read(buffer, bufferPointer = 0, BUFFER_SIZE);
                if (bytesRead == -1) {
                    buffer[0] = -1;
                }
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        private byte read() {
            if (bufferPointer == bytesRead) {
                fillBuffer();
            }
            return buffer[bufferPointer++];
        }

    }

}



Measured memory_bytes: 25984
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	int n,d[6]={};
	double h;
	cin>>n;
	rep(i,0,n){
		cin>>h;
		h-=165;
		if(h<0) d[0]++;
		else if(h<5) d[1]++;
		else if(h<10) d[2]++;
		else if(h<15) d[3]++;
		else if(h<20) d[4]++;
		else d[5]++;
	}
	rep(i,0,6){
		cout<<i+1<<":";
		rep(j,0,d[i]) cout<<"*";
		cout<<endl;
	}
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int N;
  cin >> N;
  vector<ll> a(3 * N);
  for (int i = 0; i < 3 * N; i++)
    cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  for (int i = N; i < 3 * N; i += 2)
    ans += a[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSR(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

int n,m;
int vec[200005];

struct maintain_interval{
	int bit[(1<<18)+5];
	void init(){
		memset(bit,0,sizeof(bit));
	}
	int f(int x)
	{
		return x&-x;
	}
	void add(int i,int x)
	{
		for(int s=i;s<=(1<<18);s+=f(s)) bit[s]+=x;
	}
	int sum(int i)
	{
		int res=0;
		for(int s=i;s>0;s-=f(s)) res+=bit[s];
		return res;
	}
}mt;

P forbid[200005][2];
bool ok[200005],ok2[200005];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<2*n;i++){
		scanf("%d",&vec[i]);
	}
	sort(vec,vec+2*n);
	
	int lb = -1,ub = m-1;
	while(ub-lb > 1){
		int mid = (lb+ub)/2;
		rep(i,200005) rep(j,2) forbid[i][j] = mp(0,0);
		for(int i=0;i<2*n;i++){
			//vec[i]と足してmod mでmidより大な区間
			for(int j=0;j<2;j++){
				//[mid+1+m*j,m*(j+1)-1]
				if(vec[i] <= mid+1 && j == 1) break;
				int L = mid+1+m*j-vec[i];
				int R = m*(j+1)-1-vec[i];
				L = lower_bound(vec,vec+2*n,L)-vec;
				if(j == 0){
					R = upper_bound(vec,vec+2*n,R)-vec; R--;
				}
				else{
					R = 2*n-1;
				}
				if(L <= R) forbid[i][j] = mp(L+i+1,R+i+1);
			}
		}
		mt.init();
		for(int i=0;i<2*n;i++){
			for(int j=0;j<2;j++) if(forbid[i][j].fi){
				mt.add((forbid[i][j].fi+1)/2,1);
				mt.add((forbid[i][j].sc)/2+1,-1);
			}
			if(i%2 == 1){
				ok[i] = !mt.sum((i+1)/2);
			}
		}
		mt.init();
		for(int i=2*n-1;i>=0;i--){
			for(int j=0;j<2;j++) if(forbid[i][j].fi){
				mt.add((forbid[i][j].fi+1)/2,1);
				mt.add((forbid[i][j].sc)/2+1,-1);
			}
			if(i%2 == 0){
				ok2[i] = !mt.sum((2*n+i)/2);
			}
		}
		ok2[2*n] = true;
		bool flag = 0;
		for(int i=0;i<2*n;i++){
			if(i%2 == 1){
				if(ok[i] && ok2[i+1]){
					flag = 1;
					break;
				}
			}
		}
		if(flag) ub = mid;
		else lb = mid;
	}
	printf("%d\n",ub);
	return 0;
}


Measured memory_bytes: 5504
n = int(input())
a = [int(input()) for _ in range(n)]
a.append(0) #後ろ側予防
donnyoku = 0
for i in range(n):
  pair = (a[i]+a[i+1])//2
  donnyoku += pair
  a[i+1] -= max(0,2*pair-a[i])
print(donnyoku)

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

using namespace std;
#define ll long long

const int N = 205, M = 60;
int T, n;
ll a[N];
char s[N];
struct wish{
	ll a[M];
	void insert(ll x){
		for(int i=M; i--;) if(x>>i&1){
			if(!a[i]){ a[i]=x; break;}
			else x^=a[i];
		}
	}
	bool exist(ll x){
		for(int i=M; i--;) if(x>>i&1) x^=a[i];
		return !x;
	}
	void reset(){ memset(a, 0, sizeof a);}
} x;
int main() {
	scanf("%d", &T);
	while(T--){
		scanf("%d", &n);
		for(int i=1; i<=n; ++i) scanf("%lld", a+i);
		scanf("%s", s+1);
		bool o=0;
		x.reset();
		for(int i=n; i; --i)
			if(s[i]=='0') x.insert(a[i]);
			else if(!x.exist(a[i])) o=1;
		puts(o?"1":"0");
	}
	return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int Combination(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  int n;
  cin>>n;
  vector<double> v;
  stack<double> L;
  for(int i=0;i<n;i++){
    int j;
    cin>>j;
    v.pb(j);
  }
  sort(all(v));
  for(int i=0;i<n;i++){
    if(L.empty()==1){
      L.push(v[i]);
    }
    else{
      double a,b;
      L.push(v[i]);
      a=L.top();
      L.pop();
      b=L.top();
      L.pop();
      L.push((a+b)/2);
    }
  }
  cout<<L.top();
  
}

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

int main()
{
    ios_base :: sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b && b==c)printf("No\n");
    else if(a!=b && b!=c && a!=c)printf("No\n");
    else printf("Yes\n");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int a,b,c; cin>>a>>b>>c;
	int maxi = max({a,b,c});
	int ans = 0;
	if(maxi == a) ans = maxi*10 + b + c;
	else if(maxi == b) ans = maxi*10 + c + a;
	else if(maxi == c) ans = maxi*10 + a + b;
	ote(ans);
}


Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> //tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <numeric>
using namespace std;

int main() {        
    int A, B;       
    cin >> A >> B;
    int ret = 0, c = 1;
    while (c < B) {
        c = c - 1 + A;
        ret++;
    }
    cout << ret << endl;
}

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

int main(){
  int n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++) cin>>s[i];
  vector<vector<int>> box(n,vector<int>('z'-'a'+1,0));
  for(int i=0;i<n;i++){
    for(int j=0;j<s[i].size();j++){
      box[i][s[i][j]-'a']++;
    }
  }
  vector<int> res('z'-'a'+1,1e6);
  for(int i=0;i<n;i++){
    for(int j=0;j<'z'-'a'+1;j++){
      res[j]=min(res[j],box[i][j]);
    }
  }
  for(int i=0;i<'z'-'a'+1;i++){
    for(int j=0;j<res[i];j++){
      cout<<char(i+'a');
    }
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

const MaxBuf = 200100
var buf []byte
var sc = bufio.NewScanner(os.Stdin)

func init() {
   sc.Split(bufio.ScanWords)
   sc.Buffer(buf,MaxBuf)
}

func readLine() string {
   sc.Scan()
   return sc.Text()
}

func readInt64() int64 {
   sc.Scan()
   r,_ := strconv.ParseInt(sc.Text(),10,64)
   return r
}

func readInt() int {
   sc.Scan()
   r,_ := strconv.Atoi(sc.Text())
   return r
}

func main() {
	s := readLine()
	t := readLine()
	ans := 0
	for i,_ := range s {
		if s[i] == t[i] {ans++}
	}
	fmt.Println(ans)
}

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

int main() {
  string S,T; cin >> S >> T;
  int ans =1000,SS = S.size(), TS = T.size();
  rep(i,0,SS-TS+1) {
    int count =0;
    rep(j,0,TS) {
      if (S[i+j] == T[j]) count++;
    }
    ans = min(ans,TS-count);
  }
  cout << ans << endl;
}

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

int main(){
    
    int N;
    cin >> N;
    priority_queue<double,vector<double>, greater<double>> que;
    
    double v;
    for(int i = 0; i < N;i++){
        cin >> v;
        que.push(v);
    }
    
    double a,b;
    
    int cont = N - 1;
    while(cont--){
        
        a = que.top();
        que.pop();
        b = que.top();
        que.pop();
        
        que.push( (a + b) / 2 );
        
    }
    
    cout <<setprecision(20)<< que.top() <<endl;
}
    
    



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
//#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

int n, a[200000];

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("meetings.in", "r", stdin);
	//freopen("meetings.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	int need = 1;
	for (int i = 0; i < n; i++)
		if (a[i] == need)
			need++;
	if (need == 1)
		cout << -1;
	else
		cout << n + 1 - need;
	return 0;
}

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

const int INF = 1001001001;
const int mod = 1000000007;

ll pow(ll base, ll order) {
	ll ans = 1;
	rep(i,order - 1) ans *= base;
	return ans;
}

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

ll sum(ll x) { // sum of subsequent numbers from 0 to x
	return x*(x + 1)/2;
}

int main() {
	int k, a, b;
	cin >> k >> a >> b;

	string ans = "NG";
	for (int i = a; i <= b; i++) {
		if (i % k == 0) {
			ans = "OK";
			break;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include<vector>
using namespace std;
int main(void){
   int n;
   cin >> n;
   int ans = 1;
   while(true){
       if(n == 1 || n == 2 || n == 4){
           cout << ans + 3 << endl;
           break;
       }else{
           if(n % 2 == 0){
               n /= 2;
           }else{
               n = 3 * n + 1;
           }
           ans++;
       }
   }
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a,b = map(int,input().split())
s = list(str(input()))

number = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
flag = True
for i in range(a):
    if s[i] not in number:
        flag = False
        #print("A")
if s[a] != '-':
    flag = False
    #print("B")
for i in range(a + 1, a + b + 1):
    if s[i] not in number:
        flag = False
        #print("C")

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  char str[1024];
  scanf("%s", str);
  int q;
  scanf("%d", &q);
  for(int i = 0; i < q; i++){
    char op[16], p[1024];
    int a, b;
    scanf("%s %d %d", op, &a, &b);
    if(op[0] == 'p'){
      for(int j = a; j <= b; j++){
        printf("%c", str[j]);
      }
      printf("\n");
    }
    else if(op[2] == 'v'){
      char temp[b - a + 1];
      for(int j = 0; j <= b - a; j++){
        temp[j] = str[j + a];
      }
      for(int j = 0; j <= b - a; j++){
        str[a + j] = temp[b - a - j];
      }
    }
    else{
      scanf("%s", p);
      for(int j = 0; j <= b - a; j++){
        str[a + j] = p[j];
      }
    }
  }
}



Measured memory_bytes: 2688
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO.Compression;
using System.Linq;
using System.Text;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            LinkedList<long> nums = new LinkedList<long>();
            for (int i = 1; i <= N; i++)
            {
                if (i %3 == 0 || i % 5 == 0)
                {
                    continue;
                }

                nums.AddLast(i);
            }

            Console.WriteLine(nums.Sum());
        }
    }
}

Measured memory_bytes: 54396
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define V vector<int>
using namespace std;
using ll = long long;

int main(){
    int n,k;
    cin>>n>>k;
    V h(n);
    rep(i,0,n) cin>>h[i];
    sort(h.begin(),h.end(),greater<int>());
    ll ans=0;
    if(n<=k) cout<<0<<"\n";
    else{
        rep(i,k,n) ans+=h[i];
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 1024
require 'prime'

N = gets.to_i
ary = Prime.prime_division(N)
n = N
cnt = 0
ary.each do |a|
    e = 0
    a[1].times do
        e += 1
        if n % (a[0]**e) == 0
            n = n.div(a[0]**e)
            cnt += 1
        end
    end
end
puts cnt

Measured memory_bytes: 14484
#include <bits/stdc++.h>
using namespace std;
int LOG = 20;
struct lowest_common_ancestor{
	int N;
	vector<int> d;
	vector<vector<int>> p;
	lowest_common_ancestor(vector<int> &P, vector<vector<int>> &C){
		N = P.size();
		d = vector<int>(N, 0);
		queue<int> Q;
		Q.push(0);
		while (!Q.empty()){
			int v = Q.front();
			Q.pop();
			for (int w : C[v]){
				d[w] = d[v] + 1;
				Q.push(w);
			}
		}
		p = vector<vector<int>>(N, vector<int>(LOG, -1));
		for (int i = 0; i < N; i++){
			p[i][0] = P[i];
		}
		for (int i = 1; i < LOG; i++){
			for (int j = 0; j < N; j++){
				if (p[j][i - 1] != -1){
					p[j][i] = p[p[j][i - 1]][i - 1];
				}
			}
		}
	}
	int query(int u, int v){
		if (d[u] > d[v]){
			swap(u, v);
		}
		for (int k = 0; k < LOG; k++){
			if ((d[v] - d[u]) >> k & 1){
				v = p[v][k];
			}
		}
		if (u == v){
		    return u;
		}
		for (int k = LOG - 1; k >= 0; k--){
			if (p[u][k] != p[v][k]){
				u = p[u][k];
				v = p[v][k];
				assert(u != -1);
				assert(v != -1);
			}
		}
		return p[u][0];
	}
};
int main(){
  int n;
  cin >> n;
  vector<int> parent(n, -1);
  vector<vector<int>> child(n);
  for (int i = 0; i < n; i++){
    int k;
    cin >> k;
    for (int j = 0; j < k; j++){
      int c;
      cin >> c;
      child[i].push_back(c);
      parent[c] = i;
    }
  }
  lowest_common_ancestor T(parent, child);
  int q;
  cin >> q;
  for (int i = 0; i < q; i++){
    int u, v;
    cin >> u >> v;
    cout << T.query(u, v) << endl;
  }
}


Measured memory_bytes: 20764
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        a: isize,
        v: isize,
        b: isize,
        w: isize,
        t: isize,
    }

    if a > b {
        if a - v * t <= b - w * t {
            println!("YES");
        } else {
            println!("NO");
        }
    } else if a == b {
        println!("YES");
    } else {
        if a + v * t >= b + w * t {
            println!("YES");
        } else {
            println!("NO");
        }
    }
}


Measured memory_bytes: 2172
class Node2:
    def __init__(self):
        self.parent = -1
        self.left = -1
        self.right = -1
    
def getSibling(u):
    if Nodes[u].parent == -1:
        return -1
    p = Nodes[u].parent
    if Nodes[p].left == u:
        return Nodes[p].right
    else:
        return Nodes[p].left

def getDepth(u):
    depth = 0
    while Nodes[u].parent != -1:
        depth += 1
        u = Nodes[u].parent
        
    return depth

def getDegree(u):
    if Nodes[i].left != -1 and Nodes[i].right != -1:
        return 2
    elif Nodes[i].left == -1 and Nodes[i].right == -1:
        return 0
    else:
        return 1

def getHeight(u):
    a = 0
    b = 0
    if Nodes[u].left != -1:
        a = getHeight(Nodes[u].left) + 1
    if Nodes[u].right != -1:
        b = getHeight(Nodes[u].right) + 1
    return max(a, b)

def getType(u):
    if Nodes[u].parent == -1:
        return "root"
    elif Nodes[u].right != -1 or Nodes[u].left != -1:
        return "internal node"
    else:
        return "leaf"
    
def printNode(u):
    print_str = "node " + str(u) + ": parent = " + str(Nodes[u].parent) + ", "
    print_str = print_str + "sibling = " + str(getSibling(u)) + ", "
    print_str = print_str + "degree = " + str(getDegree(u)) + ", "
    print_str = print_str + "depth = " + str(getDepth(u)) + ", "
    print_str = print_str + "height = " + str(getHeight(u)) + ", " + getType(u)
    print(print_str)

def getRoot(u):
    if Nodes[u].parent == -1:
        return u
    return getRoot(Nodes[u].parent)

    
def printPreorder(u):
    if u == -1:
        return
    print(" ", u, sep="", end="")
    printPreorder(Nodes[u].left)
    printPreorder(Nodes[u].right)
    
def printInorder(u):
    if u == -1:
        return
    printInorder(Nodes[u].left)
    print(" ", u, sep="", end="")
    printInorder(Nodes[u].right)
    
def printPostorder(u):
    if u == -1:
        return
    printPostorder(Nodes[u].left)
    printPostorder(Nodes[u].right)
    print(" ", u, sep="", end="")
    
# 入力
n = int(input())

Nodes = []
for i in range(n):
    tmp_obj = Node2()
    Nodes.append(tmp_obj)

# 登録作業
for i in range(n):
    num, left, right = map(int, input().split())
    Nodes[num].left = left
    Nodes[num].right = right
    if left != -1:
        Nodes[left].parent = num
    if right != -1:
        Nodes[right].parent = num

root = getRoot(0)
        
print("Preorder")
printPreorder(root)
print("\nInorder")
printInorder(root)
print("\nPostorder")
printPostorder(root)
print("")


Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
/*---define tricks---*/
#define ALL(v) v.begin(),v.end()
#define UN(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
#define FILL(x,y) memset(x,y,sizeof(x))
#define EACH(v,it) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define FIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define revsort(b,e) sort(b,e),reverse(b,e)
/*---define types---*/
typedef long long ll;
typedef unsigned int uint;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
/*---define variables---*/
int n;
vi L,R;
ll ans;
/*---define function---*/

/*---main code---*/
int main()
{
	FIO;
	cin>>n;
	L.resize(n+1),R.resize(n+1);
	for(int i=0;i<n;++i)
	{
		cin>>L[i]>>R[i];
	}
	revsort(L.begin(),L.end()),sort(ALL(R));
	for(int i=0;i<n;++i)
	{
		if(L[i]>R[i])
		{
			ans+=(L[i]-R[i])*2;
		}
	}
    cout<<ans<<'\n';
	return 0;
}


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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
  cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
	cout << a;
	if (&a != &vec.back()) cout << " ";
  }
  cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
	print(vec);
  }
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int a, b;
	cin >> a >> b;
	print((a + b) % 24);
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char a[1050][1050],c;
int mx[4] = {0,1,0,-1},my[4]={1,0,-1,0};
struct node{
	int x,y,st;
	node(int _x,int _y,int _z){
		x = _x;y = _y;st = _z;
	}
	node(){
	};
};
queue<node> q;
ll h,w;
int main(){
	ios::sync_with_stdio(false);
	cin >> h >> w;
	for(int i = 1;i <= h;i ++){
		for(int j = 1;j <= w;j ++){
			cin >>c;
			a[i][j] = c;
			if(a[i][j] == '#') q.push(node(i,j,1));
		}
	}
	node p;
	while(!q.empty()){
		p = q.front();
		q.pop();
		for(int i=0;i < 4;i ++)
			if(a[p.x+mx[i]][p.y+my[i]] == '.'){
				q.push(node(p.x+mx[i],p.y+my[i],p.st+1));
				a[p.x+mx[i]][p.y+my[i]] = '#';
			}		
	}

	cout << p.st-1 << endl;
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int mx=0,ans;
    for(int i=0;i<=20;i++)
    {
        if(n< (1<<(i+1)))
            {
                cout << (1<<i) << endl;
                break;
            }
    }
    return 0;
}


Measured memory_bytes: 3668
#include<bits/stdc++.h>
#include<cstdio>
#include<string>  
#include<algorithm>
#include<cmath>  
#include<iostream>
#include<queue>
#include<cstdlib>
#include<cstring>
#define maxn 2000001
#define ll long long
using namespace std;
/*
超时 
struct o
{
	int f;
	int l;
};
o a[maxn],b[maxn];
int  main()
{
	int n,m,i,j,x,y,w=0,s=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		if(x==1)
		{
			a[++w].f =x;
			a[w].l =y;
		}
		if(y==n)	
		{
			b[++s].f =x;
			b[s].l =y;	
		}	
	}
	for(i=1;i<=w;i++)
		for(j=1;j<=s;j++)
		{
			if(a[i].l==b[j].f)
			{
				printf("POSSIBLE");
				return 0;				
			}
		}
	printf("IMPOSSIBLE");	
	return 0;
 }
*/
struct o
{
    int f;
    int l;
};
o a[maxn];
int cnt;
int h[maxn];
int n,m;
int v[maxn];
int flag=0;
void dfs(int s,int t)
{
    if(t>2)
		return ; 
	if(t==2)
	{   if(s==n)
      	{
        	flag=1;
       	}
        return ;
    }
    for(int e=h[s];e!=-1;e=a[e].f)
    {
	    if(v[e]==0)
        {
            v[e]=1;
            dfs(a[e].l,t+1);
            v[e]=0;
        }

    }
   
}
int main()
{
   scanf("%d%d",&n,&m);
   memset(v,0,sizeof(v));
   memset(h,-1,sizeof(h));
   cnt=0;
   for(int i=1;i<=m;i++)
   {
    	int x,y;
    	scanf("%d%d",&x,&y);
    	if(x==1 || y==1)
    	{
    		a[cnt].l=y;
   			a[cnt].f=h[x];
    		h[x]=cnt++;
	    	a[cnt].l=x;
    		a[cnt].f=h[y];
    		h[y]=cnt++;
		}
		if(x==n || y==n)
		{
			a[cnt].l=y;
	   		a[cnt].f=h[x];
    		h[x]=cnt++;
    		a[cnt].l=x;
	    	a[cnt].f=h[y];
    		h[y]=cnt++;
		}
   }
   dfs(1,0);
   if(flag==1)
   {
      printf("POSSIBLE");
   }
   else
   {
       printf("IMPOSSIBLE");
   }
}



Measured memory_bytes: 20736
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String,Integer> map = new HashMap<>();
        int ans = 0;
        for(int i = 0;i < n;i++){
            String s = sc.next();
            map.put(s,1);
        }

        Iterator ite = map.values().iterator();
        while(ite.hasNext()){
            ans += (Integer)ite.next();
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 77108
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:
                a[j][k]=0
ans="No"
for i in range(3):
    if a[i][0]==a[i][1]==a[i][2]:
        ans="Yes"
    if a[0][i]==a[1][i]==a[2][i]:
        ans="Yes"
if a[0][0]==a[1][1]==a[2][2]:
    ans="Yes"
if a[0][2]==a[1][1]==a[2][0]:
    ans="Yes"
print(ans)


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

int main() {
	long long N, A[300][300] = {}, ans = 0;
	bool check = true, B[300][300] = {};
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> A[i][j];
		}
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (A[i][j] > A[i][k] + A[k][j]) check = false;
				if (A[i][j] == A[i][k] + A[k][j] && A[i][k] > 0 && A[k][j] > 0) B[min(i, j)][max(i, j)] = true;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = i; j < N; j++) {
			if (!B[i][j]) ans += A[i][j];
		}
	}
	if (check) cout << ans;
	else cout << -1;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

//rがランク（連結成分の大きさ）
struct UnionFind{
	int n;
	vector<int> r,p;
	UnionFind(){}
	UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
	int find(int x){
		return (x==p[x]?x:p[x]=find(p[x]));
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y) return;
		if(r[x]<r[y]) swap(x,y);
		r[x]+=r[y];
		p[y]=x;
	}
	int rank(int x){
		return r[x]=r[find(x)];
	}
};

ll n,m,k;
V<ll> v[100010],v2[100010];
UnionFind u(100010);

void init(){
	cin>>n>>m>>k;
	rep(i,m){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
		u.unite(a,b);
	}
	rep(i,k){
		int a,b;
		cin>>a>>b;
		v2[a].push_back(b);
		v2[b].push_back(a);
	}
}

int main(void){
	init();
	reg(i,1,n){
		int ans=u.rank(i)-v[i].size()-1;
		for(auto p:v2[i]){
			if(u.same(i,p))ans--;
		}
		cout<<ans<<" ";
	}
	cout<<endl;
	return 0;
}

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

int main() {
   long long N;
   cin >> N;
   long long   m=0;
  for(long long i=1;i*i<=N;i++){
    if(N%i==0)m=i;
  }  
  long long  r=N/m;
  long long res=0;
  while (r>0){
    r/=10;
    res++;
  }  
   cout <<res <<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

using vi = vector<int>;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define show(x) cout << #x << " = " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define sz(x) (int)(x).size()
#define YesNo {cout<<"Yes";}else{cout<<"No";}
#define YESNO {cout<<"YES";}else{cout<<"NO";}
#define v(T) vector<T>

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> bool lcmp(const pair<T, T>& l, const pair<T, T>& r) {
  return l.first < r.first;
}
template<class T> istream& operator>>(istream& i, v(T)& v) {
  F0R(j, sz(v)) i >> v[j];
  return i;
}
template<class A, class B> istream& operator>>(istream& i, pair<A, B>& p) {
  return i >> p.first >> p.second;
}
template<class A, class B, class C> istream& operator>>(istream& i, tuple<A, B, C>& t) {
  return i >> get<0>(t) >> get<1>(t) >> get<2>(t);
}
template<class T> ostream& operator<<(ostream& o, const vector<T>& v) {
  F0R(i, v.size()) {
    o << v[i] << ' ';
  }
  o << newl;
  return o;
}
template<class T1, class T2> ostream& operator<<(ostream& o, const map<T1, T2>& m) {
  for (auto& p : m) {
    o << p.first << ": " << p.second << newl;
  }
  o << newl;
  return o;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;

  unordered_map<int, int> a, b;

  F0R(i, n) {
    int v;
    cin >> v;
    if (i & 1) {
      ++a[v];
    }
    else {
      ++b[v];
    }
  }
  vector<pair<int,int>> c, d;
  for (auto& p : a) c.emplace_back(p.second, p.first);
  for (auto& p : b) d.emplace_back(p.second, p.first);
  sort(rrng(c), lcmp<int>);
  sort(rrng(d), lcmp<int>);
  c.emplace_back(0, -1);
  d.emplace_back(0, -1);

  int r;
  if (c[0].second != d[0].second)
    r = n - c[0].first - d[0].first;
  else {
    r = n - max(c[0].first + d[1].first, c[1].first + d[0].first);
  }
  cout << r;
}
#endif


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r;
	cin >> r;
	if (r < 1200)cout << "ABC" << endl;
	else if (r < 2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> table(H, vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> table.at(i).at(j);
    }
  }
  vector<bool> row(H,false);
  vector<bool> column(W,false);
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(table.at(i).at(j)=='#'){
        row.at(i)=true;
        column.at(j)=true;
      }
    }
  }
  for(int i=0; i<H; i++){
    if(row.at(i)){
      for(int j=0; j<W; j++){
        if(column.at(j)){
          cout << table.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int N = 1e5+5;
int n, p[N];
pair<int,int> x[N], y[N];
struct Dif {
    int x, y, d;
    bool operator<(Dif other) const {
        return d < other.d;
    }
};
int find_set(int x) {
    if(x==p[x]) return x;
    return p[x]=find_set(p[x]);
}
void unite_set(int x, int y) {
    x=find_set(x);
    y=find_set(y);
    p[x]=y;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> x[i].first >> y[i].first;
        x[i].second=i;
        y[i].second=i;
    }
    for(int i = 0; i < n; i++) p[i]=i;
    sort(x, x+n);
    sort(y, y+n);
    vector<Dif> df;
    for(int i = 0; i < n - 1; i++) {
        df.push_back({x[i].second, x[i+1].second, x[i+1].first-x[i].first});
        df.push_back({y[i].second, y[i+1].second, y[i+1].first-y[i].first});
    }
    sort(df.begin(), df.end());
    ll ans = 0;
    for(auto dif : df) {
        if(find_set(dif.x)==find_set(dif.y)) continue;
        ans += dif.d;
        unite_set(dif.x, dif.y);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 8340
#include<stdio.h>
#define MAX 200000
int main(){
  int i,n,R[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
  }
  int maxv=-2000000000;
  int minv=R[0];
  for(i=1;i<n;i++){
    if(maxv<R[i]-minv){
      maxv=R[i]-minv;
    }
    if(minv>R[i]){
      minv=R[i];
    }
  }
  printf("%d\n",maxv);
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector <vector <int>> f(n,vector <int>(10)),p(n,vector <int>(11));
    ll ans2=-1001001001001;

    rep(i,n){
        rep(j,10){
            cin >> f[i][j];
        }
    }
    rep(i,n){
        rep(j,11){
            cin >> p[i][j];
        }
    }

    vector <int> a(10),b(10,0);
    int k;
    ll ans;

    rep(i,1024){
        a=b;
        k=0;
        ans=0;
        if(i==0){
            continue;
        }
        else{
            rep(j,10){
                if((i>>j)&1==1){
                    a[j]=1;
                }
            }
            rep(j,n){
                k=0;
                rep(i2,10){
                    if(a[i2]==1 and f[j][i2]==1){
                        ++k;
                    }
                }
                ans+=p[j][k];
            }

            ans2=max(ans,ans2);

        }
    }

    cout << ans2 << endl;
    

    return 0;
}

Measured memory_bytes: 3624