akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> P(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &P[i]);
  }
  priority_queue<int, vector<int>, greater<int>> q;
  int cnt = 0;
  for (int i = 0; i < N; ++i)
  {
    q.push(P[i]);
    if (q.top() == P[i])
      cnt++;
  }
  cout << cnt << endl;

  return 0;
}


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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  int n = sz(s);
  vector <vector <int>> dp(n, vector <int> (13, -1));

  const int MOD = 1e9 + 7;

  function <int(int,int)> rec = [&] (int pos, int sum) {
    if (pos == n) return int(sum == 5);
    int& ret = dp[pos][sum];
    if (ret != -1) return ret;
    ret = 0;
    if (s[pos] != '?') ret = rec(pos + 1, (sum * 10 + s[pos] - '0') % 13);
    else for (int d = 0; d <= 9; d++) ret = (ret + rec(pos + 1, (sum * 10 + d) % 13)) % MOD;
    return ret;
  };

  cout << rec(0, 0) << endl;

  return (0);
}


Measured memory_bytes: 16720
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>
#include <stack>
#include <queue>
#include <cstring>
#include <map>
#include <list>
#include <cassert>
 
using namespace std; 

int d[2][2000];
vector<int> e[2000];
pair<int,int> ab[2000];
const int inf=1e7;
void calc(int pos,int idx){

	for(int i=0;i<e[pos].size();i++){
		int to=e[pos][i];
		if(d[idx][to]!=inf) continue;
		d[idx][to]=d[idx][pos]+1;
		calc(to,idx);
	}

}

int main(){

	int n,k;
	cin>>n>>k;

	for(int i=0;i<n-1;i++){
		cin>>ab[i].first>>ab[i].second;
		ab[i].first--; ab[i].second--;
		e[ab[i].first].push_back(ab[i].second);
		e[ab[i].second].push_back(ab[i].first);
	}

	int res=n;
	if(k%2==0){
		
		for(int i=0;i<n;i++){
			fill(&d[0][0],&d[1][n],inf);
			d[0][i]=0;
			calc(i,0);
			int cnt=0;
			for(int j=0;j<n;j++) cnt+=(d[0][j]>k/2);
			res=min(res,cnt);
		}

	}else{
		for(int i=0;i<n-1;i++){
			fill(&d[0][0],&d[1][n],inf);
			d[0][ab[i].first]=0;
			d[1][ab[i].second]=0;
			calc(ab[i].first,0);
			calc(ab[i].second,1);
			int cnt=0;
			for(int j=0;j<n;j++) cnt+=(min(d[0][j],d[1][j])>k/2);
			res=min(res,cnt);			
		}

	}

	cout<<res<<endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

//小数出力
double print_double(double d){printf("%.8f", d);}

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > 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);
}


int main() {
  int N,M,x,y;
  cin >> N >> M;
  Vi in(N,0);
  vector<Vi> v(N);
  rep(i,N-1+M) {
    cin >> x >> y;
    v[x-1].push_back(y-1);
    in[y-1]++;
  }
  // rep(i,N){
  //   cout << in[i] << ' ' << endl;
  // }

  Vi memo(N,N);
  queue<int> q;
  rep(inix,N){
      if (in[inix]>0) continue;
      q.push(inix);
      memo[inix]=0;
    }
  while(!q.empty()){
    int ch = q.front();q.pop();
    // cout << "ch=" << ch << endl;
    for(auto i:v[ch]){
      in[i]--;
      if (in[i]==0) {
        q.push(i);
        memo[i] = ch+1;
      }
    }
  }
  rep(i,N){
    cout << memo[i] << endl;
  }
}

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

