akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return (t * t) % mod;
    } else {
        return (modpow(m, n - 1) * m) % mod;
    }
}

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

struct LCA {
    vector<vector<int>> par;
    vector<int> d;
    int n;
    LCA(vector<vector<int>> graph, int root) {
        n = graph.size();
        par.resize(n, vector<int>(30));
        d.resize(n, 0);
        function<void(int, int, int)> dfs = [&](int c, int p, int depth) {
            d[c] = depth;
            par[c][0] = p;
            for (auto ch : graph[c]) {
                if (ch != p) dfs(ch, c, depth + 1);
            }
        };
        dfs(0, 0, 0);
        for (int j = 1; j < 30; j++) {
            REP(i, n) { par[i][j] = par[par[i][j - 1]][j - 1]; }
        }
    }
    int getdistance(int u, int v) { return (d[u] + d[v]) - 2 * (d[query(u, v)]); }
    int query(int u, int v) {
        if (d[u] > d[v]) {
            swap(u, v);
        }
        for (int i = 29; 0 <= i; i--) {
            if (d[u] <= d[par[v][i]]) {
                v = par[v][i];
            }
        }
        /* LCA */
        for (int i = 29; 0 <= i; i--) {
            if (par[v][i] != par[u][i]) {
                v = par[v][i];
                u = par[u][i];
            }
        }
        if (u == v) {
            return u;
        } else {
            return par[v][0];
        }
    }
};

struct UnionFind {
    vector<int> parent, size;
    UnionFind(int n) {
        parent.resize(n, -1);
        size.resize(n, 1);
    }
    void unite(int x, int y) {
        if (same(x, y)) {
            return;
        }
        x = root(x);
        y = root(y);
        if (size[x] <= size[y]) {
            swap(x, y);
        }
        parent[y] = x;
        size[x] += size[y];
    }
    bool same(int x, int y) { return (root(x) == root(y)); }
    int root(int x) {
        while (parent[x] != -1) {
            x = parent[x];
        }
        return x;
    }
    int getsize(int x) { return size[root(x)]; }
};
int n, m;
vector<vector<int>> graph;

signed main() {
    int n;
    cin >> n;
    vector<tuple<int, int, char, long long, string>> as(n);
    REP(i, n) { cin >> get<0>(as[i]) >> get<1>(as[i]) >> get<2>(as[i]) >> get<3>(as[i]) >> get<4>(as[i]); }
    sort(as.begin(), as.end());
    REP(i, n) {
        cout << get<0>(as[i]) << " " << get<1>(as[i]) << " " << get<2>(as[i]) << " " << get<3>(as[i]) << " " << get<4>(as[i])
             << endl;
    }
}


Measured memory_bytes: 11132
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (auto &x: a) cin >> x;

  int ans = 1000000007;
  for (int i = 0; i < n-k+1; i++) {
    int d = max(0, -a[i]) + max(0, a[i+k-1]) + min(max(0, -a[i]), max(0, a[i+k-1]));
    if (d < ans) ans = d;
  }

  cout << ans << endl;

  return 0;
}


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

class DSU {
	private:
		vector<int> comp, siz;
	public:
		DSU(int n) : comp(n), siz(n, 1) {
			for (int i = 0; i < n; ++i) comp[i] = i;
		}
		int get(int i) {
			if (comp[i] != i) comp[i] = get(comp[i]);
			return comp[i];
		}
		bool join(int a, int b) {
			a = get(a);
			b = get(b);
			if (a == b) return false;

			if (siz[a] < siz[b]) swap(a, b);
			siz[a] += siz[b];
			comp[b] = a;
			return true;
		}
		int compSize(int i) { return siz[get(i)]; }
};

bool solve() {
	int n, q;
	ll m;
	cin >> n >> m >> q;

	int cc = n; // component count
	DSU dsu(n);
	vector<pair<int, int>> bans;
	for (int i = 0; i < q; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		if (c == 0) cc -= dsu.join(a, b);
		else bans.emplace_back(a, b);
	}
	for (auto pr : bans) {
		if (dsu.get(pr.first) == dsu.get(pr.second)) return false;
	}
	ll low = n-cc + cc;
	ll high = n-cc + (ll)cc * (cc - 1) / 2;
	if (cc == 1 || bans.empty()) --low;
	return (low <= m && m <= high);
}

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

	bool res = solve();
	cout << (res ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 2168
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}

