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

int main(){
  int N, K;
  cin >> N >> K;
  //cout << "N=" << N << endl << "K=" << K << endl; 
  
  string S;
  cin >> S;
  //cout << "S=" << S <<endl;
  
  int unhappy = 0;
  for( int i = 0; i < N-1; i++ ){
    if( S.at(i) != S.at(i+1) ) unhappy++;
    //cout << unhappy << endl;
  }
  
  cout << (N - max( 0, unhappy - 2 * K ) - 1 );
  return 0;
}


Measured memory_bytes: 512
N,M,Q = map(int,input().split())

station = [[0]*(N+1) for i in range(N+1)]

for i in range(M):
    l,r = map(int,input().split())
    station[l][r] += 1

DP = [[0]*(N+1) for i in range(N+1)]

for i in range(N+1):
    for j in range(N):
        DP[i][j+1] = DP[i][j] + station[i][j+1]

for i in range(Q):
    p,q = map(int,input().split())
    ans = 0
    for i in range(p,q+1):
        ans += DP[i][q] - DP[i][p-1]
    print(ans)

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

int main() {
  double N, T, A;
  double x=1000000000000;
  double y, q, p;
  int k;
  cin >> N >> T >> A;
  
  for (int i=0; i< N; i++) {
    cin >> p;
    q = T - (p * 0.006);
  //  cout << q << endl;
    y= q-A;
    if (y<0) y= -y;
    if (y<x) {
      x=y;
      k=i+1;
    }
  }
  
  cout << k << endl;
}


Measured memory_bytes: 256
h,w = map(int,input().split())
if (h%3 == 0) or (w%3 == 0):
  print(0)
