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

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

using namespace std;

typedef pair<int,int> ii;

int H,W;
int G[11][11],INDEX[11][11],ep_bitmask,sp,V;
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
vector<int> edges[25][4];
//map<ii,int> memo;

bool isValid(int x,int y) { return 0 <= x && x < W && 0 <= y && y < H; }

inline void INIT(){
  //memo.clear();
  ep_bitmask = 0, sp = -1;
  rep(i,11) rep(j,11) INDEX[i][j] = -1;
  rep(i,25) rep(j,4) edges[i][j].clear();
}

inline void make_edges(){
  rep(i,H) rep(j,W) if( G[i][j] != 0 ) {
    int x = j, y = i;
    rep(k,4){
      int nx = x + dx[k], ny = y + dy[k];
      while( isValid(nx,ny) ){
        if( G[ny][nx] == 1 ) edges[INDEX[i][j]][k].push_back(INDEX[ny][nx]);
        nx += dx[k], ny += dy[k];
      }
    }
  }
}

inline void calc_last_point(int x,int y){
  rep(i,4) {
    int nx = x + dx[i], ny = y + dy[i];
    while( isValid(nx,ny) ){
      if( G[ny][nx] == 1 ) {
        ep_bitmask |= (1<<INDEX[ny][nx]);
        //break;
      }
      nx += dx[i], ny += dy[i];
    }
  }
}

int dfs(int cur,int visited,int remain,int ep_remain){

  if( ep_remain == 0 && remain != 0 ) return 0;

  if( remain <= 0 ) return ( (ep_bitmask>>cur) & 1 );

  int ret = 0;
  rep(k,4){
    rep(i,edges[cur][k].size()){
      int next = edges[cur][k][i];
      if( (visited>>next) & 1 ) continue;
      ret += dfs(next,visited|(1<<next),remain-1,ep_remain-((ep_bitmask>>next)&1));
      break;
    }
  }

  return ret;
}

