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

///////////////////////////////////////////
const long long int INF = 1000000000000000000LL;
using ll = long long int;
using vi = vector<int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
///////////////////////////////////////////

class union_find{//rank無しunion_find木
    int par[100000]={-1};
public:
    union_find(int num){ for(int i=0;i<num;i++)par[i]=-1; }
    int root(int x){//再帰
        if(par[x]<0){
            return x;
        }else{
            return par[x] = root(par[x]);
        }
    }
    bool same(int x,int y){ return root(x)==root(y); }//同じunionにいるか？
    void unite(int x,int y){//unionの結合
        x = root(x);y = root(y);
        if(x==y)return ;
        par[x] += par[y];
        par[x] = y;
    }
};

int main(){
    int n,m;
    int box[100000]={0};
    cin>>n>>m;
    union_find U(n);
    rep(i,n)cin>>box[i];
    int x,y;
    rep(i,m){
        cin>>x>>y;
        U.unite(x,y);
    }
    int ans = 0;
    rep(i,n){
        if(U.same(i+1,box[i]) || box[i]==i+1)ans++;
    }
    cout<<ans<<endl;
    return 0;
}
















Measured memory_bytes: 1024
#include <cassert>
#include <cstdint>
#include <utility>
#include <vector>

class UnionFindTree {

public:
	using size_type = std::uint_fast32_t;

private:
	std::vector<std::pair<bool, size_type>> tree;

public:
	UnionFindTree(const size_type size) : tree(size, std::make_pair(1, 1)) {}
	size_type find(const size_type x) {
		assert(x < tree.size());
		if (tree[x].first)
			return x;
		return tree[x].second = find(tree[x].second);
	}
	bool unite(size_type x, size_type y) {
		assert(x < tree.size());
		assert(y < tree.size());
		x = find(x);
		y = find(y);
		if (x == y)
			return false;
		if (tree[x].second < tree[y].second)
			std::swap(x, y);
		tree[x].second += tree[y].second;
		tree[y] = std::make_pair(0, x);
		return true;
	}
	bool same(const size_type x, const size_type y) {
		assert(x < tree.size());
		assert(y < tree.size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < tree.size());
		return tree[find(x)].second;
	}
};

#include<iostream>
int main(void) {
	int n, q;
	std::cin >> n >> q;
	UnionFindTree T(n);
	while (q--) {
		int p, a, b;
		std::cin >> p >> a >> b;
		if (p) {
			std::cout << (T.same(a, b) ? 1 : 0) << std::endl;
		}
		else {
			T.unite(a, b);
		}
	}
	return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pq priority_queue
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
// #define multicase
const int MOD = 1e9 + 7;
const int INF = 2e9;
// const int N = ;

int q, a, b, dou, ans;

void solve() {
    int T = 1;
  #ifdef multicase
    cin >> T;
  #endif
    for(int tc = 1; tc <= T; tc++) {
        cin >> q;
        while(q--) {
            cin >> a >> b;
            if(a == b) dou++;
            else {
                ans = max(ans, dou);
                dou = 0;
            }
        }
        ans = max(ans, dou);
        cout << (ans >= 3 ? "Yes\n" : "No\n");
    }
}

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    solve();
    
}

Measured memory_bytes: 3636
n,m,a,b,cost,time;
k,p,q,r;
C[9][101][101];
void floyd(){
	int*c,i,j,k,r,t;
	for(r=0;r<9;r++){
		for(k=1;k<=m;k++){
			for(i=1;i<=m;i++){
				for(j=1;j<=m;j++){
					t=C[r][i][k]+C[r][k][j];
					c=C[r][i]+j;
					*c=*c<t?*c:t;
				}
			}
		}
	}
}
main(){
	for(;scanf("%d%d",&n,&m),n|m;){
		memset(C,9,sizeof(C));
		for(p=1;p<=m;p++)
			C[0][p][p]=C[1][p][p]=0;
		for(;n--;){
			scanf("%d%d%d%d",&a,&b,&cost,&time);
			C[0][a][b]=C[0][b][a]=cost;
			C[1][a][b]=C[1][b][a]=time;
		}
		floyd();
		scanf("%d",&k);
		for(;k--;){
			scanf("%d%d%d",&p,&q,&r);
			printf("%d\n",C[r][p][q]);
		}
	}
	exit(0);
}

Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int n;
ll b;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n;
    vector<ll> a(n), b(n);
    for (auto& i : a) cin >> i;
    for (auto& i : b) cin >> i;
    vector<int> diff(n);

    for (int i = 0; i < n; i++) {
        diff[i] = b[i] - a[i];
    }
    sort(diff.begin(), diff.end(), greater<ll>());

    ll overflow = 0;
    for (auto& i : diff) {
        if (i >= 0) overflow += i / 2;
        else {
            i = -i;
            if (overflow < i) {
                cout << "No";
                return 0;
            }
            overflow -= i;
        }   
    }

    cout << "Yes";
}