vll divisors[10000001];
int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll n,d;
	cin>>n>>d;
	ll total = 0;
	rep(i,n){
		ll x,y;
		cin>>x>>y;
		if((x*x+y*y)<=d*d){
			total++;
		}
	}
	cout<<total;
	return 0;
}

Measured memory_bytes: 237992
#include<bits/stdc++.h>
using namespace std;
using vi=vector<int>;
long n,m,x,pri,primin=10000000;
vi c(12);
vector<vi> a(12,vi(12));

int main(){
  cin>>n>>m>>x;
  for(int i=0;i<n;i++){
    cin>>c[i];
    for(int j=0;j<m;j++){
      cin>>a[i][j];
    }
  }for(int bit=1;bit<pow(2,n);bit++){
    pri=0;
    vi ans(m,0);
    for(int i=0;i<n;i++){
      if(bit & (1<<i)){
        pri+=c[i];
        for(int j=0;j<m;j++){
          ans[j]+=a[i][j];
        }
      }
    }
    bool uns=true;
    for(int i=0;i<m;i++){
      if(ans[i]<x){
        uns=false;
      }
    }
    if(uns){
      primin=min(primin,pri);
    }
  }
  if(primin==10000000){
    cout<<-1<<endl;
  }else{
    cout<<primin<<endl;
  }
}

Measured memory_bytes: 4092
#include <bits/stdc++.h>
    using namespace std;
     
    int main () 
    {
        int n;
        cin >> n;
        
        long long R[n];
        for (int i = 0; i < n; i++) 
        {
            std::cin >> R[i];
        }
        
        long long max;
        long long min;
        for (int i = 0; i < n; i++) 
        {
            if (i == 0) {min = R[0]; max = R[1] - R[0];}
            else
            {
                if (min > R[i])
                {
                    min = R[i];
                    //std::cout << "min changed: " << min << std::endl;
                }
                else if (max < R[i] - min)
                {
                    max = R[i] - min;
                    //std::cout << "max changed: " << max << std::endl;
                }
            }
        }
        
        std::cout << max << std::endl;
        
        return 0;
    }


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

int main(void){
    int n;
    cin >> n;
    vector<double> v(n);
    double ave = 0;
    for(int i=0; i<n; i++){
        cin >> v.at(i);
        ave += v.at(i);
    }
    ave /= (double)n;
    double diff = 1e9, ans = -1;
    for(int i=0; i<n; i++){
        double d = abs(v.at(i) - ave);
        if(d < diff){
            diff = d;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i,n)   for (int i = 0; i < (n); ++i)
#define SORT(a)    sort((a).begin(), (a).end());
#define UNIQ(a)    SORT(a);(a).erase(unique((a).begin(), (a).end()), (a).end());
#define FIND(a,x)  find((a).begin(), (a).end(), (x)) != (a).end()
#define REVERSE(a) reverse((a).begin(), (a).end());
#define OUT(d) cout << (d);
#define OUT_L(d) std::cout<<(d)<<"\n";
#define Yes() printf("Yes\n");
#define No() printf("No\n");
#define YES() printf("YES\n");
#define NO() printf("NO\n");
#define CEIL(x, y) ((x + y - 1) / (y))

using namespace std;
using ll = long long;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));

  string s; cin >> s;
  int n = s.size();
  vector<ll> a(n);

  for (int i = 0; i < n; i++) {
    int d = s[i] == 'L' ? -1 : 1;
    int j = i;
    while (s[j] == s[i]) j += d;
    
    if ((j - i) % 2 == 0) a[j]++;
    else a[j - d]++; 
  }

  cout << a[0];
  for (int i = 1; i < n; i++)
    cout << " " << a[i];
  cout << endl;
}


Measured memory_bytes: 1472
#include <bits/stdc++.h>
using namespace std;
#define N 200005
vector<vector<int> > adj(N);
vector<int> p;
vector<bool> visited;
int main()
{
    int n, m;
    cin>>n>>m;
    p.assign(N, -1);
    visited.assign(N, false);
    for (int i=0; i<m; i++){
        int u, v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    queue<int> q;
    q.push(1);
    visited[1] = true;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for (int i = 0; i<adj[u].size(); i++){
            int v = adj[u][i];
            if (visited[v] == false){
                visited[v] = true;
                p[v] = u;
                q.push(v);
            }
        }
    }
    cout<<"Yes"<<endl;
    for (int i=2; i<=n; i++)cout<<p[i]<<endl;
}

