akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}

static void ABC096D();

#if 1
int main()
{
	ABC096D();
	fflush(stdout);
	return 0;
}
#endif

template <class _T> void tp_getPrimes(_T targ, std::map<_T, _T>& primes)
{
	_T target = targ;
	_T i = 2;
	while ((i * i) <= target) {
		if ((target % i) == 0) {
			target /= i;
			primes[i]++;
		}
		else {
			i++;
		}
	}
	if (target > 1) {
		primes[target]++;
	}
}

static void ABC096D()
{
	int N;
	getint(N);
	
	int count = 0;
	std::vector<int> primeNumbers;
	for (int i = 2; (i <= 55555) && (count < N); i++) {
		std::map<int, int> primes;
		tp_getPrimes<int>(i, primes);
		if ((primes.size() == 1) && (primes.begin()->second == 1)) {
			if (primes.begin()->first % 5 == 1) {
				primeNumbers.push_back(primes.begin()->first);
				count++;
			}
		}
	}

	std::string str;
	for (int i = 0; i < N; i++) {
		char tmp[16] = { 0 };
		sprintf(tmp, "%d", primeNumbers[i]);

		if (i) {
			str += ' ';
		}
		str += tmp;
	}
	printf("%s\n", str.c_str());
}


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

using namespace std;

int main()
{
long long int h,w;
cin >> h >> w;

if (h==1 || w==1){ cout << "1"; return 0;}

if (h&1 && w&1)
    {
        cout << (h*w)/2+1;
    }
    else cout << h*w/2;


}




















