akhauriyash/Code-Regression huggingface dataset:
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll

#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }
int fact[N],inv[N];
void pre()
{
    fact[0]=1;
    inv[0]=1;
    for(int i=1;i<N;i++)
    fact[i]=(i*fact[i-1])%mod;
    for(int i=1;i<N;i++)
    inv[i]=power(fact[i], mod-2, mod);
}
int nCr(int n, int r, int p) 
{ 
    if(n==r)
    return 1;
   if (r==0) 
      return 1; 
  
    return (((fact[n]*inv[r]) % p )*inv[n-r])%p;
} 
int32_t main()
{
    int n,m,k;
    cin>>n>>m>>k;
    pre();
    int ans=0;
    if(m==1)
    {
        if(k==(n-1))
        ans=1;
        else
        ans=0;
    }
    else
    {
        int ar[n];
        fill(ar, 0);
        ar[0]=(power(m-1, n-1, mod)*m)%mod;
        for(int i=1;i<=k;i++)
        {
            int x=(nCr(n-1, i, mod)*((power(m-1, n-1-i, mod)*power(m, 1, mod))%mod));
            ar[i]=(x+ar[i-1])%mod;
        }
        //int y=(power(m-1, n-1, mod)*m)%mod;
        //int y=fact[m];
        ans=ar[k];
    }
    cout<<ans;
}

Measured memory_bytes: 8276
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll a, ll b){
   if(b == 0) return a;
   return gcd(b, a % b);
}
int main(){
   int n; cin >> n;
   vector<ll> a(n);
   rep(i,n) cin >> a[i];
   vector<ll> b(n + 1);
   b[0] = 0;
   for(int i = 1; i < n + 1; i++){
      b[i] = a[i - 1] + b[i - 1];
   }
   sort(b.begin(), b.end());
   ll ans = 0;

   for(int i = 0; i < n + 1; i++){
      ll count = 1;
         if(b[i] == b[i + 1]){
            while(i < n && b[i] == b[i + 1]){
               count++;
               i++;
            }
         }
         ans += count * (count - 1) / 2;
         count = 1;
   }
   cout << ans << endl;

}

Measured memory_bytes: 3328
#include<vector>
#include<map>
#include<climits>
#include<set>
#include<queue>
#include<algorithm>
#include<functional>
#include<numeric>
#include<utility>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<string>
#include<bitset>
#include<cstring>
#include<list>
using namespace std;
typedef vector<int>VI;
typedef vector<VI>VVI;
typedef vector<string>VS;
typedef pair<int,int>PII;
typedef long long LL;
typedef pair<LL,LL>PLL;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PB push_back
#define EACH(i,c) for(typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define F first
#define S second

typedef string::const_iterator State;
int Number(State &Begin){
    int ret=0;
    while(isdigit(*Begin)){
        ret*=10;
        ret+=(*Begin)-'0';
        Begin++;
    }

    return ret;
}
int Expression(State&);
int Factor(State &Begin){
    if(*Begin=='('){
        Begin++;
        int ret=Expression(Begin);
        Begin++;
        return ret;
    }
    else return Number(Begin);
}

int Term(State &Begin){
    int ret=Factor(Begin);
    while(true){
        if(*Begin=='*'){
            Begin++;
            ret*=Factor(Begin);
        }
        else if(*Begin=='/'){
            Begin++;
            ret/=Factor(Begin);
        }
        else break;
    }
    return ret;
}

int Expression(State &Begin){
    int ret=Term(Begin);
    while(true){
        if(*Begin=='+'){
            Begin++;
            ret+=Term(Begin);
        }
        else if(*Begin=='-'){
            Begin++;
            ret-=Term(Begin);
        }
        else break;
    }
    return ret;
}

