akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  int count = 0;
  for (int i=0; i<N; i++) {
      cin >> vec.at(i);
  }
  while (true) {
    bool exist_odd = false;
    for (int i=0; i<N; i++) {
      if (vec.at(i) % 2 == 1) {
        exist_odd = true;
      }
    }
    if (exist_odd) break;
    for (int i=0; i<N; i++) {
      vec.at(i) /= 2;
    }
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long ;
int main()
{
   int n;
   cin>>n;
   int f=1;
   for(int i=0;i<n;i++)
   {
       int x;
       cin>>x;
       if(x%2==0&&(x%3==0||x%5==0))continue;
       else if(x%2==0)f=0;
   }
   if(f)cout<<"APPROVED"<<endl;
   else cout<<"DENIED"<<endl;
}


Measured memory_bytes: 3564
#include <stdio.h>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;
#define F first
#define S second
#define PB push_back
const int N=1e5+10;
const long long int INF=1e16+10;
struct seg_tree{
	vector<long long int> v,f;
	void init(int n){v.resize(n<<2,INF);f.resize(n<<2,-1ll);}
	void push(int n){
		if(f[n]>=0){
			if(v[n*2+1]>f[n])v[n*2+1]=f[n*2+1]=f[n];
			if(v[n*2+2]>f[n])v[n*2+2]=f[n*2+2]=f[n];
			f[n]=-1;
		}
		return ;
	}
	void pull(int n){
		v[n]=max(v[n*2+1],v[n*2+2]);
		return ;
	}
	void fix(int n,int l,int r,int L,int R,long long int x){
		if(L<=l&&r<=R){
			if(v[n]>x)f[n]=v[n]=x;
			return ;
		}
		else if(L>r||l>R||v[n]<=x)return ;
		else{
			int mid=(l+r)>>1;
			push(n);
			fix(n*2+1,l,mid,L,R,x);
			fix(n*2+2,mid+1,r,L,R,x);
			pull(n);
			return ;
		}
	}
	long long int ask(int n,int l,int r,int pos){
		if(l==r)return v[n];
		else {
			int mid=(l+r)>>1;
			push(n);
			if(pos>mid)return ask(n*2+2,mid+1,r,pos);
			else return ask(n*2+1,l,mid,pos);
		}
	}
};
int main(){
	int n,m;
	pair<pair<int,int>,int> p[N];
	long long int ans;
	seg_tree sg;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d%d%d",&p[i].F.F,&p[i].F.S,&p[i].S);
	sort(p+1,p+m+1);
	sg.init(n);
	sg.fix(0,1,n,1,1,0);
	for(int i=1;i<=m;i++)sg.fix(0,1,n,p[i].F.F,p[i].F.S,sg.ask(0,1,n,p[i].F.F)+p[i].S);
	ans=sg.ask(0,1,n,n);
	if(ans>=INF)ans=-1;
	printf("%lld\n",ans);
}


Measured memory_bytes: 7552
program example    
	implicit none

	integer :: N,K,i,j
    integer(8) kari
    integer(8),allocatable :: H(:)
    
    read(*,*) N,K
    
    allocate(H(N))
    
    read(*,*) H(:)
    
    H=dble(H)
    
    call heapsort(N,H)
    
    H=int(H)
   
   	write(*,*) sum(H(:N-K))
    
end program example

subroutine heapsort(n,array)
  implicit none
  integer,intent(in) :: n
  double precision,intent(inout) :: array(1:n)
  
  integer ::i,k,j,l
  double precision :: t
  
  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     end do
     array(i)=t
  end do

  return
end subroutine heapsort

Measured memory_bytes: 2304
inf = float('inf')
n = int(input())
s = input()

right_e = s.count("E")
left_w = 0
cnt = inf

for e in s:
  if e == "W":
    cnt = min(cnt, right_e + left_w)
    left_w += 1
  else:
    right_e -= 1
    cnt = min(cnt, right_e + left_w)
print(cnt)

Measured memory_bytes: 9772
def main():
    N, Z, W = map(int, input().split())
    a = list(map(int, input().split()))

    if N == 1:
        print(abs(a[0] - W))
    else:
        print(max(abs(a[-1] - W), abs(a[-2] - a[-1])))

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var dp = Enumerable.Repeat(int.MaxValue, n).ToArray();
            dp[0] = 0;
            for (var i = 1; i < n; i++)
            {
                dp[i] = Math.Min(dp[i], dp[i-1] + Math.Abs(h[i]-h[i-1]));
                if (i > 1) dp[i] = Math.Min(dp[i], dp[i-2] + Math.Abs(h[i]-h[i-2]));
            }
            
            Console.WriteLine(dp[n-1]);
        }
    }
}


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