Measured memory_bytes: 12976
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N,W;
    cin>>N>>W;
    vector<vector<unsigned long long int>> mp(N,{0,0});
    for(int i=0;i<N;i++)
    {
        unsigned long long int a,b;
        cin>>a>>b;
        mp[i]={a,b};
    }
    vector<unsigned long long int>col(W+1,0);
    vector<vector<unsigned long long int>> dp(N+1,col);
    for(int i=1;i<=N;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(mp[i-1][0]<=j)
            {
                dp[i][j]=max(dp[i-1][j-mp[i-1][0]]+mp[i-1][1],dp[i-1][j]);
            }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    }
    cout<<dp[N][W]<<endl;
}


Measured memory_bytes: 80256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);
ll N;
const ll MAXN = 305;
ll num[MAXN];
ll dp[MAXN][MAXN];
ll rec(ll l,ll r){
    if(dp[l][r] != -1)return dp[l][r];
    if(abs(l - r) <= 1)return 0;
    ll res = 0;
    if(abs(num[l] - num[r - 1]) <= 1 && rec(l + 1,r - 1) == r - l - 2){
        res = r - l;
    }
    for(ll i = l + 1;i <= r - 1;i++){
        res = max(res,rec(l,i) + rec(i,r));
    }
    return dp[l][r] = res;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(true){
        cin >> N;
        if(N == 0)break;
        rep(i,N)cin >> num[i];
        rep(i,N + 1){
            rep(j,N + 1)dp[i][j] = -1;
        }
        cout << rec(0,N) << endl;
    }
}


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

int main()
{
    int n, st = 1;
    cin >> n;
    vector<pair<int, int>> v;

    for(int i=0; i<n; i++){
        int t;
        cin >> t;

        v.push_back(make_pair(t, i+1));
    }

    sort(v.begin(), v.end());

    for(int i=0; i<n; i++){
        cout << v[i].second << ' ';
    }

    return 0;
}

Measured memory_bytes: 4184
#include<stdio.h>
#include <string.h>
int isPrime(int x){
	int i;
	if(x<2) return 0;
	else if(x==2) return 1;
	if(x%2==0) return 0;
	for(i=3;i*i<=x;i+=2){
		if(x%i==0) return 0;
	}
	return 1;
}
int p,cnt,cnt2,food;
int n,d=0,g,kakaku[31],flag,youso[1000001]={0};
int main()
{
	scanf("%d %d",&n,&p);
	while(1){
		memset(kakaku, 0, sizeof(kakaku));
		memset(youso, 0, sizeof(youso));
		if(n==0&&p==0){
			break;
		}
		for(cnt=1;cnt<=n;cnt++){
			scanf("%d",&food);
			youso[food]=1;
			kakaku[cnt]=food;
		}
		for(cnt=0;cnt<=p;cnt++){
			if(youso[cnt]==1){
				for(cnt2=1;cnt2<=n;cnt2++){
					if(cnt+kakaku[cnt2]<=p){
						youso[cnt+kakaku[cnt2]]=1;
					}
				}
			}
		}
		flag=0;
		for(cnt=p;cnt>=0;cnt--){
			if(youso[cnt]==1){
				g=cnt;
				d=isPrime(g);
				if(d==1){
					flag=1;
					d=cnt;
					printf("%d\n",d);
					break;
				}
			}
		}
		if(flag==0){
			printf("NA\n");
		}
		d=0;
		flag=0;
		for(cnt=0;cnt<=p;cnt++){
			youso[cnt]=0;
		}
		scanf("%d %d",&n,&p);
	}
	return 0;
}

Measured memory_bytes: 6568
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a,b;
  cin>>a>>b;
  vector<ll>vec(4);
  vec.at(0)=a;
  vec.at(1)=b;
  vec.at(2)=a-1;
  vec.at(3)=b-1;
  sort(vec.begin(),vec.end());
  cout<<vec.at(3)+vec.at(2)<<endl;
  return 0;
  
}


Measured memory_bytes: 3616
X=int(input())
maisu_max=X//100
if X<100:
    print(0)
    exit()
else:
    X=str(X)
    X=int(X[-2:])
    if X==0:
        print(1)
        exit()
ans=100
for i in range(2):
    for j in range(2):
        for k in range(2):
            for l in range(2):
                for m in range(20):
                    tmp=i+j*2+k*3+l*4+m*5
                    if tmp==X:
                        if i+j+k+l+m<ans:
                            ans=i+j+k+l+m
if maisu_max>=ans:
    print(1)
else:
    print(0)