int main(){
    int N;
    cin>>N;
    cin.ignore();
    while(N--){
        string str;
        getline(cin,str);
        State Begin=str.begin();
        cout<<Expression(Begin)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1212
function main(input) {
    var args = input
        .trim()
        .split('\n')
        .map(n => parseInt(n.trim()));
    switch (args[0] % 10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
            console.log('hon');
            break;
        case 0:
        case 1:
        case 6:
        case 8:
            console.log('pon');
            break;
        case 3:
            console.log('bon');
            break;
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;

#define foru(i, l, r) for(register int i = l; i <= r; i++)
#define ford(i, r, l) for(register int i = r; i >= l; i--)

const int maxn = 1003;

int H, N, A[maxn], B[maxn];
int dp[20004];

int main() {
  memset(dp, 0x3f, sizeof(dp));
  scanf("%d%d", &H, &N);
  for(int i = 1; i <= N; i++)
    scanf("%d%d", &A[i], &B[i]);
  dp[0] = 0;
  for(int i = 1; i <= N; i++) {
    for(int j = A[i]; j <= 20000; j++)
      dp[j] = min(dp[j], dp[j - A[i]] + B[i]);
    for(int j = 20000 - 1; j >= 0; j--)
      dp[j] = min(dp[j], dp[j + 1]);
  }
  printf("%d\n", dp[H]);
  return 0;
}


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

int a, b, c, d, e, f, g, h, i, j;

int main()
{
    for(int i=0; i < 2; ++i) {
        cin >> c >> d >> e >> f >> g >> h >> i >> j;
        a += c+d+e+f, b += g+h+i+j;
    }
    printf("%d\n", (a > b) ? a : b);
    return 0;
}

Measured memory_bytes: 1144
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static int funct(String s,String t) {
		int n=s.length();
		int m=t.length();
		int ans=Integer.MAX_VALUE;
		for(int i=0;i<n-m+1;i++) {
			int min=0;
			for(int j=0;j<m;j++) {
				if(t.charAt(j)!=s.charAt(i+j)) {
					min++;
				}
			}
			ans=Math.min(min, ans);
		}
		return ans;
	}
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.next();
		String t=sc.next();
		System.out.println(funct(s,t));
	}

}


Measured memory_bytes: 35552
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=3010;
int C[N][N],g[N][N];
inline int Pow(int x,int y,int Mo) {
    int ret=1;
    while(y) {
	if(y&1) ret=1LL*ret*x%Mo;
	x=1LL*x*x%Mo,y>>=1;
    }
    return ret;
}
int main() {
    int n,Mo,ans=0;
    cin>>n>>Mo;
    for(int i=0;i<=n;i++)
	for(int j=C[i][0]=1;j<=i;j++)
	    C[i][j]=(C[i-1][j]+C[i-1][j-1])%Mo;
    for(int i=0;i<=n;i++)
	for(int j=g[i][0]=1;j<=i;j++)
	    g[i][j]=(g[i-1][j-1]+1LL*g[i-1][j]*(j+1))%Mo;
    for(int i=0,t=1;i<=n;i++,t=-t) {
	int sum=0;
	for(int j=0,c=1,k=Pow(2,n-i,Mo);j<=i;j++,c=1LL*c*k%Mo)
	    sum=(sum+1LL*g[i][j]*c)%Mo;
	ans=(ans+1LL*t*C[n][i]*sum%Mo*Pow(2,Pow(2,n-i,Mo-1),Mo))%Mo;
    }
    cout<<(ans+Mo)%Mo;
    return 0;
}

Measured memory_bytes: 69632
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MAX = 1e5 + 2;
const ll MOD = 1e9 + 7;

int main()
{
    string str;
    cin >> str;
    //cout << str << endl;

    // dp[i][j] ...i桁目まで決めた時に13で割った余りが5の数のパターン
    //              をMODで割ったもの(i = 0, 1, .... , str.size()-1 )
    int N = str.size();
    ll dp[N][13];
    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < 13; ++j) dp[i][j] = 0;
    }

    ll digit = 1;
    // i = 0のとき、遷移の最初の状態を求める。
    if(str[N-1] != '?') {
        ll num = (ll)(str[N-1] - '0');
        dp[0][(num*digit)%13] = 1;
    }
    else {
        for(ll j = 0; j <= 9; ++j) 
            dp[0][(j*digit)%13] = 1;
    }

    for(int i = 1; i < N; ++i) {
        digit *= 10;
        digit %= 13;
        int i2 = N - i - 1;
        if(str[i2] != '?') {
            ll num = (ll)(str[i2] - '0');
            for(ll j = 0; j <= 12; ++j) {
                ll neo = (j + num*digit)%13;
                dp[i][neo] +=  dp[i-1][j];
                dp[i][neo] %= MOD;
            }
        }
        else {
            for(ll j = 0; j <= 9; ++j) {
                for(ll k = 0; k <= 12; ++k) {
                    ll neo = (k + j*digit)%13;
                    dp[i][neo] += dp[i-1][k];
                    dp[i][neo] %= MOD;
                }
            }
        }
    }

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

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
int n;
ll d;
cin>>n>>d;
ll x[n],y[n];
rep(i,n){
    cin>>x[i]>>y[i];
}
int count = 0;
rep(i,n){
ll D = _pow(x[i],2) + _pow(y[i],2);

if(D <= d*d){
    count++;
}

}
cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 6720
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
     
using namespace std;
     
typedef long long ll;
typedef pair<int, int> pii;
     
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
     
mt19937 rnd(chrono::steady_clock().now().time_since_epoch().count());

int main(){
    fastIO;
    int n;
    cin >> n;
    string s;
    string t;
    cin >> s >> t;
    string suff;
    int res = 2 * n;
    int sz = 1;
    for(int i = n - 1; i >= 0 ; i -- ){
        suff = s[i] + suff;
        if(suff == t.substr(0, sz)){
            res = min(res, 2 * n - sz);
        }
        sz ++ ;
    }
    cout << res << "\n";
    return 0;
}

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

int main () {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    map<ll,ll> cnt;

    ll ans = 0;
    rep(j, n) {
      ll now = j - a[j];
      ans += cnt[now];
      ++cnt[j + a[j]];
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
    int N;
    int H[100];
    int i;

    cin >> N;
    for(i=0; i<N; ++i) {
        cin >> H[i];
    }

    int c = 0;
    int max = 0;
    for(i=0; i<N; ++i) {
        if (H[i] >= max) {
            c++;
            max = H[i];
        }
    }
    cout << c << endl;
    return 0;

} 

Measured memory_bytes: 256
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define cn cin>>
#define co cout<<
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{

long long a,b,c,d,e,f,g,h;
cin>>a>>b>>c>>d;

if (a*b>=c*d)
{
	/* code */
	cout<<a*b<<endl;
}
else
cout<<c*d<<endl;

return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

V g[212345];
int pos = 0;
int dis = 0;

int dfs(int o, int p, int d)
{
    int res = d;
    for (int i : g[p])
        if (o != i)
            res = max(res, dfs(p, i, d + 1));
    if (res > dis)
    {
        pos = p;
        dis = res;
    }
    return res;
}

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

    int n;

    cin >> n;
    REP(i, n - 1)
    {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    dfs(0, 1, 0);

    int r = dfs(0, pos, 0);

    if (r % 3 == 1)
        cout << "Second" << endl;
    else
        cout << "First" << endl;

    return 0;
}

Measured memory_bytes: 23936
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a;i>0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

ll h, w;
vector<vector <ll>> a(3, vector<ll>(2));
ll dx[2] = {1, 0};
ll dy[2] = {0, 1};

bool check(ll y, ll x){
    if(y >= h || y < 0 || x >= w || x < 0)return 0;

    return 1;
}

int main(){
    cin >> h >> w;
    a.resize(h);
    REP(i, a.size())a[i].resize(w);
    REP(y, h)REP(x, w)cin >> a[y][x];
    jkl;
    VE X, Y, XX, YY;
    REP(y, h)REP(x, w){
        REP(i, 2){
            ll nexty = y + dy[i];
            ll nextx = x + dx[i];
            if(!check(nexty, nextx))continue;
            if(a[y][x] % 2 == 0)continue;
            a[nexty][nextx]++;
            a[y][x]--;
            Y.push_back(y);
            X.push_back(x);
            YY.push_back(nexty);
            XX.push_back(nextx);
        }
    }
    print(X.size());
    REP(i, X.size()){
        print(Y[i] + 1 << " " << X[i] + 1 << " " << YY[i] + 1 << " " << XX[i] + 1);
    }
}

Measured memory_bytes: 8148
import java.util.*;

public class Main{
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	String S = sc.next();
	int cnt = 0;
	for ( int i = 0; i < S.length(); i++ ) {
	    if ( S.charAt(i) == '1' ) cnt++;
	}
	System.out.println(cnt);
    }
}


Measured memory_bytes: 22740
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 110;
int n,W,w[N],v[N],ans;
vi sum[4];

void dfs(int c,int w,int v){
    if(c==3) {
        int remain = (W - w) / (::w[0] + 3);
        v += sum[3][min(remain,sz(sum[3])-1)];
        ans = max(ans , v);
    } else {
        rep(i,0,sz(sum[c])) {
            dfs(c + 1 , w , v + sum[c][i]);
            w += ::w[0] + c;
            if(w > W) break;
        }
    }
}

int main(){
    scanf("%d%d",&n,&W);
    rep(i,0,n) scanf("%d%d",w+i,v+i);
    rep(i,0,n) sum[w[i]-w[0]].pb(v[i]);
    rep(i,0,4) {
        vi&v=sum[i];
        sort(all(v));
        reverse(all(v));
        v.insert(v.begin(),0);
        rep(i,1,sz(v)) v[i]+=v[i-1];
    }
    dfs(0 , 0 , 0);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<int> name;
  while(n>0){
    int buf=n%26;
    n/=26;
    if(buf==0){
      if(n>=1){
        --n;
        buf=26;
      }
      else break;
    }
    name.push_back(buf);
  }
  reverse(ALL(name));
  for(auto& val:name){
    char res='a'+val-1;
    cout<<res;
  }
  cout<<endl;
  return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(n+1);
	vector<int> b(n+1,0);
	for(int i = 2; i<=n; i++){
		cin >> a[i];
		b[a[i]]++; 
	}

	for(int i = 1; i<= n; i++){
		cout << b[i] << endl;
	}

	return 0;
}

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

using namespace std;
#define ll long long
const ll MAXN=1e8;
bool f[MAXN]={0};

int main()
{
    int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1];
    return 0;
}


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

typedef long long ll;
typedef char keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

const int inf = 1012345678;
int main(){
    char a[105], b[105];

    scanf("%s %s", a, b);

    if(strlen(a) > strlen(b)){
        puts("GREATER");
        return 0;
    }else if(strlen(a) < strlen(b)){
        puts("LESS");
        return 0;
    }
    for(int i = 0; i < strlen(a); ++i){
        if(a[i] > b[i]){
            puts("GREATER");
            return 0;
        }else if(a[i] < b[i]){
            puts("LESS");
            return 0;
        }else{
            ;
        }
    }
    puts("EQUAL");

    return 0;
}


Measured memory_bytes: 1628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

  string s;
  cin >> s;

  vector<vector<int>> counter(26);
  rep(i, s.length()) {
    counter[s[i]-'a'].push_back(i);
  }

  rep(i, 26) {
    counter[i].push_back(s.length());
  }

  int ans = 100;
  rep(i, 26) {
    int cnt = 0;
    int start = -1;
    for (auto&& j : counter[i]) {
      cnt = max(cnt, j-start-1);
      start = j;
    }
    ans = min(ans, cnt);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
 
using namespace std;
 
#define ll long long
const int maxn = 1e6+5;
ll a[maxn], f[maxn];
 
int main() {
 
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n,k;
    cin >> n >> k;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> f[i];
    sort(a, a + n);
    sort(f, f + n, greater<ll>());

    ll l = 0, r = 1e12;
    while (l < r) {
        ll x = (l + r) >> 1;
        ll need = 0;
        for (int i = 0; i < n; i++) {
            need += max(0ll, a[i] - x/f[i]);
        }
        if (need <= k) {
            r = x;
        } else {
            l = x+1;
        }
    }
    cout << r << endl;




}
 

Measured memory_bytes: 5888
#include <stdint.h>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

using int_type = int64_t;

#define FOR(i, n) for (int_type i = 0; i < n; ++i)

int_type gcd(int_type a, int_type b) {
    return b == 0 ? a : gcd(b, a % b);
}
int_type lcm(int_type a, int_type b) {
    return (a * b) / gcd(a, b);
}

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

    int_type N, M;
    cin >> N >> M;

    struct xyz_t {
        int_type x, y, z;
    };
    xyz_t A[1000];
    FOR(i, N) cin >> A[i].x >> A[i].y >> A[i].z;

    int_type max_v = 0;

    auto compute = [&](int_type xpn, int_type ypn, int_type zpn) {
        std::sort(A, A + N, [&](const xyz_t& a, const xyz_t& b) {
            return (xpn * a.x + ypn * a.y + zpn * a.z) >
                   (xpn * b.x + ypn * b.y + zpn * b.z);
        });
        int_type sum = 0;
        FOR(i, M) {
            sum += xpn * A[i].x + ypn * A[i].y + zpn * A[i].z;
        }
        max_v = std::max(max_v, sum);
    };

    compute(+1, +1, +1);
    compute(+1, +1, -1);
    compute(+1, -1, +1);
    compute(+1, -1, -1);
    compute(-1, +1, +1);
    compute(-1, +1, -1);
    compute(-1, -1, +1);
    compute(-1, -1, -1);

    cout << max_v;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int ans=0,val=0;
  for(int i=0;i<n;i++){
    if(s.at(i)=='I') val++;
    else val--;
    ans=max(ans,val);
  }
  cout<<ans<<endl;
}

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

const int MAX_N = 2e5;
int check_1[MAX_N+5], check_n[MAX_N+5];
int N, M;

int main(){
    cin >> N >> M;
    
    for(int i=0;i<M;i++){
        int a, b; cin >> a >> b;
        
        if(a==1) check_1[b] = 1;
        if(b==N) check_n[a] = 1;
    }

    for(int i=2;i<N;i++){
        if(check_1[i] && check_n[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <set>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int N;
	cin >> N;
	vector<int>a(N,0);
	int input;
	rep(i,N-1){
		cin >> input;
		a[input - 1]++;
	}
	rep(i, N) {
		println(a[i]);
	}
}

Measured memory_bytes: 4836
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

        static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        public static void main(String[] args) throws Exception{

            int dn = 50;
            int[] cnts = new int[dn + 1];

            for (int i=0; i<10; i++) {
                for (int j=0; j<10; j++) {
                    for (int k=0; k<10; k++) {
                        for (int l=0; l<10; l++) {
                            int sum = i + j + k + l;
                            cnts[sum]++;
                        }
                    }
                }
            }
            
            String s;
            while ((s = reader.readLine()) != null) {
                System.out.println(cnts[Integer.parseInt(s)]);
            }

        }

}

Measured memory_bytes: 16944
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */
 
    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    
    #define TRACE
    
    #ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
      cerr << name << " : " << arg1 << std::endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
      const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
    #else
    #define trace(...)
    #endif
    
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    #define te  ll ti;   cin >> ti;  while(ti--) solve();  
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;

    vector<pii> v;
    ll pre[maxN];
    void solve(){
        ll r, ans;
        cin >> r;
        ans = 3*r*r;
        cout << ans << endl;
    }
 
    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
     /*
      #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
      #endif
     */
      //te
      solve();
      return 0;
    } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define int long long
using namespace std;

vector<int> adj[200005];
bool vis[200005]={false};

int c=1, sv=-1;
vector<int> v;

void dfs(int x){
	if(vis[x]==true){
		return;
	}

	vis[x]=true;
	
	if(vis[adj[x][0]]==false){
		c++;
		v.push_back(adj[x][0]);
		dfs(adj[x][0]);
	}
	else{
		sv=adj[x][0];
	}
}

signed main(){
	fast;
	int n, k;
	cin>>n>>k;

	
	for(int i=1; i<=n; i++){
		int a; cin>>a;
		adj[i].push_back(a);
	}
	v.push_back(1);
	dfs(1);
	vector<int > tem;
	int num=1000000009;
	//cout<<sv<<"\n";
	for(int i=0; i<c; i++){
		//cout<<v[i]<<" ";
		if(v[i]==sv){
			num=i;
		}
		
		if(i>=num) tem.push_back(v[i]);
	}
	//cout<<tem.size()<<"\n";
	if(k<c) cout<<v[k];

	else cout<<tem[(k-c)%tem.size()];
	
    return 0; 
}

Measured memory_bytes: 18804
function main(input){
	var n = +input.shift();
	var m = +input.shift();

	var x = [];
	rep(n, function(i){
		x.push(i + 1);
	});

	rep(m, function(i){
		var t = input.shift().split(',');
		var a = t[0] - 1;
		var b = t[1] - 1;
		var tmp = x[a];
		x[a] = x[b];
		x[b] = tmp;
	});

	rep(n, function(i){
		console.log(x[i]);
	});
}

function rep(n, func){
	for(var i = 0; i < n; ++i){
		func(i);
	}
}

(function(){
	process.stdin.resume();
	process.stdin.setEncoding('utf8');
	var input = '';
	process.stdin.on('data', function(chunk){
		input += chunk;
	});
	process.stdin.on('end', function(){
		main(input.split(/\s+/));
	});
})();

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define F first
#define S second
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define sz size()
#define all(A)    A.begin(), A.end()
#define mem(a, b) memset(a, b, sizeof(a))   // all elements of A are b=0 or b=-1 else don't work
#define f0(i,b)   for(ll i=0;i<(b);i++)
#define f1(i,b)   for(ll i=1;i<=(b);i++)
#define f2(i,a,b) for(ll i=(a);i<=(b);i++)
#define f3(i,b,a) for(ll i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(ll i=(a);i!=(b);i+=(c))
#define mod 1000000007

#define whilee(i,t)  while(i!=t)
#define  sl(a)  scanf("%lld",&a)
#define  pl(a)  printf("%lld\n",a)

#define scan(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
char _;

//for(auto it =A.begin(); it!=A.end(); it++)
//sort(A.begin(),A.end());
//binary_search(A.begin(),A.end(),x);
//reverse(A.begin(), A.end());
//cout << *max_element(A.begin(), A.end());
//cout << *min_element(A.begin(), A.end());
//count(A.begin(), A.end(), X); //counts the occurrences of X
//distance(A.begin(),A.end());  //distance between first to last element
//accumulate(A.begin(), A.end(), 0); //add
//next_permutation(A.begin(), A.end());
//prev_permutation(A.begin(), A.end());
//swap(S[0], T[0]);

//scanf("%lld",&x);
//printf("%lld\n",x);
//while (scanf("%lld %lld", &a, &b) == 2)
//printf("Case %lld: %lld\n", t++, a);

//vector <ll> A;
//deque <ll> A;
//queue <ll> A;
//stack <ll> A;
//list <int> A;
//set <ll> A;
//map <ll,ll> A;
//pair <ll,ll> A ;
//vector <pair <ll,ll>> A ;
//bitset<32> bset1;
//char ch;
//string S, T, U;
ll i, j, k, a, b, c, d, e, f, g, h, l, m, n, o, p, q, r, s, t=1, u, v, w, x, y, z, maxx=INT_MIN, minn=INT_MAX, ans=0, sum=0, cnt=0;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);//NULL
    cout.tie(nullptr);//NULL

    //scan(n);
    cin>>n;
    ll A[n], B[n];

    f0(i,n)
    {
        cin>>A[i];
        B[i]=A[i];
    }
    sort(B,B+n);
    j=n-1;
    f0(i,n)
    {
       if(A[i]==B[j])
       {
           cout<<B[j-1]<<endl;
       }
       else
       {
           cout<<B[j]<<endl;
       }
    }

    return 0;
}