/*
8 9
1 3
1 2
2 3
3 4
4 5
5 6
4 6
6 7
6 8





*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n, k; cin>>n>>k;
	int digit = (int)(floor(log(n)/log(k))+1);  
	cout<<digit<<'\n';
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int s = 0;
    for (int i = 0; i < m; ++i) {
        int x;
        cin >> x;
        s += x;
    }
    cout << max(-1, n - s) << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define int long long
using namespace std;
int dp[100][10001];
int n,ans=1000,cnt;
int a[100];
signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	a[n+1]=-1;
	for (int i=1;i<=n;i++)
	{
		cnt+=ans/a[i];
		ans=ans%a[i];
		if (a[i]>a[i+1]) ans+=cnt*a[i],cnt=0;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3608
N, A, B = map(int,input().split())
if A > B:
    print(0)
elif A == B:
    print(1)
else:
    if N == 1:
        print(0)
    else:
        minimum = A*(N-1)+B
        maximum = B*(N-1)+A
        print(maximum-minimum+1)

Measured memory_bytes: 9184
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    ll x = n;
    if(n%2 == 0) {
        x++;
    }

    out(n*(n-1)/2 - n/2);
    
    exrep(i, 1, n-1) {
        exrep(j, i+1, n) {
            if(i+j == x) {
                continue;
            }
            cout << i << " " << j << "\n";
        }
    }

    re0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        String s = sc.next();
        ArrayList<Character> s_list = new ArrayList<Character>();
        s_list.add(s.charAt(0));
        int cnt = 0;
        
        for(int i=1; i<n; i++) {
            if(s_list.get(cnt) != s.charAt(i)) {
                s_list.add(s.charAt(i));
                cnt++;
            }
        }
        System.out.println(s_list.size());
    }
}

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (i <= 9) ans++;
    else if (100 <= i && i < 1000) ans++;
    else if (10000 <= i && i < 100000) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <cmath>
#include    <stdio.h>
using namespace std;

int main()
{
    int N = 0;
    int Y = 0;
    cin>>N>>Y;

    for(int i= 0;i<=N;i++)
    {
        if(10000*i>Y)break;
        for(int j=0;j<=N;j++)
        {
            if(10000*i+5000*j>Y)break;
            if(N-(i+j)<0)break;
            int sum = 1000*(N-(i+j))+10000*i+5000*j;
            if(sum==Y)
            {
                printf("%d %d %d\n",i,j,N-(i+j));
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

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

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

const int MOD = 1e+9 + 7;

int main()
{
    string L;
    cin >> L;
    
    int N = L.size();
    // exact_dp[i]: 上からから i bit 目まで決めたときに、 a+b = L になる (a, b) の場合の数
    // dp[i]: 上からから i bit 目まで決めたときに、 a+b < L になる (a, b) の場合の数
    vector<long long> exact_dp(N), dp(N);
    exact_dp[0] = 2, dp[0] = 1;
    REP(i, N-1){
        if(L[i+1] == '0'){
            exact_dp[i+1] = exact_dp[i];
            dp[i+1] = 3*dp[i];
        }else{
            exact_dp[i+1] = 2*exact_dp[i];
            dp[i+1] = 3*dp[i] + exact_dp[i];
        }
        exact_dp[i+1] %= MOD;
        dp[i+1] %= MOD;
    }
    cout << (exact_dp[N-1]+dp[N-1])%MOD << endl;

    return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) printf("%.10f\n", x) // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

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

  int N;
  cin >> N;
  vi A(N);
  int mi = 1e9+7;
  int ans = 0;
  rep(i, 0, N) {
    cin >> A[i];
    if (A[i] < mi) ans++;
    mi = min(A[i], mi);
  }

  cout << ans << endl;

  return 0;
};


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

int main(){
  int N,K;
  std::cin >> N >> K;

  long double pr_t = 0;
  rep(i,N){
    int point = i+1;
    long double pr = 1.0/N;
    while(point < K){
      pr /= 2.0;
      point *= 2;
    }
    pr_t += pr;
  }

  std::cout << std::fixed << std::setprecision(10) << pr_t << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,M;cin>>N>>M;
  string s;cin>>s;
  std::vector<int> edge[N],r(N,0),b(N,0);
  while(M--){
    int u,v;cin>>u>>v;u--;v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
    if(s[u]=='A')r[v]++;else b[v]++;
    if(s[v]=='A')r[u]++;else b[u]++;
  }
  queue<int> que;
  std::vector<int> dele(N,0);
  for(int i=0;i<N;i++)if(r[i]*b[i]==0)que.push(i);
  while(que.size()){
    int p=que.front();que.pop();
    if(dele[p]++)continue;
    for(int q:edge[p]){
      if(dele[q])continue;
      if(s[p]=='A')r[q]--;else b[q]--;
      if(r[q]*b[q]==0)que.push(q);
    }
  }
  for(int i=0;i<N;i++)if(!dele[i])fin("Yes");
  fin("No");
}


Measured memory_bytes: 17028
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n,q;
    cin >> n >> q;
    vector<vector<int>> edge;
    int a,b;
    rep(i,n+1){
        edge.push_back({});
    }
    rep(i,n-1){
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    long long val[n+1]={0};
    long long ans[n+1]={0};
    fill_n(val,n+1,0);
    fill_n(ans,n+1,0);
    long long p,x;
    rep(i,q){
        cin >> p >> x;
        val[p]+=x;
    }
    ans[1]=val[1];
    queue<int> que;
    que.push(1);
    bool check[n+1];
    fill_n(check,n+1,true);
    check[1] = false;
    while(!que.empty()){
        int tmp = que.front();
        que.pop();
        for(int i = 0;i<edge[tmp].size();i++){
            int tem = edge[tmp][i];
            if(check[tem]){
                ans[tem]+=ans[tmp]+val[tem];
                que.push(tem);    
                check[tem] = false;            
            }
        }
    }
    rep(i,n){
        cout << ans[i+1] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 18668
import java.util.*;

public class Main{
	public static void main(String[] args){
		
		Scanner s=new Scanner(System.in);
		int W=s.nextInt();
		int a=s.nextInt();
		int b=s.nextInt();
		
		if(a<=b){
			if(b-(a+W)>0){
				System.out.println(b-(a+W));
			}else if(b-(a+W)<=0)System.out.println(0);
		}
		if(a>b){
			if(a-(b+W)>0){
				System.out.println(a-(b+W));
			}else if(a-(b+W)<=0)System.out.println(0);
		}
}

}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include<vector>

using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	int a[m];
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}

	for (int i = 0; i < m; i++) {
		n -= a[i];
		if (n < 0) {
			cout << -1 << endl;

			return 0;
		}
	}

	cout << n << endl;


	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int n;
string s[40];

bool find(int st) {
	int cnt[5] = {5, 7, 5, 7, 7};
	int cor = 0;
	
	for (int i = st; i < n; i++) {
		cnt[cor] -= (int)s[i].length();
		if (cnt[cor] < 0) return false;
		if (cnt[cor] == 0) cor++;
		if (cor == 5) return true;
	}
	return false;
}

int main() {
	while (cin >> n) {
		if (!n) break;
		int i, j;
		
		for (i = 0; i < n; i++) cin >> s[i];
		
		for (i = 0; ; i++) {
			if (find(i)) {
				break;
			}
		}
		cout << i + 1 << endl;
	}
	return 0;
}

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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  int n = s.size();
  for (int i = 0; i < n/2; i++) {
    if (s[i] != s[n-1-i]) ans++;
  }
  printf("%d\n", ans);
  return 0;}


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

using namespace std;

int main(){

	string s;
	int k;
	cin >> s;
	cin >> k;
	int l = s.size();
	int a[l];
	for(int i=0;i<l;i++){
		a[i] = s[i] -'a';
	}

	for(int i=0;i<l;i++){
		if(a[i]==0){
			continue;
		}else{
			if(k >= 26-a[i]){
				k -= 26-a[i];
				a[i] = 0;
			}
		}
	}
	a[l-1] = (a[l-1]+k)%26;
	for(int i=0;i<l;i++){
		cout << char('a'+a[i]);
	}
	cout << endl;


/*
	sort(a,a+l);
	for(int i=l-1;i>=0;i--){
		if(k>=26-a[i]){
			a[i] = 0;
			k -= 26-a[i];
		}else{
			a[i] += k;
		}
	}
	sort(a,a+l);
	for(int i=0;i<l;i++){
		cout << a[i] << endl;
	}
	for(int i=0;i<l;i++){
		cout << 'a' + a[i];
	}
	cout << endl;
*/	
	return 0;

}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 500500;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, D, q;
int d[maxn], go[maxn];
ll lol[maxn];
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> D, go[0] = D;
	rep(i, 1, n) {
		cin >> d[i];
		go[i] = std::min(go[i - 1], std::abs(go[i - 1] - d[i]));
	}
	lol[n + 1] = 1;
	for(int i = n;i >= 1;--i) {
		if(lol[i + 1] <= d[i] / 2) lol[i] = lol[i + 1];
		else lol[i] = lol[i + 1] + d[i];
	}
	cin >> q;
	rep(i, 1, q) {
		int x;
		cin >> x;
		cout << (go[x - 1] >= lol[i + 1] ? "YES" : "NO") << '\n';
	}
}


