akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define MOD 1000000007
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define forf(i,a,b) for(i=a;i<b;i++)
#define forr(i,a,b) for(i=a;i>b;i--)
#define mp make_pair
#define f first
#define s second
#define pb(x) push_back(x)
typedef  long long  int ll;
typedef std::vector<ll> vi;

#define input(vec,a,b) for(ll i =a;i<b;i++) cin>>vec[i]
#define print(vec,a,b) for(ll i=a;i<b;i++) cout<<vec[i]<<" " ;cout<<endl;
#define all(a) a.begin(),a.end()
using namespace std;
vector<ll> v[100000];
ll p[100000];
bool t[100000];
ll dfs (ll q)
{
         ll val=0;
         for(auto y: v[q])
         {
                  if(t[y]==0)
                  val = max(val,dfs(y)+1);
                  else
                  val=max(val,p[y]+1);
                  
         }
         p[q]=val;
         t[q]=1;
         return val;
}

void solve(){
        ll n,m,i,j,x,y,ma=0;
        cin>>n>>m;
        for(i=0;i<m;i++)
        {
                 cin>>x>>y;
                 x--;y--;
                 v[x].pb(y);
        }
        dfs(0);
        for(i=0;i<n;i++)
        {
                 if(t[i]==0)
                 dfs(i);
                 
                 ma=max(ma,p[i]);
        }
        cout<<ma<<endl;
}

int main()
{
      IO;
      ll t=1;
      //cin>>t;


      while(t--)
      {

          solve();
      }
    return 0;
}

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

int main() {
 
  int h,w,n;
  int count = 0;
  int ans = 0;
  bool m[100][100] = {false}; 

  cin >> h;
  cin >> w;
  cin >> n;

  if (h > w) swap(h, w);

  

  
  rep(i, h) {
    rep(j, w) {
      if(!m[i][j]) {
        m[i][j] = true;
        count++;
      }
    }
    if (n <= count) {
      ans = i + 1;
      break;
    }
  }

  if (ans==0) {
    rep(i, w) {
      rep(j, h) {
        if(!m[i][j]) {
          m[i][j] = true;
          count++;
        }
      }
      if (n <= count) {
        ans = i + 1;
        break;
      }
    }
  }
  cout << ans << endl;
  


   

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define inf (int)(10000000)
using namespace std;

int h, w, k;
vector<string> s;
vector<vector<int>> sum;

int solve();
int calc(int u, int d, int l, int r);

int main() {
  cin >> h >> w >> k;
  s.resize(h);
  for(int i = 0; i < h; ++i) cin >> s[i];
  cout << solve() << endl;
  return 0;
}

int solve() {
  int res = inf;
  sum.assign(h + 1, vector<int>(w + 1, 0));
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j) {
      sum[i][j] = s[i][j] - '0';
      if(i != 0) sum[i][j] += sum[i - 1][j];
      if(j != 0) sum[i][j] += sum[i][j - 1];
      if(i != 0 && j != 0) sum[i][j] -= sum[i - 1][j - 1];
    }
  for(int i = 0; i < (1LL << h); ++i) {
    int nowcnt = 0, idsize = 0;
    vector<int> id;
    id.push_back(0);
    for(int j = 1; j < h; ++j)
      if((i >> j & 1) != (i >> (j - 1) & 1))
        id.push_back(j);
    id.push_back(h);
    nowcnt = (int)id.size() - 2;
    idsize = id.size();
    for(int l = 0, r = 0; l < w;) {
      while(r < w) {
        bool ch = 1;
        for(int j = 0; j < idsize - 1; ++j)
          if(calc(id[j], id[j + 1] - 1, l, r) > k) {
            ch = 0;
          }
        if(!ch) break;
        ++r;
      }
      if(r == l) {
        nowcnt = inf;
        break;
      }
      ++nowcnt;
      l = r;
    }
    res = min(res, nowcnt - 1);
  }

  return res;
}

int calc(int u, int d, int l, int r) {
  int res = sum[d][r];
  if(l != 0) res -= sum[d][l - 1];
  if(u != 0) res -= sum[u - 1][r];
  if(l != 0 && u != 0) res += sum[u - 1][l - 1];
  return res;
}

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

int L,R=2e9,N,M;

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> N >> M;
	for(int i = 1; i <= M; i++){
		int x,y;
		cin >> x >> y;
		L = max(L,x);
		R = min(R,y);
	}
	if(L > R) cout << 0 << endl;
		else cout << R-L+1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
 
const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値
 