Measured memory_bytes: 512
N = int(input())
S = input()

cum_w = [0] * (N)
if S[0] == 'W':
  cum_w[0] = 1
for i in range(1,N):
  if S[i] == 'W':
    cum_w[i] = cum_w[i-1] + 1
  else:
    cum_w[i] = cum_w[i-1]
  
ans = N - 1 - cum_w[-1] + cum_w[0]
for i in range(1,N):
  ans = min(ans, cum_w[i-1] + N - i - 1 - cum_w[-1] + cum_w[i])

print(ans)

Measured memory_bytes: 15264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {

    int n; cin >> n;
    
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int tmp; cin >> tmp;
        mp[tmp] = 1;
    }
    int cnt = 0;
    for (auto u : mp) {
        cnt++;
    }

    cout << cnt << endl;
    return 0;

}

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

using namespace std;

int gcd(int m, int n){
	if(m < n){ return gcd(n, m); }
	if(n == 0){ return m; }
	if(m % n == 0){ return n; }
	return gcd(n, m % n);
}

bool bipartite_matching_dfs(
	int v, const vector< vector<int> > &conn,
	vector<bool> &used, vector<int> &match)
{
	used[v] = true;
	for(int i = 0; i < conn[v].size(); ++i){
		int u = conn[v][i], w = match[u];
		if(w < 0 || !used[w] && bipartite_matching_dfs(w, conn, used, match)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}
int bipartite_matching(const vector< vector<int> > &conn){
	int res = 0;
	vector<int> match(conn.size(), -1);
	vector<bool> used(conn.size(), false);
	for(int v = 0; v < conn.size(); ++v){
		if(match[v] < 0){
			fill(used.begin(), used.end(), false);
			if(bipartite_matching_dfs(v, conn, used, match)){ ++res; }
		}
	}
	return res;
}

int main(){
	while(true){
		int m, n;
		cin >> m >> n;
		if(m == 0 && n == 0){ break; }
		vector<int> cards(m + n);
		for(int i = 0; i < m + n; ++i){ cin >> cards[i]; }
		vector< vector<int> > conn(m + n);
		for(int i = 0; i < m; ++i){
			for(int j = 0; j < n; ++j){
				if(gcd(cards[i], cards[j + m]) > 1){
					conn[i].push_back(j + m);
					conn[j + m].push_back(i);
				}
			}
		}
		cout << bipartite_matching(conn) << endl;
	}
	return 0;
}

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

using namespace std;

long long n;
long long a[200010];
long long sum[200010];
long long f[200010];
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	sum[1] = a[1];
	for(int i = 2; i <= n; i++)
	{
		sum[i] = sum[i-2] + a[i];
	}
	for(int i = 2; i <= n; i++)
	{
		if(i & 1)
		{
			f[i] = max(f[i-2] + a[i], f[i-1]);
		}
		else
		{
			f[i] = max(f[i-2]+a[i], sum[i-1]);
		}
	}
	cout << f[n] << endl;
	return 0;
}


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

long int gcd(long int a, long int b)
{
return (b==0 ? a : gcd (b, a%b));
}
int main()
{
    long long a, b;
    while(scanf ("%lld %lld", &a, &b) != EOF)
    {
              long long x = gcd(a,b);
              printf("%d\n", x);
    }
return 0;
}

Measured memory_bytes: 0
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# Factoring by trial split
def getPrimeList(n):
  l=[]
  t=int(math.sqrt(n))+1
  
  for a in range(2,t):
    while n%a==0:
      n//=a
      l.append(a)
  
  if n!=1:
    l.append(n)
  
  return l

def main():
  a,b=LI()

  if a==1 and b==1:
    return 1

  a=getPrimeList(a)
  b=getPrimeList(b)

  a=list(set(a))
  b=list(set(b))

  c=a+b
  c.sort()

  ans=1
  y=c[0]
  cnt=1
  for x in c[1:]:
    if x==y:
      cnt+=1
    else:
      y=x
      cnt=1

    if cnt==2:
      ans+=1

  return ans

# main()
print(main())


Measured memory_bytes: 6736
//Shivam gupta (Codeforces handle : shivam_1999)

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

#define mod 1000000007
#define ll long long
#define ld long double
typedef vector<long long> vi;
typedef vector<vi> vvi;
typedef pair<long long, long long> pii;
typedef vector<pair<long long, long long>> vpii;
typedef map<long long, long long> mii;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define sorta(x) sort(x.begin(),x.end())
#define sortd(v) sort(all(v), greater<ll>())
#define el cout << endl;
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define cpresent(container, element) (find(all(container), element) != container.end())
#define deb(x) cout << #x << x << endl;
#define fl(i,n) for(ll i=0;i<n;i++)
#define fls(i,x,n) for(ll i=x;i<n;i++)
#define flr(i,n)  for(ll i=n-1;i>=0;i--)
#define fla(i,v)  for(auto i:v)    
#define in(v) for(auto &i:v){cin>>i;}
#define INF 1e9+1
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define tt    \
    int T;    \
    cin >> T; \
    while (T--)

int main()
{   fast
    string s,t;
    cin >> s >> t;
    int n, m;
    n = s.length();
    m = t.length();
    int dp[n + 1][m + 1];
    fl(i,n+1){
        fl(j,m+1){
            if (i == 0 || j == 0)
            {
                dp[i][j] = 0;
                continue;
            }
            if(s[i-1]==t[j-1])
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    string ans = "";
    int i = n, j = m;

    while (i > 0 && j > 0){
        if(s[i-1]==t[j-1]){
            ans.pb(s[i - 1]);
            i--;
            j--;
        }
        else if (dp[i - 1][j] > dp[i][j - 1])
            i--;
        else
            j--;
    }
    reverse(all(ans));
    cout << ans << endl;
}


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

//各桁の和を求める
int sum(int a){
    int sum = 0;
    for(int b = a;b > 0;b /= 10)sum += b % 10;
    return sum;
}


int main(void){
    int n,min = 1000000;
    cin >> n;
    
    for(int a = 1;a < n;a++){
        if(sum(a) + sum(n-a) < min)min = sum(a) + sum(n-a);
    }
    cout << min << endl;
}

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

a = 0
w = 0
t = 0
r = 0

for _ in range(n):
    s = input()
    if(s=="AC"):
        a+=1
    elif(s=="WA"):
        w+=1
    elif(s=="TLE"):
        t+=1
    else:
        r+=1

print("AC x ",end="")
print(a)
print("WA x ",end="")
print(w)
print("TLE x ",end="")
print(t)
print("RE x ",end="")
print(r)

Measured memory_bytes: 9212
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for (int i = 1; i <= N; ++i) {
    int tmp = i;
    int cnt = 0;
    while (tmp % 2 == 0) {
      tmp /= 2;
      cnt++;
    }
    ans = max(ans, cnt);
  }
  cout << pow(2, ans) << endl;
  return 0;
}


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

long long n, m, ans = 0;

int main() {
  cin >> n >> m;
  if(n > m) swap(n, m);
  if(n * m == 1)
    ans = 1;
  else if(n == 1)
    ans = m - 2;
  else {
    ans = (n - 2) * (m - 2);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007

class RSQ
{
private:
    vector<int> v;
    int init;
    int n;

public:
    RSQ(int k, int in)
    {
        n = 1;
        init = in;
        while (n < k)
            n *= 2;
        v = vector<int>(2 * n, init);
    }
    void add(int x, int val)
    {
        x += n - 1;
        v[x] += val;
        while (x > 0)
        {
            x = (x - 1) / 2;
            v[x] = v[2 * x + 1] + v[2 * x + 2];
        }
    }
    int getSum(int nl, int nr, int idx, int tl, int tr)
    {
        if (tr <= nl || nr <= tl)
            return init;
        if (tl <= nl && nr <= tr)
            return v[idx];
        return getSum(nl, (nl + nr) / 2, 2 * idx + 1, tl, tr) + getSum((nl + nr) / 2, nr, 2 * idx + 2, tl, tr);
    }
    int getSum(int l, int r) { return getSum(0, n, 0, l, r); }
};

int main()
{
    int n, q;
    cin >> n >> q;
    int c[500000];
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        c[i]--;
    }
    vector<int> prev(n, -1);
    RSQ rsq(n, 0);
    vector<vector<pair<int, int>>> lridx(n);
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r--;
        lridx[l].push_back(make_pair(r, i));
    }
    vector<int> ans(q);
    for (int i = n - 1; i >= 0; i--)
    {
        if (prev[c[i]] >= 0)
        {
            rsq.add(prev[c[i]], -1);
        }
        rsq.add(i, 1);
        prev[c[i]] = i;
        for (int j = 0; j < lridx[i].size(); j++)
        {
            int r = lridx[i][j].first;
            int idx = lridx[i][j].second;
            ans[idx] = rsq.getSum(i, r + 1);
        }
    }
    for (int i = 0; i < q; i++)
    {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 35276
def max(a, b)
a > b ? a : b
end

N = gets.to_i
arr = gets.split.map(&:to_i)
dp = Array.new(N).map{Array.new(N, 0)}#N.times.map{[0]*(N)}
N.times.each do |i|
  dp[i][i] = arr[i]
end

(1..(N-1)).each do |length|
  (0..(N-1-length)).each do |left|
    right = left + length
    dp[left][right] = max(arr[left] - dp[left + 1][right], arr[right] - dp[left][right - 1])
  end
end
puts dp.first.last

Measured memory_bytes: 74364
N = int(input())
A = list(map(int, input().split()))

right = 0
left = 0
sumEx = 0
sumNo = 0
ans = 0

while left < N :
    while right < N :
        if (sumEx ^ A[right]) == (sumNo + A[right]) :
            sumEx += A[right]
            sumNo += A[right]
            right += 1
            continue
        break
    ans += right - left
    sumEx ^= A[left]
    sumNo -= A[left]
    left += 1

print(ans)

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

#define hell                         1000000007
#define lcm(a,b)                     (a*b)/__gcd(a,b)
#define ll                           long long
#define vll                          vector<ll>
#define vi                           vector<int>
#define pll                          vector< pair<ll,ll> >
#define pb                           push_back
#define mp                           make_pair
#define all(v)                       v.begin(),v.end()
#define lbnd                         lower_bound
#define ubnd                         upper_bound
#define bs                           binary_search
#define F                            first
#define S                            second
#define rep(i,a,b)                   for(i=a;i<b;i++)
#define parr(a,n)                    for(ll it=0;it<n;it++) cout<<a[it]<<" ";cout<<endl;
#define pcont(a)                     for(auto it:a) cout<<it<<" ";cout<<endl;
#define ret(x)                       return cout<<x,0;
#define endl                           '\n'

/*constants*/
#define MAXN                         100005
#define PI                           3.14159265358979323846

/*debug*/
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>void __f(const char* name, Arg1&& arg1){ std::cout << name << " : " << arg1 << '\n';}
    template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ','); std::cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define trace(...)
#endif

using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	
	ll i,j,n,m,k,cnt=0,ans=0,t=1;
	cin>>k>>j;
	for(i=k-1;i>0;i--) cout<<j-i<<" ";
	rep(i,0,k) cout<<j+i<<" ";	
	
	return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;
 
class Main {
 
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        int d = a / b;
        int r = a % b;
        double f = (double)a / b;
        BigDecimal g = new BigDecimal(f);
        g = g.setScale(5,BigDecimal.ROUND_HALF_UP);
        System.out.printf("%d" + " " + "%d" + " " + "%.5f",d, r, g);
    }
}

Measured memory_bytes: 26528
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    int sol = max(a1, max(a2, a3)) - min(a1, min(a2,a3));
    cout << sol << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int S,h,m,s;
	scanf("%d",&S);
	s=S;
	
	h=s/3600;
	s=s%3600;
	
	m=s/60;
	s=s%60;
	
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 1020
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
int32_t main(){_

   string s;
   cin >> s;

   int ans = 0;

   int l = 0, r = sz(s) - 1;

   while(l < r){
      if(s[l] != s[r])
         ans++;
      l++;
      r--;
   }

   cout<<ans;
   

   return 0;
}


Measured memory_bytes: 256
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    # line 1 and the last
    s = ""
    for _ in range(w):
        s += "#"
    # other lines
    ss = "#"
    for _ in range(w - 2):
        ss += "."
    ss += "#"
    print(s)
    for _ in range(h - 2):
        print(ss)
    print(s + '\n')



Measured memory_bytes: 5620
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int color[220];

Int dist[220][220];
Int n;
Int ans;
char c;
bool bipartite(int v, int c = 1){
    if(color[v] != 0)return color[v] == c;
    color[v] = c;
    for(int i = 0;i < n;i++){
        if(dist[v][i] != 1)continue;
        if(!bipartite(i, 3-c))return false;
    }
    return true;
}


int main(){
    cin >> n;
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            cin >> c;
            if(c == '1')dist[i][j] = 1;
            else dist[i][j] = INF;
        }
    }
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            for(int k = 0;k < n;k++){
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    if(!bipartite(0)){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0;i < n;i++){
        for(int j = i+1;j < n;j++){
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;

signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    int cnt1 = 0;
    if(a == 1) cnt1++;
    if(b == 1) cnt1++;
    if(c == 1) cnt1++;

    if( !(a % 2) || !(b % 2) || !(c % 2)){
        cout << 0 << endl;
    }else{
        int ans = min(a*b, b*c);
        ans = min(ans, c*a);
        cout << ans << endl;
    }
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    int p;
    cin>>p;
    vector<int> v;
    vector<ll> dp(500001,0);
    dp[0]=1;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        for(int j=5000;j>=0;j--)
        {
            dp[j+a]+=dp[j];
        }
    }
    ll brojac=0;
    for(int i=0;i<=5000;i++)
    {
        if(i%2==p)
            brojac+=dp[i];
    }
    cout<<brojac<<endl;
    return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int a;
int main() {
    DAU
  	cin >> a;
    cout << 3LL * a * a;
    PLEC
}


Measured memory_bytes: 3612
from collections import deque
x,y,a,b,c = map(int,input().split())
red = [int(i) for i in input().split()]
g = [int(i) for i in input().split()]
w = [int(i) for i in input().split()]
red.sort(reverse=True)
g.sort(reverse=True)
g = g[:y]
gw = g+w
gw.sort(reverse=True)
gwrui = []
rui = 0
for i in range(y+c):
    rui += gw[i]
    gwrui.append(rui)
red = red[:x]
rrui = []
rui = 0
for i in range(x):
    rui += red[i]
    rrui.append(rui)
rrui = [0] + rrui
ans = 0
oisr = 0
lgw = len(gw)
#print(red,gw,gwrui)
for i in range(0,x+1):
    temp = rrui[i]
    if x+y-i <= lgw:
        temp += gwrui[x+y-i-1]
        ans = max(ans,temp)
print(ans)

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

typedef long long ll;

ll K, X;
int main() {
    cin >> K >> X;

    if (500 * K >= X) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
q = int(input())
A = [0 for i in range(1500000)]
A[0] = 'end'
cursor = 0
head = [0 for i in range(1500000)]
head_len = 0

def insert(x):
	global cursor
	cursor += 1
	A[cursor] = x
def move(d):
	global cursor, head, head_len
	if d >= 0:
		head[head_len-1+d+(1): head_len-1+(1):-1] = A[cursor-d+1:cursor+1]
	else:
		A[cursor+1:cursor+1+(-d)] = head[head_len-1+(1):head_len-(-d)-1+(1):-1]
	cursor -= d
	head_len += d
def erase():
	global cursor
	cursor -= 1

for i in range(q):
	a = input()
	if a != "2":
		b = [int(i) for i in a.split()]
		if b[0] == 0:
			insert(b[1])
		elif b[0] == 1:
			move(b[1])
	else:
		erase()
	#print(A[:cursor+1],head[1:1+head_len][::-1])

A[cursor+1:cursor+1+head_len] = head[head_len-1+(1):-1+(1):-1]
length = cursor +  head_len
for i in range(1,length+1)[::-1]:
	print(A[i])





Measured memory_bytes: 41528
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>
#include <iomanip>
#include <math.h>
const int MOD = 1000000007;
 
 
ll POWER(ll x,ll y)
{
	ll ret=1;
	ll p=x;
	for (ll i=y;i>0;i/=2)
	{
		if (i%2) ret=(ret*p)%MOD;
		p=(p*p)%MOD;
	}
	return ret;
}


int main(int argc, char *argv[])
{
	int n;
	cin>>n;
	
	ll _10=POWER(10,n);
	ll _9=POWER(9,n);
	ll _8=POWER(8,n);

	ll a=(_10+(MOD-_9))%MOD;
	ll b=(_8+(MOD-_9))%MOD;

	ll ret=(a+b)%MOD;
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    vector<vector<bool>> c(H, vector<bool>(W, false));
    REP(i,h) REP(j,W) c[i][j] = true;
    REP(i,H) REP(j,w) c[i][j] = true;
    int ans = 0;
    REP(i,H) REP(j,W) if (!c[i][j]) ans++;
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n, m = Is()
A = LI()
BC = TIR(m)
A.sort()
BC.sort(key=itemgetter(1), reverse=True)
D = []
for b, c in BC:
    D += [c]*b
    if len(D) > n:
        break

for i in range(min(n, len(D))):
    if A[i] < D[i]:
        A[i] = D[i]
    else:
        break

print(sum(A))


Measured memory_bytes: 109672
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

struct Solve
{
    string a, b, c, ans;

    Solve(string a, string b, string c) : a(a), b(b), c(c) {}

    void push_down(string s, string t, int apos, int bpos, int cpos, char buff)
    {
        s += buff;
        buff = a[apos];
        run(s, t, apos + 1, bpos, cpos + 1, buff);
    }

    void push_right(string s, string t, int apos, int bpos, int cpos, char buff)
    {
        t += buff;
        buff = b[bpos];
        run(s, t, apos, bpos + 1, cpos, buff);
    }

    void run(string s, string t, int apos, int bpos, int cpos, char buff)
    {
        if(s.back() != c[s.size() - 1] or apos > a.size() or bpos > b.size() or cpos > c.size()) return;
        if(s == c)
        {
            t += buff;
             while(apos != a.size()) t += a[apos++];
             while(bpos != b.size()) t += b[bpos++];
            ans = t;
            ans.erase(ans.begin());
            return;
        }
        if(a[apos] == c[cpos]) push_down(s, t, apos, bpos, cpos, buff);
        else if(b[bpos] == c[cpos]) push_right(s, t, apos, bpos, cpos, buff);
        else
        {
            push_down(s, t, apos, bpos, cpos, buff);
            push_right(s, t, apos, bpos, cpos, buff);
        }
    }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b, c;
    while(cin >> a, a != "-")
    {
        cin >> b >> c;
        Solve p(a, b, c);
        p.run("", "", 0, 0, 0, '\0');
        cout << p.ans << endl;
    }
    return 0;
}




Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <algorithm>
#include <ctime>
#include <limits>
#include <cmath>


using namespace std;

//  ||
// \

int main() {
	 int y = 0, m = 0, d = 0;
	 char c1, c2;
	 cin >> y >> c1 >> m >> c2 >> d;
	 if(m <= 04) {
	 	cout << "Heisei" << endl;
	 }
	 else {
	 	cout << "TBD" << endl;
	 }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

	int ac = 0;
	int wa = 0;
	int tle = 0;
	int re = 0;

	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s == "AC")  ac++;
		if (s == "WA")  wa++;
		if (s == "TLE") tle++;
		if (s == "RE")  re++;
	}
	
	cout << "AC x " << ac << endl;
	cout << "WA x " << wa << endl;
	cout << "TLE x " << tle << endl;
	cout << "RE x " << re << endl;

	return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<math.h>
int main()
{
  int n,i,a[10000],count=0,j,limit;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n;i++){
    if(a[i]>=2){
      limit=(int)sqrt((double)a[i]);
    for(j=limit;j>1;j--){
      if(a[i]%j == 0)
	break;
  }
    if(j==1)count++;
  }
  }
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 632
#include <stdio.h>
        #include <stdlib.h>
         
        int main(void)
        {
            long long n, a, b, max = 0, maxi;
            scanf("%lld%lld%lld", &n, &a, &b);
            long long h[n];
            for (int i = 0; i < n; ++i){
                 scanf("%lld", &h[i]);
                 if (max < h[i])
                    max = h[i];
            }
         
            long long del = a - b, l = 0, r = 1e9 + 7, t;
            while (r - l > 1){
                t = (l+r)/2;
                long long ch = t;
                for (int i = 0; i < n; ++i){
                    if (t*b < h[i]){
                        ch -= (h[i] - t*b)/del + ((h[i] - t*b)%del? 1:0);
                    }
                }
                if (ch < 0)
                    l = t;
                else
                    r = t;
            }
            printf("%lld\n", r);
            return 0;
        }

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

long long ans;
bool graph[100][100],visited[100];

void dfs(int now, int n){
  for(int i=0;i<n;i++){
    if(now!=i and graph[now][i] and !visited[i]){
      visited[i]=true;
      dfs(i, n);
    }
  }
}

int main(){
  int n,m;
  cin >> n >> m;
  int a[m],b[m];
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<n;j++){
      visited[j]=false;
    }
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    dfs(0, n);
    for(int j=0;j<n;j++){
      if(!visited[j]){
        ans++;
        break;
      }
    }
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
read
a=(`dd`)
t=0
c=1
LIM=$[10**18]
for b in ${a[@]};do
 if [ $b -eq 0 ];then
  echo 0
  exit
 fi
 if [ $t -eq -1 -o $b -gt $[LIM/c] ];then
  t=-1
 else
  c=$[c*b]
 fi
done
if [ $t -eq -1 -o $c -gt $LIM ];then
 echo -1
else
 echo $c
fi

Measured memory_bytes: 32236
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


int main() {

    int N;
    cin >> N;

    int numOfOdd = 0;

    for (int i = 0; i < N; i++) {
        int A;
        cin >> A;
        if (A % 2 == 1) {
            numOfOdd += 1;
        }
    }

    if (numOfOdd % 2 == 0) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(){
    int h, w;
    while(true){
        cin >> h >> w;
        if(h == 0 && w == 0) return 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i == 0 || j == 0 || i == h-1 || j == w-1){
                    printf("#");
                } else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }

}



Measured memory_bytes: 3076
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<climits>
#include<set>
#include<map>
#include<stack>
#define ll long long
using namespace std;

int main() {
	ll a, b, c, x, y,ans;
	cin >> a >> b >> c >> x >> y;
	ans= min({ a*x + b * y,
		2 * c*min(x,y) +( x>y?a:b)*(max(x,y) - min(x,y)),
		2*c*max(x,y)});
	//cout << 2 * c*min(x, y) << endl;
	//cout << (x > y ? a : b) << endl;
	//cout<< max(x, y) - min(x, y) << endl;
	//cout << (x > y ? a : b)*(max(x, y) - min(x, y)) << endl;
	//cout << 2 * c*min(x, y) + (x > y ? a : b)*(max(x, y) - min(x, y)) << endl;
	cout << ans << endl;

	
	
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<long> a(N+1);
  for(int i=0;i<=N;i++){
    if(i==0) a.at(i)=2;
    else if(i==1) {
      a.at(i)=1;
    }else{
      a.at(i)=a.at(i-1)+a.at(i-2);
    }
  }
  cout << a.at(N) << endl;
}

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

using namespace std;
const long long INF = (long long) (1e18)+1;


int main() {
  string s; // string
  int n_q; // number of query

  cin >> s;
  cin >> n_q;
  deque<char> d_s;

  for (int i =0; i<s.size(); ++i) {
    d_s.push_back(s[i]);
  } 
  int counts =0;
  for (int i=0; i<n_q; ++i) {
    int t; // query type 1 or 2
    cin >> t;
    if ( t == 1 ){
      ++counts;
    } else {
      // cout << t << endl;
      int t_2;
      char c;
      cin >> t_2 >> c;
      if (t_2 == 1) {
        if(counts % 2 != 0) {
          d_s.push_back(c);

        } else {
          d_s.push_front(c);

        }
      } else {
        if(counts % 2 != 0) {
          d_s.push_front(c);

        } else {
          d_s.push_back(c);

        }

      }
    }
  }
  if (counts % 2 != 0) {
    reverse(d_s.begin(), d_s.end());
  } 
  for(auto& a : d_s) {
    cout << a;
  }
  return 0;
}

Measured memory_bytes: 896
#include<cmath>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
long long solve(int a, int b) {
	if( a == b || a + 1 == b ) return 2 * (a - 1);
	int c = ceil(sqrt(1ll * a * b)) - 1;
	if( 1ll * c * (c+1) >= 1ll * a * b ) return 2 * (c - 1);
	else return 2 * (c - 1) + 1;
}
int main() {
	int Q;
	scanf("%d", &Q);
	for(int i=1;i<=Q;i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		printf("%lld\n", solve(a, b));
	}
}

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


int main() {
	string s, t;
	cin >> s >> t;
	rep(i, s.size()) {
		if (s[i] == t[i]) continue;
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main(void) {
	char s;
	scanf("%c", &s);

	if ((s >= 'a') && (s <= 'z')) {
		printf("a");
	}
	else if ((s >= 'A') && (s <= 'Z')) {
		printf("A");
	}
	else {
		return 0;
	}
	return 0;
}


Measured memory_bytes: 1596
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <iomanip>
#include <queue>
#include <algorithm>

using namespace std;
using ll = long long int;
const ll MOD = 1e9 + 7;

ll fast(ll n, ll k) {
	if (k == 0) {
		return 1;
	}
	if (k == 1) {
		return n;
	}
	if (k % 2 == 0) {
		ll tmp = fast(n, k / 2);
		return tmp * tmp % MOD;
	}
	else {
		ll tmp = fast(n, k / 2);
		tmp = tmp * tmp % MOD;
		return n * tmp % MOD;
	}
}

int main() {

	ll a, b, c;
	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		cout << min(a * b, min(b * c, a * c)) << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<set>

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	rep(i, n)cin >> a[i];
	ll cnt(0);
	rep(i, n) {
		if (i == 0)continue;
		if (a[i] < a[i - 1]) {
			ll k = a[i - 1]-a[i];
			cnt += k;
			a[i] += k;
		}
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
int main()
  {
    int n;
  long long d;
    cin>>n>>d;
  int ans = 0;
  while(n--)
  {
	long long a,b;
    cin>>a>>b;
    if(ceil(sqrt(pow(1.0*a,2.0)+pow(1.0*b,2.0)))<=d)ans++;
  }
  cout<<ans;
  }

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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int count = 0;
    for (int i = 0; i < 1000; i++) {
        string str;
        if (i < 10) {
            str = "00" + to_string(i);
        } else if (i < 100) {
            str = "0" + to_string(i);
        } else {
            str = to_string(i);
        }
        int idx = 0;
        bool found = true;
        for (int in = 2; in >= 0; in--) {
            bool local_found = false;
            for (int k = idx; k < (int)s.size(); k++) {
                if (s[k] == str[in]) {
                    idx = k + 1;
                    local_found = true;
                    break;
                }
            }
            if (!local_found) {
                found = false;
                break;
            }
        }
        if (found) {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = 3.1415926535897932;
const ll MOD = 1000000007;

int main()
{
    int n;
    cin >> n;
    int cnt = 0;
    int ans = 0;
    int h_pre = 0;
    rep(i, n) {
        int h;
        cin >> h;
        if (h <= h_pre) {
            cnt++;
        }
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
        h_pre = h;
    }
    ans = max(ans, cnt);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
using namespace std;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a % b << " ";
	double d;
	d = (double) a / b;
	printf("%.10lf\n", d);
	return 0;
}

Measured memory_bytes: 1240
//
// Created by 拓真 on 2018/06/24.
//

#include "bits/stdc++.h"

using namespace std;


int x[11234];
int main(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<n;i++)x[i]=1;
    for(int i=0;i<m;i++){
        int c,d;
        cin>>c>>d;
        for(int j=c;j<d;j++){
            x[j]=3;
        }
    }
    int ans=0;
    for(int i=0;i<n;i++){
        ans+=x[i];
    }
    cout<<ans+1<<endl;
}



Measured memory_bytes: 3104
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


def ZIP(n): return zip(*(MAP() for _ in range(n)))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    ans = 0
    for i in range(1, n+1):
        if i % 3 != 0 and i % 5 != 0:
            ans += i

    print(ans)


if __name__ == '__main__':
    main()


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

#define FOR(i,l,r) for(int i = (l);i < (r);i++)
#define ALL(x) (x).begin(),(x).end()
template<typename T> void chmax(T& a,const T& b){if(a < b) a = b;}
template<typename T> void chmin(T& a,const T& b){if(b < a) a = b;}
typedef long long ll;

int N;

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

	cin >> N;
	vector<ll> A(N),P(N + 1);
	FOR(i,0,N){
		cin >> A [i];
		P [A [i]] = i;
	}

	ll ans = 0;
	set<int> st{-1,N};
	for(int i = 1;i <= N;i++){
		auto it = st.lower_bound(P [i]);
		ll r = *it,l = *(--it);
		st.insert(P [i]);
		ans += (r - P [i]) * (P [i] - l) * i;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <algorithm>
#define N 5002
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
int a, b, c;
int main() {
	cin>>a>>b>>c;
    if (c >= a && c <= b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define ALL(x) (x).begin(),(x).end()
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define int ll

signed main(){
    int a[26]={};
    string s;
    cin >> s;
    REP(i,LEN(s)) a[s[i]-97]++;
    int ans = LEN(s)*(LEN(s)-1)/2;
    int sub = 0;
    REP(i,26){
        sub += a[i]*(a[i]-1)/2;
    }
    printf("%lld\n",ans-sub+1);
}

Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve() {
  ll n;
  cin>>n;
  vi a(n),b(n+1,0);
  rep(i,n) cin>>a[i];
  rep(i,n) b[a[i]]++;
  REP(i,1,n+1) out(b[i]);
}

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


Measured memory_bytes: 6348
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cerr<<" #"<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=2000005;
char s[N],t[N];
int n,a,b,ans;

int main(){
	read(n);
	scanf("%s",s+1);
	a=strlen(s+1);
	scanf("%s",t+1);
	b=strlen(t+1);
	n=max(n,max(a,b));
	ans=max(n,a+b);
	rep(i,max(0,n-b),a-1){
		int flag=1;
		for(int x=i+1,y=1;x<=a&&y<=b;x++,y++)	
			if(s[x]!=t[y]){
				flag=0;
				break;
			}
		if(flag)ans=min(ans,i+b);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

K = i()
print('ACL'*K)

Measured memory_bytes: 72732