Measured memory_bytes: 9728
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ret = 0;
            var S = Console.ReadLine();
            foreach (var s in S)
            {
                if (s == '+')
                {
                    ret++;
                }
                else
                {
                    ret--;
                }
                
            }
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 11092
L,R = map(int,input().split())
mn = 2018
if R - L >= 2018:
  print(0)
else:
  for i in range(L,R):
    for j in range(i+1,R+1):
      if (i*j)%2019 < mn:
        mn = (i*j)%2019
  print(mn)

Measured memory_bytes: 40556
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define ll long long
#define lli long long int
#define li long int
#define ld long double
#define vi vector<int>
#define vlli vector<lli>
#define vii vector<pair<int, int>>
#define pii pair<int, int>
#define mp(a, b) make_pair(a, b)
#define all(arr) arr.begin(), arr.end()
using namespace std;
const lli mod = 1e9 + 7;
const lli mod_ = 998244353;
const int INF = 1000000000;
const lli INF64 = (lli)1E18;

int n, k;
int heights[100005];
lli dp[100005];

int main() {
	// ifstream cin("input.in");
	// ofstream cout("output.out");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n >> k;
	
	for(int i = 0; i < n; i++)
		cin >> heights[i];
	dp[1] = abs(heights[1]-heights[0]);
	
	for(int i = 2; i < n; i++) {
		dp[i] = INF64;
		for(int j = max(0, i-k); j < i; j++)
			dp[i] = min(dp[i], dp[j] + abs(heights[i]-heights[j]));
	}
		
	cout << dp[n-1] << endl;

	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main(void)
{
  int n;
  scanf("%d",&n);
  double x[n];
  char u[n][n];
  int i;
 for(i=0;i<n;i++){
   scanf("%lf %s",&x[i],u[i]);
 }
  double sum=0;
  for(i=0;i<n;i++){
    if('B'==u[i][0]){
      sum=sum+x[i]*380000.0;
    }
    else{
      sum=sum+x[i];
    }
  }
  printf("%lf",sum);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, M;
    cin >> N;
    vector<string> s(N);
    for (int i = 0; i < N; i++){
        cin >> s.at(i);
    }
    cin >> M;
    vector<string> t(M);
    for (int i = 0; i < M; i++){
        cin >> t.at(i);
    }
    map <string, int> mp;
    for(int i = 0; i < N; i++){
        if (mp.count(s.at(i))){
            mp.at(s.at(i))++;
        }
        else{
            mp[s.at(i)] = 1;
        }
    }
    for(int i = 0; i < M; i++){
        if (mp.count(t.at(i))){
            mp.at(t.at(i))--;
        }
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if (ans <= mp[s.at(i)]) ans = mp[s.at(i)];
    }
    cout << ans << endl;    
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int s,w;
    cin>>s>>w;
    if(s<=w){
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }





return 0;
}


Measured memory_bytes: 3596
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

a, b = map(int, input().split())

print("Even" if a * b % 2 == 0 else "Odd")

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

using namespace std;
const long long  N=2e5+10,big=1e18,mod=1e9+7;
const double pi=acos(-1);
 
long long n,m,a[N],k,mini=N,maxi;
int main()
{
    string s1,s2;
    cin>>s1;
    for(int i=0;i<s1.size()-1;i++)
    if(s1[i]==s1[i+1])
    return cout<<"Bad",0;
    cout<<"Good";
        
}


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

void solve(long long N, string A, string B, string C){
	int res = 0;
	for (int i=0; i<N; i++) {
		if (A[i] != B[i] && A[i] != C[i] && B[i] != C[i]) res+=2;
		if ((A[i] != B[i] && A[i] == C[i]) || (A[i] != C[i] && A[i] == B[i]) || (A[i] != C[i] && C[i] == B[i])) res++;
	}
	cout << res << "\n";
}

int main(){
	string B;
	string A;
	long long N;
	string C;
	scanf("%lld",&N);
	cin >> A;
	cin >> B;
	cin >> C;
	solve(N, A, B, C);
	return 0;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  sort(rng(a));
  int ans=0;
  for(int i=0;i<=100000;i++){
    int l=lower_bound(rng(a),i-1)-a.begin();
    int r=upper_bound(rng(a),i+1)-a.begin();
    ans=max(ans,r-l);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int M=262144;
const ll mod=1e9+7;
const int mg=30;
int n;
int sz=2;
vector<int>v1,v2;
vector<int>bin[64];
ll a[200001];
int q=0;
void add(int id,int x,int y){
	cout << "+ " << x << ' ' << y << ' ' << id << '\n';
	a[id]=a[x]+a[y];
	q++;
}
void cmp(int id,int x,int y){
	cout << "< " << x << ' ' << y << ' ' << id << '\n';
	a[id]=a[x]<a[y];
	q++;
}
void makebinary(vector<int>&v,int id){
	add(id,3,id);//a[id]++
	v.resize(mg);
	int boom=++sz;
	for(int i=mg-1; i>=0 ;i--){
		sz++;add(sz,3,sz);//a[sz]=1
		for(int j=0; j<i ;j++) add(sz,sz,sz);//a[sz]*=2;
		sz++;add(sz,boom,sz-1);
		sz++;cmp(sz,sz-1,id);
		v[i]=sz;
		sz++;add(sz,sz,sz-1);
		for(int j=0; j<i ;j++) add(sz,sz,sz);
		add(boom,sz,boom);
	}
}
int makeand(int x,int y){
	cmp(++sz,x,y);
	cmp(++sz,y,x);
	sz++;add(sz,sz-2,sz-1);
	sz++;cmp(sz,sz-1,x);
	return sz;
}
int main(){
	ios::sync_with_stdio(false);
//	cin >> a[0] >> a[1];
	cout <<  8254 << endl;
	cmp(++sz,3,0);//a[3]=1;
	makebinary(v1,0);
	makebinary(v2,1);
	for(int i=0; i<mg ;i++){
		for(int j=0; j<mg ;j++){
			int e=makeand(v1[i],v2[j]);
			bin[i+j].push_back(e);
		}
	}
	for(int i=0; i<mg*2-1 ;i++){
		for(int j=1; j<bin[i].size() ;j++){
			add(bin[i][0],bin[i][0],bin[i][j]);
		}
		for(int j=0; j<i ;j++) add(bin[i][0],bin[i][0],bin[i][0]);
		add(2,2,bin[i][0]);
	}
//	cout << a[2] << endl;
	//cout << q << endl;
}

Measured memory_bytes: 3652
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("C:\\Users\\BOG\\Desktop\\path.txt");ofstream out("C:\\Users\\BOG\\Desktop\\crd.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

int main(){
    fast;
    int a; cin>>a;
    int need = 1;
    for(int q=0; q<a; q++){
        int x; cin>>x;
        if(x==need) need++;
    }
    cout<<(need==1 ? -1 : (a-need+1));
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    ll N;
    cin >> N;
    double n = 0;
    REP(i, N)
    {
        if ((i + 1) % 2 == 1)
            n++;
    }
    cout << OF64 << n / N << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>

using namespace std;

typedef int itn;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef map<int, int> M;
typedef pair<int, int> P;
typedef stack<int> S;
typedef queue<int> Q;

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

    LL n, s;
    cin >> n >> s;
    LL ans = 0;
    for (int i = 0; i < n; ++i)
    {
        LL x;
        cin >> x;
        ans = __gcd(ans, abs(x-s));
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
a,b = map(int, input().split())

if a == 1:
  if b== 1:
    print("Draw")
  else:
    print("Alice")
else:
  if b == 1:
    print("Bob")
  elif a == b:
    print("Draw")
  elif a<b:
    print("Bob")
  elif a>b:
    print("Alice")

Measured memory_bytes: 3060
import sys
def input():
    return sys.stdin.readline().rstrip('\n')


def calc(X):
    i = 0
    while True:
        y = i ** 5
        if y == X:
            return "{0} {1}".format(i, 0)
        elif y < X:
            j = int((X - y) ** (1 / 5))
            intj = int(j)
            if abs(j - intj) < 1e-5 and y + intj ** 5 == X:
                return "{0} {1}".format(i, -intj)
        else:
            j = int((y - X) ** (1 / 5))
            intj = int(j)
            if abs(j - intj) < 1e-5 and y - intj ** 5 == X:
                return "{0} {1}".format(i, intj)
        i += 1
    

X = int(input())
print(calc(X))

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    cin >> s;
    string ans = (s.substr(0, 4) == "YAKI") ? "Yes" : "No";
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const int oo = 1e9 + 7;
const int mod = 1e9 + 7, maxn = 200200;
const long double PI = acos(-1);

ll n, m, k;

int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;

    vector<pii> v(n);

    for (int i=0; i<n; i++){
        cin >> v[i].ff >> v[i].ss;
    }

    sort(all(v));

    int id = 0;

    while (k > 0){
        k-=v[id++].ss;
    }

    cout << v[--id].ff << endl;
    
    return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

struct edge
{
	int s, t, cost;
	edge(int s, int t, int cost) :s(s), t(t), cost(cost) {}
	edge() :edge(-1, -1, -1) {}
};

vector<edge> G[1010];
edge edges[2010];
int d[1010];
bool reach[1010];
int V, E;

void shortest_path(int s)
{
	rep(i, 0, V)d[i] = INF;
	d[s] = 0;

	for (int k = 0;; k++)
	{
		bool update = false;

		rep(i, 0, E)
		{
			if (d[edges[i].s] != INF && d[edges[i].t] > d[edges[i].s] + edges[i].cost)
			{
				d[edges[i].t] = d[edges[i].s] + edges[i].cost;
				if (k == V + 1)
				{
					if (reach[edges[i].t])
					{
						d[V - 1] = INF;
					}
					return;
				}
				update = true;
			}
		}

		if (!update)
		{
			break;
		}
	}
}

void dfs(int v)
{
	if (reach[v])return;
	reach[v] = true;
	for (auto e : G[v])
	{
		dfs(e.t);
	}
}

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

	cin >> V >> E;
	int a, b, c;
	rep(i, 0, E)
	{
		cin >> a >> b >> c;
		a--, b--;
		edges[i] = edge(a, b, -c);
		G[b].push_back(edge(b, a, -c));
	}

	dfs(V - 1);
	shortest_path(0);

	if (d[V - 1] == INF)
	{
		cout << "inf" << endl;
	}
	else
	{
		cout << -d[V - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

int N, a[111];

long long f(vector<int> v, int n, bool b)
{
	auto r = 0ll;
	if (b) {
		for (int i = n; i <= N; i += n)
			v[i] = 1;
	}
	else r += a[n];
	while (v[++n]);
	if (n > N) return r;
	if (n < 33) {
		auto i = f(v, n, false);
		auto j = f(v, n, true);
		return i < j ? j + r : i + r;
	}
	if (n == 33) {
		int a3 = a[33];
		int a6 = v[66] ? 0 : a[66];
		int a9 = v[99] ? 0 : a[99];
		if (a3 <= 0 && a3 + a6 <= 0 && a3 + a9 <= 0 && a3 + a6 + a9 <= 0)
			v[33] = v[66] = v[99] = 1;
		else r += a[n];
		while (v[++n]);
	}
	while (n <= N) {
		int a1 = a[n];
		int a2 = n * 2 > N || v[n * 2] ? 0 : a[n * 2];
		if (a1 <= 0 && a1 + a2 <= 0) {
			v[n] = 1;
			if (n * 2 <= N) v[n * 2] = 1;
		}
		else r += a[n];
		while (v[++n]);
	}
	return r;
}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i + 1];
	vector<int> d(102);
	cout << f(d, 0, false) << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int d = 0;
        int [] num = new int[n];
        for (int i=0;i<n;i++){
            num[i]=scanner.nextInt();
        }
        for (int i=0;i<n;i++){
            for (int j=i+1;j<n;j++){
                d += num[i]*num[j];
            }

        }
        System.out.println(d);
    }
}

Measured memory_bytes: 21716
//author Eterna
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<utility>
#include<cmath>
#include<climits>
#include<deque>
#include<functional>
#define INF 0x7fffffff
#define maxn 100000
#define eps 1e-15
#define MOD ((int)(1e9+7))
#define ABS(x) ((x)>=0?(x):(-(x)))
#define pb(x) push_back(x)
#define lowbit(x) (x&-x)
#define mid (L+R)/2
#define Lson (index*2)
#define Rson (index*2+1)
using namespace std;
typedef long long ll;
inline ll read() {
	char c;
	ll ret = 0, sgn = 1;
	do { c = getchar(); } while ((c < '0' || c > '9') && c != '-');
	if (c == '-') sgn = -1; else ret = c - '0';
	while ((c = getchar()) >= '0' && c <= '9') ret = ret * 10 + (c - '0');
	return sgn * ret;
}
int arr[100][100];
int n, m, t, p, o, x, a, b;
void move_left(ll x) {
	for (ll i = 1; i <= m; i++)
		for (ll j = 1; j <= max(x, n - x); j++) {
			arr[i][j] = arr[i][j + x];
			arr[i][j + x] = 0;
		}
	n = max(x, n - x);
}
void move_down(ll x) {
	for (ll i = 1; i <= n; i++)
		for (ll j = 1; j <= max(x, m - x); j++) {
			arr[j][i] = arr[j + x][i];
			arr[j + x][i] = 0;
		}
	m = max(x, m - x);
}
int main(void)
{
	while (scanf("%d %d %d %d", &n, &m, &t, &p) && n&&m&&t&&p) {
		memset(arr, 0, sizeof(arr));
		for (ll i = 1; i <= m; i++)
			for (ll j = 1; j <= n; j++) arr[i][j] = 1;
		for (ll i = 1; i <= t; i++) {
			cin >> o >> x;
			if (o == 1) {
				for (int k = 1; k <= m; k++) {
					for (int j = 1; j <= x; j++)
						arr[k][2 * x - j + 1] += arr[k][j];
				}
				move_left(x);
			}
			else if (o == 2) {
				for (int k = 1; k <= n; k++)
					for (int j = 1; j <= x; j++)
						arr[2 * x - j + 1][k] += arr[j][k];
				move_down(x);
			}
		}
		for (int i = 1; i <= p; i++) {
			cin >> a >> b; a++; b++;
			cout << arr[b][a] << endl;
		}
	}
	//system("pause");
	return 0;
}


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

using namespace std;

int main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    vector <int> was(250, 0);
    for (int j = 0; j <= i; ++j) 
      was[s[j]] = 1;
    int cnt = 0;
    vector <int> get(250, 0);
    for (int j = i + 1; j < n; ++j) {
      if (was[s[j]])
        if (!get[s[j]])
          ++cnt;
        get[s[j]] = 1;
    }
    ans = max(ans, cnt);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define fi first
#define se second
using namespace std;
const int inf=0x3f3f3f3f;
string s;
int main()
{
    cin>>s;
    int n=s.size();
    int cnt=0;
    for(int i=0,mark=0;i<n;i++,mark^=1)
        cnt+=s[i]-'0'==mark;
    int ans=cnt;
    cnt=0;
    for(int i=0,mark=1;i<n;i++,mark^=1)
        cnt+=s[i]-'0'==mark;
    ans=min(ans,cnt);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
main(){
    int a,b;
    scanf("%d %d",&a,&b);

    if(a%3 == 0){
        printf("Possible");
    }else if(b%3 == 0){
        printf("Possible");
    }else if((a+b)%3 == 0){
        printf("Possible");
    }else{
        printf("Impossible");
    }

}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_Training
{

    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var v = Console.ReadLine().Split(' ').Select(int.Parse).OrderBy(x => x).ToArray();
            var ans = (double)v[0];
            for(int i = 1; i < n; i++)
            {
                ans = (ans + v[i]) / 2;
            }
            Console.WriteLine(ans);
        }
        

    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<60);

vector<int> Eratosthenes( const int N )
{
    vector<bool> is_prime( N + 1 );
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;
    }
    vector<int> P;
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
    return P;
}

ll gcd(ll x,ll y){
    if(x<y) swap(x,y);
    //xの方が常に大きい
    ll r;
    while(y>0){
        r=x%y;
        x=y;
        y=r;
    }
    return x;
}

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    ll ma = -1;
    map<int, int> mp;
    rep(i,N){
        cin >> A[i];
        mp[A[i]]++;
        ma = max(ma, A[i]);
    }
    ll SA=A[0];
    rep(i,N-1){
        SA = gcd(SA, A[i+1]);
    }

    bool is_P=true, is_S=false;
    if(SA==1) is_S = true;

    if(ma==1){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    vector<int> prime = Eratosthenes(ma);

    for(int i=0;i<=prime.size();i++){
        int p = prime[i];
        int x = p;
        if(p==0) continue;
        int tmp = 0, cnt=1;
        while(x <= ma){
            //cout << x << " " << tmp << endl;
            cnt++;
            tmp += mp[x];
            x=p*cnt;
        }
        if(tmp>=2){
            is_P = false;
            break;
        }
    }

    if(is_P) cout << "pairwise coprime" << endl;
    else if(is_S) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
    
}

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

int main() {
  int N , a , b , c , d;
  cin >> N ;
  a = N / 1000 ;//4けた目
  b = N % 1000 / 100; //3
  c = N % 100 / 10; // 2
  d = N % 10; //1
  if( b == c ){
    if( a == b || d == b ){
      cout << "Yes" << endl;
    }
    else cout << "No" << endl;
  }
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
{
    long a, b, r, x, tmp;
     while( scanf("%ld %ld",&a ,&b) != EOF ){
    
    
        x = a * b;
 
        if(a<b){
            tmp = a;
            a = b;
            b = tmp;
        }
  
        while( (r = a % b) != 0 ) {
            a = b;
            b = r;
        }
        r = a % b;
        while(r!=0){
            a = b;
            b = r;
            r = a % b;
        }
        printf("%ld %ld\n",b, x/b);
    
     }
    
    return 0;

         
    
}


Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
vector<bool>seen(1000,false);
vector<pair<int,int>>ans(1000);
vector<int>first_order(1000,10e7),last_order(1000,10e7);
void dfs(const vvll &gura, int v, int& now) {
    first_order[v] = min(first_order[v],now++);

    seen[v] = true; 
    for (auto next_v : gura[v]) { 
        if (seen[next_v]) continue;
        dfs(gura, next_v, now);
    }

    last_order[v] = min(last_order[v],now++);
}
int main(){
    int n;
    cin >> n;
    vvll gura(n);
    for(int i=0;i<n;i++){
        int ww; cin >>ww;
        int w;
        cin >> w;
        for(int j=0;j<w;j++){
            int d;
            cin >> d;
            gura.at(i).push_back(d-1);
        }
    }
    int now = 1;
    for(int i=0;i<n;i++){
        if(seen[i])continue;
    dfs(gura,i,now);
    }
    for(int i=0;i<n;i++){
        cout << i+1<<" "<< first_order[i]<<" "<<last_order[i]<<endl;
    }
}



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

int main() {
	int n, al[50][26] = { 0 };
	string s[50];
	cin >> n;
	rep(i, n) {
		cin >> s[i];
		rep(j, s[i].size()) {
			al[i][s[i][j] - 'a']++;
		}
	}
	rep(i, 26) {
		const int INF = 1000;
		int cnt = 0;
		int mi = INF;
		rep(j, n) {
			mi = min(mi, al[j][i]);
		}
		rep(j, mi) cout << (char)(i + 'a');
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int h, w;
string t[20];
int cost[20][20];

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

int solve(int sx, int sy) {
  memset(cost, -1, sizeof(cost));
  queue<P> open;
  open.push(P(sx, sy));
  cost[sy][sx] = 0;

  int res = 0;
  while (!open.empty()) {
    P p = open.front(); open.pop();
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if (nx < 0 || w <= nx || ny < 0 || h <= ny || t[ny][nx] == '#' || cost[ny][nx] != -1) {
        continue;
      }
      cost[ny][nx] = cost[p.second][p.first] + 1;
      res = max(res, cost[ny][nx]);
      open.push(P(nx, ny));
    }
  }
  return res;
}

int main() {
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    cin >> t[i];
  }
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (t[i][j] == '#') {
        continue;
      }
      ans = max(ans, solve(j, i));
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	std::vector<int> h(n);
	for(int i = 0; i < n; ++i){
		int a;
		cin >> a;
		++h[a - 1];
	}
	sort(h.begin(), h.end());
	int answer = 0;
	for(int i = 0; i < n - k; ++i){
		answer += h[i];
	}
	cout << answer << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
using ll = long long;

struct V {
  int index;
  ll x, y;
};
struct E {
  int v, u;
  ll cost;
};
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
  int N;
  cin >> N;
  vector<V> vs;
  for (int i = 0; i < N; i++) {
    ll x, y;
    cin >> x >> y;
    vs.push_back(V{ i, x, y });
  }
  vector<E> es;
  sort(vs.begin(), vs.end(), [](const V &a, const V &b) {
    return a.x < b.x;
  });
  for (int i = 1; i < N; i++) {
    es.push_back(E{ vs[i-1].index, vs[i].index, vs[i].x - vs[i-1].x });
  }
  sort(vs.begin(), vs.end(), [](const V &a, const V &b) {
    return a.y < b.y;
  });
  for (int i = 1; i < N; i++) {
    es.push_back(E{ vs[i-1].index, vs[i].index, vs[i].y - vs[i-1].y });
  }
  sort(es.begin(), es.end(), [](const E &a, const E &b) {
    return a.cost < b.cost;
  });
  UnionFind uf(N);
  ll res = 0;
  for (const auto &e: es) {
    if (!uf.findSet(e.v, e.u)) {
      res += e.cost;
      uf.unionSet(e.v, e.u);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 10480
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cmath>
#include <set>
#include <string.h>
#include <functional>

using namespace std;

int a[1010];
int b[1010];
int c[1010];
int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            if(b[i]>=a[j]){
                c[j]++;
                break;
            }
        }
    }
    int max=0;int ans=-1;;
    for(int i=0;i<n;i++){
        if(c[i]>max){
            max=c[i];
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main() {
    int n;
    int a, b, c;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> a >> b >> c;
        if(a*a == b*b + c*c){
            cout << "YES" << endl;
        }
        else if(b*b == c*c + a*a){
            cout << "YES" << endl;
        }
        else if(c*c == a*a + b*b){
            cout << "YES" << endl;
        }
        else{
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
int dfs(vector<vector<int> > &v,vector<bool> &vis,int src,int &s){
  vis[src]=true;
  s++;
  for(int i=0;i<v[src].size();i++){
    int g=v[src][i];
    if(!vis[g])
        dfs(v,vis,g,s);
  }
  return s;
}
int main(){
   int n,m;
   cin>>n>>m;
   int a[n],sz[n];
   set<pii > s;
   int x,y;
   vector<vector<int> > v(n);
   //cin>>x>>y;
   while(m--){
    cin>>x>>y;
    if(s.find({x-1,y-1})==s.end()&&s.find({y-1,x-1})==s.end()){
     v[x-1].push_back(y-1);
     v[y-1].push_back(x-1);
     s.insert({x-1,y-1});
     s.insert({y-1,x-1});
   }
   }
   vector<bool> vis(n,false);
   int ans=1;
   for(int i=0;i<n;i++){
      if(!vis[i]){
        int ma;
        int s=0;
        dfs(v,vis,i,s);
        ans=max(ans,s);
      }
   }
   cout<<ans;
   return 0;
}

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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

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

    ll A, B, Q;
    std::cin >> A >> B >> Q;

    vector<ll> S(A + 2), T(B + 2);
    S[0] = -LINF;
    T[0] = -LINF;
    S[A + 1] = LINF;
    T[B + 1] = LINF;
    REP(i, A) {
        std::cin >> S[i + 1];
    }
    REP(i, B) {
        std::cin >> T[i + 1];
    }

    REP(i, Q) {
        ll x;
        std::cin >> x;
        auto s_itr = lower_bound(ALL(S), x);
        auto t_itr = lower_bound(ALL(T), x);

      ll ans = LINF;
        ans = min(ans, x - min(*(s_itr - 1), *(t_itr - 1)));
        ans = min(ans, x - *(s_itr - 1) + *t_itr - *(s_itr - 1));
        ans = min(ans, x - *(t_itr - 1) + *s_itr - *(t_itr - 1));
        ans = min(ans, *s_itr - x + *s_itr - *(t_itr - 1));
        ans = min(ans, *t_itr - x + *t_itr - *(s_itr - 1));
        ans = min(ans, max(*s_itr, *t_itr) - x);
        std::cout << ans << "\n";
    }

    return 0;
}


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

int main(){
  int n,k;
  cin >>n >> k;
  vector<int> dp(n);
  vector<int> h(n);
  for(int i = 0; i<n;i++){
    cin >> h[i];
  }
  dp[0] = 0;
  dp[1] = abs(h[0]-h[1]);
  for(int i = 2; i<n;i++){
    int cos = INT_MAX;
    for(int j = 1; j<=k && j<=i;j++){
      cos = min(dp[i-j]+abs(h[i-j]-h[i]),cos);
    }
    dp[i] = cos;
  }
  cout << dp[n-1];
}


Measured memory_bytes: 1024
N = int(input())
num_list = list(map(int, input().split()))
 
ans = 10**10
 
for i in num_list:
  div_num = 0
  while i % 2 == 0:
    i  //= 2
    div_num += 1  
    
  if ans > div_num:
     ans = div_num
print(ans)


Measured memory_bytes: 2940