Measured memory_bytes: 4736
try while 0=0do Scanf.scanf"%f %f %f %f %f %f %f %f
"(fun a b c d e f g h->let i=(a-.e)*.(h-.b)-.(b-.f)*.(g-.a)and j=(c-.a)*.(h-.d)-.(d-.b)*.(g-.c)and k=(e-.c)*.(h-.f)-.(f-.d)*.(g-.e)in print_endline(if i>0.&&j>0.&&k>0.||i<0.&&j<0.&&k<0.then"YES"else"NO"))done with _->()

Measured memory_bytes: 2152
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
   Scanner s=new Scanner(System.in);
    int n=s.nextInt();
    int a[]=new int[n];
    for(int i=0;i<n;i++)
    {
      a[i]=s.nextInt();
    }
    long ans=0;
    for(int i=1;i<n;i++)
    {
      ans+=Math.max(0,a[i-1]-a[i]);
      a[i]=Math.max(a[i],a[i-1]);
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 59876
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        mut s: Chars,
        mut t: Chars
    };
    s.sort();
    t.sort();
    t.reverse();
    let tf = (0..s.len()).any(|index| (index < t.len()) && (s[index] < t[index]))
        || ((s.len() < t.len()) && (0..s.len()).all(|index| s[index] == t[index]));
    println!("{}", ["No", "Yes"][tf as usize]);
}