int main()
{
    int N;
    cin >> N;
    vector<double> A(N, 0);
    for (int i = 0; i < N; ++i){
        cin >> A[i];
    }
    double ans = 0;
    for (int i = 0; i<N; ++i){
        ans += 1 / A[i];
    }

    cout << fixed << 1 / ans << endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int inf = 1<<30;
constexpr int mod = 1e9+7;
constexpr ll infl = 1ll<<60;
vector<int> E[10];
int n,m;
int rec(int u,int pre,int state){
    if((state | 1<<u) == ((1<<n)-1))return 1;
    int ret = 0;
    for(auto v : E[u])if(pre != v and !((state & 1<<v))){
        ret += rec(v,u,state|1<<u);
    }
    return ret;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    
    cin>>n>>m;
    for(int i=0;i<m;++i){
        int a,b;
        cin>>a>>b;
        a--;b--;
        E[a].push_back(b);
        E[b].push_back(a);
    }
    cout << rec(0,-1,0) << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		sc.close();
		int n = Integer.parseInt(a + b);
		int s = (int)Math.sqrt(n);
		if(s * s == n) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 22740
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class DBlackAndWhiteTree {
public:

    vector<int> graph[100005];
    vector<int> sort;
    vector<bool> used;

    void dfs(int p) {
      used[p] = true;
      for(auto e: graph[p]) {
        if (used[e]) continue;
        dfs(e);
      }
      sort.push_back(p);
    }

    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      used.resize(n);
      if (n%2 == 1) {
        cout << "First" << endl;
        return;
      }

      rep(i, n-1) {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
      }
      dfs(0);
      rep(i, n) used[i] = false;

      for(auto p: sort) {
        if (used[p]) continue;
        bool flag = false;
        for(auto e: graph[p]) {
          if (used[e]) continue;
          used[e] = true;
          flag = true;
          break;
        }
        if (!flag) {
          cout << "First" << endl;
          return;
        }
      }
      cout << "Second" << endl;
    }
};

signed main() {
  DBlackAndWhiteTree solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

using namespace std;

class Dice {
    public:
        int D[6];

        void constractor(int d1, int d2, int d3, int d4, int d5, int d6);
        void Rotate_E();
        void Rotate_N();
        void Rotate_S();
        void Rotate_W();

};

void Dice::constractor (int d1, int d2, int d3, int d4, int d5, int d6) {
    D[0] = d1;
    D[1] = d2;
    D[2] = d3;
    D[3] = d4;
    D[4] = d5;
    D[5] = d6;
}

void Dice::Rotate_E () {
    int tmp;

    tmp = D[2];
    D[2] = D[0];
    D[0] = D[3];
    D[3] = D[5];
    D[5] = tmp;
}

void Dice::Rotate_N () {
    int tmp;

    tmp = D[4];
    D[4] = D[0];
    D[0] = D[1];
    D[1] = D[5];
    D[5] = tmp;
}

void Dice::Rotate_S () {
    int tmp;

    tmp = D[4];
    D[4] = D[5];
    D[5] = D[1];
    D[1] = D[0];
    D[0] = tmp;
}

void Dice::Rotate_W () {
    int tmp;

    tmp = D[2];
    D[2] = D[5];
    D[5] = D[3];
    D[3] = D[0];
    D[0] = tmp;
}

bool Dice_Compare (Dice dice0, Dice dice1) {

    for (int X = 0; X < 6; X++) {

        Dice dice[2];
        dice[0] = dice0;
        dice[1] = dice1;

        if (X == 0) {

            dice[1].Rotate_S();
        
        } else if (X == 1) {

        } else if (X == 2) {

            dice[1].Rotate_W();
            dice[1].Rotate_S();

        } else if (X == 3) {

            dice[1].Rotate_E();
            dice[1].Rotate_S();

        } else if (X == 4) {

            dice[1].Rotate_S();
            dice[1].Rotate_S();

        } else {

            dice[1].Rotate_N();

        }

        for (int i = 0; i < 4; i++) {

            dice[1].Rotate_E();

            for (int i = 0; i < 6; i++) {
                if (dice[0].D[i] != dice[1].D[i]) {
                    // cout << "X: " << X << " i: " << i << endl;
                    break;
                }

                if (i == 5) {
                    // cout << "X: " << X << endl;
                    return true;
                }
            }
        }

    }

    return false;

}

int main () {

    Dice dice[2];
    
    for (int i = 0; i < 2; i++) {
        
        int d1, d2, d3, d4, d5, d6;
        cin >> d1 >> d2 >> d3 >> d4 >> d5 >> d6;

        dice[i].constractor(d1, d2, d3, d4, d5, d6);

    }

    bool answer = Dice_Compare (dice[0], dice[1]);

    if (answer) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3112
//

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a / __gcd(a, b) * b
#define range(a) (a).begin(),(a).end()
const int inf = 2147483647;

int main (){
    int X;cin>>X;
    ll ansa,ansb;
    rep(i,-400,400){
        rep(j,-400,400){
            if(X==pow(j,5.0)-pow(i,5.0)){
            ansa = j;
            ansb = i;
            break;
            }
        }
    }
    cout << ansa << " " << ansb << endl;
}

Measured memory_bytes: 4088
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cinttypes>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
#include<stack>


#define FSCNd64 "%" SCNd64
#define FPRId64 "%" PRId64

using namespace std;

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

#define PI 3.1415926535897932384626433832795

template<typename X>
bool max_u(X&m, X v)
{
	if(m<v)
	{
		m=v;
		return true;
	}
	return false;
}


template<typename X>
bool min_u(X&m, X v)
{
	if(m>v)
	{
		m=v;
		return true;
	}
	return false;
}


struct solve
{
	solve(){}
	ll operator()() {
		return 0;
	}
};

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

	for(;;)
	{
		string n;
		cin >> n;
		if(cin.fail()) break;
		if(n[0]<'0' || '9'<n[0]) break;

		int x=0;
		for(int i=0;n[i];i++) x+=n[i]-'0';

		bool ans=(x%9==0);

		cout << (ans?"Yes":"No") << "\n";
	}
	return 0;
}


Measured memory_bytes: 3740
#include<stdio.h>
#include<algorithm>
#include<set>
using namespace std;
int c[100001];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%d",c+i);
	int count=0;
	set <int> S;
	for(int i=a-1;i>=0;i--){
		if(!S.count(c[i])){
			printf("%d\n",c[i]);
			S.insert(c[i]);
			count++;
		}
		if(count==b)break;
	}
}

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

using namespace std;

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

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n, m;
    ll k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1), b(m + 1);
    rep (i, n) cin >> a[i + 1];
    rep (i, m) cin >> b[i + 1];
    rep (i, n) a[i + 1] += a[i];
    rep (i, m) b[i + 1] += b[i];
    int res = 0;
    rep (i, n + 1) {
        int tmp = i;
        ll rest = k - a[i];
        if (rest < 0) continue;
        auto iter = upper_bound(b.begin(), b.end(), rest);
        if (iter != b.begin()) tmp += (iter - b.begin()) - 1;
        res = max(res, tmp);
    }
    cout << res << endl;
    
    return 0;
}



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

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

 int x, y, r;
 cin>>x>>y>>r;

 if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H)
cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
 return 0;
}


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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
#define mp            make_pair
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int n;
int m[55];
int x[55][22], y[55][22];

inline bool rotate(int k, int i, int j)
{
  if(k == 0){
    if(x[0][j + 1] - x[0][j] != x[i][j + 1] - x[i][j]) return false;
    if(y[0][j + 1] - y[0][j] != y[i][j + 1] - y[i][j]) return false;
    return true;
  }
  if(k == 1){
    if(x[0][j + 1] - x[0][j] != - y[i][j + 1] + y[i][j]) return false;
    if(y[0][j + 1] - y[0][j] !=   x[i][j + 1] - x[i][j]) return false;
    return true;
  }
  if(k == 2){
    if(x[0][j + 1] - x[0][j] != - x[i][j + 1] + x[i][j]) return false;
    if(y[0][j + 1] - y[0][j] != - y[i][j + 1] + y[i][j]) return false;
    return true;
  }
  if(k == 3){
    if(x[0][j + 1] - x[0][j] !=   y[i][j + 1] - y[i][j]) return false;
    if(y[0][j + 1] - y[0][j] != - x[i][j + 1] + x[i][j]) return false;
    return true;
  }
}

int main(int argc, char *argv[])
{
  while(cin >> n, n){
    rep(i, n + 1){
      cin >> m[i];
      rep(j, m[i]){
        cin >> x[i][j] >> y[i][j];
      }
    }

    erep(i, 1, n){
      bool ok = false;
      if(m[0] == m[i]) rep(_, 2){
        int p = INF;
        rep(k, 4) if(rotate(k, i, 0)){
          p = k;
          break;
        }
        if(p < INF){
          ok = true;
          rep(j, m[i] - 1) if(!rotate(p, i, j)){
            ok = false;
            break;
          }
          if(ok) break;
        }
        rep(j, m[i] / 2){
          swap(x[i][j], x[i][m[i] - j - 1]);
          swap(y[i][j], y[i][m[i] - j - 1]);
        }
      }
      if(ok) cout << i << endl;
    }

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

Measured memory_bytes: 1164
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

long long modpower(long long radix, long long x) {
    // 高速階乗計算 radix^x
    int mod       = (int)1E9 + 7;
    long long ans = 1;
    while (0 < x) {
        if (x & 1) {
            ans = ans * radix % mod;
        }
        radix = radix * radix % mod;
        x >>= 1;
    }
    return ans;
}

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

    int N, K;
    cin >> N >> K;

    double ans = 0.0;

    REP(i, N) {
        int cnt = 0;
        int a   = i + 1;
        while (a < K) {
            cnt++;
            a *= 2;
        }
        ans += (double)(1.0 / N) * pow(0.5, cnt);
    }

    std::cout << setprecision(11) << ans << std::endl;

    return 0;
}

Measured memory_bytes: 256
N=int(input())
B=list(map(int,input().split()))
A=[]
A.append(B[0])
A.append(B[0])
num=0
for i in B:
    if num==0:        
        num+=1
    elif A[num]<=B[num]:
        A.append(B[num])
        num+=1
    elif A[num]>B[num]:
        A[num]=B[num]
        A.append(B[num])
        num+=1

max_sum=0
for i in A:
    max_sum+=i
print(max_sum)



Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;//入力
	int i = 0, j = 0,d;//内部使用
		  //出力

	cin >> n;
	d = n % 10;
	if(d==3)	cout << "bon" << "\n";
	else if (d == 0 or d == 1 or d == 6 or d == 8) {
		cout << "pon" << "\n";
	}
	else cout << "hon" << "\n";


}


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

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

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

    // 後ろから解くかわりにすべての文字列を「左右反転」する
    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());

    // 端から切っていく
    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false; // 4 個の文字列たちどれかで divide できるか
        for (int j = 0; j < 4; ++j) {
            string d = divide[j];
            if (S.substr(i, d.size()) == d) { // d で divide できるか
                can2 = true;
                i += d.size(); // divide できたら i を進める
            }
        }
        if (!can2) { // divide できなかったら
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 3700
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String args[]) {
        int n, q, time = 0;
        Queue<String> queueName = new ArrayDeque<String>();
        Queue<Integer> queueTime = new ArrayDeque<Integer>();
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        q = sc.nextInt();
        sc.nextLine();

        for (int i = 0; i < n; i++) {
            String s[] = sc.nextLine().split(" ");
            queueName.add(s[0]);
            queueTime.add(Integer.parseInt(s[1]));
        }

        while (!queueName.isEmpty()) {
            String qn = queueName.poll();
            int t = queueTime.poll();

            time += (t > q)? q: t;

            if (t > q) {
                queueTime.add(t - q);
                queueName.add(qn);
            } else {
                System.out.println(qn + " " + time);
            }
        }
    }
}