ll dp[MX][MX];
inline void chmax(ll& a, ll b) {
  a = max(a, b);
}
 
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define PB push_back
 
 
int main(){
    ll n; cin >> n;
    ll ans = 0;
    vector<ll> a(n+5,0);
    for (ll i = 1; i <= n; i++){
        for (ll j = i; j <= n; j += i){
            a.at(j) += 1;
        }
    }
    for (ll i = 1; i <= n; i++) ans += i * a.at(i);
    cout << ans;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) {
    int x;
    cin >> x;
    a[x-1]++;
  }
  sort(a.begin(),a.end());
  vector<int> s(n+1); // sum of [0,i)
  rep(i,n) s[i+1] = s[i]+a[i];
  int ans = n, i = n;
  for (int k = 1; k <= n; ++k) {
    while (1) {
      bool ok = [&](int c) {
        while (i >= 1 && a[i-1] >= c) --i;
        int sum = c*(n-i) + s[i];
        return (sum >= c*k);
      }(ans);
      if (ok) break;
      --ans;
    }
    printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 3200
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c,x;cin>>a>>b>>c>>x;
    int ans=0;
    for(int i=0;i<=a;i++){
        for(int j=0;j<=b;j++){
            for(int z=0;z<=c;z++){
                if(i*500+j*100+z*50==x)
                    ans++;
            }
        }
    }
    cout<<ans<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    vector<vector<int>> a(3,vector<int>(3));
    rep(i,0,3)
    rep(j,0,3)
    cin>>a[i][j];
    int n;cin>>n;
    vector<int> b(n);
    rep(i,0,n) cin>>b[i];
    vector<vector<int>> A(3,vector<int>(3));
    rep(i,0,3)
    rep(j,0,3)
    A[i][j]=0;

    rep(i,0,3)
    rep(j,0,3)
    rep(k,0,n){
        if(a[i][j]==b[k]) A[i][j]=1;
    }
    bool f = false;
    rep(i,0,3){
        if(A[i][0]==1&&A[i][1]==1&&A[i][2]==1)
        f=true;
    }
    rep(i,0,3){
        if(A[0][i]==1&&A[1][i]==1&&A[2][i]==1)
        f=true;
    }
    if(A[0][0]==1&&A[1][1]==1&&A[2][2]==1) f=true;
    if(A[0][2]==1&&A[1][1]==1&&A[2][0]==1) f=true;

    if(f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}

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

#define pow(x) (x)*(x)
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define pb push_back
#define skip continue
#define PI 3.14159265
#define name "input"

typedef unsigned long long ull;
typedef  long long ll;
typedef long double ld;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll INF = 1e18;
const ll MOD = 998244353;
const ll MAXN = 6e5 + 1;
const ld EPS = 1e-12;

//это приём, позволяющий возводить любое число в n-ую степень за O(logn)
int binPow(int v, int u, int mod) {
    if(!u)  return 1;   
    int res = binPow(v, u / 2, mod);  
    res = (res * 1ll * res) % mod;  
    if(u & 1) 
        res = (res * 1ll * v) % mod;  
    return res; 
} 
//это количество чисел от 1 до n, взаимно простых с n Асимтотика O(sqrt(n))
int phi (int n) {
    int result = n;
    for (int i=2; i*i<=n; ++i)
        if (n % i == 0) {
            while (n % i == 0)
                n /= i;
            result -= result / i;
        }
    if (n > 1)
        result -= result / n;
    return result;
}
//NOD
int gcd (int a, int b) {
    return b ? gcd (b, a % b) : a; }
int lcm(int a, int b) { 
    return a / gcd (a, b) * b; }

int fib(int n){ int a=0,b=1; for (int i = 0; i < n; ++i){ b=b+a; a=b-a; }return b; }
bool compare(const string &c1,const string &c2){ return c1.size() < c2.size(); }


string alph = "abcdefghijklmnopqrstuvwxyz";

int n;
string s;
void solve(){
    cin >> n >> s;
    if(n>=(int)(s.size()))
        cout<<s;
    else
        cout<<s.substr(0,n)<<"...";
}

int main(){

    faster();

    int T=1; 
    //cin>>T;

    while(T--){
        solve();
        cout<<"\n";
    }
    return 0;     
}

Measured memory_bytes: 3624
#include<stdio.h>
int main(){
    while(1) {
        int n, sum, max, min, rslt, i;
        sum = 0;
        max = 0;
        min = 1000;
        scanf("%d", &n);
        if (n == 0)
            return 0;
        for (i=0; i<n; i++){
            int s;
            scanf("%d", &s);
            sum += s;
            if (s > max)
                max = s;
            if (s < min)
                min = s;
        }
        sum -= max;
        sum -= min;
        rslt = sum / (n - 2);
        printf("%d\n", rslt);
    }
}

Measured memory_bytes: 600
/*
 author : nit1n
 created : 13/09/2020 17:33:19
*/
#include<bits/stdc++.h>
#define int long long
using namespace std ;


signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	int a ,b , c ,d ; 
	cin >> a >> b >> c >> d ; 
	int ans= max({a*c , a*d , b*c , b*d}) ; 
	cout << ans ;	
}



Measured memory_bytes: 3656
#include<iostream>
#include<cmath>
#include<map>
using namespace std;
#define int long long int
int32_t main()
{
	int n;
	cin>>n;
	int j;
	int arr[n+1];
	for(j=1;j<=n;j++)
	   cin>>arr[j];
	map<int,int> mp1,mp2;
	for(j=1;j<=n;j++)
	{
		int val1=j-arr[j];
		int val2=j+arr[j];
		mp1[val1]++;
		mp2[val2]++;
	}
	int answer=0;
	for(auto p:mp1)
	{
		int val1=p.second;
		int val2=mp2[p.first];
		answer+=(val1*val2);
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 39480
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))