Measured memory_bytes: 9128
##https://atcoder.jp/contests/abc134/submissions/6482430
import sys
input = sys.stdin.readline
def main():
    n = int(input())
    A = [0] + list(int(i) for i in input().split())
    for i in range(n//2,0,-1):
        A[i] = sum(A[i::i]) % 2
    ans = [i for i, j in enumerate(A) if j]
    print(len(ans))
    print(*ans)
 
 
if __name__ == "__main__":
    main()

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

int main(){
  int n,l;
  cin >> n >> l;
  int a[n];
  for(int i=0;i<n;i++) {
    a[i] = l+i;
  }
  int sum =a[0], min = abs(a[0]);
  int min_id = 0;
  for(int i=1;i<n;i++){
    if(min>abs(a[i])){ 
      min = abs(a[i]);
      min_id = i;
    }
    sum += a[i];
  }
  cout << sum - a[min_id] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
char s[N];
int sumw[N],sumr[N];
int main(){
	int n;
	scanf("%d",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++){
		sumw[i]=sumw[i-1];
		if(s[i]=='W') sumw[i]++;
	}
	for(int i=n;i>=1;i--){
		sumr[i]=sumr[i+1];
		if(s[i]=='R') sumr[i]++;
	}
	if(sumw[n]==0||sumr[1]==0){
		puts("0");return 0;
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(sumw[i]==sumr[i+1]){
			ans=sumw[i];break;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 5496
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
#include <map>
#include <numeric>

#define ll long long
using namespace std;
static ll imin = std::numeric_limits<ll>::min();
static ll imax = std::numeric_limits<ll>::max();
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define rev_rep(i, n) for(int i = n - 1; i >= 0; --i)
#define dump(x) cout << #x << ":" << x << "\n";
#define all(v) v.begin(), v.end()

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair);
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec);
template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::pair<T1, T2>& pair){
  os << '(' << pair.first << ',' << pair.second << ')';
  return os;
}

template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template<class T1, class T2>
std::ostream& operator << (std::ostream& os, std::map<T1, T2>& mp){
  std::size_t n = mp.size();
  if(n == 0){
    return os;
  }
  os << " ";
  for(auto && x:mp){
    os << x << " ";
  }
  os << std::endl;
  return os;
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  ll N;
  cin >> N;
  vector<ll> a(N), b(N);
  rep(i, N){
    cin >> a[i];
  }
  rep(i, N){
    cin >> b[i];
  }
  int res = 0;
  rep(turn, N){
    int r = 0;
    rep(i, N){
      if(i < turn){
        r += a[i];
      }else if(i == turn){
        r += a[i] + b[i];
      }else{
        r += b[i];
      }
    }
    res = max(res, r);
  }
  cout << res;

}
#endif



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
vector<vector<int>> adj;
vector<int> dp;
int dfs(int v) {
	int mx = -1;
	for (auto u : adj[v]) {
		if (dp[u] == -1) dfs(u);
		mx = max(mx, dp[u]);
	}
	return dp[v] = mx + 1;
}
int main(void)
{
	FIO
	int t = 1;
	// cin>>t;
	while (t--)
	{
		int n, m, u, v;
		cin >> n >> m;
		adj.assign(n + 1, vector<int>());
		dp.assign(n + 1, -1);
		for (int i = 0; i < m; i++) {
			cin >> u >> v;
			adj[u].pb(v);
		}
		for (int i = 1; i <= n; i++) {
			if (dp[i] == -1)dfs(i);
		}
		cout << *max_element(all(dp)) << "\n";

	}
	return 0;
}

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

int main() {

  // int型の2次元配列(3×3要素の)の宣言
  vector<vector<int>> data(3, vector<int>(3));
  int n;
  string ans;
   
  // 入力 (2重ループを用いる)
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data.at(i).at(j);
    }
  }
  cin >>n;
  vector<int> v(n);
  for(int k = 0; k < n; k++){
    cin >> v.at(k);
  }
   for(int m = 0; m<n;m++){
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
      if(v.at(m)==data.at(i).at(j)){
        data.at(i).at(j) = 0;
    }}}}
  if(data.at(0).at(0)+data.at(0).at(1)+data.at(0).at(2)==0
     ||data.at(1).at(0)+data.at(1).at(1)+data.at(1).at(2)==0
     ||data.at(2).at(0)+data.at(2).at(1)+data.at(2).at(2)==0
     ||data.at(0).at(0)+data.at(1).at(0)+data.at(2).at(0)==0
     ||data.at(0).at(1)+data.at(1).at(1)+data.at(2).at(1)==0
     ||data.at(0).at(2)+data.at(1).at(2)+data.at(2).at(2)==0
     ||data.at(0).at(0)+data.at(1).at(1)+data.at(2).at(2)==0
     ||data.at(0).at(2)+data.at(1).at(1)+data.at(2).at(0)==0)
  {ans = "Yes";}
  else{ans = "No";}
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    if (A <= 9 && B <= 9) {
      System.out.println(A * B);
    } else {
      System.out.println("-1");
    }
  }
}