Measured memory_bytes: 104860
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int max = 0;
  int sum = 0;

  for(int i=0;i<N;i++){
    if(S.at(i) == 'I'){
      sum += 1;
    }else{
      sum -= 1;
    }
    if(max < sum){
      max = sum;
    }
  }
  
  cout << max;
  
}


Measured memory_bytes: 256
//naveen mall
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb               push_back
#define sz(c)            (int)c.size()
#define len(c)           (int)c.length()
#define vec              vector
#define int              long long int
#define all(c)           c.begin(), c.end()
#define rall(c)          c.rbegin(), c.rend()
#define trav(a,i)        for(auto i: a)
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define invect(v,n)       for(int i=0;i<n;i++ ){int arb;cin>>arb;v.pb(arb);}
#define inset(s,n)        fl(i,0,n){int aset;cin>>aset;s.insert(aset);}
#define display(c)        trav(c,i) cout<<i<<" ";cout<<"\n";
#define F                 first
#define S                 second
#define pii               pair<int,int>
#define PB                pop_back
#define endl              "\n"
#define what(x) cerr << #x << " is " << x << endl;
int sum() { return 0; }template<typename T,typename... Args>T sum(T a, Args... args) { return a + sum(args...); }

  int fact[300];

  
int nCr(int n, int r) 
{ 
    return (fact[n] / (fact[r] * fact[n - r])); 
} 
  
// Returns factorial of n 


void solve()
{ 
   int n,m;
   cin>>n>>m;
    int ans=n*(n-1)/2 + m*(m-1)/2 ;   
    cout<<ans;	



    	



   
 }

  

signed main()
{fast
	int t;
	//cin>>t;
	t=1;
	while(t--)
		{solve();}
	
}












Measured memory_bytes: 256
#include <stdio.h>
#include <vector>

using namespace std;
const long long mod=1e9+7;
vector<int> edge[100001];
long long work( int now,int pre,int k){
    long long ans=1;int tmp;
    if (pre==-1) tmp=k-1;else tmp=k-2;
    if (k<edge[now].size()) return 0;
    for (int i=0;i<edge[now].size();++i){
        if(edge[now][i]!=pre){
            ans*=tmp;--tmp;ans%=mod;
            ans*=work(edge[now][i],now,k);ans%=mod;
        }
    }
    return ans;
}


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

    for (int i=1;i<n;++i){
        int t1,t2;scanf("%d%d",&t1,&t2);
        edge[t1].push_back(t2);
        edge[t2].push_back(t1);
    }
    long long ans= work(1,-1,k)*k;
    ans %= mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 11520
#include <iostream>

using namespace std;

int main()
{
  int N,Y;
  cin >> N >> Y;
  Y /= 1000;

  for( int i=0;i<=N;i++ )
    {
      for( int j=0;j<=N-i;j++ )
	{
	  int k = N-i-j;
	  if( k < 0 )
	    continue;
	  if( Y==10*i+5*j+k )
	    {
	      cout << i << " " << j << " " << k << endl;
	      return 0;
	    }
	}
    }
  cout << "-1 -1 -1" << endl;
  
}


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

int main(int argc, char *argv[]){
  int N;
  cin>>N;
  vector<int> C(N+1,0);
  vector<int> S(N+1,0);
  vector<int> F(N+1,0);
  for(int i=1; i<N; i++){
    int c,s,f;
    cin>>c>>s>>f;
    C[i]=c;
    S[i]=s;
    F[i]=f;
  }
  for(int i=1; i<=N; i++){
    int sum=0;
    for(int j=i; j<N; j++){
      if(j==i){
      sum+=S[j]+C[j];
      continue;
      }
      if(sum<=S[j]){ 
	sum=S[j];
	sum+=C[j];
      }
      else if(sum>S[j]){
	int m;
	if(sum%F[j]==0) m=0;
	else            m=F[j]-(sum%F[j]);
	sum=sum+m+C[j];     
      }
    }
    cout<<sum<<endl;
  }
}
	


Measured memory_bytes: 256
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 200000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

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

