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

// x番の組織が親組織に提出する枚数を返す
// childrenは組織の関係を表す2次元配列(参照渡し)
bool is_isolated(vector<vector<char>> &map, int x, int y) {
  int H= map.size();
  int W= map.at(0).size();
  
  bool ans= true;
  if( x>0 && map.at(x-1).at(y)=='#' ){
  	return false;
  }
  if( x<H-1 && map.at(x+1).at(y)=='#' ){
  	return false;
  }
  if( y>0 && map.at(x).at(y-1)=='#' ){
  	return false;
  }
  if( y<W-1 && map.at(x).at(y+1)=='#' ){
  	return false;
  }
  
  return ans;
}

int main() {
  int H,W;
  cin >> H >> W;

  vector<vector<char>> Map(H, vector<char>(W)); 
  for (int i=0; i<H; i++) {
    for(int j=0; j<W; j++){
      cin >> Map.at(i).at(j);
    }
  }

  bool ans= true;
  for (int i=0; i<H; i++) {
    for(int j=0; j<W; j++){
      if( Map.at(i).at(j)=='#' && is_isolated(Map,i,j) ){
      	ans= false;
        break;
      }
    }
    if(!ans) break;
  }
  
  if(ans){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
}

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

int main(){
    vector<int>vec1={1,3,5,7,8,10,12};
    vector<int>vec2={4,6,9,11};
    vector<int>vec3={3};
    vector<int>hit(3,0);
    int x,y;
    cin>>x>>y;
    for(k:vec1){
        if(k==x){
            hit.at(0)++;
            break;
        }
    }
    for(k:vec1){
        if(k==y){
            hit.at(0)++;
            break;
        }
    }
    for(k:vec2){
        if(k==x){
            hit.at(1)++;
            break;
        }
    }
    for(k:vec2){
        if(k==y){
            hit.at(1)++;
            break;
        }
    }
    if(vec3.at(0)==x&&vec3.at(0)==y)hit.at(2)=2;
    for(k:hit){
        if(k==2){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
    int h, n;
    cin >> h >> n;
    int sum=0;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        sum+=x;
    }
    if(sum>=h){
        cout<<"Yes"<<endl;

    }else if(sum<h){
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long a,b,k;
	cin>>a>>b>>k;
	if(a>=k){
		cout<<a-k<<' '<<b;
		return 0;
	}
	else if(k>a+b){
		cout<<0<<' '<<0;
		return 0;
	}
	else cout<<0<<' '<<b-(k-a);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
     
    int main() {
      char a, b;
      scanf("%c %c", &a, &b);
     
      if(a == 'H') {
        if(b == 'H') {
          printf("H\n");
        } else {
          printf("D\n");
        }
      } else {
        if(b == 'H') {
          printf("D\n");
        } else {
          printf("H\n");
        }
      }
      return 0;
    }

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}


//cout << setprecision(123)<<ans;
//a=atoi(S.c_str());
//S=to_string(a);
int main(){
  string s;
  cin>>s;
if(s=="SUN")cout<<7;
if(s=="MON")cout<<6;
if(s=="TUE")cout<<5;
  if(s=="WED")cout<<4;
  if(s=="THU")cout<<3;
  if(s=="FRI")cout<<2;
  if(s=="SAT")cout<<1;
}

Measured memory_bytes: 256
import sys
import numpy as np

X = int(input())


if 399 < X and X < 600:
    print(8)
elif X < 800:
    print(7)
elif X < 1000:
    print(6)
elif X < 1200:
    print(5)
elif X < 1400:
    print(4)
elif X < 1600:
    print(3)
elif X < 1800:
    print(2)
elif X < 2000:
    print(1)

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

int main(){
    // あとで消す
    //std::ifstream in("ain3.txt");
    //std::cin.rdbuf(in.rdbuf());

    string N,M;
    cin >> N >> M;

    string judge = (N==M) ? "Yes" : "No" ;

    cout << judge << endl;

    return 0;
}


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

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>
#include <queue>
#include <stack>

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair

const double INF = 1e+09;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,  n) {
    cin >> a[i];
    a[i]--;}
  int max_val = 0;
  REP(i, n) max_val = max(max_val, a[i]);
  vector<ll> vec(n);
  REP(i, n){
    vec[a[i]]++;
  }
  ll ans = 0;
  REP(i, n){
    ans += vec[i] * (vec[i]-1)/2;
  }

  REP(i, n){
    ll res = ans;
    ll val = vec[a[i]];
    if (val >= 2){
    res -= val * (val - 1)/2 ;
    res += (val-1) * (val-2)/2;
    cout << res << endl;
  }
    else {res = ans - val * (val-1)/2;
    cout << res << endl;}}
  return 0;
}



Measured memory_bytes: 4992
s = gets.chomp.split('')

count = 1
i = 1
while i < s.length
    if s[i] == s[i - 1] then
        i += 1
        if i < s.length then
            i += 1
            count += 1
            if i < s.length then
                i += 1
                count += 1
            end
        end
    else
        i += 1
        count += 1
    end
end

puts count


Measured memory_bytes: 12796
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 300003
#define MOD 998244353

int main(){
  int N,K;
  cin>>N>>K;
  vector<ll> a(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }

  vector<ll> sum(N+1,0);
  for(int i=0;i<N;i++){
    sum.at(i+1)=sum.at(i)+a.at(i);
  }

  vector<vector<int>> beau(N*(N+1)/2,vector<int>(42));
  int index=0;
  for(int i=0;i<N;i++){
    for(int j=i;j<N;j++){
      ll A=sum.at(j+1)-sum.at(i);
      for(int k=0;k<42;k++){
        beau[index][k]+=A%2;
        A/=2;
      }
      index++;
    }
  }

  N=N*(N+1)/2;
  ll ans=0;
  ll res=1ull<<42;
  vector<bool> to_be_seen(N,true);
  for(int j=41;j>=0;j--){
    res>>=1;
    int count=0;
    for(int i=0;i<N;i++){
      if(to_be_seen.at(i)){
        count+=beau.at(i).at(j);
      }
    }
    if(count<K){
      continue;
    }
    ans+=res;
    for(int i=0;i<N;i++){
      if(beau.at(i).at(j)==0){
        to_be_seen.at(i)=false;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 98048
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define p (int)(1e9 + 7)

int MOD(int a){
	return (a %= p) >= 0 ? a : a + p;
}

int power(int a, int N){
	if(N == 0) return 1;
	else if(N % 2 == 0) return power(MOD(a * a), N / 2);
	else return MOD(a * power(a, N - 1));
}

int inverse(int a){
	return power(a, p - 2);
}

int fact(int N){
	static vector<int> _fact(1, 1);
	for(int i = _fact.size(); i <= N; i++){
		_fact.push_back(MOD(i * _fact[i - 1]));
	}
	return _fact[N];
}
 
int fact_inv(int N){
	static vector<int> inv(2, 1), _fact_inv(2, 1);
	for(int i = inv.size(); i <= N; i++){
		inv.push_back(MOD(-(p / i) * inv[p % i]));
		_fact_inv.push_back(MOD(inv[i] * _fact_inv[i - 1]));
	}
	return _fact_inv[N];
}
 
int combination(int N, int k){
	if(k < 0 || N < k || N < 0) return 0;
	else return MOD(fact(N) * MOD(fact_inv(N - k) * fact_inv(k)));
}

int gcd(int a, int b){
	if(b == 0){
		return a;
	}
	else{
		return gcd(b, a % b);
	}
}

int yakusuu(int x){
	int i, ans = 0;
	for(i = 1; i * i <= x; i++){
		if(i * i == x){
			ans++;
		}
		else if(x % i == 0){
			ans += 2;
		}
	}
	return ans;
}

int solve(int H, int W){
//	printf("solve(%lld, %lld)\n", H, W);
	int ans = 1;
	ans = MOD(ans + power(2, H) - 1);
	ans = MOD(ans + power(2, W) - 1);
//	printf("ans0 = %lld\n", ans);
	ans = MOD(ans + power(2, gcd(H, W)) - 2);
//	printf("ans = %lld\n", ans);
	return ans;
}

signed main(){
	int H, W, T;
	scanf("%lld%lld%lld", &H, &W, &T);
	int gh = gcd(H, T);
	int gw = gcd(W, T);
	printf("%lld\n", power(solve(H / gh, W / gw), gh * gw));
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <bits/stdc++.h>
#include <algorithm>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int num_array[n];

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

    for (int i=0; i<n; i++) {
        int temp;
        cin >> temp;
        num_array[temp-1]++;
    }

    sort(num_array, num_array + n);

    int ans = 0;

    for (int i=distance(num_array, upper_bound(num_array, num_array+n, 0)); i<n-k; i++) {
          ans += num_array[i];
    }

    cout<<ans<<endl;
}


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

class Time{
private:
  int h;
  int m;
  int s;
public:
  Time(int hour,int min,int sec){
    h = hour;
    m = min;
    s = sec;
  }
  int get_h(void){
    return h;
  }
  int get_m(void){
    return m;
  }
  int get_s(void){
    return s;
  }
  void set_h(int hour){
    h = hour;
  }
  void set_m(int min){
    m = min;
  }
  void set_s(int sec){
    s = sec;
  }
  void print(){
    cout << h << " " << m << " " << s << endl;
  }
  Time def(Time in){
    int tmp;
    Time stay(0,0,0);

    tmp = in.get_h();
    stay.set_h( this->h - tmp);

    tmp = in.get_m();
    stay.set_m( this->m - tmp);
    tmp = stay.get_m();
    if(tmp<0){
      tmp += 60;
      stay.set_m(tmp);
      tmp = stay.get_h();
      tmp--;
      stay.set_h(tmp);
    }

    tmp = in.get_s();
    stay.set_s( this->s - tmp );
    tmp = stay.get_s();
    if(tmp<0){
      tmp +=60;
      stay.set_s(tmp);
      tmp = stay.get_m();
      tmp--;
      stay.set_m(tmp);
      tmp = stay.get_m();
      if(tmp<0){
	tmp += 60;
	stay.set_m(tmp);
	tmp = stay.get_h();
	tmp--;
	stay.set_h(tmp);
      }
    }
    return stay;
  }
};

int main(){
  int h,m,s;

  for(int i=0;i<3;i++){
    cin >> h >> m >> s;
    Time in(h,m,s);
    cin >> h >> m >> s;
    Time out(h,m,s);

    Time stay = out.def(in);

    stay.print();
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <utility>
#include <functional>
#include <vector>
#include <algorithm>
#include <string>


using namespace std;

typedef pair<double, string> P;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0) {
      break;
    }
    vector<P> v(n);

    for (int i = 0; i < n; i++) {
      string L;
      int p, a, b, c, d, e, f, s, m;
      cin >> L >> p >> a >> b >> c >> d >> e >> f >> s >> m;
      int t = a + b + c + (d + e) * m; 
      double u = (s * f * m - p) / (double)t;
      v[i] = P(u, L);
    }

    sort(v.begin(), v.end(), [](P a, P b) {
      if (a.first > b.first) {
        return true;
      } else if (a.first == b.first) {
        return a.second < b.second;
      } else {
        return false;
      }
    });

    for (int i = 0; i < n; i++) {
      cout << v[i].second << endl;
    }
    cout << "#" << endl;
  }

  return 0;
}

Measured memory_bytes: 3168
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define reps(x,c) for(auto x:c)
#define all(x) begin(x), end(x)
#define pb(a) emplace_back(a) 
#define mp(a,b) make_pair((a),(b))
#define pl pair<ll,ll>
#define INF 2147483600
#define MOD 1000000007
#define fi first
#define se second
#define dbg(x) cout << #x"="<< (x) << endl
#define dbgv(x) cout<<#x<<endl;reps(y,x){cout<<y<<" ";}cout<<endl

int main(){
  ll n,a,b;cin>>n>>a>>b;
  if(n==1){
    cout<<"Hello World"<<endl;
  }else{
    cout<<a+b<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a, b;
	
	for (a = 1; a != 10; a++){
		for (b = 1; b != 10; b++){
			printf("%dx%d=%d\n", a, b, a*b);
		}
	}
	
	return (0);
}

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

char S[3];

int main() {
  cin >> S[0] >> S[1] >> S[2];
  sort(S, S + 3);
  cout << (S[0] == 'a' && S[1] == 'b' && S[2] == 'c' ? "Yes" : "No") << endl;
  return 0;
}


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

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 2005

ll n , k;
ll c[MAXX][MAXX];

int main()
{
    _FastIO;
    cin >> n >> k;
    for(ll i = 0; i < 2002; i++){
        c[i][0] = 1;
        c[i][i] = 1;
    }
    for(ll i = 1; i < 2002; i++){
        for(ll j = 1; j < i; j++){
            c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
            c[i][j] %= 1000000007;
        }
        }
        for(ll i = 1; i <= k; i++){
            ll ans = c[n - k + 1][i];
            ans *= c[k - 1][i - 1];
            ans %= 1000000007;
            cout << ans << endl;
        }
    return 0;
}


Measured memory_bytes: 30208
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	int64_t a[n]; rep(i,n) cin >> a[i];
	int64_t now = a[0], sum = 0;
	for(int i = 1; i < n; ++i) {
		if(now > a[i]) {
			sum += now - a[i];
			a[i] = now;
		}
		now = a[i];
	}
	cout << sum << '\n';
	return 0;
}

Measured memory_bytes: 5196
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 2222;
const double EPS = 1e-8;
const int MOD = 1000 * 1000 * 1000 + 7;


char buf[MAX];
int S[MAX][MAX];
int SS[MAX][MAX];
int U[MAX][MAX];
int L[MAX][MAX];

int main()
{
    int n, m, q;
    scanf("%d%d%d", &n, &m, &q);
    FOR(i, 0, n)
    {
        scanf("%s", buf);
        FOR(j, 0, m)
        S[i][j] = buf[j] == '1';
    }
    
    FOR(i, 0, n)
        FOR(j, 0, m)
    {
        if (!S[i][j])continue;
        if (i && S[i-1][j] == 1)
        {
            U[i][j] = 1;
        }
        if (j && S[i][j-1] == 1)
        {
            L[i][j] = 1;
        }
    }
    
    FOR(i, 0, n)
        FOR(j, 0, m)
    {
        if(i)S[i][j] += S[i-1][j];
        if(j)S[i][j] += S[i][j-1];
        if(i && j)S[i][j] -= S[i-1][j-1];
        
        if(i)U[i][j] += U[i-1][j];
        if(j)U[i][j] += U[i][j-1];
        if(i && j)U[i][j] -= U[i-1][j-1];
        
        if(i)L[i][j] += L[i-1][j];
        if(j)L[i][j] += L[i][j-1];
        if(i && j)L[i][j] -= L[i-1][j-1];
    }
    
    
    FOR(i, 0, q)
    {
        int x, y, xx, yy;
        scanf("%d%d%d%d", &x, &y, &xx, &yy);
        --x, --y, --xx, --yy;
        
        int ans = S[xx][yy];
        if (x)ans -= S[x-1][yy];
        if (y)ans -= S[xx][y-1];
        if (x && y)ans += S[x-1][y-1];
        
       // cout << "!!" << ans << endl;
        
        ans -= U[xx][yy];
        ans += U[x][yy];
        if (y)ans += U[xx][y-1];
        if (y)ans -= U[x][y-1];
        
        //cout << "!!!" << ans << endl;
        
        ans -= L[xx][yy];
        if (x)ans += L[x-1][yy];
        ans += L[xx][y];
        if (x)ans -= L[x-1][y];
        
        
        printf("%d\n", ans);
        
    }
    
    
}


Measured memory_bytes: 57088
t = 0; h = 0
for _ in range(int(input())):
  a, b = map(str, input().split())
  if a == b:
    t += 1
    h += 1
    continue
  l = sorted([a, b])
  if [a, b] == l:
    h += 3
  else:
    t += 3
print("{0} {1}".format(t, h))


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;
    
#define EPS (1e-7)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    if((a+b)%2){
        cout<<"IMPOSSIBLE"<<endl;
    }else{
        cout<<(a+b)/2<<endl;
    }
}

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    ll c[10];
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            std::cin >> c[i*3+j];
        }
    }
    if(c[0]-c[3] == c[1]-c[4] && c[1]-c[4] == c[2] -c[5] && c[0] -c[6] == c[1] - c[7] && c[1] -c[7] == c[2] -c[8] ){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
}

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