Measured memory_bytes: 35684
lines = []
def fi(i, x):
    a, b = lines[i]
    return a*x+b

def find(x):
    def f(i):
        return fi(i+1,x) > fi(i,x)
    mn, mx = -1, len(lines)-1
    idx = (mn+mx)//2
    while mx-mn>1:
        if f(idx):
            mx, idx = idx, (mn + idx)//2
            continue
        mn, idx = idx, (mx + idx)//2
    return fi(idx+1, x)

def find2(x):
    # x が単調増加
    I = find2.I
    u, v = lines[I]
    while I+1<len(lines):
        w, y = lines[I+1]
        if u*x+v < w*x+y:
            break
        u, v = w, y
        I += 1
    find2.I = I
    return u*x+v
find2.I = 0

def insert(a, b):
    pass

def insert2(a, b):
    # a が単調減少
    if not lines:
        lines.append((a,b))
        return
    (e, f) = lines[-1]
    while len(lines)-1:
        (c, d), (e, f) = (e, f), lines[-2]
        if (c-e)*(b-d) < (d-f)*(a-c):
            break
        lines.pop()
    lines.append((a, b))

N, C = map(int, input().split())
hs = map(int, input().split())
r = 0
lines = []
for i, h in enumerate(hs):
    if i!= 0:
        r = find(h) + h**2+C
    insert2(-2*h, r+h**2)
print(r)


Measured memory_bytes: 89932
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s;
  cin>>s;  int X;
  vector<int> A;
  X=s;
  A.push_back(s);
  for(int i=0;i<100000000;i++){
    
    if(X%2==0){
      X=X/2;
      A.push_back(X);
      
      for(int j=0;j<i;j++){
        if(A.at(j)==A.at(i)){
          cout<<i+1<<endl;
          return 0;
        }
      }
    }

      
    if(X%2==1){
      X=X*3+1;
      A.push_back(X);
      
      for(int j=0;j<i;j++){
        if(A.at(j)==A.at(i)){
          cout<<i+1<<endl;
          return 0;
        }
       }
    }
  }
}


      
      

    


Measured memory_bytes: 256
def solve(n, A):
    if A.count(0) > 0:
        return sum(map(abs, A))
    total = 0
    minval = 10 ** 9
    count = 0
    for a in A:
        total += abs(a)
        if a < 0:
            count += 1
        if abs(a) < minval:
            minval = abs(a)
    return total - (2 * minval if count % 2 == 1 else 0)

_n = int(input())
_A = list(map(int, input().split()))
print(solve(_n, _A))


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