a = sorted(a)
d = {}
for i in a:
  if i not in d.keys():
    d[i] = 1
  else:
    d[i] += 1

print(len([i for i in d.values() if i % 2 == 1]))

Measured memory_bytes: 16312
#include <stdio.h>
int main(){
    int i,n, data[10000],min,max;
    long long int sum = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%d", &data[i]);
    }
    min = data[0];
    max = data[0];
    for (i = 0; i < n; i++)
    {
   
        if (min>data[i])
        {
            min = data[i];
        }
        if (max < data[i])
        {
            max = data[i];
        }
   
        sum +=data[i];
   
    }
    printf("%d %d %lld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 1856
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 200;
int n;
vector < int > g[N];
int ans[N], t[N], a[N], b[N];
int dp[N][N];
set < int > s;
map < pair < int, pair < int, int > >, int > mp;
vector < int > d[N][N];
void solve1(int x, int y, int c){
    if (dp[x][y] <= c) return;
    dp[x][y] = c;
    for (int j = 1; j <= 50; j++){
        solve1(x, y % j, c + (1LL << j));
    }
}
void solve2(int x, int y, int c){
   // cout << x << " " << y << " " << c << " " << mp[{x, {y, c}}] << endl;
    if (mp[{x, {y, c}}]) return;
    mp[{x,{y, c}}] = 1;
    d[x][y].pb(c);
    for (int j = 1; j <= y; j++){
        solve2(x, y % j, c + (1LL << j));
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    for (int i = 0; i <= 50; i++){
        for (int j = 0; j <= 50; j++){
            dp[i][j] = 2e18;
        }
    }
    for (int i = 0; i <= 50; i++) solve1(i, i, 0);
    for (int i = 0; i <= 50; i++) solve2(i, i, 0);
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    int res = 0;
    int c = 0;
    for (int i = 1; i <= n; i++){
        cin >> b[i];
        if (dp[a[i]][b[i]] == 2e18){
            cout << -1;
            return 0;
        }
    }
    for (int k = 50; k >= 1; k--){
        int q = ((1LL << k) - 1);
        q |= res;
        int f = 1;
        for (int i = 1; i <= n; i++){
            int z = 0;
            for (auto l: d[a[i]][b[i]]){
                if ((l & q) == l) z = 1;
            }
            f &= z;
        }
        if (f == 0) res += (1LL << k);
    }
    cout << res;
}


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

struct node {
	struct node *left;
	struct node *right;
	char word[11];
};

struct node *
insert(struct node *p, char *word)
{
	int cmp;
	if (p == NULL) {
		p = (struct node *)malloc(sizeof(struct node));
		p->left = (struct node *)NULL;
		p->right = (struct node *)NULL;
		strcpy(p->word, word);
		return p;
	} else {
		cmp = strcmp( word, p->word);
		if ( cmp == 0) {
			/* already exist */
			return p;
		} else if (cmp < 0) {
			p->left = insert(p->left, word);
			return p;
		} else if (cmp > 0) {
			p->right = insert(p->right, word);
			return p;
		} else {
			printf("This case is not exist");
		}
	}
}

int countNode(struct node *p, int n)
{
	n++;
	if (p->left != NULL)
		n =	countNode(p->left, n);
	if (p->right != NULL)
		n = countNode(p->right, n);
	return n;
}

int main()
{
	int i, n, ret;
	int N;
	char **S;
	char **Depot;
	int hit;
	struct node *root = (struct node *)NULL;
	
	ret = scanf("%d", &N);
	
	S = (char **) malloc(sizeof(char *)*N);
	for (i = 0;i < N; i++) {
		S[i] = (char *) malloc(sizeof(char)*11);
	}

	for (i = 0; i < N; i++){
		ret = scanf("%s\n", S[i]);
		root = insert(root, S[i]);
	}
	n = countNode(root, 0);
	printf("%d\n",n);
	fflush(stdout);
	free(S);
	return EXIT_SUCCESS;
}


Measured memory_bytes: 18632
#include <iostream>
#include <string>

int main() {
	std::string A;
	std::cin >> A;

	if (A == "000")
		std::cout << 0 << std::endl;
	else if (A == "110")
		std::cout << 2 << std::endl;
	else if (A == "101")
		std::cout << 2 << std::endl;
	else if (A == "011")
		std::cout << 2 << std::endl;
	else if (A == "111")
		std::cout << 3 << std::endl;
	else
		std::cout << 1 << std::endl;

	return 0;
}



Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
dct = {}

for i in range(9):
  dct[i] = 0
  
for i in A:
  if (i >= 1 and i < 400):
    dct[0] += 1
  elif (i >= 400 and i < 800):
    dct[1] += 1
  elif (i >= 800 and i < 1200):
    dct[2] += 1
  elif (i >= 1200 and i < 1600):
    dct[3] += 1    
  elif (i >= 1600 and i < 2000):
    dct[4] += 1    
  elif (i >= 2000 and i < 2400):
    dct[5] += 1    
  elif (i >= 2400 and i < 2800):
    dct[6] += 1    
  elif (i >= 2800 and i < 3200):
    dct[7] += 1    
  else:
    dct[8] += 1  

color1 = 0
color2 = 0
for i in dct.items():  
  if (i[0] == 8):
    color2 = i[1]
  else:
    if (i[1] > 0):
      color1 += 1

ans1 = color1
ans2 = color1+color2
if (color1 == 0):
  ans1 = 1
print(ans1,ans2)

Measured memory_bytes: 38256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <limits.h>

#define lli long long int
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define	abs(a) ((a)<0?-(a):(a))



int main(void){
	int n;
	char *s,*t;
	char *sh,*th;
	scanf("%d",&n);
	s = calloc(sizeof(char),n+1);
	t = calloc(sizeof(char),n+1);
	scanf("%s",s);scanf("%s",t);
	sh = s;th = t;
	while(*s){
		sh = s;
		th = t;
		while(*sh == *th){
			sh++;th++;
			if(!*sh){
				printf("%d\n", 2*n-(th-t));
				return 0;
			}
		}
		s++;
	}
	printf("%d\n", 2*n);
	return 0;
}

Measured memory_bytes: 128
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<string> a(2*n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i] = a[i] + a[i];
    rep(i, n) a[n+i] = a[i];
    int ans = 0;
    rep(i, n) {
        bool flag = true;
        for (int k = 0; k < n; ++k) {
            for (int l = k+1; l < n; ++l) {
                if (a[i+k][l] != a[i+l][k]) flag = false;
            }
        }
        if (flag) ans++;
    }
    ans *= n;
    cout << ans << endl;
}


Measured memory_bytes: 3884
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <utility>
#include <string.h>
#include <map>
#include <stack>
#include <iomanip>
#include <chrono>
#include <random>
#include <math.h>
#include <time.h>
#include <assert.h>
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define pb push_back 
#define mp make_pair
#define ff first
#define ss second
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x) x.begin(),x.end() 
#define PII pair <ll,ll>
#define N 100005
#define MOD 1000000007
#define INF 1000000000000000000
using namespace std;