#define rep_(i,n) for(int i=n;i >= 0;i--)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	string s;
	int a[10];
	while(cin >> s)
	{
		rep(i,10)
		{
			a[i] = s[i] - '0';
		}

		rep_(i,9)
		{
           rep(j,i)
			{
		        a[j] = (a[j]+a[j+1]) % 10;
            }
        }
        cout<<a[0]<<endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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;}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    int n;cin>>n;
    cout<<0<<endl<<flush;
    string s,t,R,L;
    cin>>s;
    if(s=="Vacant")return 0;
    t=s;
    int l=0,r=n,cnt=1;
    while(cnt<20){
        int m=(l+r)/2;
        cout<<m<<endl<<flush;
        cin>>s;
        if(s=="Vacant")return 0;
        if(m%2==0&&s!=t||m%2==1&&t==s){
            r=m;
        }
        else l=m;
        cnt++;
    }
}


Measured memory_bytes: 852
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, x; cin >> a >> b >> x;
    int flg = 0;
    if (a > x) flg = 1;
    else if (!(x <= a + b)) flg = 1;
    if (flg) cout << "NO" << endl;
    else cout << "YES" << endl;
    
    
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		
		Set<Integer> XSet=new TreeSet<Integer>();
		Set<Integer> YSet=new TreeSet<Integer>();
		YSet.add(0);
		boolean facingX=true;
		String s=sc.next()+"T";
		int temp=0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='F') {
				temp++;
			}
			else {
				if(facingX) {
					Object[] tempArray=XSet.toArray();
					for (Object num: tempArray) {
						XSet.remove(num);
						XSet.add((Integer)num+temp);
						XSet.add((Integer)num-temp);
					}
					if(XSet.isEmpty()) {
						XSet.add(temp);
					}
				}
				else {
					Object[] tempArray= YSet.toArray();
					for (Object num: tempArray) {
						YSet.remove(num);
						YSet.add((Integer)num+temp);
						YSet.add((Integer)num-temp);
					}
				}
				temp=0;
				facingX=!facingX;
			}
		}
		
		int x=sc.nextInt();
		int y=sc.nextInt();
		if(XSet.contains(x) && YSet.contains (y)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
 
}