using namespace std;

#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n);i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(a);i>=(int)(b);--i)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;

const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}

template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  REP(i, SZ(v)) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  vll a(n);
  REP(i, n) {
    cin >> a[i];
    if(a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  ll ans = 1;
  REP(i, n) {
    if(ans > LLONG_MAX / a[i]) {
      ans = -1;
      break;
    } else {
      ans *= a[i];
    }
  }
  if(ans > 1000000000000000000ll) cout << -1 << endl;
  else cout << ans << endl;

}
























Measured memory_bytes: 3992
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define Vb vector<bool>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN2(a,b);
  Vs data(a);
  REP(i,a){
    IN(data[i]);
  }
  //横
  Vb H(a);
  Vb W(b);
  REP(i,a){
    REP(j,b){
      if(data[i][j]=='#') {H[i]=true;W[j]=true;}
    }
  }
  REP(i,a){
    bool test1 = false;
    REP(j,b){
      if(H[i] && W[j]) {cout << data[i][j];test1=true;}
    }
    if(test1) OUT("");
  }
}

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

main () {
  int n;
  scanf("%d", &n);

  //xはargと入力値をpairとするvector
  vector<pair<int, int>> x(n);
  rep(i,n) {
    int a;
    scanf("%d", &a);
    x[i] = make_pair(i, a);
  }

  //valueを基準にsortする。
  sort(x.begin(), x.end(), [](auto& a, auto& b){return a.second < b.second;});

  //x[i]を取り除いたあとのxに対して中央値はx[n/2-1]
  //中央値のリストにxを変換する
  int med1 = x[n/2 - 1].second;
  int med2 = x[n/2].second;
  rep(i,n) {
    x[i] = make_pair(x[i].first, (i > n/2 - 1) ? med1 : med2);
  }

  //argを基準にsortし直す
  sort(x.begin(), x.end(), [](auto& a, auto&b){return a.first < b.first;});

  //valueを出力
  rep(i,n) printf("%d\n", x[i].second);

  return 0;
}


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

std :: vector < std :: vector < int > > group;

int main() {
    group.reserve(3);
    std :: vector < int > vec = {1, 3, 5, 7, 8, 10, 12};
    group.emplace_back(vec);
    vec = {4, 6, 9, 11};
    group.emplace_back(vec);
    vec = {2};
    group.emplace_back(vec);

    int n, m;
    std :: cin >> n >> m;

    for(auto & i : group) {
        if(std :: count(i.begin() , i.end() , n) != 0 &&
        std :: count(i.begin() , i.end(), m) != 0) {
            std :: cout << "Yes\n";
            return 0;
        }
    }

    std :: cout << "No\n";
}

Measured memory_bytes: 3520
#include <iostream>
#include<stack>
#include <math.h>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <cstdio>
#include <fstream>
#include<iomanip>
#include<bitset>
#include <numeric>
#define fastIO ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define ff first
#define ss second
using namespace std;
//const int MAX = 1e6 + 5;
const int MAX_DIST = 1e9 + 7;

ll gcd(ll x, ll y) {
	return y == 0 ? x : gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x*y / gcd(x, y);
}
//Lcm=a*b/gcd(x,y)

int n, w;
pair<ll, ll>a[100001];
ll memo[101][100001];
ll check(ll i, ll sum) {
	if (i == n)return 0;
	if (memo[i][sum] != -1)return memo[i][sum];
	ll x1 = 0, x2 = 0;
	if(sum+a[i].first<=w)
	x1 = a[i].second + check(i + 1, sum + a[i].first);
	x2 = check(i + 1, sum);
	return memo[i][sum] = max(x1, x2);
}

int main() {
	fastIO;
	cin >> n >> w;
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	for (int i = 0; i < 100; i++) { for (int j = 0; j < 100000; j++)memo[i][j] = -1; }

	cout << check(0, 0) << "\n";
}


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

int MOD=1000000007;