Measured memory_bytes: 2192
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4

int main(){
  int A, B, C, X, Y; cin >> A >> B >> C >> X >> Y;
  
  int bill = 0;
  if (A+B>2*C) {
    bill += 2*min(X,Y)*C;
    if (X>=Y) {
      bill += min((X-Y)*A, 2*(X-Y)*C);
    }
    else {
      bill += min((Y-X)*B, 2*(Y-X)*C);
    }
  }
  else {
    bill += A*X + B*Y;
  }

  cout << bill << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String [] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();
            
            if(h < 3) break;
            
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                	
                	if(i == 0 || i + 1 == h || j == 0 || j + 1 == w){
                		System.out.print("#");
                	}else{
                		System.out.print(".");
                	}
                
                    //System.out.print(i == 0 || i + 1 == h || j == 0 || j + 1 == w ? '#' : '.');
                }
                System.out.println();
            }
            
            System.out.println();
        }
    }
}

Measured memory_bytes: 34256
N = int(input())
A = []
B = []
while len(A) != N:
    A.append(int(input()))
B = A[0:N]
B.sort()
if B[-1] == B[-2]:
    for _ in range(N):
        print(B[-1])
else:
    for _ in range(N):
        if A[_] == B[-1]:
            print(B[-2])
        else:
            print(B[-1])