Measured memory_bytes: 94576
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int a, b;
  scanf("%d %d", &a, &b);
  if (a%2 == 0 || b%2 == 0)
    printf("Even\n");
  else printf("Odd\n");
  return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        long n = fs.nextLong();
        List<Long> factors = new ArrayList<>();
        for(long i=1;i*i<=n;i++){
            if(n%i==0){
                factors.add(n/i);
            }
        }
        long val = factors.get(factors.size()-1);
        int digit = 0;
        while(val > 0){
            val/=10;
            digit++;
        }
        System.out.println(digit);
    }
    static class FastScanner {
            private final InputStream in = System.in;
            private final byte[] buffer = new byte[1024];
            private int ptr = 0;
            private int buflen = 0;
            private boolean hasNextByte() {
                if (ptr < buflen) {
                    return true;
                }else{
                    ptr = 0;
                    try {
                        buflen = in.read(buffer);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                    if (buflen <= 0) {
                        return false;
                    }
                }
                return true;
            }
            private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
            private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
            public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
            public String next() {
                if (!hasNext()) throw new NoSuchElementException();
                StringBuilder sb = new StringBuilder();
                int b = readByte();
                while(isPrintableChar(b)) {
                    sb.appendCodePoint(b);
                    b = readByte();
                }
                return sb.toString();
            }
            public long nextLong() {
                if (!hasNext()) throw new NoSuchElementException();
                long n = 0;
                boolean minus = false;
                int b = readByte();
                if (b == '-') {
                    minus = true;
                    b = readByte();
                }
                if (b < '0' || '9' < b) {
                    throw new NumberFormatException();
                }
                while(true){
                    if ('0' <= b && b <= '9') {
                        n *= 10;
                        n += b - '0';
                    }else if(b == -1 || !isPrintableChar(b)){
                        return minus ? -n : n;
                    }else{
                        throw new NumberFormatException();
                    }
                    b = readByte();
                }
            }
            public int nextInt() {
                long nl = nextLong();
                if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
                return (int) nl;
            }
            public double nextDouble() { return Double.parseDouble(next());}
        }
}