//2の累乗(mod)の関数
long long modpow(long long a, int n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//逆元
ll inv(ll a){
	return modpow(a,MOD-2,MOD);
}

//nck
ll nCr(int n, int r) {
    ll bunbo=1,bunshi=1;
	rep(i,r){
		bunbo=bunbo*(r-i)%MOD;
		bunshi=bunshi*(n-i)%MOD;
	}
	
	return bunshi*inv(bunbo)%MOD;
}





int main() {
	int n,a,b;
	cin>>n>>a>>b;
	
	ll ans=modpow(2,n,MOD)-1-nCr(n,a)-nCr(n,b);
	while(ans<0)ans+=MOD;
	
	cout<<ans<<endl;


}

//つぎはぎで一部RE
//modの計算は互いに素のときのみok

Measured memory_bytes: 256
#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 H, W, K;
constexpr int Hmax = 800;
vector<vector<int>> A, dp;

int main()
{
    cin >> H >> W >> K;
    A.resize(H + 2, vector<int>(W + 2, 1));
    dp.resize(H + 2, vector<int>(W + 2, 0));
    int sx, sy;
    REP(h, H)
    {
        string s;
        cin >> s;
        REP(w, W)
        {
            if (s[w] != '#') A[h + 1][w + 1] = 0;
            if (s[w] == 'S') sx = h + 1, sy = w + 1;
        }
    }

    using tpl = tuple<int, int, int>;
    queue<tpl> q;
    q.push(tpl(sx, sy, K + 1));
    int ans = 100000000;
    while (!q.empty())
    {
        int x, y, Know;
        tie(x, y, Know) = q.front();
        q.pop();
        if (Know <= dp[x][y]) continue;
        dp[x][y] = Know;
        ans = min(ans, (x + K - 2) / K);
        ans = min(ans, (H + 1 - x + K - 2) / K);
        ans = min(ans, (y + K - 2) / K);
        ans = min(ans, (W + 1 - y + K - 2) / K);
        if (!A[x + 1][y] and dp[x + 1][y] < Know - 1) q.push(tpl(x + 1, y, Know - 1));
        if (!A[x - 1][y] and dp[x - 1][y] < Know - 1) q.push(tpl(x - 1, y, Know - 1));
        if (!A[x][y + 1] and dp[x][y + 1] < Know - 1) q.push(tpl(x, y + 1, Know - 1));
        if (!A[x][y - 1] and dp[x][y - 1] < Know - 1) q.push(tpl(x, y - 1, Know - 1));
    }
    dbg(dp);
    cout << ans + 1 << endl;
}


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

int main(){
    string s;
    cin >> s;
    int ans = -1;
    for (int i = s.size()/2-1;i > 0;i--){
        bool w = true;
        for (int j = 0;j < i;j++){
            if (s[j] != s[j+i]){
                w = false;
                break;
            }
        }
        if (w){
            ans = i*2;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int a, b, x;
int main() {
    while (cin >> a >> b >> x) {
        if (x >= a && a + b >= x) puts("YES");
        else puts("NO");
    }
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}
typedef pair<ll, ll> pll;

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	cin >>n >>k;
	
	vector<pii> xy(n);
	rep(i, n) cin >>xy[i].first >>xy[i].second;
	
	VI ys(n);
	rep(i,n) ys[i] = xy[i].second;
	sort(all(ys));
	ys.erase(unique(all(ys)), ys.end());
	int yz=sz(ys);
	sort(all(xy));
	ll ans = 1LL<<62;
	VI adk(n);
	rep(y1, yz) rep2(y2, y1,yz){
		adk.clear();
		rep(i, n){
			if(ys[y1] > xy[i].second || xy[i].second > ys[y2]) continue;
			adk.push_back(xy[i].first);
			if(sz(adk) >=k){
				ll w=(1LL*ys[y2]-ys[y1]) * (adk.back() - adk[sz(adk) -k]);
				ans = min(ans, w);
			}
		}
	}

	cout << ans <<"\n";
	return 0;
}


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

int cmp(const void* a, const void* b) {
  return *(int*)a - *(int*)b;
}

int main() {
  int n, k, min = INT_MAX;
  scanf("%d%d", &n, &k);
  int h[n];
  for (size_t i = 0; i < n; i++) {
    scanf("%d", h+i);
  }
  qsort(h, n, sizeof(int), cmp);
  for (size_t i = 0; i <= n-k; i++) {
    int tmp = h[k+i-1] - h[i];
    min = (tmp < min) ? tmp : min;
  }
  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<20)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int check[100005], group=0;
int n,m,k,block[100005]={};
vector<int> num;
queue<int> edge[100005];

void dfs(){
  rep(i,n){
    if(check[i]==INF&&edge[i].size()){
      int count=1;
      queue<int> que;

      check[i]=group;

      while(edge[i].size()){
        que.push(edge[i].front());
        edge[i].pop();
      }
      while(que.size()){
        int t=que.front();
        que.pop();
        if(check[t]==INF){
          count++;
          check[t]=group;
          while(edge[t].size()){
            que.push(edge[t].front());
            edge[t].pop();
          }
        }
      }
      num.pb(count);
      group++;
    }
  }
}

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

  rep(i,n)check[i]=INF;
  rep(i,m){
    int t1,t2;
    cin>>t1>>t2;
    edge[t1-1].push(t2-1);
    edge[t2-1].push(t1-1);
    block[t1-1]++;
    block[t2-1]++;
  }
  int c[100005],d[100005];
  rep(i,k)cin>>c[i]>>d[i];

  dfs();

  rep(i,k){
    if(check[c[i]-1]==check[d[i]-1]){
      block[c[i]-1]++;
      block[d[i]-1]++;
    }
  }
  rep(i,n){
    if(check[i]==INF)cout<<0<<' ';
    else cout<<num[check[i]]-1-block[i]<<' ';
  }


  return 0;
}


Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define ll long long
#define iii tuple<int, int, bitset<100010> >

using namespace std;

int main(){
  ll N, A, B;

  cin >> N >> A >> B;


  vector<ll> v(N+1);
  cin >> v[0];

  ll res = 0;
  for(ll i = 1;  i < N; ++i){
    cin >> v[i];
    ll a_dist = abs(v[i] - v[i -1]) * A;
    res += min(a_dist, B);
  }

  cout << res << endl;

	return 0;
}


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

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

	int cost = 1e9;
	for(int i=-100;i<=100;i++){
		int tmp = 0;
		for(int j=0;j<N;j++){
			tmp += pow(a[j]-i,2);
		}
		cost = min(cost,tmp);
	}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    int h[100001];
    int dp[100001];

    cin >> N;

    for (int i = 1; i <= N; i++) {
        cin >> h[i];
    }

    dp[1] = 0;
    dp[2] = abs(h[1] - h[2]);
    for (int i = 3; i <= N; i++) {
        int jump_2 = dp[i - 2] + abs(h[i - 2] - h[i]);
        int jump_1 = dp[i - 1] + abs(h[i - 1] - h[i]);
        dp[i] = min(jump_2, jump_1);
    }

    cout << dp[N] << endl;
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	string l[N];
	for(int i = 0; i < N; i++){
		cin >> l[i];
	}
	set<string> myset (l, l+N);
	
	cout << myset.size() << endl;
	
	return 0;
} 

Measured memory_bytes: 20416
#include<iostream>
#include<cstdio>
#include<ios>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<string>
#include<list>
#include<utility>
#include<tuple>
#include<map>
#include<unordered_map>
#include<complex>
using namespace std;
typedef long long llong;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通


int main() {

	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;

	return 0;
}

Measured memory_bytes: 256
#coding:utf-8

input_line1 = raw_input()
flag = 0

for i in range(0,len(input_line1)):
	for j in range(i+1,len(input_line1)):
		if input_line1[i] == input_line1[j]:
			flag = 1

if flag == 1:
	print 'no'
else:
	print 'yes'

Measured memory_bytes: 2568
let l = read_line ();;
let n = String.length l;;

(* dp[n][3][2] *)

let md = 1000000007
let ( +++ ) x y = let z = x + y in if z < md then z else z - md;;

let eq = 0;;
let lt = 1;;
let gt = 2;;

let dp = Array.make ((n+1)*3*2) 0;;
let index (i, j, k) = i*3*2 + j*2 + k;;
let get k = dp.(index k);;
let add k v = dp.(index k) <- dp.(index k) +++ v;;
add (n, eq, 0) 1;;

for i = n-1 downto 0 do 
  for j = 0 to 2 do
    for k = 0 to 1 do
      for x = 0 to 1 do
        for y = 0 to 1 do
          let c = (x + y + k) / 2 in
          let s = (x + y + k) mod 2 in
          let nj = match compare s (Char.code l.[i] - Char.code '0') with
            | -1 -> lt
            | 1 -> gt
            | _ -> j in
          if s = (x + y) mod 2 then
            add (i, nj, c) (get (i+1, j, k))
        done
      done
    done
  done
done;;

let ans = get (0, lt, 0) +++ get (0, eq, 0);;
Printf.printf "%d\n" ans;;


Measured memory_bytes: 11136
import java.util.Scanner;
//int[] date=new int[2];
public class Main {
int i,o,sum,h,s,e,u,ty,yu,ui,n,num,qw;
double m,t,r,j,k,f,d,g,w;
static double l;
String b,c,z,x,v,a,q;
Scanner scan =new Scanner(System.in);
//入力
	public void input() {	
	
	}
	//演算
	public void compute() {
	
		}
//出力
public void output() {
h=scan.nextInt();
if(h/100!=7) {
	o=h/10;
	if(o%10!=7) {
		if(h%10!=7) {
			System.out.println("No");
		}else {
	System.out.println("Yes");
}
	}else {
	System.out.println("Yes");
}
}else {
	System.out.println("Yes");
}
}
	public static void main(String [ ] args) {
		 Main p = new  Main ();
		p.input();
		p.compute();
		p.output();
		}
	}

Measured memory_bytes: 35780
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 301

ld dp[N][N][N];

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

    int n;
    cin>>n;
    int a[n];
    int freq[4]={0};
    ifr(i,0,n) cin>>a[i],freq[a[i]]++;
    ifr(i,0,n+1) ifr(j,0,n+1) ifr(k,0,n+1) dp[i][j][k]=0;
    dp[freq[1]][freq[2]][freq[3]]=1;
    for(ll k=n;k>=0;k--) {
        for(ll j=n;j>=0;j--) {
            for(ll i=n;i>=0;i--) {
                if(i-1>=0)
                    dp[i-1][j][k]+=(dp[i][j][k]*((i*1.0)/(i+j+k)));
                if(i<n && j-1>=0)
                    dp[i+1][j-1][k]+=(dp[i][j][k]*((j*1.0)/(i+j+k)));
                if(j<n && k-1>=0)
                    dp[i][j+1][k-1]+=(dp[i][j][k]*((k*1.0)/(i+j+k)));
            }
        }
    }
    ld ans=0;
    for(ll k=n;k>=0;k--) {
        for(ll j=n;j>=0;j--) {
            for(ll i=n;i>=0;i--) {
                if((i+j+k)==0 || (i+j+k)>n) continue;
                ans+=dp[i][j][k]*((n*1.0)/(i+j+k));
                // cout<<i<<" "<<j<<" "<<k<<" "<<((n*1.0)/(i+j+k))<<endl;
            }
        }
    }
    cout<<setprecision(14)<<fixed;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 426368
#include <iostream>

int main()
{
	int64_t N;
	std::cin >> N;

	int64_t*  A = (int64_t*)malloc(sizeof(int64_t) * N);
	std::cin >> A[0];
	int64_t Max = A[0];

	int64_t BaseSum = 0;
	for (int i = 1; i < N; i++)
	{
		std::cin >> A[i];
		if (A[i] >= Max)
		{
			Max = A[i];
		}
		else 
		{
			BaseSum += Max - A[i];
		}
	}

	std::cout << BaseSum << std::endl;

	return 0;
}

Measured memory_bytes: 5156
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define queint queue<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>//大きい順
#define pqg priority_queue<int,vec,greater<int>>//小さい順
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
char charin() {char c; cin>>c; return c;}
string strin() {string s; cin>>s; return s;}
int main(){
    string s=strin(),t=strin();
    int cnt=0;
    rep(i,3)if(s[i]==t[i])cnt++;
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
typedef long long int ll;
using namespace std;
int main(){
	int n;
	ll a,b,maxa,maxb;
	cin >> n >> maxa >> maxb;
	for(int i=1;i<n;i++){
		cin >> a >> b;
		if(a > maxa){
			maxa = a;
			maxb = b;
		}
	}
	cout << maxa + llabs(maxb) << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
import javax.sound.midi.SysexMessage;
  
public class Main{      
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = 1;
        for(;i<1000;i++){
            String str = sc.nextLine();
            if(str!=null){
                String[] str2 = str.split(" ");
                int m = Integer.parseInt(str2[0]);           
                int f = Integer.parseInt(str2[1]);
                int r = Integer.parseInt(str2[2]);

                if(m == -1 && f == -1)
                {
                    break;
                }
                else if(m ==-1 || f == -1)
                {
                    System.out.println("F");
                }
                else if(m+f>=80)
                {
                    System.out.println("A");
                }
                else if(m+f>=65)
                {
                    System.out.println("B");
                }
                else if(m+f>=50)
                {
                    System.out.println("C");
                }
                else if(m+f>=30)
                {
                    if (r>=50) {
                        System.out.println("C");
                    }
                    else
                    {
                        System.out.println("D");
                    }
                }
                else
                {
                    System.out.println("F");
                }
            }
        }  
    }
}              

    


Measured memory_bytes: 26184
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, m, p[100008];

//union-find tree
#define MAX_N 100008
ll par[MAX_N];
ll depth[MAX_N];

void init(ll n){
	for(ll i = 1; i <= n; i++){
		par[i] = i;
		depth[i] = 0;
	}
}

ll find(ll x){
	if(x == par[x]){
		return x;
	}else{
		return par[x] = find(par[x]);
	}
}

void unite(ll x, ll y){
	x = find(x);
	y = find(y);
	if(x == y){return;}
	
	if(depth[x] < depth[y]){
		par[x] = y;
	}else{
		par[y] = x;
		if(depth[x] == depth[y]) depth[x]++;
	}
}

bool same(ll x, ll y){
	return find(x) == find(y);
}
//
int main(){
	cin >> n >> m;
	for(ll i = 1; i <= n; i++){cin >> p[i];}
	
	init(n);
	int xbuf, ybuf;
	for(ll j = 1; j <= m; j++){
		cin >> xbuf >> ybuf;
		unite(xbuf, ybuf);
	}
	
	ll ans = 0;
	for(ll i = 1; i <= n; i++){
		if(same(i, p[i])){ans++;}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

long long lcm(long long a, long long b){ return (a/__gcd(a, b)*b); }

int main(){
    Init();
    ll n; cin >> n;
    ll ans = 1;
    rep(i, n){
        ll in; cin >> in;
        ans = lcm(ans, in);
    }
    cout << ans << endl;
}

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

string island[12];
bool c[12][12];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int cnt;

void dfs(int px , int py){
	c[px][py]=true;
	for(int i=0;i<4;++i){
		int tx=px+dx[i];
		int ty=py+dy[i];
		if(tx>=12||ty>=12||tx<0||ty<0) continue;
		if(island[ty][tx]=='0') continue;
		if(c[tx][ty]==true) continue;
		dfs(tx,ty);
	}
} 

int main(){
	while(cin >> island[0]){
		for(int i=1;i<12;++i){
			cin >> island[i];
		}
		for(int j=0;j<12;++j){
			for(int i=0;i<12;++i){
				c[i][j]=false;
			}
		}
		cnt=0;
		for(int j=0;j<12;++j){
			for(int i=0;i<12;++i){
				if(island[j][i]=='1' && c[i][j]==false){
					dfs(i,j);
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

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

using namespace std;

#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

typedef long long ll;
typedef long double ld;

void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	int t = 1;
	// cin >> t;
	while (t--) { 
		solve();
	}
	return 0;
}
string s;
int n;
const int N = 5e5 + 55;
int f[26][N] = {{0}};
void add (int which, int x, int v) {
	while (x < N) {
		f[which][x] += v;
		x += x & -x;
	}
}
int get (int which, int x) {
	int ans = 0;
	while (x > 0) {
		ans += f[which][x];
		x -= x & -x;
	}
	return ans;
}
void solve() {
	cin >> n;
	cin >> s;
	s = '$'+s;
	for (int i = 1; i <= n; ++i) {
		add(s[i] - 'a', i, 1);
	}
	int q;
	cin >> q;
	while (q--) {
		int qt;
		cin >> qt;
		if (qt == 1) {
			int i;
			char c;
			cin >> i >> c;
			add(s[i] - 'a', i, -1);
			s[i] = c;
			add(s[i] - 'a', i, 1);
		}
		else {
			int l, r;
			cin >> l >> r;
			int ans = 0;
			for (int i = 0; i < 26; ++i) {
				if (get(i, r) - get(i, l-1) > 0)
					++ans;
			}
			cout << ans << '\n';
		}
	}
}	
	

Measured memory_bytes: 102448
def main():
    info_num = int(input())
    min_score_index = 0
    min_score = float("inf")
    for _ in range(info_num):
        a, b = map(int, input().split())
        if min_score_index < a:
            min_score_index = a
            min_score = b
    print(min_score + min_score_index)


if __name__ == '__main__':
    main()



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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> higher(N, 0);
    vector<int> H(N);
    for (int i = 0; i < N; ++i) cin >> H[i];

    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        A--; B--;
        if (H[A] > H[B]) higher[B]++;
        else if (H[A] < H[B]) higher[A]++;
        else higher[B]++, higher[A]++;
    }
    int ans = 0;
    for (int i = 0; i < N; ++i) if (higher[i] == 0) ++ans;
    cout << ans << endl;
}

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

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int sort(const void *a ,const void *b){
  return *(int*)a - *(int*)b;
}

int f(int a){
  int count = 0;
  int flag = 0;
  for(int i = 1; i <= pow(a,0.5); ++i){
    if(a % i == 0) count ++;
    if(i*i == a)flag = 1;
  }
  count *= 2;
  if(flag == 1) --count;
  return count;
}


int main(){

  char s[101];
  scanf("%s",s);

  int len = strlen(s);

  for(int i = 0; i < len; ++i){
    printf("x");
  }

  return 0;
}


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<string>> S(H,vector<string>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> S.at(i).at(j);
      if(S.at(i).at(j)=="snuke"){
        char C='A'+j;
        cout << C << i+1 << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}


fn main() {
   input! {
      n: usize,
      a: [usize; n],
   }
   let mut color = vec![0; 8];
   let mut gold = 0;
   for &a in a.iter() {
      if a < 3200 {
         color[a/400] += 1;
      } else {
         gold += 1;
      }
   }
   let mut mn = 0;
   for c in color {
      if c != 0 {
         mn += 1;
      }
   }
   println!("{} {}", std::cmp::max(1, mn), mn + gold);
}


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

int main(){

  int N,K;
  cin >> N >> K;
  string S;
  cin >> S;

  if(S[K-1]=='A') S[K-1]='a';
  if(S[K-1]=='B') S[K-1]='b';
  if(S[K-1]=='C') S[K-1]='c';

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a==7 && b==5 && c==5)
		printf("YES\n");
	else if(a==5 && b==7 && c==5)
		printf("YES\n");
	else if(a==5 && b==5 && c==7)
		printf("YES\n");
    else 
    	printf("NO\n");
    	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n  = int(input())
  Ls = list(map(int, input().strip().split())) + [2*10**3+1]
  Ls.sort()
  def bs(l, r, x):
    while r - l > 1:
      mid = (r+l)//2
      if Ls[mid] >= x:
        r = mid
      if Ls[mid] <  x:
        l = mid
    return r
  
  count = 0
  for i in range(n-2):
    for j in range(i+1, n-1):
      r = bs(j, len(Ls), Ls[i]+Ls[j])
      count += (r - 1  - j)
  print(count)
  
if __name__=='__main__':
  main()



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

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

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());



int main(){
    string S, T;
    cin >> S >> T;

    if (S == T) {
        cout << "Yes" << endl;
        return 0;
    }

    rep(i, S.size()) {
        char a = T[0];
        T.erase(0, 1);
        T += a;
        if (S == T) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
n = gets.to_i
ans = Array.new(2) { 0 }
arr = n.times.map { gets.chomp.split }
arr.each do |v|
  if v[0] == v[1]
    ans[0] += 1
    ans[1] += 1
  elsif v[0] > v[1]
    ans[0] += 3
  else 
    ans[1] += 3
  end
end

puts ans * ' '

Measured memory_bytes: 6116
#include<bits/stdc++.h>
using namespace std;
int n,l;
string st[110];
int main() {
    scanf("%d%d",&n,&l);
    for(int i=1;i<=n;i++)
	cin>>st[i];
	sort(st+1,st+n+1);
	for(int i=1;i<=n;i++)
	cout<<st[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long a = Long.parseLong(sc.next());
		long b = Long.parseLong(sc.next());
		long c = Long.parseLong(sc.next());
		long d = Long.parseLong(sc.next());

		System.out.println(Math.max(Math.max(a * c, a * d),
				Math.max(b * c, b * d)));

	}
}


Measured memory_bytes: 35564
#include<iostream>
#include<algorithm>
 
using namespace std;
typedef long long Int;
#define INF (1LL<<60)

int main(){
	Int N,A,B,ans;
	cin >> N>>A>>B;
	ans = A*N<B?A*N:B;	
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
//Andrew Yang
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <fstream>
#include <string>
#include <string.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>	
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <climits>
using namespace std;
#define FOR(index, start, end) for(int index = start; index < end; index++)
#define RFOR(index, start, end) for(int index = start; index > end; index--)
#define FOREACH(itr, b) for(auto itr = b.begin(); itr != b.end(); itr++)
#define RFOREACH(itr, b) for(auto itr = b.rbegin(); itr != b.rend(); itr++)
#define INF 1000000000
#define M 1000000007
typedef long long ll;
typedef pair<int, int> pii;

int main(void)
{
	int x;
	cin >> x;
	int l = 0;
	int r = x;
	int ans = -1;
	while (l <= r)
	{
		int m = (l + r) / 2;
		if ((ll)(m) * ((ll)m + 1) / 2 >= x)
		{
			ans = m;
			r = m - 1;
		}
		else
		{
			l = m + 1;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int>L(N);
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  sort(L.begin(),L.end());
  int sum=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      int x=L[i]+L[j];
      int r=lower_bound(L.begin(),L.end(),x)-L.begin();
      sum+=(r-1-j);
    }
  }
  cout<<sum<<endl;
  return 0;
}

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

// 定義
typedef long long         ll;
typedef pair<ll, ll>      P;
#define ALL(x)            (x).begin(),(x).end()
#define REP(i, n)         for(ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)     for(ll i = m ; i < (ll)n ; ++i)
#define REVREP(i, n)      for(ll i = n - 1; i >= 0 ; i--)
#define VL                vector<ll>
#define VVL               vector<vector<ll>>
#define VVVL              vector<vector<vector<ll>>>
#define VC                vector<char>
#define VVC               vector<vector<char>>
#define INF               (ll)2e9
#define INF_LL            1LL<<60
//#define MOD             998244353
#define MOD               1000000007

ll Ceil(ll val, ll div)   { return (val + div - 1) / div; }
ll CeilN(ll val, ll div)  { return Ceil(val, div) * div; }
ll FloorN(ll x, ll n)     { return (x - x % n); }
bool IsOdd(ll x)          { return ((x & 1) == 1); }
bool IsEven(ll x)         { return ((x & 1) == 0); }
template<class T> bool chmax(T& a, T b) { if (a <= b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, T b) { if (a >= b) { a = b; return 1; } return 0; }

void Solve()
{
	ll K;
	cin >> K;

	ll divVal = 7 % K;
	ll amariTotal = divVal;
	REP(i, 2000000) {
		if (0 == amariTotal) {
			cout << i + 1 << endl;
			return;
		}
		divVal = (divVal * 10) % K;
		amariTotal += divVal;
		amariTotal %= K;
	}

	cout << -1 << endl;
}

// メイン
int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Solve();
	return 0;
}


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

const int MAX = 1 << 30;

struct Matrix {
  Matrix(int r,int c){
    row = r;
    col = c;
  }
  int row,col;
};

int dp[100][100];

int rec(int left, int right, vector<Matrix>& M)
{
  if(left==right){ return 0; }
  
  if(dp[left][right]<MAX){ return dp[left][right]; }
  
  if(right-left==1){
    dp[left][right] = M[left].row * M[left].col * M[right].col;
    return dp[left][right];
  }
  
  int answer = MAX;
  for(int mid=left;mid<right;mid++){
    //////////////
    //int a = rec(left,mid,M)+rec(mid+1,right,M) + M[mid].row * M[mid].col * M[mid+1].col;
    //cout << "left:" << left << ",mid:" << mid << ",right:" << right << ",answer:" << a << endl;
    //////////////
    answer = min(answer,rec(left,mid,M)+rec(mid+1,right,M) + M[left].row * M[mid].col * M[right].col);
  }
  
  dp[left][right] = answer;
  return dp[left][right];
}


int main(void){
    // Your code here!
    int n;
    cin >> n;
    
    if(n==1){
      cout << 0 << endl;
      return 0;
    }
    
    vector<Matrix> M;
    for(int i=0;i<n;i++){
      int row,col;
      cin >> row >> col;
      M.push_back(Matrix(row,col));
    }
    
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        dp[i][j] = MAX;
      }
    }
    
    rec(0,n-1,M);

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



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

int read(){
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+(c^48);c=getchar();}
	return x*f;
}


int main(){
	int L=read(),R=read();
	if(R/2019>(L-1)/2019)
		puts("0");
	else{
		int Ans=0x7fffffff;
		for(int i=L;i<=R;i++){
			for(int j=i+1;j<=R;j++){
				Ans=min(Ans,(i%2019)*(j%2019)%2019);
			}
		}
		printf("%d",Ans);
	}
}


Measured memory_bytes: 128
import sys

N, M = [int(n) for n in input().split()]

A = []

modulus = 10**9 + 7

for _ in range(M):
    a = int(input())
    if A and A[-1] + 1 == a:
        print(0)
        sys.exit(0)
    A.append(a)

fib_list = [1, 1]

def fib_mod(n):
    l = len(fib_list)
    if n < l:
        return fib_list[n]
    while l <= n:
        fib_list.append((fib_list[-1] + fib_list[-2]) % modulus)
        l += 1
    return fib_list[-1]

total = 1
left = 0

A.append(N+1)

for a in A:
    right = a - 1
    total *= (fib_mod(right - left) % modulus)
    left = right + 2


print(total % modulus)

Measured memory_bytes: 12552
#include <bits/stdc++.h>
#define ll long long
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++)
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); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;
ll dp[100100];
 
int main() {
     int n,a,b;
     cin >> n >> a>>b;
     cout << min (a*n,b) <<endl;
}

Measured memory_bytes: 256