Measured memory_bytes: 14096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		if (n == m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
import java.util.List;
import java.util.Scanner;
import java.util.Arrays;
public class Main {
	public static void main(String[] args) {
        Scanner sn = new Scanner(System.in);
        int n = Integer.parseInt(sn.next());
        int cnt = 1000;
        for (int i = 1000; i <= 10000; i = i+1000){
          if ( n <= cnt){
            break;
          }
          cnt = cnt + 1000;
        }
        System.out.println(cnt - n);
	}
}



Measured memory_bytes: 35632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<pair<pair<string, int>,int> > s(n);
    for(int i = 0; i < n; i++){
        cin >> s[i].first.first >> s[i].first.second;
        s[i].first.second *= -1;
        s[i].second = i + 1;
    }
    sort(s.begin(), s.end());
    for(int i = 0; i < n; i++){
        cout << s[i].second << endl;
    }
}

Measured memory_bytes: 256
s = input()
t = input()
ans = 300000
for i in range(len(s)-len(t)+1):
    temp = 0
    for j in range(len(t)):
        if t[j] != s[i+j]:
            temp += 1
    ans = min(ans,temp)

print(ans)

for i in range(0):
    print(i)

Measured memory_bytes: 9116
// Problem : L - Deque
// Contest : AtCoder - Educational DP Contest
// URL : https://atcoder.jp/contests/dp/tasks/dp_l
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ull 		unsigned long long
#define ll 			long long
#define MM			1000000007
#define N			100005
#define pb 			push_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define Endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define F           first
#define S           second
#define rep(i, begin, end) for(int i=begin;i<end;i++)
#define repr(i,begin,end) for(int i=end-1;i>=begin;i--)
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define cset(a)		__builtin_popcountll(a)
#define hell 		(ull)1e9
#define re 			resize
 
 
 