Measured memory_bytes: 21460
# map(int, input().split())
# list(map(int, input().split()))
# for _ in range(int(input())):
# print(' '.join([str(x) for x in ans]))

s = input()

numBC = 0
total = 0
i = len(s)-1
while i >= 0:    
    if s[i] == 'A':
        total += numBC
    elif s[i] == 'C' and i > 0 and s[i-1] == 'B':
            numBC += 1
            i -= 1
    else:
        numBC = 0
    i-=1

print(total)



Measured memory_bytes: 40304
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
	int n ,m, lin, rin, l, r;
	cin >> n >> m;
	l = 1;
	r = n;
	while(cin >> lin >> rin){
		if(lin > l)
			l = lin;
		if(rin < r)
			r = rin;
	}
	if(r-l >= 0)
		cout << r-l+1 << endl;
	else
		cout << 0 << endl;
	return 0;
}

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


int main()
{
	int N = 0, ans = 0;
	cin >> N;

	for (int i = 0; i < N; i++) {
		int l, r;
		cin >> r >> l;

		if (r < l) {
			ans = ans + (l - r) + 1;
		}

		else if (r == l) {
			ans++;
		}
	}

	cout << ans << endl;
    
}

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

int main(void) {
	string S;
	cin >> S;
	if (S[0] == 'A') {
		if (S[1]>='a' && S[1] <='z') {
			int cntC = 0;
			int cntl = 0;
			for (int i=2; i<S.size()-1; i++) {
				if (S[i]=='C') cntC++;
				if (S[i]>='a' && S[i] <='z') cntl++;
			}
			if (cntC==1 && cntl==S.size()-4 && (S[S.size()-1]>='a')&&(S[S.size()-1]<='z')) {cout << "AC" << endl; return 0;}
		}
	}
	cout << "WA" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int i,n;
    int emax1,emax2,omax1,omax2;
    int ep1,ep2,op1,op2;
    int num[100100],evennum[114514],oddnum[114514];
    scanf("%d",&n);
    emax1=emax2=omax1=omax2=0;
    for(i=0;i<114514;i++)
    {
        evennum[i]=oddnum[i]=0;    
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&num[i]);
        if(i%2)
        {
            evennum[num[i]]++;
            if(evennum[num[i]]>emax1)
            {
                emax1=evennum[num[i]];
                ep1=num[i];
            }
            else if(evennum[num[i]]>emax2)
            {
                emax2=evennum[num[i]];
                ep2=num[i];
            }
        }
        else
        {
            oddnum[num[i]]++;
            if(oddnum[num[i]]>omax1)
            {
                omax1=oddnum[num[i]];
                op1=num[i];
            }
            else if(oddnum[num[i]]>omax2)
            {
                omax2=oddnum[num[i]];
                op2=num[i];
            }
        }
    }
    if(ep1!=op1)
    {
        printf("%d\n",n-emax1-omax1);
    }
    else if(emax1+omax2>emax2+omax1)
    {
        printf("%d\n",n-emax1-omax2);
    }
    else
    {
        printf("%d\n",n-emax2-omax1);    
    }
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
int main()
{
    int i,j,h,w;
    char s[100][100];
    int sum;
    scanf("%d%d",&h,&w);
        for(i=0;i<h;i++)
            scanf("%s",s[i]);
        for(i=0;i<h;i++)
            for(j=0;j<w;j++)
            {
                sum=0;
                if(s[i][j]!='.')
                    continue;
                if(s[i-1][j-1]=='#')
                    sum+=1;
                if(s[i-1][j]=='#')
                    sum+=1;
                if(s[i-1][j+1]=='#')
                    sum+=1;
                if(s[i][j-1]=='#')
                    sum+=1;
                if(s[i][j+1]=='#')
                    sum+=1;
                if(s[i+1][j-1]=='#')
                    sum+=1;
                if(s[i+1][j]=='#')
                    sum+=1;
                if(s[i+1][j+1]=='#')
                    sum+=1;
                s[i][j]=sum+'0';
            }
        for(i=0;i<h;i++)
            printf("%s\n",s[i]);

    return 0;
}