int main() {
  int n;
  cin>>n;
  if (n <= 9) {
    cout<<n<<endl;
  } else if (n <= 99) {
    cout<<9<<endl;
  } else if (n <= 999) {
    cout<<9+n-99<<endl;
  } else if (n <= 9999) {
    cout<<9+999-99<<endl;
  } else if (n <= 99999) {
    cout<<9+999-99+n-9999<<endl;
  } else {
    cout<<9+999-99+99999-9999<<endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

Measured memory_bytes: 3636
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cstring>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
//#include<math.h>

using namespace std;
#define int long long
/*                      */    //#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007ll
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int N, A, B, x[60], C[60][60];

void comb()
{
    for(int i = 0; i <= N; i++){
        for(int j = 0; j <= i; j++){
            if(i == 0 || j == 0){
                C[i][j] = 1ll;
            }
            else{
                C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
            }
        }
    }
}

signed main()
{
    cin >> N >> A >> B;
    comb();
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    int n = 0, k = 0;
    double ave;
    sort(x, x + N, greater<int>() );
    for(int i = 0; i < N; i++){
        if(i < A){
            ave += (double)x[i];
            if(x[A - 1] == x[i]){
                k++;
            }
        }
        if(x[A - 1] == x[i]){
            n++;
        }
    }
    ave /= (double)A;
    if(k != A){
        //printf("n:%lld k:%lld\n", n, k);
        printf("%.8lf\n%lld\n", ave, C[n][k]);
    }
    else{
        int ans = 0;
        for(int i = A; i <= min(B, n); i++){
            ans += C[n][i];
        }
        printf("%.8lf\n%lld\n", ave, ans);
    }

    return 0;
}
/*


*/


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;
T chmin(T)(ref T x, T y){ if(x > y) x = y; return x; } T chmax(T)(ref T x, T y){ if(x < y) x = y; return x; }

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

void solve(){
	int n = rint;
	long m = rlong, v = rlong, p = rlong;
	log("n:", n, "m:", m, "v:", v, "p:", p);

	long[] as = rlong(n);
	as.sort!"a>b"();
	log("as:", as);

	long b = as[p - 1]; // 第p位のスコア。ボーダーになる
	log("b:", b);

	int ans;
	long sum;
	long u = 0;
	foreach(i, a; as){
		log("i:", i, "a:", a, "sum:", sum, "u:", u);
		if(i < p - 1) ans += 1;
		else{
			if(a + m < b) break;
			long h = a + m;
			long q = (u * h - sum) + m * (p - 1) + m * (n - i);
			log("h:", h, "q:", q);
			if(q >= m * v){
				ans += 1;
				sum += a;
				u += 1;
			}
			else break;
		}
		log("sum:", sum, "u:", u, "ans:", ans);
	}
	ans.writeln;
}

Measured memory_bytes: 4532
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define fi first
#define se second
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
int n, a[N], dp[N][65];
ll k;
int main()
{
	scanf("%d%lld", &n, &k);
	for(int i=1; i<=n; i++) scanf("%d", a+i);
	for(int i=1; i<=n; i++) dp[i][0] = a[i];
	for(int j=1; j<=62; j++)
		for(int i=1; i<=n; i++)
			dp[i][j] = dp[dp[i][j-1]][j-1];
	int c = 1;
	for(int j=62; j>=0; j--)
		if((k>>j)&1) c = dp[c][j];
	printf("%d\n", c);
	return 0;
}

Measured memory_bytes: 55388
#include<stdio.h>

int main(){
  int n,n1,n2,n3;
  scanf("%d",&n);
  
  n1=n%10;
  n=n/10;
  n2=n%10;
  n=n/10;
  n3=n;
  if(n1==7 || n2==7 || n3==7){
    printf("Yes");
  }else{
    printf("No");
  }
}

Measured memory_bytes: 1736
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0);ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);cerr<<fixed<<setprecision(5);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod=1e9+7;
/* VARIABLE DECLARATION START */
int globe[int(1e6)];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   vector<int> v(3);
   for(int i=0;i<3;++i)cin>>v[i];
    sort(all(v));
   if(v[2]==(v[1]+v[0]))
   {
    cout<<"Yes"<<endl;
   }
   else
    cout<<"No"<<endl;
   
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,D,cnt=0;
  cin >> N >> D;
  vector<vector<int>> x(N,vector<int>(D));
  
  for(int i=0; i<N;i++){
    for(int j=0;j<D;j++){
      cin >> x.at(i).at(j);
    }
  }
  
  for(int i=0; i<N;i++){    
    for(int j=i+1; j<N;j++){
      int ans=0;
      for(int k=0; k<D;k++){
        ans=ans+abs(x.at(i).at(k)-x.at(j).at(k))*abs(x.at(i).at(k)-x.at(j).at(k));
      }
//      cout << ans<<endl;
      bool flag=false;
      for(int k=0;k<=ans;k++){
        if(k*k==ans) flag=true;    
      }
      if(flag) cnt++;
    } 
  }
  cout <<cnt<<endl;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        l: usize,
        a: [i64; l],
    }
    const INF: i64 = 1 << 58;
    // 0: not started
    // 1: started, odd not started
    // 2: odd started
    // 3: started, odd ended
    // 4: ended
    let mut dp = vec![[INF; 5]; l + 1];
    dp[0][0] = 0;
    for i in 0..l {
        let mut cost = vec![0; 3];
        cost[0] = a[i];
        if a[i] == 0 {
            cost[1] = 1;
            cost[2] = 2;
        } else {
            let r = a[i] % 2;
            cost[1] = 1 - r;
            cost[2] = r;
        }
        // 5: not allowed
        let trans =
            [
                [0, 2, 1],
                [4, 2, 1],
                [4, 2, 3],
                [4, 5, 3],
                [4, 5, 5],
            ];
        for j in 0..5 {
            for k in 0..3 {
                let to = trans[j][k];
                if to >= 5 { continue; }
                dp[i + 1][to] = min(dp[i + 1][to], dp[i][j] + cost[k]);
            }
        }
    }
    //eprintln!("dp = {:?}", dp);
    let mi: i64 = dp[l].iter().min().cloned().unwrap();
    puts!("{}\n", mi);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 18684