signed main(void)
{ios
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
	{
		int n;
		cin>>n;
		int a[n+1];
		rep(i,1,n+1) cin>>a[i];
		int dp[n+1][n+1];
		for(int l=n;l>=1;l--)
		{
		    for(int r=l;r<=n;r++)
		    {
		        if(l==r) dp[l][r]=a[l];
		        else dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1]);
		    }
		}
		cout<<dp[1][n];
	}
}

Measured memory_bytes: 49784
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

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

#include <iostream>
#include <bits/stdc++.h>

using namespace std;

int dfs(map<int,vector<int>> &m, bool v[], int ans[], int n) {
    //cout<<n<<endl;
    if(v[n]) return ans[n];
    ans[n]=0;
    v[n]=true;
    if(m.find(n)==m.end()) return 0;
    int i,j,k,l=m[n].size();
    for(i=0;i<l;i++) {
        j=dfs(m,v,ans,m[n][i]);
        ans[n]=max(ans[n],j+1);
    }
    //cout<<n+1<<" "<<ans[n]<<endl;
    return ans[n];
}

int main()
{
    int n,p;
    cin>>n>>p;
    map<int,vector<int>> m;
    int i,j,k,l,x,y;
    for(i=0;i<p;i++) {
        cin>>x>>y;
        if(m.find(x)==m.end()) {
            vector<int> u;
            u.push_back(y);
            m[x]=u;
        } else {
            m[x].push_back(y);
        }
    }
    bool v[n+1]={false};
    int ans[n+1]={0};
    
    for(i=1;i<n+1;i++) {
        if(!v[i]) {
           k= dfs(m,v,ans,i);
        }
    }
    int mx=INT_MIN;
    for(i=1;i<n+1;i++) {
        mx=max(mx,ans[i]);
    }
    cout<<mx<<endl;
    return 0;
}


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