int main(){
  while( cin >> W >> H, H|W ){
    INIT();
    int idx = 0,remain = 0,sx,sy;
    rep(i,H) rep(j,W) {
      cin >> G[i][j];
      if( G[i][j] == 1 ) INDEX[i][j] = idx++, remain++;
      if( G[i][j] == 2 ) sx = j, sy = i;
    }
    sp = INDEX[sy][sx] = idx++;
    make_edges();

    calc_last_point(sx,sy);
    assert(remain <= 23);
    V = remain;
    cout << dfs(sp,0,remain,__builtin_popcount(ep_bitmask)) << endl;

  }
  return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    ll A[N];
    rep(i, N) cin >> A[i];
    int ans = 0;
    sort(A, A+N, greater<ll>());
    ll sum = 0;
    rep(i, N){
        if(i < P-1) {ans++; continue;}
        if(A[i]+M < A[P-1]) break;
        ll S = (N-i-1)*M; 
        S += (i-P+1)*(A[i]+M) - sum;
        if(S >= M*(V-P)) ans++;
        sum += A[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string s;
  cin >> s;
  if(s.length() == 1){
    say("YES");
    return 0;
  }
  int a_c = 0;
  int b_c = 0;
  int c_c = 0;
  rep_i(i, s.length()){
    if(s[i] == 'a'){
      a_c++;
    }else if(s[i] == 'b'){
      b_c++;
    }else{
      c_c++;
    }
  }

  if(s.length() == 2){
    if(a_c == 2 || b_c == 2 || c_c == 2){
      say("NO")
    }else{
      say("YES")
    }
    return 0;
  }

  if(abs(a_c - b_c) > 1 || abs(a_c - c_c) > 1 || abs(b_c - c_c) > 1){
    say("NO")
    return 0;
  }
  say("YES")
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll a, b;
    cin >> a >> b;
    if ((a * b) % 2 == 0) {
        cout << "Even" << endl;
    } else {
        cout << "Odd" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int a,d,n,count;
    double q;
    while(true){
        count=0;
        cin>>a>>d>>n;
        if(a==0&&d==0&&n==0){
            break;   
        }else{
            a-=d;
            while(count!=n){
                a+=d;
                if(a>3){
                    q=sqrt(a);
                    bool r=true;
                    for(int j=2;j<=q;j++){
                        if(a%j==0){
                            r=false;
                            break;
                        }
                    }
                    if(r==true){
                        count++;
                    }
                }else if(a==2||a==3){
                    count++;
                }
            }
            cout<<a<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    string S;
    cin >> N >> S;
    vector<int> west(N+2, 0), east(N+2, 0);
    
    for (int i = 1; i <= N; i++) {
        west[i] = west[i - 1] + (S[i - 1] == 'W' ? 1 : 0);
        east[N + 1 - i] = east[N + 2 - i] + (S[N - i] == 'E' ? 1 : 0);
    }

    int minimum = N;
    for (int i = 1; i <= N; i++) {
        minimum = min(minimum, west[i - 1] + east[i + 1]);
    }

    cout << minimum << endl;

    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, M;
constexpr int Nmax = 200000;
int A[Nmax];
int count_[Nmax + 1];
int dup[Nmax + 1];

int main()
{
    cin >> N >> M;
    memset(count_, 0, sizeof(count_));
    memset(dup, 0, sizeof(dup));
    REP(i, N)
    {
        cin >> A[i];
        if (A[i] - count_[A[i]] > 0) dup[A[i] - count_[A[i]]]++;
        count_[A[i]]++;
    }

    int invans = 0;
    REP(i, N) if (dup[i + 1]) invans++;

    REP(_, M)
    {
        int X, Y;
        cin >> X >> Y;

        int del = A[X - 1];
        count_[del]--;
        if (del - count_[del] > 0)
        {
            dup[del - count_[del]]--;
            if (dup[del - count_[del]] == 0) invans--;
        }
 
        A[X - 1] = Y;
        if (Y - count_[Y] > 0)
        {
            dup[Y - count_[Y]]++;
            if (dup[Y - count_[Y]] == 1) invans++;
        }
        count_[Y]++;
        printf("%d\n", N - invans);
    }
}


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

int main(){
	int count[5][4][11] = {};

	int n;
	int b, f, r, v;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> b >> f >> r >> v;
		count[b][f][r] += v;
	}

	for (int j = 1; j < 5; j++){
		for (int h = 1; h < 4; h++){
			for (int k = 1; k < 11; k++){
				cout << " " << count[j][h][k];
			}
			cout << "\n";
		}
		if (j != 4){
			for (int l = 0; l < 20; l++) cout << "#";
			cout << "\n";
		}
	}

	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using vpii=vector<pair<int,int>>;
using vi=vector<int>; 
int main() {
  int n,x,t;
  cin>>n>>x>>t;
  if(n%x==0){cout<<n/x*t<<endl;}
  else{cout<<n/x*t+t<<endl;}
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main()
{
    int n;
    while (cin >> n && n)
    {
        int a = 1;
        int b = 2;
        int c = 4;
        int sum;
        int answer;
        for (int i = 4; i <= n; i++)
        {
            sum = a + b + c;
            a = b;
            b = c;
            c = sum;
        }
        if (n <= 3)
        {
            answer = 1;
        }
        else
        {
            answer = (sum / +10) / 365;
            if (sum % 3650 != 0)
            {
                answer += 1;
            }
        }

        cout << answer << endl;
    }
}



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

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

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	vl v(26,0);
	ll n = s.size();
	REP(i, n) {
		v[s[i] - 'a']++;
	}
	ll ans = n*(n - 1) / 2;
	REP(i, 26) {
		ans -= v[i]*(v[i] - 1) / 2;
	}
	cout << ans+1 << endl;

}


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

using namespace std;
int n,x,t;
int main()
{
    cin>>n>>x>>t;
    int dem=0;
    int xx=x;
    while(x<n)
    {
        dem++;
        x+=xx;
    }
    cout<<(dem+1)*t;
}


Measured memory_bytes: 3632
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int s, w; cin >> s >> w;
	cout << ((w >= s) ? "unsafe" : "safe");

	return 0;
}

Measured memory_bytes: 2988
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############
a,b = inputIL()
if a*b%2 ==1 :
  print("Odd")
else:
  print("Even")

Measured memory_bytes: 64748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<int>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=100005;
int ans;
PI a[N],b[N],c[N];
PI operator + (PI a,PI b){
	return mp(max(a.fi,b.fi),min(a.se,b.se));
}
int get(PI a){
	return max(0,a.se-a.fi+1);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read();
	For(i,1,n){
		a[i].fi=read(); a[i].se=read();
	}
	sort(a+1,a+n+1);
	b[0]=mp(0,1e9);
	For(i,1,n)b[i]=b[i-1]+a[i];
	c[n+1]=mp(0,1e9);
	Rep(i,n,1){
		c[i]=c[i+1]+a[i];
		if(i>1)ans=max(ans,get(c[i])+get(b[i-1]));
	}
	For(i,1,n)ans=max(ans,get(a[i])+get(b[i-1]+c[i+1]));
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

bool vis[N];
vector<int> v[N];
void dfs(int i) {
  if(vis[i]) return;
  vis[i] = true;
  for(auto it:v[i]) {
    dfs(it);
  }
}
void solve() {
  int n,m;
  cin>>n>>m;
  int x,y;
  REP(i,1,m) {
    cin>>x>>y;
    v[x].pb(y);
    v[y].pb(x);
  }
  int cnt = 0;
  REP(i,1,n) {
    if(!vis[i]) {
      cnt++;
      dfs(i);
    }
  }
  cout<<cnt-1;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    // cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 12004
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	ll a[n][n];
	for(int i = 0; i<n; i++)
		for(int j = 0; j<n; j++)
			cin>>a[i][j];
	ll flag = 0,ans=0;
	for(int k = 0; k<n; k++)
		for(int i = 0;i <n; i++)
		{
			int flag2 = 0;
			for(int j = 0; j<n; j++)
			{
				if(a[i][j]>a[i][k]+a[k][j])
					flag = 1;
				if(a[k][i]==a[k][j]+a[j][i] && j!=k && j!=i)
					flag2 = 1;
			}
			if(!flag2)
				ans += a[k][i];
		}
	if(flag ==1)
		cout<<-1<<endl;
	else
		cout<<ans/2<<endl;
	return 0;
}

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

using namespace std;
#define ll long long
#define M 1000000007


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>arr(n+1,0);
    for(ll i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    vector<ll>dp(n+1,0);
    dp[n-1]=abs(arr[n]-arr[n-1]);
    for(ll i=n-2;i>=0;i--)
    {
        // dp[i]=min(abs(arr[i]-arr[i+1])+dp[i+1],abs(arr[i]-arr[i+2])+dp[i+2]);
        ll hold=INT_MAX;
        for(ll j=i+1;j<=n && j<=i+k;j++)
        {
            ll h=abs(arr[i]-arr[j])+dp[j];
            hold=min(hold,h);
        }
        dp[i]=hold;
    }
    cout<<dp[1]<<endl;
}

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

using namespace std;

string a;
int n;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  while (cin >> a) {
    int b = a.size() - 1;
    bool flag = true;
    for (int i = 0; i < b / 2; i++) {
      if (!(a[i] == a[b-i])) {
        flag = false;
        break;
      }
    }
    cout << (flag ? "Yes" : "No") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
int main() {
  ll A,B,N;
  cin >> A >> B >> N;
  ll p = min(B-1,N);
  ll ans = A*p/B;
  cout << ans << endl;
}

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

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

int main(){
    int N;
    cin >> N;
    vector<int> L(N);
    rep(i, N) cin >> L[i];
    int cnt = 0;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            for(int k = j + 1; k < N; k++){
                if(L[i] != L[j] && L[j] != L[k] && L[k] != L[i]){
                    if(L[i] + L[j] > L[k] && L[j] + L[k] > L[i] && L[k] + L[i] > L[j]) cnt++;
                }
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3628
N,K = map(int,input().split())

ans = 0
if K == 0:
    ans = N ** 2
else:
    for i in range(K+1,N+1):
        ans += (i - K) * ((N - K + 1) // i) + min((N - K + 1) % i,i - K)
print(ans)


Measured memory_bytes: 2940
/* 
AUTHOR : @Sam_Jn
*/
//lo + 1, hi, ret lo
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<pair<int, int>, null_type, less_equal<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long
#define MOD 1000000007
#define pb push_back
#define ff first
#define ss second
#define NN 1000002
#define in(a, n) for(int i = 0; i < n; i++) cin >> a[i];
#define ot(a, n) for(int i = 0; i < n; i++) cout << a[i] << " ";
#define ot2(a, n) for(int i = 0; i < n; i++) cout << a[i] << "\n";
ll pwr(ll a, ll b);
ll pwr(ll a, ll b, ll m);
int baap[200002];
int prime[NN];
int find(int i);  
bool Union(int x, int y);
ll inv(ll x) {return pwr(x, MOD - 2, MOD);}
void init();
ll max(ll x, ll y, ll z) {return max(x, max(y, z));}
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {-1, 1, 0, 0, 1, -1, 1, -1};
//----------------------------------SOLUTION-BELOW-------------------------------------------// 

void solve(){
    ll n, k, t;
    cin >> n >> k >> t;
    ll fac= 0 ;
    if(n % k) fac = 1;
    cout << ((n / k) + fac) * t; 
    // cout << e;
}
int main(){


                                                            #ifndef ONLINE_JUDGE    
                                                            freopen("../../input.txt", "r", stdin);
                                                            freopen("../../output.txt", "w", stdout);
                                                            #else
                                                            // online submission
                                                            #endif
// 

    boost
    int _ = 1;
    // cout << 0 << endl;
    // cin >> _;
    while(_--){
        solve();
        cout << endl;
    }
}
 
 
//--------------------------------------DEFININTIONS---------------------------------------
ll pwr(ll a, ll b){
    if(b == 0)
        return 1 ;
    ll c = pwr(a, b/2) ;
    c = c * c;
    if(b % 2)
        return c*a;
    return c ;
}
ll pwr(ll a, ll b, ll m){
    if(b == 0)
        return 1;
    ll c = pwr(a, b/2, m) % m ;
    c = (c * c) % m;    
    if(b % 2)
        return (c * a%m) % m;
    return c ;
}
int find(int i)  
{  
    if (baap[i] != i)  
        baap[i] = find(baap[i]);  
  
    return baap[i];  
}
 
bool Union(int x, int y)
{
    x = find(x);
    y = find(y);
    if(x == y) return false;
    baap[x] = y;
    return true;
}
void init(){
  for(ll i = 2; i < NN; i++){
      if(prime[i]) continue;
      for(ll j = 2*i; j < NN; j += i)
          prime[j] = i;
  }
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    string A,B,C;
    cin >> A >> B >> C;
    
    if(A[A.size()-1]==B[0] && B[B.size()-1]==C[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion


int main()
{
	int n, m; cin >> n >> m;
	UnionFind uf(n);
	rep(i, 1, m)
	{
		int x, y, z; cin >> x >> y >> z;
		--x, --y;
		uf.merge(x, y);
	}
	set<int> s;
	rep(i, 0, n - 1)
	{
		s.insert(uf.root(i));
	}
	cout << s.size() << endl;
}

Measured memory_bytes: 5376
/*
氏名：鈴木丈人
学籍番号：190441067
概要：長方形の面積と周の長さを求めるプログラム
*/
#include<stdio.h>
int main(void)
{
	int vertical;   //縦
	int side;   //横
	int area;   //面積
	int lap;   //周
	scanf("%d %d", &vertical, &side);   //縦、横の値入力
	area = vertical*side;   //面積計算
	lap = vertical * 2 + side * 2;   //周計算
	printf("%d %d\n", area, lap);   //面積、周出力
	return 0;
}


Measured memory_bytes: 2044
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    let p = get!([usize]);
    let mut count = 0usize;
    for i in 1..n-1 {
        if (p[i] < p[i+1] && p[i] >= p[i-1]) || (p[i] < p[i-1] && p[i] >= p[i+1]) {
            count += 1;
        }
    }
    println!("{}", count);
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

long int M = 1e+9+7;
int main(void){
    int n;
    cin >> n;
    vi a(n), mx(n);
    rep(i,n){
        cin >> a[i];
    }
    vi a_cp(n);
    a_cp = a;
    rep(i,n){
        int mxj=0;
        srep(j,1,n){
            if(a_cp[j] > a_cp[mxj]) mxj = j;
        }
        mx[i] = mxj;
        a_cp[mxj] = 0;
    }
    /*
    rep(i,n){
        cout << a[mx[i]] << endl;
    }
    */
    vvl dp(n+1,vl(n+1));
    rep(i,n){
        int pi = mx[i];
        rep(l,i+1){
            int r = i-l;
            chmax(dp[i+1][l], dp[i][l]+ll((n-r-1)-pi)*a[pi]);
            dp[i+1][l+1] = dp[i][l]+ll(pi-l)*a[pi];
        }
    }
    /*
    rep(i,dp.size()){
        rep(j,dp[i].size()){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    ll ans=0;
    rep(i,n+1) chmax(ans, dp[n][i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34664
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    string s;
    cin >> s;
    int a = 0;
    rep(i,4){
        a *= 10;
        a += s[i] - '0';
    }
    a *= 100;
    a += (s[5]-'0')*10 + s[6]-'0';
    if(a <= 201904){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }


}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(a+b > c+d) cout << "Left" << endl;
  else if(a+b < c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 3580
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline char gc(){
	static char buf[1000000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int frd(){
	int x=0,f=1; char ch=gc();
	for (;ch<'0'||ch>'9';ch=gc())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=gc())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline int read(){
	int x=0,f=1; char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar())	if (ch=='-')	f=-1;
	for (;ch>='0'&&ch<='9';ch=getchar())	x=(x<<3)+(x<<1)+ch-'0';
	return x*f;
}
inline void print(int x){
	if (x<0)	putchar('-'),x=-x;
	if (x>9)	print(x/10);
	putchar(x%10+'0');
}
const int N=3e3;
int pre[(N<<1)+10],now[N+10],child[(N<<1)+10],tot;
int V[N+10];
bool vis[N+10];
void join(int x,int y){pre[++tot]=now[x],now[x]=tot,child[tot]=y;}
void insert(int x,int y){join(x,y),join(y,x);}
bool dfs(int x){
	bool flag=0;
	for (int p=now[x],son=child[p];p;p=pre[p],son=child[p])	if (V[son]<V[x])	flag|=dfs(son)^1;
	return flag;
}
int main(){
	int n=read(); V[0]=inf;
	for (int i=1;i<=n;i++)	V[i]=read();
	for (int i=1;i<n;i++){
		int x=read(),y=read();
		insert(x,y);
	}
	for (int i=1;i<=n;i++)	dfs(i)?printf("%d ",i):0;putchar('\n');
	return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n;
	cin >> n;
	vector<P> p;
	for(int i = 1; i <= n; i++){
		int a;
		cin >> a;
		p.emplace_back(a,i);
	}
	sort(all(p));
	for(int i = 0; i < n; i++){
		cout << p[i].second;
		if(i != n-1) cout << " ";
		else cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1780
#coding utf-8
N,K=map(int,input().split())
V =list(map(int,input().split())) 

dpl=[]
temp=[]
T =min(N,K)+1
ans=0
for i in range(T):
  for j in range(T-i):
    dpl.clear()
    if i>0:
      dpl.extend(V[0:i])
    if j>0:
      dpl.extend(V[N-j:N])
    dpl.sort()            
    for k in range(K-i-j+1):
      if dpl != [] and k>0:
        if dpl[0]<=0:
          del dpl[0]       
      if ans<sum(dpl):
        ans=sum(dpl)
      if dpl == [] or dpl[0]>0:
        break

print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void){
    long long N,M,ans=0;
    cin>>N>>M;
    if(N==1||M==1){
        ans=N+M-3;
    }else{
        ans=(N-2)*(M-2);
    }
    if(N==1&&M==1){
        ans=1;
    }
    cout<<ans<<endl;
    
}


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

using namespace std;

long long specified_function(int a, long long b, long long x)
{
    double p0 = static_cast<double>(x) / static_cast<double>(b);
    double p1 = p0 * static_cast<double>(a);
    long long p1_int = static_cast<long long>(p1);
    long long p2 = static_cast<long long>(p0);
    p2 = p2 * a;
    return (p1 - p2);
}

int main()
{
    int a;
    long long b, n;
    cin>>a>>b>>n;
    long long max = 0;
    if (n <= b-1) max = specified_function(a, b, n);
    else max = specified_function(a, b, b-1);
    printf("%ld\n", max);
    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;
class Main {
	int max = -1000000,min = 1000000;
	public void min() {
		Scanner sc = new Scanner(System.in);
		long sum = 0;
		int n = sc.nextInt();
		if(n == 0) {
			max = 0;
			min = 0;
		} else if (n == 1) {
			int ai = sc.nextInt();
				max = ai;
				min = ai;
				sum += ai;
		} else {
			for(int I = 1; I <= n; I++) {
				int ai = sc.nextInt();
				if(ai > max) {
					max = ai;
					if(ai < min) {
						min = ai;
					}
				} else if(ai < min) {
					min = ai;
					if(ai > max) {
						max = ai;
					}
				}
				sum += ai;
			}
		}
		System.out.println(min + " " + max + " " + sum);
	}
	public static void main(String[] args) {
		new Main().min();
	}
}

Measured memory_bytes: 31772
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<map>
#include<stack>
#include<queue>
#include<set>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
int main(){
	ll n;
	cin>>n;
	cout<<n/2+n%2;
}


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

bool rg(char a, char b) {
    return (a == 'R' && b == 'G') || (a == 'G' && b == 'R');
}
bool gb(char a, char b) {
    return (a == 'G' && b == 'B') || (a == 'B' && b == 'G');
}
bool br(char a, char b) {
    return (a == 'B' && b == 'R') || (a == 'R' && b == 'B');
}

// 累積和
struct cumulative_sum {
    using lint = long long int;
    int sz;
    // data[i]:元の数列
    vector<lint> data;
    // cum[i]:[0,i)の和
    vector<lint> sum;
    // 要素数を指定して初期化
    cumulative_sum(const int _sz) : sz(_sz) {
        data.assign(sz, 0);
        sum.assign(sz + 1, 0);
    }
    lint& operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        for (int i = 0; i < sz; i++) sum[i + 1] = sum[i] + data[i];
    }
    // [a,b)の和を求める
    lint query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

int main() {
    int n;
    string s;
    cin >> n >> s;
    cumulative_sum r(n), g(n), b(n);
    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') {
            r[i] = 1;
        }
        if (s[i] == 'G') {
            g[i] = 1;
        }
        if (s[i] == 'B') {
            b[i] = 1;
        }
    }
    r.build();
    g.build();
    b.build();
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (rg(s[i], s[j])) {
                ans += b.query(j + 1, n);
                int d = 2 * j - i;
                if (d < n && s[d] == 'B') {
                    ans--;
                }
            }
            if (gb(s[i], s[j])) {
                ans += r.query(j + 1, n);
                int d = 2 * j - i;
                if (d < n && s[d] == 'R') {
                    ans--;
                }
            }
            if (br(s[i], s[j])) {
                ans += g.query(j + 1, n);
                int d = 2 * j - i;
                if (d < n && s[d] == 'G') {
                    ans--;
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3696
s=list(input())
s.reverse()

MOD=10**9+7
dp = [[0 for _ in range(13)] for _ in range(len(s)+1)]
dp[0][0]=1
keta=1
for i in range(len(s)):
    nd=s[i]
    for mod in range(13):
        dp[i][mod] %=MOD
        if dp[i][mod]==0:
            continue

        for d in range(10):
            if nd != "?" and str(d)!=nd:
                continue
            nmod=(d*keta + mod) % 13
            dp[i+1][nmod] += dp[i][mod]
    keta*=10
    keta%=13

print(dp[-1][5]%MOD)

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

int main(){
  int n,m;
  cin>> n >> m;
  vector<vector<int>> v(m);
  int a,b;
  for (int i=0; i<n; i++){
    cin>> a >> b;
    if (a-1<m) v.at(a-1).push_back(b);
  }
  
  int ans=0;
  priority_queue<int> can;
  for (int i=0; i<m; i++) can.push(0);
  for (auto i: v){
    for (auto j: i){
      can.push(j);
    }
    ans+=can.top();
    can.pop();
  }
  
  cout<< ans << endl;
}

Measured memory_bytes: 6140
n, c, k = map(int, input().split())
t = []    
for _ in range(n):
    t.append(int(input()))
t.sort()
first = t[0]
wait = 0
need = 1
for i in t:
    wait += 1
    if first + k < i or wait > c:
        need += 1
        wait = 1
        first = i
        continue
print(need)

Measured memory_bytes: 13032
/**
  @file b.cpp
  @title B - 文字列大好きいろはちゃんイージー / Iroha Loves Strings (ABC Edition)
  @url https://atcoder.jp/contests/abc042/tasks/abc042_b
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  REP(i, N) {
    cin >> S[i];
  }

  sort(ALL(S));

  string ret = "";
  REP(i, N) {
    ret += S[i];
  }

  cout << ret << endl;
  return 0;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	rep(i,1,n)
	cin>>a[i];
	ll dp[n+1];
	dp[1]=0;
	rep(i,2,n)
	{
		if(i==2)
			dp[i]=abs(a[i]-a[1]);
		else
		{	
			dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
			rep(j,1,k)
			{	

				if((i-j)>=1)
				{
					dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
				}
			}
			//dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
		}
	}
	cout<<dp[n];
	


	return 0;
	
}

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

void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   }  
   int index = L[m][n]; 
   //char lcs[index+1]; 
   string lcs = ""; 

   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (X[i-1] == Y[j-1]) 
      { 
          lcs += X[i-1];
          i--; j--; index--;
      } 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   }
  reverse(lcs.begin(), lcs.end());
  cout << lcs;
}

int main()
{
  string s1, s2;
  cin >> s1 >> s2;
  lcs(s1, s2, s1.length(), s2.length());
  return 0;
}

Measured memory_bytes: 35456
#include <stdio.h>

int face[7][7][4] = {
{{0},{0},{0},{0},{0},{0},{0}},
{{0},{0},{0,1,2,3},{0,1,3,5},{0,1,4,2},{0,1,5,4},{0}},
{{0},{0,2,1,4},{0},{0,2,3,1},{0,2,4,6},{0},{0,2,6,3}},
{{0},{0,3,1,2},{0,3,2,6},{0},{0},{0,3,5,1},{0,3,6,5}},
{{0},{0,4,1,5},{0,4,2,1},{0},{0},{0,4,5,6},{0,4,6,2}},
{{0},{0,5,1,3},{0},{0,5,3,6},{0,5,4,1},{0},{0,5,6,4}},
{{0},{0},{0,6,2,4},{0,6,3,2},{0,6,4,5},{0,6,5,3},{0}}};
int assign[7];

int main()
{
	int q, i, t, f;

	for (i = 1; i <= 6; i++) scanf("%d", assign+i);
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d", &t, &f);
		for (i = 1; i <= 6; i++) {
			if (assign[i] == t) t = i;
			if (assign[i] == f) f = i;
		}
		printf("%d\n", assign[face[t][f][3]]);
	}
	return 0;
}



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

using namespace std;
#define FOR(i,bg,ed) for(int i=bg;i<ed;i++)
#define REP(i,n) FOR(i,0,n)

typedef long long LL;
typedef vector<int> V;
string s;
int i(char x){
    return x-'0';
}
LL M(){
    LL sum=0;
    LL mul=i(s[0]);
    int id=1;
    int n=s.size();
    while(id<n){
        char op = s[id++];
        int num = i(s[id++]);
        if(op=='+'){
            sum += mul;
            mul = num;
        }
        if(op=='*'){
            mul*=num;
        }
    }
    sum+=mul;
    return sum;
}

LL L(){
    LL sum=i(s[0]);
    int id=1;
    int n=s.size();
    while(id<n){
        char op = s[id++];
        int num = i(s[id++]);
        if(op=='+'){
            sum += num;
        }
        if(op=='*'){
            sum*=num;
        }
    }
    return sum;
}
string ans[]={"I","L","M","U"};
        
int main(){
    LL ret;
    cin>>s>>ret;
    int x=0;
    if(M()==ret)x|=2;
    if(L()==ret)x|=1;
    cout<<ans[x]<<endl;
    return 0;
}

Measured memory_bytes: 3200