Measured memory_bytes: 128
a,b = gets.split.map &:to_i

def tax8(x)
	(x * 0.08).floor
end

def tax10(x)
	(x * 0.1).floor
end

x_a1 = (a / 0.085).floor
x_a2 = (a / 0.075).ceil

(x_a1 .. x_a2).each{ |y|
	if tax8(y) == a && tax10(y) == b then
		puts y
		exit
	end
}

puts -1

Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
      cout << 0;
    }else{
      cout << a-b;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int diff = b - a;
        int sum = 0;

        for(int i = 1 ; i < diff ; i++){
            sum += i;
        }
         
        System.out.println(sum - a);
    }
}

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

#define MAX_N 1003
#define MAX_NW 10000007

struct box{
    int w ,s ,v;
    bool operator<(const box&rhs) const{
        return s+w < rhs.s+rhs.w;
    }
};

int n;
box bs[MAX_N];
long long dp[MAX_NW];

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d%d%d",&bs[i].w,&bs[i].s,&bs[i].v);
    sort(bs ,bs+n);

    memset(dp ,-1 ,sizeof dp);
    dp[0] = 0;
    for(int i=0; i<n; i++)
    for(int j=bs[i].s; ~j; j--)
        if(~dp[j])
            dp[j+bs[i].w] = max(dp[j+bs[i].w] ,dp[j]+bs[i].v);

    printf("%lld\n",*max_element(dp ,dp+MAX_NW));
}


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