int main() {

  int h, w; cin >> h >> w;
  char s[h][w]; rep(i, h) { rep(j, w) cin >> s[i][j]; }

  rep(i, h) {
    rep(j, w) {
      if(s[i][j]=='#') {
        if(i+1<h) {
          if(s[i+1][j]=='#') continue;
        }
        if(i-1>=0) {
          if(s[i-1][j]=='#') continue;
        }
        if(j+1<w) {
          if(s[i][j+1]=='#') continue;
        }
        if(j-1>=0) {
          if(s[i][j-1]=='#') continue;
        }
        cout << "No" << endl;
        return 0;
      }
    }
  }

  cout << "Yes" << endl;

  return 0;
}


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! 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!{
        s: usize,
    }
    println!("{}",s * s);
}
     

Measured memory_bytes: 4352
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()

def main():
    N, T = map(int, input().split())
    A = list(map(int, input().split()))
    M = [0] * (N - 1) + [A[-1]]
    for i in range(N - 2, -1, -1):
        M[i] = max(M[i + 1], A[i])
    cnt = 0
    maxA = 0
    for a, m in zip(A, M):
        if maxA < m - a:
            maxA = m - a
            cnt = 1
        elif maxA == m - a:
            cnt += 1
    print(cnt)






if __name__ == "__main__":
    main()


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

long long MOD = 1e9+7;
int MAX_INT = 1e9;

// 最大公約数
long long gcd(long long a, long long b){
  if(b == 0) return a;
  return gcd(b, a % b);
}
// 最小公倍数
long long lcm(long long a, long long b) {
  return a / gcd(a, b) * b;
}

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

  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for(int i = 0; i < N; i++) {
    cin >> x[i];
  }
  int ans = MAX_INT;
  for(int i = 0; i + K < N + 1; i++) {
    int l = x[i], r = x[i + K - 1];
    ans = min(ans, min(abs(r) + abs(r - l), abs(l) + abs(r - l)));
  }

  cout << ans << endl;

  return 0;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

int main(int argc, char **argv)
{
	ll N, x; cin >> N >> x;
	vector<ll> A(N); REP(i, N) cin >> A[i];
	
	ll res{0};

	REP(i, N-1)
	{
		if (A[i] + A[i+1] > x)
		{
			ll d = A[i] + A[i+1] - x;
			res += d;

			if (A[i+1] < d)
			{
				A[i] -= (d - A[i+1]);
				A[i+1] = 0;
			}
			else
				A[i+1] -= d;
		}
	}

	std::cout << res << std::endl;
}

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

#define F first
#define S second
#define prev azaza
#define MP make_pair
#define PB push_back

using namespace std;
typedef long long ll;
typedef long double ld;

const int max_n = 200111, inf = 1000111222;

int n, k;
ll ans[max_n];

vector<ll> col[max_n];
vector<pair<ll, int>> v;
bool has_ch_left[max_n];
bool np[max_n];
bool has[max_n];

multiset<ll> r1; // that has pair in the left
multiset<ll> r2; // over all
multiset<ll> r3; // over all
multiset<ll> l1; // over all
multiset<ll> l2; // that has no child in the left

ll set_mx(const multiset<ll>& ms) {
    if (ms.empty()) {
        exit(228);
    }
    auto it = ms.end();
    --it;
    return *it;
}

void add2(int k) {
    vector<ll>& c = col[k];
    r2.erase(r2.find(c[0] + c[1]));
    if (c.size() > 2) {
        r3.erase(r3.find(c[0] + c[1] + c[2]));
    }
    for (int i = 2; i < c.size(); ++i) {
        r1.insert(c[i]);
    }
    l2.insert(c[0] + c[1]);
}

void add1(int k, ll val) {
    vector<ll>& c = col[k];
    r1.erase(r1.find(val));
    l1.insert(val);
    /*if (has_ch_left[k] == 0) {
        has_ch_left[k] = 1;
        l2.erase(l2.find(col[k][0] + col[k][1]));
    }*/
}

int main()
{
    //freopen("input.txt", "r", stdin);
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        int val, c;
        scanf("%d %d", &c, &val);
        val *= 2;
        --c;
        col[c].PB(val);
    }
    for (int i = 0; i < k; ++i) {
        sort(col[i].begin(), col[i].end(), greater<ll>());
        col[i][0] = col[i][1] = (col[i][0] + col[i][1]) / 2;
        r2.insert(2 * col[i][0]);
        if (col[i].size() > 2) {
            r3.insert(col[i][0] + col[i][1] + col[i][2]);
        }
        for (int val : col[i]) {
            v.emplace_back(val, i);
        }
    }
    sort(v.begin(), v.end(), greater<pair<ll, int>>());
    for (int i = 0; i < v.size(); ++i) {
        if (has[v[i].S] == 0) {
            has[v[i].S] = 1;
            np[i] = true;
        }
    }
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        ans[i] = -inf;
        if (np[i]) {
            if (!r1.empty()) {
                ans[i] = max(ans[i], sum + set_mx(r1));
            }
            if (!l1.empty() && !r2.empty()) {
                ans[i] = max(ans[i], sum - *l1.begin() + set_mx(r2));
            }
            if (!l2.empty() && !r3.empty()) {
                ans[i] = max(ans[i], sum - *l2.begin() + set_mx(r3));
            }
            sum += v[i].first;
            continue;
        }
        sum += v[i].first;
        ans[i] = sum;
        if (i && np[i - 1]) {
            add2(v[i].S);
        } else {
            add1(v[i].S, v[i].F);
        }
    }
    for (int i = 0; i < n; ++i) {
        if (ans[i] == -inf) {
            ans[i] = -2;
        }
        printf("%lld\n", ans[i] / 2);
    }

    return 0;
}