else:
  ans = h*w
  for i in range(1,max(h,w)//2 + 1):
    a = min(h,w)*i
    b = (max(h,w)-i)*(min(h,w)//2)
    if min(h,w)%2 != 0:
      c = (max(h,w)-i)*(min(h,w)//2 + 1)
    else:
      c = b
    kari = max(a,b,c)-min(a,b,c)
    if ans > kari:
      ans = kari
  ans3 = h*w
  for i in range(1,min(h,w)//2 + 1):
    a = max(h,w)*i
    b = (min(h,w)-i)*(max(h,w)//2)
    if max(h,w)%2 != 0:
      c = (min(h,w)-i)*(max(h,w)//2 + 1)
    else:
      c = b
    kari = max(a,b,c)-min(a,b,c)
    if ans3 > kari:
      ans3 = kari
  ans2 = ((max(h,w)//3 + 1)*min(h,w))-((max(h,w)//3)*min(h,w))
  print(min(ans,ans2,ans3))

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

#define mx 100005
typedef long long int ll;
vector<ll>v[mx];
ll dis[mx];
bool vis[mx];
ll dp[mx];
void dfs(ll sn)
{
    vis[sn]=true;
    for(auto i:v[sn]){
        if(!vis[i]){
            dfs(i);
        }
        dp[sn]=max(dp[sn],dp[i]+1);
    }
}

int main()
{
    ll n,m;
    cin>>n>>m;

    for(int i=1;i<=m;i++){
        int x,y;cin>>x>>y;
        v[x].push_back(y);
    }
    for(int i=1;i<=n;i++){
        if(vis[i]==false){
            dfs(i);
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
    cout<<ans<<endl;
}


Measured memory_bytes: 12660
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>


using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 


long long int N,M,K,sum=0,res=0,A,B,C,D;
string S[200030];

int main()
{
    cout << fixed << setprecision(18);
    cin>>N;
    for(long long int i = 0; i < N; i++){
        cin>>S[i];
    }
    sort(S,S+N);
    res=1;
    for(long long int i = 1; i < N; i++){
        if(S[i]!=S[i-1]){res++;}
    }
    cout<<res<<endl;
}    


Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int z=x%10;
    if (z==3)
        cout<<"bon";
    else if (z==0||z==1||z==6||z==8)
        cout<<"pon";
    else
        cout<<"hon";
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s; getline(cin, s);
  for (char c : s) if (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z') cout << char(c ^ 32); else cout << c;
  cout << endl;
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  string S; cin >> S;
  if(S.size() == 3){
    reverse(S.begin(), S.end());
  }
  cout << S << endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <vector>

using namespace std;

#define debug(x) (cout << # x ": " << x << endl)
#define int long long int
#define repeat(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()

signed main() {
    int n, m;
    cin >> n >> m;

    vector<int> vs, vc;
    repeat(i, m) {
        int s, c;
        cin >> s >> c;
        vs.push_back(s);
        vc.push_back(c);
    }

    repeat(i, 1000) {
        auto s = to_string(i);
        if (s.size() < n) continue;

        bool flg = true;
        repeat(j, m) {
            if (s[vs[j] - 1] != '0' + vc[j]) flg = false;
        }

        if (flg) {
            cout << i;
            return 0;
        }
    }

    cout << -1;
    return 0;
}

Measured memory_bytes: 3164
import Queue

while True:
    w, h = [int(_) for _ in raw_input().split()]
    if w == h == 0:
        break
    dat = [list(raw_input()) for _ in xrange(h)]
    queue = Queue.Queue()
    for y, r in enumerate(dat):
        if "@" in r:
            queue.put([r.index("@"), y])

    while not queue.empty():
        x, y = queue.get()
        for dx, dy in [[1, 0], [0, 1], [-1, 0], [0, -1]]:
            if not (0 <= x + dx < w) or not (0 <= y + dy < h):
                continue
            if dat[y + dy][x + dx] == ".":
                dat[y + dy][x + dx] = "@"
                queue.put([x + dx, y + dy])

    ans = 0
    for r in dat:
        ans += r.count("@")

    print(ans)

Measured memory_bytes: 6820
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define INF 1000000007
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int>v(n);
  unordered_map<int,int>cnt;
  rep(i,n){
    cin >> v[i];
    cnt[v[i]]++;
  }
  int ans = 0;
  rep(i,n){
    cnt[v[i]]--;
    bool ok = true;
    ll N = v[i];
    for(int64_t j = 1; j * j <= N; j++) {
    if(N % j == 0) {
      if(cnt[j] >= 1)ok = false;
      if(j * j != N && cnt[N / j] >= 1)ok = false;
    }
    }
    if(ok)ans++;
    cnt[v[i]]++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 32536
#include <iostream>
#include <vector>
#include <algorithm>

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

int main()
{
    vector<vector<int>> bingo(3);
    int a,N,b;
    rep(i, 3)
    {
        rep(j, 3)
        {
            cin >> a;
            bingo.at(i).push_back(a);
        }
    }
    
    cin >> N;
    rep(i, N)
    {
        cin >> b;
        rep(j, 3)
        {
            rep(k, 3)
            {
                if (b == bingo.at(j).at(k))
                {
                    bingo.at(j).at(k) = 0;
                }
            }
        }
    }

    rep(i, 3)
    {
        if (!(bingo.at(i).at(0)) && !(bingo.at(i).at(1)) && !(bingo.at(i).at(2)))
        {
            cout << "Yes" << endl;
            return 0;
        }

        if (!(bingo.at(0).at(i)) && !(bingo.at(1).at(i)) && !(bingo.at(2).at(i)))
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

    if (!(bingo.at(0).at(0)) && !(bingo.at(1).at(1)) && !(bingo.at(2).at(2)))
    {
        cout << "Yes" << endl;
        return 0;
    }
    if (!(bingo.at(0).at(2)) && !(bingo.at(1).at(1)) && !(bingo.at(2).at(0)))
    {
        cout << "Yes" << endl;
        return 0;
    }

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

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

int main(){
  string s;
  int v,mini=10000;
  cin >> s;
  for(int i=0;i<s.size()-2;i++){
  v= abs(753-((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0')));
  if(mini>v){
    mini=v;
  }
  }
  cout << mini << endl;
}

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

int main() {
  int h,w;
  while(cin >> h >> w && h||w){
    for(int i=0;i<h;i++){
    for(int j=0;j<w;j++) cout << "#";
    cout << endl;
      
      if(h==0 && w==0)
        break;
      }
    cout << endl;
  }
}




Measured memory_bytes: 3068
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var ret = getAns(n);
        Console.WriteLine(ret);
    }
    public static int getAns (int n)
    {
        if (n == 2 | n == 3) return 1;
        if (n >= 4  && n <= 8 ) return 2;
        if (n % 3 == 0) return 1 + getAns(n / 3);
        else
        {
            var w1 = n / 3;
            return Math.Max(getAns(w1), getAns(w1 + 1)) + 1;
        }
    }
}



Measured memory_bytes: 9160
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];
            int C = input[2];
            Console.WriteLine(C >= A && C <= B ? "Yes" : "No");
        }
    }
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) 
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)
#define YES(cond) cond ? OUT("YES") : OUT("NO")
#define Yes(cond) cond ? OUT("Yes") : OUT("No")

template<class T> T gcd(const T x,const T y){if(!y){return x;}return gcd(y,x%y);}
template<class T> T lcm(const T x,const T y){return x/gcd(x,y)*y;};
template<class T> T modpow(const T x,const T n,const T mod) {
  T res=1;while(n>0){if(n%2)res=res*x%mod;x=x*x%mod;n/=2;};return res;
}
template<class T> bool alltrue(const T &a){return all_of(ALL(a),[](bool x){return x;});}
template<class T> bool anytrue(const T &a){return any_of(ALL(a),[](bool x){return x;});}
template<class T> bool contain(const T &a,const T &b){for(auto x:b){if (a.find(x)==a.end()){return false;}}return true;}
template<class T> bool mmax(T &m,const T q){ if (m < q) {m = q; return true;} else return false; }
template<class T> bool mmin(T &m,const T q){ if (m > q) {m = q; return true;} else return false; }
template<class T> int siz(const T &a) {return (int)a.size();}
template<class T> set<T> devisers(T n) {
  set<T> res;for(T i=1;i<(T)sqrt(n)+1;i++){if(n%i==0){res.insert(i);res.insert(n/i);}}return res;
}
template<class T> void concat(T &a, const T &b){a.insert(a.end(),b.begin(),b.end());}
template<class T> void getand(const T &a,const T &b,T &c) {
  set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}
template<class T> void getor(const T &a,const T &b,T &c) {
  set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.end()));
}

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

const int MOD=1e9+7;

vector<int> Zalgo(const string &s) {
  int N=siz(s);
  vector<int> z(N,0);
  z[0]=N;
  int i=1,j=0;
  while (i<N) {
    while (i+j<N && s[j]==s[i+j]) j++;
    z[i]=j;
    if (j==0) { i++;continue; }
    int k=1;
    while (i+k<N && z[k]+k<j) {
      z[i+k]=z[k];
      k++;
    }
    i+=k;j-=k;
  }
  return z;
}

int main() {
  int N;cin>>N;
  string S;cin>>S;
  int ans = 0;
  REP(i,N) {
    vector<int> tmp=Zalgo(S.substr(i));
    REP(j,tmp.size()) mmax(ans,min((int)j,tmp[j]));
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <math.h>
#include <time.h>
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <iterator>
#include <algorithm>

using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define reprrev(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define reprev(i, n) reprrev(i, 0, n)

#define PI M_PI
#define INF 1000000000
#define MOD 1000000007;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<bool>> vvb;

int N;
int ans = 0;


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


	cout << (m - 1) * (n - 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////


int main() {
	ll N, C, K;
	cin >> N >> C >> K;

	vector<ll> T(N + 1);
	repn(i, N) cin >> T[i];

	sort(++T.begin(), T.end());

	ll ans = 1;
	ll wait = 1;

	for (ll i = 2; i <= N; i++) {
		if (T[wait] + K < T[i] || i-wait>=C) {
			ans++;
			wait = i;
		}
	}

	cout << ans;

	system("PAUSE");

}





Measured memory_bytes: 1272
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main(void)
{   
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
    }

    int p = 1;
    rep(i, n) {
        if(a[i] == p) p++;
    }

    if(p - 1 == 0) cout << -1 << endl;
    else cout << n - p + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
    int a, b, k, i, ans = 0;
    
    scanf("%d %d %d", &a, &b, &k);
    
    if(a >= b){
        i = a;
    }else{
        i = b;
    }
    for(;;){
        if(a % i == 0 && b % i == 0){
            ans = i;
            k = k - 1;
            if(k == 0){
                printf("%d\n", ans);
                break;
            }
        }
        i = i - 1;
    }
}


Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
int main (){
  int n;cin>>n;
  int a[n+5],b[n+5];
  for(int i=0;i<n;i++){
    cin>>a[i]>>b[i];
  }
  for(int i=2;i<n;i++){
    if(a[i]==b[i]&&a[i-1]==b[i-1]&&a[i-2]==b[i-2]){
        cout<<"Yes";
        return 0;
    }
  }
  cout<<"No";
  return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    for(int i = 0; i < S.size(); i++) {
        S[i] = 'x';
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    h, w=map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):
            if i%2==0 and j%2==1:
                print(".", end="")
            elif i%2==0 and j%2==0:
                print("#", end="")
                
            elif i%2==1 and j%2==1:
                print("#", end="")
                
            elif i%2==1 and j%2==0:
                print(".", end="")
        print("")
    print("")


Measured memory_bytes: 7008
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

const long long MAXN = 1e12;
long long x,y;

void Slove(){
	long long xx,yy,sum1,sum2,sum3,ma_x,mi_n,ans,tot = min(x,y);
	xx = x;
	yy = y;
	for(int i = 1;i <= yy - 1;i++){
		sum1 = i * xx;
		sum2 = (yy - i) * (xx / 2);
		sum3 = (yy - i) * ((xx + 1) / 2);
		ma_x = max(sum1,sum2) , ma_x = max(ma_x,sum3);
		mi_n = min(sum1,sum2) , mi_n = min(mi_n,sum3);
		ans = ma_x - mi_n;
		tot = min(tot,ans);
	}
	swap(xx,yy);
	for(int i = 1;i <= yy - 1;i++){
		sum1 = i * xx;
		sum2 = (yy - i) * (xx / 2);
		sum3 = (yy - i) * ((xx + 1) / 2);
		ma_x = max(sum1,sum2) , ma_x = max(ma_x,sum3);
		mi_n = min(sum1,sum2) , mi_n = min(mi_n,sum3);
		ans = ma_x - mi_n;
		tot = min(tot,ans);
	}
	printf("%lld\n",tot);
}

int main(){
	scanf("%lld %lld",&x,&y);
	if(x % 3 == 0 || y % 3 == 0) printf("0\n");
	else Slove();
}

Measured memory_bytes: 128
import java.util.*;
import java.util.Map.Entry;
 
class Main {
	 static int mod =  (int) (Math.pow(10,9)+7);
//	 static int mod = 998244353;
   public static void main(String[] args) {
	   
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int M = sc.nextInt();
//       String S = sc.next();
//       char[] c = S.toCharArray();
       
       Integer[][] a = new Integer[M][2];
       List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
       for(long i=0;i<N;i++)list.add(new ArrayList<Integer>());
       for (int i=0 ; i<M; i++) {
    	   int ai= sc.nextInt()-1;
    	   int bi= sc.nextInt()-1;
    	   int c= sc.nextInt()-1;
    	   list.get(ai).add(bi);
    	   list.get(bi).add(ai);
       }
       long cnt=0;
       boolean[] m=new boolean[N];
       LinkedList<Integer> queue = new LinkedList<Integer>();
       for(int i=0;i<N;i++) {
    	   if(m[i]==false) {
    		  cnt++;
    		  queue.add(i);
    		  while(!queue.isEmpty()) {
    			  int node=queue.poll();
        		  m[node]=true;
    			  for(int j:list.get(node)) {
    				  if(m[j]==true)continue;
    	    		  queue.add(j);    				  
    			  }
    		  }
    	   }
       }
       
       
       System.out.println(cnt);
   }
      

}

Measured memory_bytes: 106224
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
using namespace std;
ll a[214514]; ll n, ans = 0;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	rep(i, n) {
		if (a[i] + 2 <= a[i + 1]||a[0]!=0) {
			cout << -1 << endl;
			return 0;
		}
		if (a[i] + 1 == a[i + 1])continue;
		ans += a[i];
	}
	cout << ans << endl;
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	N := nextInt()

	var times, starts, durations []int
	for i := 0; i < N - 1; i++ {
		times = append(times, nextInt())
		starts = append(starts, nextInt())
		durations = append(durations, nextInt())
	}

	for i := 0; i < N - 1; i++ {
		t := starts[i] + times[i]

		for j := i+1; j < N - 1; j++ {
			// wait next train
			if starts[j] <= t {
				if t % durations[j] != 0 {
					t += durations[j] - (t % durations[j])
				}
			} else {
				t = starts[j]
			}
			t += times[j]
		}

		fmt.Println(t)
	}

	fmt.Println(0)
}

Measured memory_bytes: 640
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
n= ni()
ab = []
dif = []
for i in range(n):
    a,b = ma()
    ab.append((a,b))
    dif.append((a+b,i))
dif.sort(reverse=True)
tak = 0
ao = 0
for i in range(n):
    d,idx = dif[i]
    if i%2==0:
        tak+=ab[idx][0]
    else:
        ao+=ab[idx][1]
print(tak-ao)
#print(tak,ao)


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

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define all(a) a.begin(),a.end()
#define fst first
#define scd second

signed main()
{
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	vector<int> b;
	
	b.push_back(0);
	b.push_back(1);
	
	for(int i=1;i<n;++i) {
		if (a[i]!=a[i-1])b[b.size()-1]++;
		else b.push_back(1);
	}
	
	b.push_back(0);
	
	//rep(i, b.size()) printf("b[%d] = %d\n", i, b[i]);
	
	int ans = 0;
	
	for (int i = 2; i < b.size(); ++i) {
		ans = max(ans, b[i-2]+b[i-1]+b[i]);
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 3468
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define sh cin.tie(0); cin.sync_with_stdio(0); cout.tie(0);
#define FILE freopen("test.in", "r", stdin);
#define vprint(v) for (int ii = 0; ii < v.size(); ii++){cout << v[ii] << " ";}
#define debugv(v) if (v.size() != 0) {cout << "[ "; for (int __ = 0; __ < (int)(v.size()) - 1; __++){cout << v[__] << ", ";} cout << v[(int)(v.size()) - 1] << " ]" << endl;} else {cout << "[]" << endl;}
#define debug cout << "-----------------------------------------------" << endl;
#define print1(a) cout << "{ " << a << " }" << endl;
#define print2(a, b) cout << "{ " << a << ", " << b << " }" << endl;
#define print3(a, b, c) cout << "{ " << a << ", " << b << ", " << c << " }" << endl;
#define print4(a, b, c, d) cout << "{ " << a << ", " << b << ", " << c << ", " << d << " }" << endl;
using namespace std;
//#define int long long
const int INF = 1e9 + 228;
const int MAXN = 1e5 + 228;

signed main()
{
#ifdef LOCAL
    FILE;
#endif
    sh;
    int n;
    cin >> n;
    string p = "", q = "";
    for (int i = 0; i < n; i++) {
    	string aa;
    	cin >> aa;
    	p += aa;
    }
    for (int i = 0; i < n; i++) {
    	string aa;
    	cin >> aa;
    	q += aa;
    }
   	int a = 0, b = 0;
   	string x = "";
   	for (int i = 1; i <= n; i++) {
   		x += ((char)i + '0');
   	}
   	int cnt = 0;
   	do {
   		//print1(x);
   		if (x == p) {
   			a = cnt;
   		}
   		if (x == q)
   			b = cnt;
   		cnt++;
   	} while (next_permutation(all(x)));
   	cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		// input
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int d = scan.nextInt();

		// answer
		if(d == 1){
			System.out.println(1);
		} else {
			System.out.println(0);
		}

	}
}


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

int main(){
    ll  n , m , k ;
    cin >> n >> m >> k ;
    vector<ll> A(n,0) ;
    vector<ll> B(m,0) ;
    rep(i,n) cin >> A.at(i) ;
    rep(i,m) cin >> B.at(i) ; 
    rep(i,n-1) A[i+1] = A[i+1] + A[i] ;
    rep(i,m-1) B[i+1] = B[i+1] + B[i] ;
    auto it = upper_bound(B.begin(),B.end(),k);
    ll ans = distance(B.begin(),it) ;
    for(ll i = 0 ; i < n ; i++ ){
      if ( k - A[i] < 0 ) continue ;
      auto Iter1 = upper_bound(B.begin(),B.end(), k - A[i] );
      ll j =  Iter1 - B.begin() ;
      //cout << i + 1 << ' ' <<  j << endl ; 
      ans = max(i+j+1,ans) ;
    }
    cout << ans << endl ;
}


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

const long double PI = acos(-1);
 
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main(){
    ll n;
    cin >> n;
    ll a[n];
    for(int i = 0; i < n; i++) cin >> a[i];

    sort(a, a+n);
    map<ll, ll> mp;
    for(int i = 0; i < n; i++){
        mp[a[i]]++;
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(i > 0){
            if(a[i-1] == a[i]) continue;
        }
        
        if(a[i] > mp[a[i]]) ans += mp[a[i]];
        else ans += mp[a[i]] - a[i]; 
    }

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

Measured memory_bytes: 9088
#include <stdio.h>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(void) {
  int n, i, j, m, k, g;
  vector< pair< int, int > > v;
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d%d", &k, &g);
    pair<int, int> p = make_pair(k, g);
    v.push_back(p);
  }
  scanf("%d", &n);
  for(i = 0; i < n; ++i) {
    scanf("%d%d", &k, &g);
    pair<int, int> p = make_pair(k, g);
    v.push_back(p);
  }
  sort(v.begin(), v.end());
  vector<pair<int, int>>::iterator it;
  for(it = v.begin(); it != v.end(); ++it) {
    if(it == v.begin()) printf("%d:%02d", (*it).first, (*it).second);
    else if((*it).first != (*(it - 1)).first || (*it).second != (*(it - 1)).second) printf(" %d:%02d", (*it).first, (*it).second);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 2728
import math
DBG = False
def is_prime(N):
    tf = True
    for i in range(2, int(math.sqrt(N))):
        if N%i == 0:
            tf = False
    return tf

X = int(input())
while(is_prime(X)==False):
    X += 1
    if DBG:
        print("%7d is Prime: %s"%(X, str(is_prime(X))))
print(X)

Measured memory_bytes: 3060
/*
g++ --std=c++17 A.cpp
*/

#include <iostream>
#include <iomanip> //! for setprecision(20)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;
using mint = static_modint<MOD>;

/*
  == AC Library Cheat sheet
  documentation: file:///Users/nobu/Downloads/ac-library/document_ja/index.html

  mint
    mint m.pow(int p)  //! return m^p
    mint m.inv() //! returns i that gives (m * i).val() == 1 
    int m.val() 

  fenwick_tree (BIT)
    fenwick_tree<T> fw(int n) //! init a[0] .. a[n-1] with all 0
    void fw.add(int idx, T x); //! a[idx] += x
    T fw.sum(int l, int r); //! return a[l] + .. + a[r-1]

  dsu (UnionFind)
    dsu d(int n)  //! prepare dsu with n nodes
    void d.merge(int x, int y)  //! connect node x and y
    bool d.same(int x, int y)  //! return true if node x and y are connected
    int d.leader(int x)  //! return the leader node of the connected group
    int d.size(int x) //! return the size of the group that node x belongs to
    vector<vector<int>> d.groups() //! return a vector of vectors that contain the nodes in each group

  floor_sum(ll n, ll m, ll a, ll b)   
*/

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

    int t;
    cin >> t;
    rep(i, t) {
        LL n, m, a, b;
        cin >> n >> m >> a >> b;
        cout << floor_sum(n, m, a, b) << endl;
    }

    return 0;
}


Measured memory_bytes: 3668
#include<stdio.h>
int main(){
int W,H,x,y,r;
scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
if (x-r<0){
printf("No\n");
}
else if(y+r>H)
{
printf("No\n");
}
else if(x+r>W){
printf("No\n");
}
else if(y-r<0){
printf("No\n");
}
else{
printf("Yes\n");
}
return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n); ++i)
typedef long long ll;
int main(){
  ll n; cin >> n;
  vector<vector<ll>> v(n, vector<ll>(3, 0));
  rep(i,n){
    ll x, l;
    cin >> x >> l;
    v[i][0]=x+l; v[i][1]=x; v[i][2]=x-l; 
  }
  sort(v.begin(), v.end());
  /*
  rep(i,n){
    cout << v[i][0] << ',' << v[i][1] << ',' << v[i][2] << endl; 
  }*/
  
  ll res=0;
  ll pre=-1000000001;
  rep(i,n){
    if(pre <= v[i][2]){
      pre = v[i][0];
      res++;
    }
  }
  cout << res;

}

Measured memory_bytes: 5760
#include <bits/stdc++.h>  // ver1.9
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
#define PAI 3.14159265358979
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  cout << fixed << setprecision(8);
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  a *= 100;
  b *= 100;
  double per=0.0,maxx=0.0;
  double gen = e*1.0/(e*1.0 + 100);
  int ans1=0,ans2=0;
  
  repeq(x,0,f/a){
    repeq(y,0,(f-x*a)/b){
      repeq(s,0,(f-x*a-y*b)/c){
        repeq(t,0,(f-x*a-y*b-s*c)/d){
          
          if(x*a+y*b+s*c+t*d > f) continue;
          if(x*a+y*b+s*c+t*d==0) continue;
          per=(s*c+t*d)*1.0/(1.0*(x*a+y*b+s*c+t*d));
          
          if(per > gen) continue;
          
          /*cout << x << ' '<<y<<' '<<s<<' '<<t<<endl;
          cout << per<< endl;*/
          
          if(per >= maxx) {
            ans1=x*a+y*b+s*c+t*d, ans2=s*c+t*d;
            maxx = per;
          }
          
        }
      }
    }
  }
  
  cout << ans1 << ' ' << ans2 << endl;
  
  return 0;
}


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

using namespace std;

int n,m;
int a[301][301];
int M[301];
bool stop[301];
const int INF = 1e9;
int main() {
  cin >> n >> m;

  for(int i = 0; i < n; i++) {
    for(int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }

  int ans = INF;
  for(int i = 0; i < m; i++) {
    int tmp = 0;
    fill(M,M+m+1,0);
    int num;
    for(int j = 0; j < n; j++) {
      for(int k = 0; k < m; k++) {
	if(stop[a[j][k]]) continue;
	M[a[j][k]]++;
	if(M[a[j][k]] > tmp) {
	  tmp = M[a[j][k]];
	  num = a[j][k];
	}
	break;
      }
    }
      ans = min(ans,tmp);
      stop[num] = true;
  }

  cout << ans << endl;
}
  


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  string s;
  cin>>a>>b>>s;
  string ans="Yes";
  for(int i=0;i<a+b+1;i++){
    if(i==a){continue;}
    else if(s.at(i)=='-'){ans="No"; break;}
  }
  if(s.at(a)!='-'){ans="No";}
  cout<<ans<<endl;
}


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

c = min(n, b - 1)
for i in range(c, max(c-a-1, -1), -1):
    v = (a * i // b) - a * (i // b)
    max_v = max(max_v, v)
print(max_v)


Measured memory_bytes: 79608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  int r = 0;
  if(a > b){
    for(int i=0; i<a; i++){
      r += b*(std::pow(10, i));
    }
  }
  else{
    for(int i=0; i<b; i++){
      r += a*(std::pow(10, i));
    }
  }
  cout << r << endl;
}

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

int main(){
  int N;
  cin >> N ;
  vector<int64_t> A(N,0);
  vector<vector<pair<int,int>>> X(N, vector<pair<int,int>>(N));
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    for(int j=0;j<A.at(i);j++){
      cin >> X.at(i).at(j).first >> X.at(i).at(j).second;
    }
  }
  int ans=0;
  for (int tmp = 0; tmp < (1 << N); tmp++) {
    bitset<15> s(tmp);
    int x=0;
    for(int i=0;i<N;i++){
      if(s.test(i)){
        for(int j=0;j<A.at(i);j++){
          if(X.at(i).at(j).second!=s[X.at(i).at(j).first-1]){
            x++;
          }
        }
      }
    }
    if(x==0){
      int S;
      S=s.count();
      ans=max(ans,S);
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
// Code for D - Road to Millionaire
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define FOR(i,x,y) for(ll i=x;i<(ll)(y);i++)

#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

int main() {
  ll N;
  cin >> N;

  vector<ll> A(N);
  REP(i, N) {
    cin >> A[i];
  }

  ll total = 1000;
  REP(i, N - 1) {
    if (A[i] < A[i+1]) {
      ll count = (total / A[i]);
      total -= count * A[i];
      total += count * A[i + 1];
    }
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 3624
import scipy.misc as scm

H, W, A, B = [int(i) for i in input().split()]
MOD = 10**9 + 7
f = [1]
a = [1]
for i in range(1, H+W-1):
    f.append((f[i-1] * i) % MOD)
    a.append(pow(f[i], MOD-2, MOD))
ans = 0
for i in range(B, W, 1):
    ans += (((f[(H-A-1)+i] * a[H-A-1] * a[i]) % MOD) * ((f[(A-1)+(W-1-i)] * a[A-1] * a[W-1-i]) % MOD))
    ans %= MOD
print(ans)

Measured memory_bytes: 29292
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int c[110000];
int ret;
int K;
vector<int>g[110000];
int dfs(int a,int b){
	int dep=0;
	for(int i=0;i<g[a].size();i++){
		dep=max(dfs(g[a][i],b+1),dep);
	}
	dep=max(dep,b);
	if((b>1&&dep==b+K-1)||(b==1&&dep==b+K)){
		ret++;
		dep=0;
	}
	return dep;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",c+i);
		c[i]--;
	}
	K=b;
	if(c[0]){
		ret++;
		c[0]=0;
	}
	for(int i=1;i<a;i++)g[c[i]].push_back(i);
	dfs(0,0);
	printf("%d\n",ret);
}

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

using namespace std;
using VI = vector<int>;
using PII = pair<int,int>;
#define MP make_pair
#define FF first
#define SS second
#define SZ(x) (int)((x).size())

int eval(string& s, int l, int r, map<char,int>& lens, map<char,map<int,int>>& arr){
  if(isdigit(s[l])){
    return stoi(s.substr(l,r-l));
  }
  char c = s[l];
  int res = eval(s, l+2, r-1, lens, arr);
  if(res < 0 || !arr.count(c) || lens[c] <= res || !arr[c].count(res)){
    return -1;
  }
  return arr[c][res];
}

int main(){
  string line;
  std::vector<string> vs;
  while(getline(cin,line)) vs.emplace_back(line);

  int pv = -1;
  int ans = 0;
  map<char,int> lens;
  map<char,map<int,int>> arr;
  for(int i=0;i<SZ(vs)-1;++i){
    if(vs[i] == "."){
      lens.clear();
      arr.clear();
      cout << ans << endl;
      ans = 0;
      pv = i;
      continue;
    }
    if(ans) continue;

    int b = 0, N = SZ(vs[i]);
    for(;b<N;++b){
      if(vs[i][b] == '='){
        break;
      }
    }
    if(b < N){ // assignment
      int l = eval(vs[i], 2, b-1, lens, arr);
      int r = eval(vs[i], b+1, N, lens, arr);
      if(l < 0 || r < 0 || lens[vs[i][0]] <= l){
        ans = i - pv;
      }
      else{
        arr[vs[i][0]][l] = r;
      }
    }
    else{
      char c = vs[i][0];
      int sz = stoi(vs[i].substr(2,N-3));
      arr[c];
      lens[c] = sz;
    }
  }

  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

int main(){
  int n,m;cin>>n>>m;
  int num[] = {0, 1, 2, 3, 4, 5, 6, 7};
  bool c[8][8];rep(i,8)rep(j,8)c[i][j] = false;
  rep(i,m){
    int a,b;cin>>a>>b;a--;b--;
    c[a][b] = c[b][a] = true;
  }
  int ans = 0;
  do{
    bool b = true;;
    rep(i,n-1){
      if(!c[num[i]][num[i+1]]){
        b = false;break;
      }
    }
    if(b)ans++;
  }while(next_permutation(num+1, num+n));
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int inf=1e7+9;
vector<int> a;
int temp,m,n,x;
int main()
{
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	cin>>x;
	for(int i=0;i<x;i++)
	{
		cin>>temp;
		a.push_back(temp);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	
//	for(int i=0;i<x;i++) cout<<a[i]<<" ";
//	cout<<endl;
	
	for(int i=0;i<x;i++)
	if(i%2) n+=a[i];
	else m+=a[i];
	
//	cout<<m<<" "<<n<<endl;
	
	cout<<abs(m-n)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
//#include "atcoder/all"
//using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
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;}
constexpr int INF = 1e18;

signed main(){
	int N;
	cin >> N;
	vector<int>a(N);
	cin >> a;
	sort(ALL(a));
	out(a.back() - a[0]);
}

Measured memory_bytes: 3600
//https://atcoder.jp/contests/abc134/tasks/abc134_c
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll N; cin>>N;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }
    vector<ll> sa=an;
    sort(sa.begin(),sa.end(),greater<ll>());
    for(const auto&a: an){
        if(a==sa[0]) cout<<sa[1]<<endl;
        else cout<<sa[0]<<endl;
    }
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();

    //setとすることで自動的に重複を除いてくれる
    set<char> p;
    rep(i,n){
        p.insert(s.at(i));
    }

    //重複がないならpとsの要素数は一致するはず
    if((int)p.size() == n){
        cout << "yes" << endl;
    }
    else{
        cout << "no" << endl;
    }
    
}

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

typedef  long long ll;
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//
//
#define int long long

using namespace std;

int ctoi(char c) {
 switch (c) {
 case '0': return 0;
 case '1': return 1;
 case '2': return 2;
 case '3': return 3;
 case '4': return 4;
 case '5': return 5;
 case '6': return 6;
 case '7': return 7;
 case '8': return 8;
 case '9': return 9;
 default: return 0;
 }
}


 ll a,b,c,s,t,x,y,z;
 ll A,B,C,S,T,X,Y,Z;

 ll cnt;

 long double pi=3.14159265358979323846;

 string N,M;

unsigned long long D;

signed main(){
	bool wo=true;

	cin>>a>>b;

	vector<int> f(b);

	REP(i,b) cin>>f[i];

	x=0;
	REP(i,b+1){
		if(i%2==0) x=a+i/2;
		if(i%2==1) x=a-(i+1)/2;
		REP(i,b) if(x==f[i]) wo=false;
		if(wo==true){
			break;
		}
		wo=true;
	}

	cout<<x;

	return 0;

}


Measured memory_bytes: 3600
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let input_string = '';

process.stdin.on('data', (chunk) => {
    input_string += chunk;
});

process.stdin.on('end', () => {
    let lines = input_string.split('\n');

    const n = parseInt(lines[0]);
    console.log(Math.pow(n, 3));
});


Measured memory_bytes: 15584
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string S;
  cin >> S;
  bool bl = false;
  for (char s : S) {
    if (s == '7') bl = true;
  }
  puts(bl ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int mod = 1000000007;

int main() {
  int n, m;
  cin >> n >> m;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());
  ll ans = 0;
  rep(i, n) {
    if(m <= 0) break;
    ll a = p[i].first, b = p[i].second;
    if(m <= p[i].second) ans += m * p[i].first;
    else ans += p[i].second * p[i].first;
    m -= p[i].second;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;
typedef long long int lli;
typedef pair<int, int> ii;

int main() {
    int N;
    cin >> N;
    lli a[200009];
    for (int i = 1; i <= N; i++) {
        lli _a;
        cin >> _a;
        a[i-1] = _a - i;
    }

    sort(a, a + N);
    lli b1 = a[N/2];
    lli b2 = N != 1 ? a[0] : a[N/2+1];

    lli ans1 = 0, ans2 = 0;
    for (int i = 0; i < N; i++) {
        ans1 += abs(a[i] - b1);
        ans2 += abs(a[i] - b2);
    }

    cout << min(ans1, ans2) << endl;
}


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

int main(){
    ll n;cin>>n;
    ll ans = LINF;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0){
            ans = min(ans,n/i+i);
        }
    }
    cout << ans - 2 << endl;
}
// ABC144C

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 100005;
int n, k;
string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> k >> s;
    n = s.size();
    if(n <= k)return cout << s, 0;
    string t = s.substr(0, k);
    cout << t;
    cout << "...";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main(){
  ll n;
  string u;
  long double ans=0.0,x;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x>>u;
    if(u=="JPY")ans+=x;
    else ans+=x*380000.0;
  }
  cout<<fixed<<ans<<endl;
  return 0;
}


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

int main ()
{
    int a,b;
    cin >> a >> b;
    int tmp=b;
    while (tmp)
    {
        a*=10;
        tmp/=10;
    }
    a += b;
    if ((int)sqrt(a) * (int)(sqrt(a)) == a) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long

int main () {
  int N, K;
  cin >> N >> K;
  static int white[1000][1000] = {};
  static int black[1000][1000] = {};
  ll x, y;
  char c;     
  for (ll i = 0; i < N; i++) {
    cin >> x >> y >> c;
    if ((x / K) % 2 == (y / K) % 2) {
      if (c == 'W') {
        white[y % K][x % K]++;  
      }         
      else {
        black[y % K][x % K]++;  
      }
    }
    else {
      if (c == 'W') {
        black[y % K][x % K]++;  
      }  
      else {
        white[y % K][x % K]++;  
      }
    }
  }

  // 二次元累積和だと.....?
  int sum_white[1000][1000] = {};
  int sum_black[1000][1000] = {};
  for (int i = 0; i < K; i++) {
    for (int j = 0; j < K; j++) {
      if (i == 0) {
        if (i == 0 && j == 0) {
          sum_white[i][j] = white[i][j];
          sum_black[i][j] = black[i][j];  
        }  
        else {
          sum_white[i][j] = white[i][j] + sum_white[i][j - 1];  
          sum_black[i][j] = black[i][j] + sum_black[i][j - 1];  
        }
      }
      else {
        if (j == 0) {
          sum_white[i][j] = sum_white[i - 1][j] + white[i][j];
          sum_black[i][j] = black[i][j] + sum_black[i - 1][j];  
        }  
        else {
          sum_white[i][j] = sum_white[i - 1][j] + white[i][j] + sum_white[i][j - 1]
                          - sum_white[i - 1][j - 1];  
          sum_black[i][j] = sum_black[i - 1][j] + black[i][j] + sum_black[i][j - 1]
                          - sum_black[i - 1][j - 1];
        }
      }
    }  
  }
  /*
  for (ll i = 0; i < K; i++) {
    for (ll j = 0; j < K; j++) {
      cout << sum_white[i][j] << " ";  
    }
    cout << endl;
  }
  for (ll i = 0; i < K; i++) {
    for (ll j = 0; j < K; j++) {
      cout << sum_black[i][j] << " ";  
    }
    cout << endl;
  }
  */

  ll ans = 0;
  for (ll i = 0; i < K; i++) {
    for (ll j = 0; j < K; j++) {
      ll sub = sum_white[i][j] + (sum_black[i][K - 1] - sum_black[i][j]);
      sub = sub + (sum_black[K - 1][j] - sum_black[i][j]);
      sub = sub + (sum_white[K - 1][K - 1] - sum_white[K - 1][j] - sum_white[i][K - 1]);
      sub = sub + sum_white[i][j];
      if (ans < sub) {
        ans = sub;  
      }  
    }  
  }
  for (ll i = 0; i < K; i++) {
    for (ll j = 0; j < K; j++) {
      ll sub = sum_black[i][j] + (sum_white[i][K - 1] - sum_white[i][j]);
      sub = sub + (sum_white[K - 1][j] - sum_white[i][j]);
      sub = sub + (sum_black[K - 1][K - 1] - sum_black[K - 1][j] - sum_black[i][K - 1]);
      sub = sub + sum_black[i][j];
      if (ans < sub) {
        ans = sub;  
      }  
    }  
  }
  cout << ans << endl;
}

Measured memory_bytes: 15872