#include<iostream>
using namespace std;
int main(){
    int h,w,i,j,d[10]={1,1,1,0,-1,-1,-1,0,1,1};
    cin>>h>>w;
    char s[h][w];
    for(i=0;i<h*w;i++)cin>>s[i/w][i%w];
    for(i=0;i<h*w;i++)if(s[i/w][i%w]=='.')for(j=0,s[i/w][i%w]='0';j<8;j++)if(i/w+d[j]>=0&&i/w+d[j]<h&&i%w+d[j+2]>=0&&i%w+d[j+2]<w&&s[i/w+d[j]][i%w+d[j+2]]=='#')s[i/w][i%w]++;
    for(i=0;i<h*w;i++)cout<<s[i/w][i%w]<<(i%w==w-1?"\n":"");
    return 0;
}

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

#define ll long long
#define fi first
#define sec second

ll n,m,k,x,x2,y,y2,sol=0;
char c;
string s;
vector <ll> V;

int main()
{
    cin >> c;
    if (c<='z' && c>='a') cout << 'a';
    else cout << 'A';
}


Measured memory_bytes: 3616
//Code Author: S.M. Istiak Ahmed
#include<bits/stdc++.h>
#define ll long long
#define INF 100000000000000
#define MOD 1000000007
using namespace std;

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  ll arr[n],csum[n];
  for(int i=0; i<n; i++) cin>>arr[i];
  csum[n-2]=arr[n-1];
  for(int i=n-3; i>=0; i--) csum[i]=(csum[i+1]+arr[i+1])%MOD;
  ll ans=0;
  for(int i=0; i<n-1; i++) ans+=((arr[i]%MOD)*(csum[i]%MOD))%MOD;
  cout<<ans%MOD;
  return 0;
}


Measured memory_bytes: 6756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
const long long mod = 1e9 + 7;

int main(){
	string N;
	cin >> N;
	if(N[0] == N[2])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

template<class T>void outarr(int s,int e,vector<T> &V){
	for(int i=s;i<e;i++)cout<<V[i]<<(i<e-1?" ":"\n");
}
// outarr<int>(0,V.size(),V);
// outarr<ll>(0,V.size(),V);

// #define NMAX 1000000000
int K,N,a,b,c;
string S,T;
vi A;

ll solve(){

	vi d(A.size()-1);

	rp(i, 0, A.size()-1){
		d[i] = A[i+1] - A[i];
	}

	// for(auto x:A)cout<<x<<" ";puts("");//
	// for(auto x:d)cout<<x<<" ";puts("");//

	sort(all(d));

	// for(auto x:d)cout<<x<<" ";puts("");//

	ll ans = 0;
	rp(i, 0, N-1){
		ans += d[i];
	}

	return ans;
}

int main(){
	cin>>K>>N;
	A.resize(N+1);
	rp(i,0,N){
		cin>>A[i];
	}
	A[N] = A[0] + K;
	cout<< solve() <<endl;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  string x, y;
  int count = 0;
  int ans = 0;
  for(int i=0; i<n-1; i++) {
    x = s.substr(0,i+1);
    y = s.substr(i+1);
    sort(x.begin(), x.end());
    for(int j=0; j<x.size(); j++) {
      if(j==0 || x[j]!=x[j-1]) {
        for(int k=0; k<y.size(); k++) {
          if(x[j]==y[k]) {
            count++;
            break;
          }
        }
      }
    }
    if(count>ans) ans = count;
    count = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
 int A=int.Parse(Console.ReadLine());
 int B=int.Parse(Console.ReadLine());
 int C=int.Parse(Console.ReadLine());
 int D=int.Parse(Console.ReadLine());
      int ans=Math.Min(A,B)+Math.Min(C,D);
      Console.WriteLine(ans);
      
}
  }

}


Measured memory_bytes: 27528
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int a, b, c, n;
	scanf("%d %d %d", &a, &b, &c);
	if(a > b)
	{
		n = a;
		a = b;
		b = n;
	}
	if(a > c)
	{
		n = a;
		a = c;
		c = n;
	}
	if(b > c)
	{
		n = b;
		b = c;
		c = n;
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2064
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b)
{
	return ((a)*1ll*(b))%mod;
}
 
void add_self(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
}
 