signed main()
{
  int n; cin >> n;
  ll num = 1,a;

  for(int i = 0; i < n; i++) {
    cin >> a;

    if(a > 0 && 1000000000000000000 / num >= a) {
      num *= a;
    }

    else if (a==0) {
      num = 0;
      break;
    }

    else{
      num = -1;
    }

  }

  cout << num;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

#define VMAX 100001

int main()
{
  int N, W;
  int v[110], w[110];
  int res=0;
  cin >> N >> W;

  rep(i,N) cin >> w[i] >> v[i];

  long int dp[110][VMAX];
  memset(dp, INF, sizeof(dp));
  rep(i,N+1) dp[i][0] = 0;

  FOR(i, 0, N-1) {
    FOR(j, 1, VMAX) {
      if(j-v[i]<0) dp[i+1][j] = dp[i][j];
      else dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
    }
  }

  rep(j, VMAX) {
    if(dp[N][j] <= W) {
      res = max(res, j);
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 86144
from collections import deque
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def solve():
  h,w,d  = (int(i) for i in input().split())
  a = [list(map(int, input().split())) for _ in range(h)]

  query = [False]*(h*w)
  distance = [0]*(h*w+1)
  for i in range(h):
    for j in range(w):
      query[a[i][j] - 1] = (i,j)
  q = int(input())
  
  for i in range(d,h*w):
    leftx,lefty = query[i-d]
    rightx,righty = query[i]
    distance[i] = distance[i-d]+abs(rightx-leftx)+abs(righty-lefty)
  #print(distance)
  ans = deque([])
  for i in range(q):
    l,r = (int(m) for m in input().split())
    ans.append(distance[r-1]-distance[l-1])
  print("\n".join(map(str,ans)))
solve()

Measured memory_bytes: 29580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p.at(i);
    }
    int mini = 200001;
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (min(p.at(i), mini) == p.at(i)) {
            count++;
            mini = p.at(i);
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
q main(){
    q i,b,c;
    s ss;
    cin>>ss;
    if(ss=="a"||ss=="o"||ss=="i"||ss=="u"||ss=="e")cout<<"vowel";
    else cout<<"consonant";




return 0;}


Measured memory_bytes: 256
n, w = map(int, input().split())
weight = []
value = []
for _ in range(n):
    wi, vi = map(int, input().split())
    weight.append(wi)
    value.append(vi)
weight.append(0)
value.append(0)
dp = [[float('inf')] * (10 ** 5 + 1) for i in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    for j in range(10 ** 5 + 1):
        if j - value[i] >= 0:
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - value[i]] + weight[i])
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
for j in range(10 ** 5, -1, -1):
    if dp[n][j] <= w:
        print(j)
        break

Measured memory_bytes: 312632
#include<iostream>
#include<vector>

using namespace std;

bool linearsearch(vector<int>vec,int num){
    for(auto a : vec){
        if(a == num) return true;
    }
    return false;
}

int main(){
    int n,q;
    cin >> n;
    vector<int> S(n);
    for(int i=0;i < n;i++){
        cin >> S.at(i);
    }
    cin >> q;
    vector<int> T(q);
    for(int i=0;i < q;i++){
        cin >> T.at(i);
    }
    
    int ans = 0;
    
    for(auto t : T){
        if(linearsearch(S,t)) ans++;
    }
    
    cout << ans << endl;
    return 0;
}


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

int main() {
  long long A,B,K,a,b;
  cin>>A>>B>>K;
  if(K>A+B){a=0;b=0;}
  if(K>A && K<=A+B){
    a=0;
    b=A+B-K;
  }
  if(K<=A){
    a=A-K;
    b=B;
  }
  cout<<a<<" "<<b<<endl;
}

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

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

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


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

signed main(void) {
	int K, X;
	cin >> K >> X;
	int min = X - K + 1;
	int max = X + K - 1;
	int edge = 1000000;
	if (max > edge) max = edge;
	if (min < -1 * edge)min = -1 * edge;
	rep(i, max - min + 1) {
		print(min + i);
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys

WHITE, GRAY, BLACK = 0, 1, 2


def prim_span_tree():
    min_weight_vertices[0] = 0

    while True:
        min_cost = 2001
        current_vertex = -1
        for i in range(vertices_num):
            if color[i] != BLACK and min_weight_vertices[i] < min_cost:
                min_cost = min_weight_vertices[i]
                current_vertex = i

        if min_cost == 2001:
            break

        color[current_vertex] = BLACK

        for j in range(vertices_num):
            v_weight = int(init_vertices_matrix[current_vertex][j])
            if color[j] != BLACK and v_weight >= 0:
                if v_weight < min_weight_vertices[j]:
                    min_weight_vertices[j] = v_weight
                    parent_list[j] = current_vertex
                    color[j] = GRAY

    return min_weight_vertices


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    init_vertices_matrix = list(map(lambda x: x.split(), _input[1:]))

    parent_list, min_weight_vertices = [-1] * vertices_num, [2001] * vertices_num
    color = [WHITE] * vertices_num
    ans = prim_span_tree()
    print(sum(ans))

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

int main() {
    const int S_MAX=100;
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    char turn = 'a';
    for (int i=0; i<S_MAX*3; i++) {
        switch (turn) {
            case 'a':
                if (sa.empty()) {
                    cout << "A\n";
                    return 0;
                }
                turn = sa.at(0);
                sa.erase(sa.begin());
                break;
            case 'b':
                if (sb.empty()) {
                    cout << "B\n";
                    return 0;
                }
                turn = sb.at(0);
                sb.erase(sb.begin());
                break;
            case 'c':
                if (sc.empty()) {
                    cout << "C\n";
                    return 0;
                }
                turn = sc.at(0);
                sc.erase(sc.begin());
                break;
        }
    }
}

Measured memory_bytes: 256
n, m, k = map(int, input().split())
MOD = (10**9) + 7


S = 0

def stick(n):
    return n * (n+1) // 2

def calc(w, h):
    L = w * (w-1) // 2
    R = L + w * (h-1)
    return (L + R) * h // 2

for i in range(n):
    for j in range(m):
        S += calc(i+1, j+1)
        S += calc(i+1, m-j)
        S += calc(n-i, j+1)
        S += calc(n-i, m-j)
        S -= stick(i)
        S -= stick(j)
        S -= stick(n-i-1)
        S -= stick(m-j-1)
        S %= MOD
        
if S % 2 == 0:S //= 2
else: S = (S + MOD) // 2
S %= MOD
if S < 0:S += MOD

def fact(x):
    res = 1
    for i in range(1, x+1):
        res = res * i % MOD
    return res


def rev(x):
    return pow(x, MOD-2, MOD)

def nCk(n, k):
    return fact(n) * rev(fact(k)) % MOD * rev(fact(n-k)) % MOD

print(S * nCk(n*m-2, k-2) % MOD)

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
a.sort()
count = 0
for i in range (0,len(a)-1):
    if (a[i] == a[i+1]):
        count += 1
if (count % 2 == 1):
    print(len(a)-count-1)
else:
    print(len(a)-count)

Measured memory_bytes: 14388
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
int main(){
    int n;
    cin >> n;
    int left=0,right=0;
    rep(i,n){
        string s,t;
        cin >> s >> t;
        if(s == t){left++; right++;}
        else if(s > t) left += 3;
        else right += 3;
    }
    cout << left << ' ' << right << endl;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define maxn 20
using namespace std;
int n,m,dis[maxn][maxn],sum;
int dp[1<<maxn][maxn],s[1<<maxn];
int main() {
	scanf("%d %d",&n,&m);
	memset(dis,0,sizeof(dis));
	sum=0;
	for (int i=1;i<=m;i++) {
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		a--; b--;
		dis[a][b]=c;
		dis[b][a]=c;
		sum+=c;
	}
	for (int i=0;i<(1<<n);i++) {
		for (int j=0;j<n;j++)
			for (int k=j+1;k<n;k++)
				if ((i>>j)%2==1&&(i>>k)%2==1)
					s[i]+=dis[j][k];
	}
	memset(dp,-1,sizeof(dp));
	dp[1][0]=0;
	for (int i=0;i<(1<<n);i++) {
		for (int j=0;j<n;j++) {
			if (dp[i][j]==-1)
				continue;
			for (int t=0;t<n;t++) {
				if ((i>>t)%2==1||dis[j][t]==0)
					continue;
				dp[i|(1<<t)][t]=max(dp[i|(1<<t)][t],dp[i][j]+dis[j][t]);
			}
			int x=(1<<n)-1-i;
			for (int y=x;y>=1;y=(y-1)&x)
				dp[i|y][j]=max(dp[i|y][j],dp[i][j]+s[y|(1<<j)]);
		}
	}
	printf("%d\n",sum-dp[(1<<n)-1][n-1]);
	return 0;
}

Measured memory_bytes: 82304
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

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

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int a,b,c;
	cin >> a >> b >> c;
	OUT(std::min({a + b, b + c,c + a})) BR;
	RET;
}


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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int A, B;
  cin >> A >> B;
  bool ans = A <= 8 && B <= 8;
  cout << (ans?"Yay!":":(") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#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 srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int dist[(1 << 16)];
int s[4][4];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi h(n), w(n);
    rep(i,n){
        cin >> h[i] >> w[i];
    }
    rep(i,4){
        string hoge;
        cin >> hoge;
        rep(j,4){
            if(hoge[j] == 'R'){
                s[i][j] = 0;
            }else if(hoge[j] == 'G'){
                s[i][j] = 1;
            }else{
                s[i][j] = 2;
            }
        }
    }
    rep(i,(1 << 16)){
        dist[i] = INF;
    }
    dist[0] = 0;
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int p = que.front();
        que.pop();
        rep(i,3){
            rep(j,n){
                srep(k,-h[j]+1,4){
                    srep(l,-w[j]+1,4){
                        int nx = p;
                        srep(t,max(k,0),min(k+h[j],4)){
                            srep(u,max(l,0),min(l+w[j],4)){
                                if((p >> (4*t+u))&1){
                                    if(s[t][u] != i) nx -= (1 << (4*t+u));
                                }else{
                                    if(s[t][u] == i) nx += (1 << (4*t+u));
                                }
                            }
                        }
                        if(dist[nx] > dist[p] + 1){
                            dist[nx] = dist[p] + 1;
                            que.push(nx);
                        }
                    }
                }
            }
        }
    }
    cout << dist[(1 << 16)-1] << "\n";
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;



int main(){
    AC
    ll x;
    cin>>x;
    for(ll i=-1000; i<=1000; i++){
        for(ll j=-1000; j<=1000; j++){
            if(pow(i,5)-pow(j,5)==x){
                cout<<i<<" "<<j<<endl;
                return 0;
            }
        }
    }

}

Measured memory_bytes: 4104
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define INF 1e10
    const double pi=3.14159265358979323;
    const int mod=998244353;
    const int MAX=1e7+5;
    int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    int  binpow(int  a,int  b) 
    {
    int res = 1;
    while (b > 0) {
        if (b%2 == 1)
            res = (res * a)%mod;
        a = (a* a)% mod;
        b >>= 1;
    }
    return res;
}
    int modinv(int y)
    {
        return binpow(y,mod-2);
    }
 
    int fact[500000+5];
    void precal()
    {
    fact[0]=1;
    for(int i=1;i<500000+5;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
    }
}   
    bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
   
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
    int ans[MAX]={0};
;    signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
     if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout); 
      }
    #endif  
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1; 
    //cin>>t;
    while(t--)
    {
        int n;
       cin>>n;
       f(i,1,n+1)
       {
            for(int j=1;j*i<=n;j++)
            {
                ans[i*j]++;
            }
       }
       int tot=0;
       f(i,1,n+1)
       {
        tot+=(ans[i]*i);
       }
       cout<<tot<<endl;
    }
}

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

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

  int n, d, x;
  cin >> n >> d >> x;
  int tot = x;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    tot += (d - 1) / a + 1;
  }
  cout << tot << '\n';
  return 0;
}

Measured memory_bytes: 256