vector <int> v[N];
ll ans = 0, dp[N];
bool vis[N];
void dfs(int s)
{
	vis[s] = true;
	dp[s] = 0;
	for (auto g : v[s])
	{
		if(!vis[g])
		{
			dfs(g);
		}
		if(dp[g] + 1 > dp[s])
		{
			dp[s] = dp[g] + 1;
		}
		ans = max(ans, dp[s]);
	}
}
int main()
{
	int n, m, x, y;
	memset(vis, false, sizeof(vis));
	cin >> n >> m;
	for (int i = 0; i < m; ++i)
	{
		cin >> x >> y;
		v[x].push_back(y);
	}
	for (int i = 1; i <= n; ++i)
	{
		if(!vis[i])
		{
			dfs(i);
		}
	}
	cout << ans;	
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int dp[N];
int main(){
  
  int n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  for(int i = 1 ; i < n ; ++i){
    	
    	if(s[i]=='C' && s[i-1] == 'A')
          dp[i] = dp[i-1] + 1;
    	else dp[i] = dp[i-1];
  }
  
  while(q--){
    
    int l,r;
    cin>>l>>r;
    --l,--r;
    int ans = 0;
    if(l==0)
      ans = dp[r];
    else ans = dp[r]-dp[l];
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    auto f = [&](ll x){
        return x- x/c - x/d + x/(c*d/__gcd(c,d));
    };
    cout << f(b) - f(a-1) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
 using namespace std;
 
int main() {
    long a, b, c, x, y;
 
    cin >> a >> b >> c >> x >> y;
 
    long maxI = max(x, y);
    long minPrice = NULL;
 
    for (long i = 0; i < maxI+1; ++i) {
        long price = i*2*c + max((long)0, x-i) *a + max((long)0, y-i)*b;
 
        minPrice = minPrice == NULL or minPrice > price ? price : minPrice;
    }
 
    cout << minPrice << std::endl;
 
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 3000000007;
const double INFD = 1e100;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int N,K;
int R,S,P;

int main(){
  cin >> N >> K;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  ll ans=0;
  for(int i=0; i<N; i++){
    if(i-K < 0 || T[i] != T[i-K]){
      if(T[i] == 'r'){
        ans += P;
      }else if(T[i] == 's'){
        ans += R;
      }else{
        ans += S;
      }
    }else{
      if(T[i] == T[i-K]){
        T[i] = 'A';
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main() {
	vector<int> vec1;
	vector<int> vec2;
	int n,i,count;
	cin >> n;
	for(int i =0;i<n;i++){
	    int x;
	    cin >> x;
	    vec1.push_back(x);
	}
    for(int i = 0;i<n;i++){
	    int x;
	    cin >> x;
	    vec2.push_back(x);
    }
	i = -1;

	count = 0;
	while(1){
	    if(n == i+1){
	        break;
	    }else{
	        i = i+1;
	             if(vec1[i] > vec2[i]){
	                        count = count + vec1[i] - vec2[i];
	                }  
	    }
	}
	cout << count << endl;
}

Measured memory_bytes: 256
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n = onem()

a = l()
a.sort(reverse = True)

ans = a[0]
co = 2
whe = 1
while co <= n:
	if n-co >= 2:
		ans += a[whe] * 2
		whe += 1
		co += 2
	elif n-co == 1:
		ans += a[whe]
		co += 1
		break
	else:
		break
print(ans) 



Measured memory_bytes: 92192
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        a: usize,
        b: usize,
    }

    let d = n / (a+b);
    let mut r = n % (a+b);

    if r >= a {
        r = a;
    }
    println!("{}", d*a+r);

}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

class Point {
  public:
  long double x, y;

  Point(long double x = 0, long double y = 0): x(x), y(y) {}

  Point operator + (Point &p) {
    return Point(x + p.x, y + p.y);
  }

  Point operator - (Point &p) {
    return Point(x - p.x, y - p.y);
  }

  Point operator * (long double k) {
    return Point(x * k, y * k);
  }

  Point operator / (long double k) {
    return Point(x / k, y / k);
  }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

long double norm(Point p) {
  return p.x * p.x + p.y * p.y;
}

long double abs(Point p) {
  return sqrt(norm(p));
}

long double dot(Point p1, Point p2) {
  return p1.x * p2.x + p1.y * p2.y;
}

long double cross(Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

int ccw(Point p0, Point p1, Point p2) {
  Point v1 = p1 - p0, v2 = p2 - p0;
  if (cross(v1, v2) > 0) return 1;
  else if (cross(v1, v2) < 0) return -1;
  else if (dot(v1, v2) < 0) return 2;
  else if (norm(v1) < norm(v2)) return -2;
  else return 0;
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

long double getDistanceLP(Point p1, Point p2, Point p3) {
  return fabs(cross(p2-p1, p3-p1) / abs(p2-p1));
}

long double getDistanceSP(Point p1, Point p2, Point p3) {
  if (dot(p2-p1, p3-p1) < 0) return abs(p3-p1);
  else if (dot(p1-p2, p3-p2) < 0) return abs(p3-p2);
  else return getDistanceLP(p1, p2, p3);
}

long double getDistanceTS(Point p1, Point p2, Point p3, Point p4) {
  if (intersect(p1, p2, p3, p4)) return 0;
  long double ans = INF;
  ans = min(ans, getDistanceSP(p1, p2, p3));
  ans = min(ans, getDistanceSP(p1, p2, p4));
  ans = min(ans, getDistanceSP(p3, p4, p1));
  ans = min(ans, getDistanceSP(p3, p4, p2));
  return ans;
}

int main() {
  int n;
  cin >> n;
  vector<Point> P(n);
  rep(i, n) cin >> P[i].x >> P[i].y;

  int nC2 = n * (n - 1) / 2;
  int sum = 1;
  FORR(i, n, 1) sum *= i;
  int fn = sum;
  sum *= n - 1;
  sum /= nC2;


  long double ans = 0.0;
  rep(i, n) {
    FOR(j, i + 1, n) {
      ans += abs(P[j] - P[i]) * sum;
    }
  }
  cout << setprecision(20) << ans / fn<< endl;


  
  return 0;
}

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

stack = 0
for i in range(n):
	c = str[i]
	if(c == '('):
		stack += 1
	elif(stack == 0):
		ans = '(' + ans
	else:
		stack -= 1

for i in range(stack):
	ans = ans + ')'

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
using namespace std;

const int mx = 100005;

int dtime = 0;
int n, m, par[mx], low[mx], start[mx];
vector<int> adj[mx], child[mx];
bool vis[mx];
set<int> art;

void dfs(int n, int p = -1) {
  //printf("DFS %d from %d\n", n, p);
  vis[n] = true;
  par[n] = p;
  child[p].pb(n);
  start[n] = dtime++;
  low[n] = start[n];
  
  for (int h : adj[n]) {
    if (!vis[h]) {
      dfs(h, n);
      // printf("Low[%d] = min(%d, %d) = %d\n", n, low[n], low[h], min(low[n], low[h]));
      low[n] = min(low[h], low[n]);
      if ((n == 0 && child[0].size() > 1) || (n != 0 && low[h] >= start[n])) {
	art.insert(n);
      }
    } else if (h != p) {
      low[n] = min(low[n], start[h]);
    }
  }
}

int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int u, v; cin >> u >> v;
    adj[u].pb(v); adj[v].pb(u);
  }
  dfs(0);
  for (int h : art) cout << h << endl;
}



Measured memory_bytes: 9300
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  rep(i, n){
    ll a, b, c;
    cin >> a >> b >> c;
    ll mini = min(a, min(b, c));
    ll maxi = max(a, max(b, c));
    ll mid = a + b + c - mini - maxi;
    if(mini * mini + mid * mid == maxi * maxi)cout << "YES" << endl;
    else cout << "NO" << endl;
  }
	return 0;
}



Measured memory_bytes: 2992
#include <bits/stdc++.h>
//#define DBG

using namespace std;

vector <int> p, q;


int main(){
  int n;
  cin >> n;
  cin.ignore();
  int tmp;
  for(int i = 0; i < n; i++){
    cin >> tmp;
    p.push_back(tmp);
  }
  cin.ignore();
  for(int i = 0; i < n; i++){
    cin >> tmp;
    q.push_back(tmp);
  }
  cin.ignore();

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

  bool flag_p = true;
  bool flag_q = true;
  int cnt = 1;
  int cnt_p = 0;
  int cnt_q = 0;
  do{
    flag_p = true;
    flag_q = true;
    #ifdef DBG
    for(int i = 0; i < n; i++){
      cout << array[i] << " " << flush;
    }
    cout << endl;
    #endif
    for(int i = 0; i < n; i++){
      flag_p = (array[i] == p[i]);
      if(flag_p == false){
        break;
      }
    }
    if((cnt_p == 0) && (flag_p == true)){
      cnt_p = cnt;
    }
    for(int i = 0; i < n; i++){
      flag_q = (array[i] == q[i]);
      if(flag_q == false){
        break;
      }
    }
    if((cnt_q == 0) && (flag_q == true)){
      cnt_q = cnt;
    }
    ++cnt;
  }while(next_permutation(array, array + n));

  int ans;
  if(cnt_p >= cnt_q){
    ans = cnt_p - cnt_q;
  } else {
    ans = cnt_q - cnt_p;
  }
  cout << ans << endl;
  return 0;
}
      
    


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

template<typename T> void chmin(T &a,T b){if(a>b) a=b;}
template<typename T> void chmax(T &a,T b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<string> s(n);
  for(Int i=0;i<n;i++) cin>>s[i];
  vector<string> t(2);
  for(Int i=0;i<2;i++) cin>>t[i];

  auto calc=[&](Int y,Int x){
    if(0<=y&&y+1<n&&0<=x&&x+1<m){
      bool flg=1;
      for(Int i=0;i<2;i++)
	for(Int j=0;j<2;j++)
	  flg&=s[y+i][x+j]==t[i][j];
      return flg;
    }
    return false;
  };
  
  Int tmp=0;
  for(Int i=0;i<n-1;i++)
    for(Int j=0;j<m-1;j++)
      tmp+=calc(i,j);

  Int ans=tmp;
  
  string x="JOI";
  for(Int i=0;i<n;i++){
    for(Int j=0;j<m;j++){
      char c=s[i][j];
      for(Int a=0;a<2;a++)
	for(Int b=0;b<2;b++)
	  tmp-=calc(i-a,j-b);
      for(auto y:x){
	Int res=tmp;
	s[i][j]=y;
	for(Int a=0;a<2;a++)
	  for(Int b=0;b<2;b++)
	    res+=calc(i-a,j-b);
	chmax(ans,res);
      }
      s[i][j]=c;
      for(Int a=0;a<2;a++)
	for(Int b=0;b<2;b++)
	  tmp+=calc(i-a,j-b);
      //cout<<i<<" "<<j<<":"<<tmp<<endl;
    }
  }
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3888
import fractions
a,b,c,d = map(int,input().split())
lg = b - a + 1

def div (n):
    rt = lg // n
    if lg % n != 0 and ((n- a%n) + (b%n) < n):
        rt += 1
    return(rt)

cm = c * d // fractions.gcd(c,d)
ans = lg - div(c) - div(d) + div(cm)
print(ans)

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

typedef long long lint;
typedef long double louble;

template<typename T1,typename T2> inline T1 max(T1 a,T2 b){return a<b?b:a;}
template<typename T1,typename T2> inline T1 min(T1 a,T2 b){return a<b?a:b;}

namespace ae86
{
	const int bufl = 1<<15;
	
	char buf[bufl],*s=buf,*t=buf;
	
	inline int fetch()
	{
		if(s==t){t=(s=buf)+fread(buf,1,bufl,stdin);if(s==t)return EOF;}
		return *s++;
	}
	
	inline int ty()
	{
		int a=0,b=1,c=fetch();
		while(!isdigit(c))b^=c=='-',c=fetch();
		while(isdigit(c))a=a*10+c-48,c=fetch();
		return b?a:-a;
	}
}
using ae86::ty;

const int _ = 100007 , __ = _<<1;

int to[__],ne[__],he[_]={0},ecnt=1;
inline void adde(int a,int b){to[++ecnt]=b,ne[ecnt]=he[a],he[a]=ecnt;}
inline void addde(int a,int b){adde(a,b),adde(b,a);}

int n,m,dep[_]={0},val[_]={0},ed[_]={0},cx=0,cy=0;
lint sval=0;

void dfs(int x,int ff)
{
	ed[x]=1,dep[x]=dep[ff]+1,val[x]=(dep[x]&1)?1:-1,sval+=val[x];
	for(int i=he[x];i;i=ne[i])
	{
		int b=to[i];
		if(b==ff)continue;
		if(ed[b]){cx=x,cy=b;continue;}
		dfs(b,x);
	}
}

int dlt[_]={0};

void dfs2(int x,int ff)
{
	for(int i=he[x];i;i=ne[i])
	{
		int b=to[i];
		if(b==ff || (b==cx && x==cy) || (b==cy && x==cx))continue;
		dfs2(b,x),val[x]+=val[b],dlt[x]+=dlt[b];
	}
}

inline int treefn()
{
	if(sval!=0){puts("-1");return 0;}
	dfs2(1,0);
	lint ans=0;
	for(int i=1;i<=n;i++)ans+=abs(val[i]);
	printf("%lld\n",ans);
	return 0;
}

inline int oddcfn()
{
	if(sval&1){puts("-1");return 0;}
	sval/=2,val[cx]-=sval,val[cy]-=sval,dfs2(1,0);
	lint ans=abs(sval);
	for(int i=1;i<=n;i++)ans+=abs(val[i]);
	printf("%lld\n",ans);
	return 0;
}

int stk[_]={0},top=0;

inline int evecfn()
{
	if(sval!=0){puts("-1");return 0;}
	dlt[cx]=1,dlt[cy]=-1,dfs2(1,0);
	lint ans=0;
	stk[++top]=0;
	for(int i=1;i<=n;i++)
	{
		if(dlt[i]==0)ans+=abs(val[i]);
		else stk[++top]=-dlt[i]*val[i];
	}
	sort(stk+1,stk+top+1);
	for(int i=1,x=stk[(top+1)/2];i<=top;i++)ans+=abs(stk[i]-x);
	printf("%lld\n",ans);
	return 0;
}

int main()
{
	n=ty(),m=ty();
	for(int i=1,a,b;i<=m;i++)a=ty(),b=ty(),addde(a,b);

	dfs(1,0);

	if(m==n-1)return treefn();
	if(val[cx]==val[cy])return oddcfn();
	return evecfn();
}


Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  for(int i=0; i<2; ++i) {
    if(s[i] == s[i+1] && s[i] == s[i+2]){
      cout << "Yes" << endl;
      return 0;
    }
  };
  cout << "No" << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,h,i,j;
    scanf("%d%d",&h,&n);
    vector<int> a(n),b(n);
    for(i=0;i<n;i++)
	{
		scanf("%d%d",&a[i],&b[i]);
	}
	int ma=0;
	for(i=0;i<n;i++)
	{
		ma=max(a[i],ma);
	}
	vector<int> dp(h+ma+1,1e9);
    dp[0]=0;
    for(i=0;i<n;i++)
	{
		for(j=0;j<h+1;j++)
		{
			dp[j+a[i]]=min(dp[j+a[i]],dp[j]+b[i]);
//			printf("%d %d\n",dp[j]+b[i],dp[j+a[i]]);
		}
	}
	int mi=1e9+1;

	for(i=0;i<n;i++)
	{
		ma=max(a[i],ma);
	}
	for(j=h;j<=h+ma;j++)
	{
		mi=min(dp[j],mi);
	}
//	for(i=0;i<h+ma;i++)
//	{
//		printf("%d ",dp[i]);
//	}
    printf("%d",mi);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m, n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mk make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<int>(n,a)));
typedef long long ll;
const int INF = 2000000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;
int main(){
    int n;
    std::cin >> n;
    string s;
    std::cin >> s;
    std::vector<int> a(n,0);
    rrep(i,1,s.size()){
        if(s[i]=='E')a[0]++;
    }
    rrep(i,1,s.size()){
        a[i]=a[i-1];
        if(s[i]=='E')a[i]--;
        if(s[i-1]=='W')a[i]++;
    }
    //rep(i,n)std::cout << a[i]; //<< std::endl;
    //std::cout  << std::endl;
    sort(all(a));
    
    std::cout << a[0] << std::endl;
}

Measured memory_bytes: 1796
#include <iostream>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;

int main(){
    int a,b,c;  cin >> a >> b >> c;
    if(a+b+c >= 22){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    } 
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
	//return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow
	//return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数

//素数判定
template<typename T>
bool IsPrime(T num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
//vector<vector<int>> data(3, vector<int>(4));
//vector<vector<Type>> vv(n);

int main() {
	ll N,M, ans = 0;cin >> N>>M;
	ll mina = 0;
	vector<ll>sum;
	priority_queue<ll> A;
	for (ll i = 0;i < N;i++) {
		cin >> mina;
		A.push(mina);
	}
	ll i = 0, kai = 0;ll tmp = 0;
	while(1){
		kai++;
		tmp = A.top();
		tmp /= 2;
		A.pop();
		A.push(tmp);
		if (A.top() == 0) break;
		if (kai == M)break;
	}
	for (ll i = 0;i < N;i++) {
		ans += A.top();
		A.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 1400
def main():
    n=int(input())
    mod = 10**9 + 7
    arr = sorted(map(int, input().split()))
    arr.reverse()

    sm = arr[0] + arr[1]
    ans = arr[0] * arr[1] % mod

    for x in range(2, len(arr)):
        ans += sm * arr[x]
        sm += arr[x]

    print(ans % mod)


if __name__ == '__main__':
    main()

Measured memory_bytes: 31620
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main() {
	long long inf = 1e18;

	int n, k;
	cin >> n >> k;

	vector<int> data(n + k + 10, inf);
	rep(i, n) {
		cin >> data[i];
	}

	vector<long long> dp(n + k + 10, inf);
	dp[0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 1; j < k + 1; j++) {
			if (dp[i + j] > dp[i] + abs(data[i] - data[i + j]))  {
				dp[i + j] = dp[i] + abs(data[i] - data[i + j]);
			}
		}
	}
	//dp確認用
	/*
	rep(i, n) {
		cout << dp[i] << endl;
	}*/

	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 4484
MAX = 600000
MOD = 10 ** 9 + 7
fac = [0] * MAX
ifac = [0] * MAX
fac[0] = 1
for i in range(1,MAX):
    fac[i] = (fac[i-1] * i) % MOD
ifac[MAX-1] = pow(fac[MAX-1],MOD-2,MOD)
for i in reversed(range(1,MAX)):
    ifac[i-1] = (ifac[i] * i) % MOD

def combinations(n, k):
    if k < 0 or n < k:
        return 0
    else:
        return (fac[n] * ifac[k] * ifac[n-k]) % MOD

ans = 0
S = int(input())
for i in range(1,1000):
    ans += combinations((S+i-1)-i*3,i-1)
    ans %= MOD
print(ans)



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

using namespace std;
using ll = long long;
constexpr int INF = numeric_limits<int>::max();
template <typename T, typename... Args>
const T& min(const T& a, Args... args) {
  return min(a, min(args...));
}
template <typename T, typename... Args>
const T& max(const T& a, Args... args) {
  return max(a, max(args...));
}

#pragma GCC optimize("O3")
static const auto __ = [] {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  return nullptr;
}();

int n, h[100000];

int main(int argc, char* argv[]) {
  cin >> n;
  int max = 0;
  for (int i = 0; i < n; ++i) {
    cin >> h[i];
    if (h[i] < max) {
      cout << "No" << '\n';
      return 0;
    }
    max = std::max(max, h[i] - 1);
  }
  cout << "Yes" << '\n';

  return 0;
}


Measured memory_bytes: 640
if __name__ == '__main__':
    n = int(input())
    a = list(map(lambda x: int(x) + 1, input().split()))
    counts = [0] * (n + 1)
    counts[0] = 3
    ans = 1
    for i in range(n):
        ans *= counts[a[i] - 1]
        ans %= (10 ** 9 + 7)
        counts[a[i] - 1] -= 1
        counts[a[i]] += 1
    print(ans)


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

using namespace std;

bool isPrime(int x) {
    if (x <= 3) return (x >= 2);
    if (x % 2 == 0 || x % 3 == 0) return false;
    for (int i = 5; i * i <= x; i += 6) {
        if (x % i == 0 || x % (i + 2) == 0) return false;
    }
    return true;
}

int main() {
    int x;
    cin >> x;
    while (1) {
        if (isPrime(x)) {
            cout << x << '\n';
            return 0;
        }
        x++;
    }
}

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

using int64 = long long;

int main() {
    int64 N, H;
    cin >> N >> H;

    vector<int64> a(N);
    vector<int64> b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end(), greater<int64>());
    sort(b.begin(), b.end(), greater<int64>());

    // [0, i)までの刀を投げつける
    int64 ans = (1LL << 50);
    int64 sum = 0;
    for (int i = 0; i <= N; i++) {
        int64 res = i + (max(0LL, H - sum) + a[0] - 1) / a[0];
        // cerr << "res: " << res << endl;
        ans = min(ans, res);

        if (i < N) sum += b[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    int n;
    cin >> n;
    vector<P>a,b,c;
    rep(i,n){
        string s;
        cin >> s;
        int h = 0;
        int m = 0;
        int l = s.size();
        rep(j,l){
            if(s[j]==')'){
                h--;
                chmin(m,h);
            }
            if(s[j]=='('){
                h++;
            }
        }
        int d = h;
        if(d>0){
            int u = -m;
            a.push_back(make_pair(u,d));
        }
        if(d==0){
            int u = -m;
            b.push_back(make_pair(u,d));
        }
        if(d<0){
            int u = h-m;
            c.push_back(make_pair(u,-d));
        }
    }
    int now = 0;
    bool ans = true;
    sort(a.begin(),a.end());
    sort(c.begin(),c.end());
    rep(i,(int)a.size()){
        if(a[i].first>now){
            ans = false;    
        }
        else{
            now += a[i].second;
        }
    }
    rep(i,(int)b.size()){
        if(b[i].first>now){
            ans = false;
        }
    }
    int cnow = 0;
    rep(i,(int)c.size()){
        if(c[i].first>cnow){
            ans = false;    
        }
        else{
            cnow += c[i].second;
        }
    }
    if(now != cnow)ans=false;
    if(ans==true)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 11072
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
        int K = sc.nextInt();

        int D = 0;
        int tmp = 0;
        int[] arrA = new int[N];
        int cnt = 0;

        for(int i = 0; i < K; i++) {
            D = sc.nextInt();
            for(int j = 0; j < D; j++) {
                tmp = sc.nextInt();
                tmp--;
                arrA[tmp]++;
            }
        }
        for(int i = 0; i < N; i++) {
            if(arrA[i] == 0) {
                cnt++;
            }
        }
        System.out.println(cnt);
    }
}


Measured memory_bytes: 37244