Measured memory_bytes: 24812
let () =
  let a,b = Scanf.scanf "%d %d " (fun a b -> a,b) in

  let h_arr = Array.init 1000 (fun _ -> 0) in
  for i = 1 to 999 do
    h_arr.(i) <- h_arr.(i-1)+i
  done;
  let d = b - a in

  Printf.printf "%d\n" (h_arr.(d) - b)


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const long long maxn=1e5+5;
const long long p=998244353;
long long d[maxn];
long long cnt[maxn],mx;
long long fac[maxn],inv[maxn];
long long ksm(long long a,long long b,long long p){
	long long ans=1;
	for(;b;b>>=1,a=1ll*a*a%p){
		if(b&1) ans=1ll*ans*a%p;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	long long n;
	cin>>n;
	if(!n){
		cout<<0<<'\n';exit(0);
	}
	for(long long i=1;i<=n;++i){
		cin>>d[i];
		if(d[1]!=0) cout<<0<<'\n',exit(0);
		++cnt[d[i]];
		mx=max(mx,d[i]);
	}
	if(cnt[0]>1) cout<<0<<'\n',exit(0);
	for(long long i=1;i<=mx;++i){
		if(!cnt[i]){
			cout<<0<<'\n';
			exit(0);
		}
	}
	long long ans=1;
	for(long long i=1;i<=mx;++i){
		ans=(1ll*ans*ksm(cnt[i-1],cnt[i],p)%p);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 1792
import sys

input = sys.stdin.readline


def main():
    bingo = [list(map(int, input().split())) for _ in range(3)]
    N = int(input())
    bn = [int(input()) for _ in range(N)]
    hit = [[0] * 3 for _ in range(3)]
    cnt = 0
    hitz = []
    hzb, hb = False, False
    for b in bn:
        for v, i in enumerate(bingo):
            for w, j in enumerate(i):
                if b == j:
                    if j in hit:
                        continue
                    hit[w][v] = 1
                    cnt += 1
    hitz = list(map(list, zip(*hit)))
    for i in hitz:
        if sum(i) == 3:
            hzb = True
            break
    for i in hit:
        if sum(i) == 3:
            hb = True
            break
    if cnt >= 3 and (
        hzb == True
        or hb == True
        or hit[0][0] == hit[1][1] == hit[2][2] == 1
        or hit[0][2] == hit[1][1] == hit[2][0] == 1
    ):
        print("Yes")

    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
unittest
{
	assert( [ "6", "1 3 -4 2 2 -2" ].parse.expand.solve == 3 );
	assert( [ "7", "1 -1 1 -1 1 -1 1" ].parse.expand.solve == 12 );
	assert( [ "5", "1 -2 3 -4 5" ].parse.expand.solve == 0 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	auto ans = 0L;
	auto t = 0L;
	long[ long ] cs;
	foreach( i, a; as )
	{
		// as[ 0 .. i ].sum を計算
		t += a;
		
		// as[ 0 .. i ].sum == 0 だったら答えに加算
		ans += ( t == 0 );
		
		// as[ 0 .. i ].sum - as[ 0 .. k ].sum == 0 ( k < i ) だったら答えに加算
		if( t in cs ) ans += cs[ t ];
		
		// as[ 0 .. k ].sum の個数を加算
		cs[ t ]++;
	}
	return ans;
}


Measured memory_bytes: 25740
<?php
  fscanf(STDIN, "%d %d", $a,$b);
if($a<=$b){
for ($i = 1; $i <= $b; $i++) {
    echo $a;
}
}else{
  for ($i = 1; $i <= $a; $i++) {
    echo $b;
}
}
?>
      


Measured memory_bytes: 3700
#include<bits/stdc++.h>
#define rep(i,l,r) for (int i=l;i<=r;i++)
using namespace std;
int n;
long long ans;
int a[100500];
int main(){
    scanf("%d",&n);
    rep(i,1,n) scanf("%d",&a[i]);
    int last=0;
    rep(i,1,n) {
        if (last&&a[i]) a[i]--,ans++,last=0;
        ans+=a[i]/2;
        if (a[i]&1) last=1;
        else last=0;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,mod=998244353;
struct node
{
    int x,y;
    bool operator<(const node&o)const
    {
        return x<o.x;
    }
}a[N];
int n,t[N],hs[N];
ll lu[N],ld[N],ru[N],rd[N];
ll f[N];
void add(int x)
{
    while(x<=n)
        t[x]++,x+=x&-x;
}
int query(int x)
{
    int ans=0;
    while(x) ans+=t[x],x-=x&-x;return ans;
}
int main()
{
    f[0]=1;
    for(int i=1;i<N;i++)
        f[i]=f[i-1]*2%mod;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d%d",&a[i].x,&a[i].y),hs[i]=a[i].y;
    sort(a+1,a+1+n);
    sort(hs+1,hs+1+n);
    for(int i=1;i<=n;i++)
        a[i].y=lower_bound(hs+1,hs+1+n,a[i].y)-hs;
    for(int i=1;i<=n;i++)
    {
        ld[i]=query(a[i].y);
        lu[i]=i-1-ld[i];
        add(a[i].y);
    }
    memset(t,0,sizeof(t));
    for(int i=n;i>=1;i--)
    {
        rd[i]=query(a[i].y);
        ru[i]=n-i-rd[i];
        add(a[i].y);
    }
    ll ans=0;
	for(int i=1;i<=n;++i)
    {
		ans=(ans+f[n-1])%mod;
		ans=(ans+f[n-1])%mod;
		ans=(ans-f[lu[i]+ld[i]])%mod;
		ans=(ans-f[ru[i]+rd[i]])%mod;
        ans=(ans-f[lu[i]+ru[i]])%mod;
        ans=(ans-f[ld[i]+rd[i]])%mod;
        ans=(ans+f[lu[i]])%mod;
        ans=(ans+f[ru[i]])%mod;
        ans=(ans+f[ld[i]])%mod;
        ans=(ans+f[rd[i]])%mod;
        ans=(ans-1)%mod;
	}
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


Measured memory_bytes: 11136
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  ll a,b,n; cin >> a >> b >> n;
  ll x;
  if(b<=n) x=b-1;
  else x=n;
  ll ans=a*x/b-a*(x/b);
  cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//1に繋がる枝の長さを配列に収め、大きい順にソートしてi+a[i]の最大値が深さ
int N;
int lost[100010];
vector<int> win[100010];

int dfs(int cur){
	int ret=0;
	vector<int> depth;
	for(int i=0;i<win[cur].size();i++){
		depth.push_back(-dfs(win[cur][i]));
	}
	sort(depth.begin(),depth.end());
	for(int i=0;i<depth.size();i++){
		ret=max(ret,i-depth[i]);
	}
	return ret+1;
}

int main(){
	cin>>N;
	for(int i=2;i<=N;i++)	cin>>lost[i];
	for(int i=2;i<=N;i++)	win[lost[i]].push_back(i);
	cout<<dfs(1)-1<<endl;
	return 0;
}


Measured memory_bytes: 13952
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

const ll inf = 1e14;

ll ans;
int N,M,R;
vector<int> used;
vector<int> r;
vector<vector<ll>> d;

void wf(){
  rep(k,N){
    rep(i,N){
      if(d[i][k] == inf) continue;
      rep(j,N){
        if(d[k][j] == inf) continue;
        d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }
}

void dfs(int now, int depth, ll dist){
  if(used[now]) return;
  if(depth==R) {
    if(ans > dist) ans = dist;
    return;
  }
  used[now] = 1;
  rep(i,R){
    dfs(i,depth+1,dist+d[r[now]][r[i]]);
  }
  used[now] = 0;
  return;
}


int main(){
  cin >> N >> M >> R;
  rep(i,N) used.pb(0);
  r.resize(R);
  rep(i,R) {cin >> r[i]; r[i]--;}
  d.resize(N,vector<ll>(N));
  rep(y,N)rep(x,N) d[y][x]=inf;
  int a,b;
  ll c;
  rep(i,M){
    cin >> a >> b >> c;
    a--; b--;
    d[a][b] = d[b][a] = c;
  }
  wf();
  ans = inf;
  rep(i,R){
    dfs(i,1,0);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
m = 0
ai = 0
m_l = []

for i in range(n):
    if a[i] - b[i] >= 0:
        m += b[i]        
        a[i] -= b[i]        
    else:
        m += a[i]        
        ai = a[i]
        a[i] = 0        
        if a[i+1] - (b[i] - ai) >= 0:
            a[i+1] -= b[i] - ai
            m += b[i] - ai            
        else:
            m += a[i+1]
            a[i+1] = 0            

print(m)

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

using namespace std;

int main()
{

    while (true) {
        string str;
        getline(cin, str);
        if (str == ".") {
            break;
        }
        stack<char> kakko;
        bool ok = true;
        for (const char c : str) {
            if (c == '.') {
                break;
            }
            if (c == '[') {
                kakko.push('[');
            } else if (c == ']') {
                if (not kakko.empty() and kakko.top() == '[') {
                    kakko.pop();
                } else {
                    ok = false;
                }
            } else if (c == '(') {
                kakko.push('(');
            } else if (c == ')') {
                if (not kakko.empty() and kakko.top() == '(') {
                    kakko.pop();
                } else {
                    ok = false;
                }
            }
        }
        if (ok and kakko.empty()) {
            cout << "yes" << endl;
        } else {
            cout << "no" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int mod_pow(int x,int y){
	int res=1;
	while(y>0){
		if(y&1)res*=x;
		x*=x;
		res%=mod;x%=mod;
		y>>=1;
	}
	return res;
}
int n,a[114514];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	if(n%2){
		rep(i,n){
			if(a[i]!=(i+1)/2*2){
				cout<<0<<endl;return 0;
			}
		}
	}else {
		rep(i,n){
			if(a[i]!=i/2*2+1){
				cout<<0<<endl;return 0;
			}
		}
	}
	cout<<mod_pow(2,n/2)<<endl;
}


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

    int count;
    int ans = 0;
    rep(i, s.size()){
        count = 0;
        for(int j=i; j<s.size(); j++){
            if(s[j]=='A' || s[j]=='C' || s[j]=='G' || s[j]=='T'){
                count++;
            }
            else{
                break;
            }
        }
        ans = max(ans, count);
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;




#define P pair<ll,ll>
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define st std::string 
#define pb push_back 
#define ll long long 
#define pq(x) std::priority_queue<x> 
#define ultapq(x) priority_queue<x,vector<x>,greater<x>> cle
#define show_pq(x,n) for(ll i = 0; i < n; i++){cout<<x.top(); x.pop();} 
#define itrt(yo) for(auto x:yo){std::cout<<x<<" ";} 
#define vec(x) std::vector<x> 
#define inll(x)  ll x; cin>>x;
#define inint(x)  ll x; cin>>x;
#define nl '\n' 
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define ALL(x) x.begin(),x.end() 
#define BN(x) x.begin()
#define ED(x) x.end()
#define MAP_traverse(it,x)  for(auto it = BN(x); it!= ED(x); it++)

int main()
{
    inll(a);

    st str;
    cin>>str;
    st temp="";
    int cnt = 0;

    if (a>=str.size())
    {
        cout<<str;
    }else
    {
        for (int i = 0; i < a; i++)
        {
            temp+=str[i];
        }
        temp+="...";
        cout<<temp;
        
    }
    
    
    
    
    
    
     
}

Measured memory_bytes: 3592
#include<cstdio>
#include<algorithm>
 
int dp[101][10001];
 
int main(){
    int n, w;
    scanf("%d %d\n", &n, &w);
    int val[n], wei[n];
    for(int i=1; i<=n; i++){
        scanf("%d %d\n",&val[i], &wei[i]);
    }
    // init. dp table
    for(int i=0; i<=n; i++){
        dp[i][0] = 0;
    }
    for(int j=0; j<=w; j++){
        dp[0][j] = 0;
    }

    for(int i=1; i<=n; i++){
        for(int j=1; j<=w; j++){
            if(wei[i]<=j){
                dp[i][j] = std::max(dp[i][j-wei[i]] + val[i], dp[i-1][j]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
        }
    }
 
    printf("%d\n", dp[n][w]);
/*
    for(int i=0; i<=n; i++){
        for(int j=0; j<=w; j++){
            printf("%d ",dp[i][j]);
        }
        printf("\n");
    }
*/
 
    return 0;
}

Measured memory_bytes: 6632
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
     char ch;
     cin>>ch;
     if(ch>='a'&&ch<='z')
       cout<<"a";
     else
       cout<<"A";
   }
}

Measured memory_bytes: 3600
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;
int main(){

	int a,b,c,sum=1;
	cin >> a >> b >> c;

	if(a!=b)
		sum++;
	if(c!=a&&c!=b)
		sum++;
	cout << sum << endl;

	return 0;
}

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

using namespace std;
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)

#pragma comment(linker, "/STACK:16777216")

typedef long long int64;
typedef unsigned long long uint64;

int main()
{
	int n, c, k;
	cin >> n >> c >> k;

	vector<int> T;
	for (int i = 0; i < n; i++) 
	{
		int x; cin >> x;
		T.PB(x);
	}
	sort(T.begin(), T.end());

	int cur_bus = -1;
	int cur_cap = 0;
	int res = 0;

	for (int i = 0; i < n; i++)
	{
		if (cur_bus < T[i])
		{
			res++;
			cur_bus = T[i] + k;
			cur_cap = 1;
		}
		else
		{
			if (cur_cap == c)
			{
				res++;
				cur_bus = T[i] + k;
				cur_cap = 1;
			}
			else cur_cap++;
		}
	}

	cout << res << endl;
	return 0;
}

Measured memory_bytes: 892
n, m = map(int, input().split())
h = tuple(map(int, input().split()))
graph = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

ans = 0
for i in range(n):
    is_good = True
    for v in graph[i]:
        if h[i] <= h[v]:
            is_good = False
            break
    if is_good:
        ans += 1

print(ans)


Measured memory_bytes: 29376
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,p;
	cin>>a>>p;
	cout<<((a*3)+p)/2<<endl;
	return 0;

}


Measured memory_bytes: 256