int add(int a,int b){
	int c=a+b;
	if(c>=mod){
		c-=mod;
	}
	return c;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=1000002;

void solve(){
	int m;
	cin>>m;
	ll sum=0,digit=0;
	for(int i=0;i<m;i++){
		int x;
		ll y;
		cin>>x>>y;
		sum+=x*1ll*y;
		digit+=y;
	}
	cout<<(9*(digit-1)+sum-1)/9;	
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


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

const int maxn = 200005;
using ll = long long;

ll mod = 1e9 + 7;
ll a[maxn], sum = 0, pref[maxn];

int main(int argc, char const *argv[])
{
  int n;
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    scanf("%lld", &a[i]);
  }
  for(int i = 1; i <= n; ++i){
    pref[i] = pref[i - 1] + a[i];
  }
  ll ans = 0;
  for(int i = 1; i <= n; ++i){
    ll sum = (pref[n] - pref[i] + mod) % mod;
    ll cnt = sum;
    cnt = (cnt * a[i]) % mod;
    ans = (ans + cnt) % mod;
  }
  cout << ans << endl;

  return 0;
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	int flag = 0;
	REP(i, b) {
		if (a*(i + 1) % b == c)flag = 1;
	}
	if (flag)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


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

int main(){
	string s;
	//s = "vwxyz";
	while (cin >> s){
		if (s == "-") break;
		long n;
		n = s.size();
		string t(n, '-');
		long m;
		//m = 3;
		cin >> m;
		long cnt = 0;
		long hm = 0;
		for (long i = 0; i < m; i++){
			cin >> hm;
			cnt += hm;
		}
		cnt = cnt % n;
		for (long i = 0; i < n; i++){
			if (i < n - cnt) t[i] = s[i + cnt];
			else t[i] = s[i - n + cnt];
		}
		for (long i = 0; i < n; i++){
			cout << t[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)x.size())
#define ALL(x) x.begin(),x.end()
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef vector<int> Vi;
template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
template<class T> T gcd(T a, T b){return !b?a:gcd(b,a%b);}
template<class T> inline void umin(T &x, T y){x=x<y?x:y;}
template<class T> inline void umax(T &x, T y){x=x>y?x:y;}
mt19937 R(chrono::system_clock().now().time_since_epoch().count());

const int N = 266666;
int n,len;char S[N];map<Pii,int>Map;
Pii s[N];ll res,f[N];
int main() {
	read(n);rep(i,1,n){
		scanf("%s",S+1);int len=strlen(S+1);
		ll x=0,p=len;
		
		rep(j,1,len)
			if(S[j]=='.')p=j;
			else x=10*x+S[j]-'0';
		int a=0,b=0;
		while(x%2==0)x/=2,a++;
		while(x%5==0)x/=5,b++;
		a-=len-p;b-=len-p;Map[mp(a,b)]++;
	}
	for(auto x:Map)s[++len]=x.fi,f[len]=x.se;
	rep(i,1,len)rep(j,i+1,len)if(s[i].fi+s[j].fi>=0&&s[i].se+s[j].se>=0)
		res+=1ll*f[i]*f[j];
	rep(i,1,len)if(s[i].fi>=0&&s[i].se>=0)
		res+=1ll*f[i]*(f[i]-1)/2;
	cout<<res;
	return 0;
}


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

using namespace std;

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


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()

//データ格納の仕方がおかしい


int main(){
    int N,ANS=0;
    cin>>N;
    vector<vector<pair<int,int> > > XY(N,vector<pair<int,int> >());
    vector<int> A(N);
    rep(i,N){
        cin>>A[i];
        rep(j,A[i]){
            int a,b;
            cin>>a>>b;
            a--;
            XY[i].pb(make_pair(a,b));
        }
    }

    for(int bit=0;bit<(1<<N);bit++){
        bool ok=true;
        int Co=0;

        vector<int> honest(N,0);

        rep(i,N){
            if(bit&(1<<i)){
                honest[i]=1;
                Co++;
            }
        }
        rep(i,N){
            if(honest[i]){
                rep(j,A[i]){//証言
                    int a=XY[i][j].first,b=XY[i][j].second;
                    if(honest[a]!=b)ok=false;
                    if(honest[a]==1){
                        rep(k,A[a]){
                            int c=XY[a][k].first,d=XY[a][k].second;
                            if(honest[c]!=d)ok=false;
                            if(!ok)break;
                        }
                        if(!ok)break;
                    }
                }
                if(!ok)break;
            }
        }
        if(ok)ANS=max(ANS,Co);
    }
    cout<<ANS<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256