using namespace std;

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

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

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

ll A[1005];
ll B[1005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    ll Q;
    cin >> Q;
    REP(_, Q) {
        ll b, m, e;
        cin >> b >> m >> e;
        REP(i, N) {
            B[i] = A[i];
        }
        REP(i, e - b) {
            B[b + (i + e - m) % (e - b)] = A[b + i];
        }
        swap(A, B);
    }

    REP(i, N) {
        cout << A[i];
        if (i < N - 1)
            cout << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  int min;
  int h[100005];
  int dp[100005];
  cin>>n>>k;
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<=k;i++){
    dp[i]=abs(h[i]-h[0]);
  }
  for(int i=k;i<n;i++){
    min=dp[i-1]+abs(h[i]-h[i-1]);
    for(int j=2;j<=k;j++){
      dp[i]=dp[i-j]+abs(h[i]-h[i-j]);
      if(min>dp[i]){
	min=dp[i];
      }
    }
    dp[i]=min;
  }
  cout<<dp[n-1]<<"\n";
  return 0;
}


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

int main()
{
  int N, L; cin >> N >> L;
  vector<string> S(N);
  for(int i = 0; i < N; i++){
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  string ans;
  for(int i = 0; i < N; i++){
    ans += S[i];
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main(){
    int N,ans=0;
    long long int now = 0;
    cin >> N;
    vector<pair<long long int, long long int>> XL(N);
    for(int i=0;i<N;i++){
        long long int x,l;
        cin >> x >> l;
        XL[i].first = x+l;
        XL[i].second = x-l;
    }

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

    now = XL[0].first;
    ans++;

    for(int i=1;i<N;i++){
        if(now<=XL[i].second){
            now = XL[i].first;
            ans++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 1920
#include<stdio.h>
int main(void){
    int n;
    scanf("%d",&n);
    int a[n];
    int i;
    int ma=0;
    int mi=0;
    long long sum=0;
    for(i=0;i<=n-1;i++){
        scanf("%d",&a[i]);
       sum=sum+a[i];
    }
    int j=0;
    ma=a[0];
    for(i=1;i<=n-1;i++){
        if(a[j]<=a[i]){
            ma=a[i];
            j=i;
        }
    }
    j = 0;
    mi = a[0];
     for(i=1;i<=n-1;i++){
        if(a[j]>=a[i]){
            mi=a[i];
            j=i;
        }
    }
    printf("%d %d %ld\n",mi,ma,sum);
    return 0;
}

Measured memory_bytes: 640
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        c: char,
    }
    if 'a' <= c && c <= 'z' {
        println!("a");
    } else {
        println!("A");
    }
}


Measured memory_bytes: 2084
from decimal import Decimal

# 整数の入力
N = int(input())

# スペース区切りの整数の入力
A = map(Decimal, input().split())

under_sum = Decimal(0)

for a in A:
    under_sum += Decimal(1) / Decimal(a)

# 出力
print(Decimal(1)/under_sum)


Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n,l;
    cin >> n >> l;
    string S[n];
    REP(i,n) cin >> S[i];
    sort(S,S+n);
    REP(i,n) cout << S[i];
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main ( void )
{
	int x;
	unsigned int mx = 0, data[101] = { 0 };

	while (cin >> x)
	{
		++data[x];
		mx = max( mx, data[x] );
	}

	for (int i = 1; i < 101; ++i)
	{
		if (data[i] == mx)
			cout << i << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll digsum(ll n, ll b)
{
	if(n < b) return n;
	return (digsum(n/b, b) + n%b);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n, s; cin >> n >> s;
	for(ll i = 2; (i-2)*(i-2) <= n; i++)
	{
		if(digsum(n, i) == s)
		{
			cout << i; return 0;
		}
	}
	vector<ll> ans;
	for(ll i = 1; (i-2)*(i-2) <= n; i++)
	{
		ll s2 = s - i;
		if(s2 < 0) continue;
		if((n - s2)%i == 0)
		{
			ll q = (n-s2)/i;
			if(s2 < q && i < q)
			{
				ans.pb(q);
				//cout << i << ' ' << q << ' ' << s2 << '\n';
			}
		}
	}
	sort(ans.begin(), ans.end());
	if(ans.empty()) 
	{
		if(n == s) cout << n+1;
		else cout << -1;
	}
	else cout << ans[0];
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n;
  cin >> n;
  ll a[n];
  rep(i,n)cin >> a[i];
  ll ans=longinf;
  ll sum=0;
  rep(i,n)sum+=a[i];
  ans=min(ans,sum);
  ll x=0;
  rep(i,n){
    x+=a[i];
    ans=min(ans, abs(sum-2*x) );
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 1792