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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

const int N = 1005;
int x[N], y[N], r[N];
double d[N][N];

typedef pair<double, int> P;
double dp[N];

void dijkstra(int s, int n) {
	const double INF = 1e18;
    priority_queue<P, vector<P>, greater<P>> que;
    fill(dp, dp + N, INF);
    dp[s] = 0;
    que.push(P(0, s));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        if (dp[p.second] < p.first) continue;
        for (int i = 0; i <= n + 1; ++i) if (i != p.second) {
            if (dp[i] > dp[p.second] + d[i][p.second]) {
                dp[i] = dp[p.second] + d[i][p.second];
                que.push(P(dp[i], i));
            }
        }
    }
}

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int xt, yt; cin >> x[0] >> y[0] >> xt >> yt;
	int n; cin >> n;
	REPU(i, 1, n + 1) {
		cin >> x[i] >> y[i] >> r[i];
	}
	x[n + 1] = xt, y[n + 1] = yt;
	REPU(i, 1, n) REPU(j, i + 1, n + 1) {
		int dx = x[i] - x[j], dy = y[i] - y[j];
		double dist = sqrt(dx * 1.0 * dx + dy * 1.0 * dy);
		d[i][j] = d[j][i] = max(0.0, dist - r[i] - r[j]);
	}
	REPU(i, 1, n + 1) {
		int dx = x[i] - x[0], dy = y[i] - y[0];
		double dist = sqrt(dx * 1.0 * dx + dy * 1.0 * dy);
		d[0][i] = d[i][0] = max(0.0, dist - r[i]);
		dx = x[i] - x[n + 1], dy = y[i] - y[n + 1];
		dist = sqrt(dx * 1.0 * dx + dy * 1.0 * dy);
		d[i][n + 1] = d[n + 1][i] = max(0.0, dist - r[i]);
	}
	{
		int dx = x[n + 1] - x[0], dy = y[n + 1] - y[0];
		double dist = sqrt(dx * 1.0 * dx + dy * 1.0 * dy);
		d[0][n + 1] = d[n + 1][0] = dist;
	}
	dijkstra(0, n);
	printf("%.10f\n", dp[n + 1]);

	return 0;
}


Measured memory_bytes: 12400
#include <stdio.h>
int main()
{
  int s[20],c[20],s2[20],c2[20];
  int n,i,j,count;
  for(;;)
    {
      scanf("%d",&n);
      if(n==0)
	return 0;
      count=0;
      for(i=0;i<n;i++)
	{
	  scanf("%d",&s[i]);
	  c[i]=0;
	}
      for(;;)
	{
	  for(i=0;i<n;i++)      
	    for(j=0;j<n;j++)
	      if(s[i]==s[j])
		c[i]++;

	  for(j=0,i=0;i<n;i++)      
	    if(s[i]!=c[i])
	      break;
	    else
	      j++;
	  if(n==j)
	    {
	      printf("%d\n",count);
	      for(i=0;i<n;i++)
		{
		  printf("%d",c[i]);
		  if(i==n-1)
		    puts("");
		  else
		    printf(" ");
		}
	      break;
	    }
	  for(i=0;i<n;i++)
	    {
	      s[i]=c[i];
	      c[i]=0;
	    }
	  count++;
	}   
      
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 1000000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll N,M;
ll a[1010],b[1010],c[1010];
ll D[110][110];
int main(){
    cin >> N >> M;
    rep(i,110) rep(j,110){
        if(i == j) D[i][j] = 0;
        else D[i][j] = INF;
    }
    rep(i,M){
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;b[i]--;
        D[a[i]][b[i]] = c[i];
        D[b[i]][a[i]] = c[i];
    }
    rep(k,N) rep(i,N) rep(j,N) D[i][j] = min(D[i][k] + D[k][j],D[i][j]);
    ll ans = 0;
    rep(i,M){
        if(D[a[i]][b[i]] != c[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    readLine()!!.toInt()
    val pl: List<Int> = readLine()!!.split(" ").map { it.toInt() }

    val wl: MutableList<Pair<Int, Int>> = mutableListOf()
    pl.forEachIndexed { index, i ->
        if ((index + 1 != i)) {
            wl.add(Pair(index + 1, i))
        }
    }

    when (wl.size) {
        0 -> {
            print("YES")
        }
        2 -> {
            if (wl[0].first == wl[1].second) {
                print("YES")
            } else {
                print("NO")
            }
        }
        else -> {
            print("NO")
        }
    }
}


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

using namespace std;

int main()
{
	int h, w;
	
	while(true)
	{
		scanf("%d %d", &h, &w);
		
		if(h == 0 && w == 0)
			break;
		
		for(int i = 0; i < h; i++)
			cout << string(w, '#') << "\n";
		printf("\n");
	} 
	return 0;
}


Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    ll x;
    cin >> x;
    ll money = 100;
    int ans=0;
    while(money < x){
        ans++;
        money *= 1.01;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
 
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else{
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;

int main(){
    string s;
    cin >> s;
    
    //Aの後ろに"BC"が続いていればAを後に送る
    //Aがいれば合わせて送る
    ll ans = 0;
    ll count = 0;
    bool maeb = false;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='A'){
            if(maeb)
                count = 0;
            count++;
            maeb = false;
        }
        if(s[i]=='B'){
            if(maeb)
                count = 0;
            maeb = true;
        }
        if(s[i]=='C'){
            if(maeb)
                ans += count;
            else
                count = 0;
            maeb = false;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 640
import numpy as np


def min_10(num):
    if num % 10 == 0:
        return num
    else:
        return ( num // 10 + 1 ) * 10

t = []

for _ in range(5):
    t.append(int(input()))

min_rem = 9
min_ind = 0

for i in range(len(t)):
    rem = t[i] % 10
    if rem == 0:
        continue
    if rem < min_rem:
        min_rem = rem
        min_ind = i

sum = 0

for i in range(len(t)):
    if i == min_ind:
        continue

    sum = min_10(sum) + t[i]


sum = min_10(sum) + t[min_ind]

print(sum)


Measured memory_bytes: 21144
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
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);
    int n;
    cin >> n;
    vector<int> a(n, 0);
    vector<string> ss = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};
    vector<string> ans[1000000];
    vector<int> aaa[1000000];
    ans[0].push_back("");
    aaa[0].push_back(0);
    rep(i, n){
        auto prevs =  ans[i];
        auto prevaaa = aaa[i];
        rep(j, prevs.size()){
            int tt = aaa[i][j];
            if (i==0) tt--;
            rep(k, tt+2){
                ans[i+1].push_back(prevs[j] + ss[k]);
                aaa[i+1].push_back(max(tt, k));
            }
        }
    }

    sort(ans[n].begin(), ans[n].end());
    rep(i, ans[n].size()){
        cout << ans[n][i] << endl;
    }
    return 0;
}

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

using vi = vector<int>;
using vvi = vector<vi>;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for(int i=0; i<(int)n; i++)
using vb = vector<bool>;


int main(){
  int N,M,K;
  cin>>N>>M>>K;
  vvi fri(N);
  vvi blk(N);
  vi A, B, C, D;
  int p,q;
  rep(i,M){
    cin>>p>>q;
    p--;q--;
    A.pb(p);B.pb(q);
    fri[p].pb(q);
    fri[q].pb(p);
  }
  rep(i,K){
    cin>>p>>q;
    p--;q--;
    C.pb(p);D.pb(q);
    blk[p].pb(q);
    blk[q].pb(p);
  }

  //連結成分調査
  vi where(N);
  vi renketusize(N, 0);
  int renketu = 0;
  vb checked(N, false);
  for(int i=0; i<N; i++){
    //iがどの連結成分にあるか
    if(checked[i])continue;
    queue<int> unchecked;
    unchecked.push(i);

    while(!unchecked.empty()){
      int current = unchecked.front();
      unchecked.pop();

      if(!checked[current]){
        //チェックしてない
        where[current] = renketu;
        checked[current] = true;
        renketusize[renketu]++;
        for(int next: fri[current]){
          unchecked.push(next);
        }
      }
    }
    //一旦dfs終わったらrenketu++
    renketu++;
  }

  /*
  //どこの連結成分に入っているか
  rep(i,N){
    cout<<i<<" is in "<<where[i]<<endl;
  }

  //各連結成分の数は
  for(int x: renketusize){
    if(x==0)break;
    cout<<"size = "<<x<<endl;
  }
  */

/*
  rep(i,N){
    ll ans = renketusize[where[i]] - fri[i].size()
      - blk[i].size() - 1;
    if(i!=0)cout<<" ";
    cout<<ans;
  }
  cout<<endl;
  return 0;
*/

  vi ans(N);
  rep(i,N){
    //連結成分の大きさ = 可能性あり
    //1引いとく
    ans[i] = renketusize[where[i]] -1;
  }
  rep(i,M){
    //同じ連結成分内の友達リンクの両方で可能性が減る
    //if(where[A[i]]==where[B[i]]){
      ans[A[i]]--;
      ans[B[i]]--;
    //}
  }
  rep(i,K){
    //同じ連結成分内でのブロックリンクの両方で可能性が減る
    if(where[C[i]]==where[D[i]]){
      ans[C[i]]--;
      ans[D[i]]--;
    }
  }
  rep(i,N){
    if(i!=0)cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
}

Measured memory_bytes: 14568
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
ll mod =1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,a,b) for(int i=(a);i<(b);++i)

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.begin(), v.end(), [](auto& x, auto& y){return x[1] < y[1];});


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

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



// ll combination_mod(int n, int k) {
//   k = mint(k,n-k);
//   ll ans = 1;
//   if (n==0 || k ==0) return ans;
//   rep(i,k) {
//     ans = ans*(n-i)%mod;
//     ans = ans*modinv(i+1)%mod;
//   }
//   return ans;
// }

struct edge {
  int from; //出発点
  int to;   //到達点
  ll cost; //移動コスト
};

//ベルマンフォード法
vector<ll> bellman_ford (vector<edge> edges, int V, int E, int r, ll INF = 100000000000) {  
  vector<ll> cost_to(V,INF);
  cost_to[r] = 0;
  rep(i,V) {
    rep(j,E) {
      edge e = edges[j];
      if (cost_to[e.from]==INF) continue;
      if (cost_to[e.to] > cost_to[e.from] + e.cost) {
        cost_to[e.to] = cost_to[e.from] + e.cost;
        if (i==V-1) {
          printf("NEGATIVE CYCLE\n");
          return {};
        }
      }

    }
  }
  return cost_to;
}

// combination
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}


// 木上の探索
vector<int> cnt;
void dfs(const vector<vector<int>> &G, int v, int p) {
    for (auto nv : G[v]) {
        if (nv == p) continue; // nv が親 p だったらダメ
        dfs(G, nv, v);
    }

    // 帰りがけ時に、部分木サイズを求める
    cnt[v] = 1; // 自分自身
    for (auto c : G[v]) {
        if (c == p) continue;
        cnt[v] += cnt[c]; // 子のサイズを加える
    }
}

int main() {
  int N;
  cin >> N;
  vector<ll> a(N);
  rep(i,N) cin >> a[i];
  vector<vector<ll>> dp(N,vector<ll> (N,0));
  rep(i,N){
    rep(j,N-i) {
      if (i==0) dp[i][j] = a[j];
      else {
        dp[i][j] = maxt(a[j]-dp[i-1][j+1],a[j+i]-dp[i-1][j]);
      }
      // cout << dp[i][j] << ' ';
    }
      // cout << endl;
    
  }
  cout << dp[N-1][0] << endl;
}


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

int main(){
	int N;
	cin>>N;
	int maxv = 0;
	int sum =0;
	int L[N];
	for(int i=0;i<N;i++){
		cin >> L[i];
		maxv = max(maxv,L[i]);
		sum +=L[i];
	}
	if(maxv < sum-maxv)cout << "Yes";
	else cout << "No";
	
	
}


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

void counting_sort(ll a[], ll b[], ll k, ll n){
    ll c[k+1];
    memset(c, 0, (k+1)*sizeof(ll));
    rep(i, 0, n) c[a[i]]++;
    rep(i, 1, k+1) c[i] += c[i-1];
    rep(i, 0, n) b[--c[a[i]]] = a[i];
    return;
}

int main(){
    ll n; cin >> n;
    ll a[n]; rep(i, 0, n) cin >> a[i];
    ll b[n];

    counting_sort(a, b, 10000, n);
    rep(i, 0, n) cout << b[i] << char((i == n-1) ? '\n' : ' ');

    return 0;
}



Measured memory_bytes: 34416
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    read(arr);
    int count = 0; 
    for (int i = 0; i < n; i++) { 
        for (int j = i + 1; j < n; j++) { 
            for (int k = j + 1; k < n; k++) {
                if(arr[i] != arr[j] && arr[i] != arr[k] && arr[j] != arr[k]){
                    if (arr[i] + arr[j] > arr[k] && arr[i] + arr[k] > arr[j] && arr[k] + arr[j] > arr[i]){
                        count++; 
                    }
                }
            }
        } 
    } 
    cout <<  count; 
}

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

int dp[101][4][4][4];

int main() {
    int n;
    cin >> n;
    rep(c1,4)rep(c2,4)rep(c3,4) {
      if (c1 == 2 && c2 == 1 && c3 == 0) continue;
      if (c1 == 2 && c2 == 0 && c3 == 1) continue;
      if (c1 == 1 && c2 == 2 && c3 == 0) continue;
      dp[3][c1][c2][c3] = 1;
    }

    int mod = 1e9 + 7;
    for (int len = 3; len < n; len++) {
      rep(c1,4)rep(c2,4)rep(c3,4) {
        if (dp[len][c1][c2][c3] == 0) continue;
        rep(a,4) {
          if (a == 2 && c1 == 1 && c2 == 0) continue;
          if (a == 2 && c1 == 0 && c2 == 1) continue;
          if (a == 1 && c1 == 2 && c2 == 0) continue;
          if (a == 2 && c1 == 1 && c3 == 0) continue;
          if (a == 2 && c2 == 1 && c3 == 0) continue;
          dp[len+1][a][c1][c2] += dp[len][c1][c2][c3];
          dp[len+1][a][c1][c2] %= mod;
        }
      }
    }
    int ans = 0;
    rep(c1,4)rep(c2,4)rep(c3,4) {
      ans += dp[n][c1][c2][c3];
      ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  int D; cin >> D;
  string S = "Christmas";
  if(D == 24){
    S += " Eve";
  } else if(D ==23){
    S += " Eve Eve";
  } else if(D == 22 ){
    S += " Eve Eve Eve";
  }
  cout << S <<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;


//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用


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

	int a, b, c;
	cin >> a >> b >> c;

	cout << max(0, c - (a - b)) << endl;

}

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

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

    map<ll, ll> map; map[0]++;
    ll sum = 0;
    REP(acc_i, N) {
        sum += A[acc_i];
        map[sum]++;
    }

    ll ans = 0;
    for(const auto& v : map) {
        ans += v.second * (v.second - 1) / 2;
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 13568
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const int MOD = 1e9+7;
//}}}

int main(){
  string s;
  cin >> s;
  sort(s.begin(), s.end());
  puts((s == "abc") ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    X, Y, A, B, C = LI()
    p, q, r = sorted(LI(), reverse=True)[:X], sorted(
        LI(), reverse=True)[:Y], LI()
    print(sum(sorted(p + q + r, reverse=True)[:X+Y]))


main()


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

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

    // for(int i=0;i<n;i++) cout << a[i] << ' ';
    // cout << endl;

    ll move=0,cnt1=0,cnt2=0;
    for(int i=0;i<n;i++){
        ll new_move;
        ll tmp = a[i] + move;
        if(i%2==0){
            new_move = max((ll)0,1-tmp);
            cnt1 += abs(new_move);
            move += new_move;
        }else{
            new_move = -1*max((ll)0,1+tmp);
            cnt1 += abs(new_move);
            move += new_move;
        }
        // cout << cnt1 << ' ';
    }
    move = 0;
    for(int i=0;i<n;i++){
        ll new_move;
        ll tmp = a[i] + move;
        if(i%2==0){
            new_move = -1*max((ll)0,1+tmp);
            cnt2 += abs(new_move);
            move += new_move;
        }else{
            new_move = max((ll)0,1-tmp);
            cnt2 += abs(new_move);
            move += new_move;
        }
        // cout << cnt2 <<' ';
    }
    // cout << cnt1 <<' ' << cnt2 <<  endl;
    cout << min(cnt1,cnt2) << endl;
    return 0;
}

Measured memory_bytes: 1024
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>

using namespace std;

#define C_MAX(a, b) ((a)>(b)?(a):(b))
#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

struct IntL {
    long long pos;
    long long s;
    long long t;
};

bool comp_intl(const IntL &a, const IntL &b) {
    return a.pos < b.pos;
}

int main() {

    int N;
    cin >> N;

    vector<IntL> vx;
    vector<IntL> vy;

    for (int i = 0; i < N; i++) {
        long long x1, y1, x2, y2;
        cin >> x1 >> y1 >> x2 >> y2;
        if (x1 == x2) {
            IntL intL = {x1, min(y1, y2), max(y1, y2)};
            vy.push_back(intL);
        }
        if (y1 == y2) {
            IntL intL = {y1, min(x1, x2), max(x1, x2)};
            vx.push_back(intL);
        }
    }

    sort(vy.begin(), vy.end(), comp_intl);

    long long ans = 0;
    for (auto li: vx) {
        long long left = li.s;
        long long right = li.t;
        long long posY = li.pos;
        auto s1 = lower_bound(vy.begin(), vy.end(), (IntL) {left, LONG_LONG_MIN, LONG_LONG_MIN}, comp_intl);
        auto s2 = lower_bound(vy.begin(), vy.end(), (IntL) {right + 1, LONG_LONG_MIN, LONG_LONG_MIN}, comp_intl);
        for (auto i = s1; i != s2; i++) {
            if (i->s <= posY && posY <= i->t) ans++;
        }
    }

    cout << ans << endl;

}














































Measured memory_bytes: 6052
#include <bits/stdc++.h>
#define int long long
#define all(a) (a).begin(),(a).end()
using namespace std;

signed main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    cout << (1000 - n%1000)%1000 << endl ;
    return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var q = int.Parse(Console.ReadLine());
            var rightBuilder = new StringBuilder(s, q);
            var leftBuilder = new StringBuilder(q);
            var isReverse = false;

            for (var i = 0; i < q; i++)
            {
                var query = Console.ReadLine().Trim().Split(' ');
                if (query[0] == "1")
                {
                    isReverse = !isReverse;
                }
                else if (query[0] == "2")
                {
                    if (query[1] == "1")
                    {
                        if (isReverse) rightBuilder.Append(query[2]);
                        else leftBuilder.Append(query[2]);

                    }
                    else if (query[1] == "2")
                    {
                        if (isReverse) leftBuilder.Append(query[2]);
                        else rightBuilder.Append(query[2]);
                    }
                }
            }
            var right = rightBuilder.ToString();
            var left = leftBuilder.ToString();
            var result = isReverse ? Reverse(right) + left : Reverse(left) + right;
            Console.WriteLine(result);
        }

        static string Reverse(string str)
        {
            var chars = str.ToCharArray();
            var length = chars.Length;
            for (var i = 0; i < length / 2; i++)
            {
                var tmp = chars[i];
                chars[i] = chars[length - i - 1];
                chars[length - i - 1] = tmp;
            }
            return new string(chars);
        }

    }
}


Measured memory_bytes: 20912
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define pm(first, second) pb(mp(first, second))
#define SPACE " "
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()

int main(){

	int N;
	cin >> N;
	vector<int> V(N);
	for(int i = 0; i < N; i ++) cin >> V[i];
	int ans = 0;
	for(int i = 1; i < N - 1; i++){
		if((V[i - 1] < V[i] && V[i] < V[i + 1]) || (V[i + 1] < V[i] && V[i] < V[i - 1])) ans++;
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  string s;
  cin >> s;
  map<char, int> mp;
  for (char x : s) {
    mp[x] += 1;
  }
  int ok = 1;
  for (auto i : mp) {
    if (i.second % 2) {
      ok = 0;
      break;
    } 
  }
  if (ok) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
d, x = map(int, input().split(" "))

def count(j):
    k = 0
    choco = 0
    while (1 + j*k) <= d:
        choco += 1
        k += 1
    return choco

i=1
while i <= n:
    j = int(input())
    x += count(j)
    i += 1

print(x)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class C
{
	public static void Main()
	{
		string[] args = Console.ReadLine().Split(' ');
		int N = Int32.Parse(args[0]);
		int M = Int32.Parse(args[1]);

		double pAC = 1/(double)(1 << M);
		double pWA = 1 - pAC;
		double runtime = 1900 * M + (N - M) * 100;
		double ans = 0;
		for(int i = 1; ; i++)
		{
			double term = i * runtime * Math.Pow(pWA, i - 1) * pAC;
			if(term <= Double.Epsilon)
				break;
			ans += term;
		}

		Console.WriteLine((int)Math.Round(ans));
	}
}





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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int cnt[200000][26];

int main() {
    std::ios::sync_with_stdio(false);
    string s;cin >> s;
    int n = s.size();
    memset(cnt, 0, sizeof(cnt));

    cnt[0][s[0]-'a'] = 1;
    for(int i=1;i<n;i++){
        for(int j=0;j<26;j++){
            cnt[i][j] = cnt[i-1][j];
        }
        cnt[i][s[i]-'a']++;
    }

    LL ans = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<26;j++){
            if(s[i]-'a' == j) continue;
            ans += cnt[n-1][j] - cnt[i][j];
        }
    }

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


Measured memory_bytes: 20884
#include <iostream>
#include <vector>
#include <iomanip>

using namespace std;

double calc_exp(int p){
  double ans = 1.*(p+1)/2;
  return ans;
}

int main(){
  int N,K;
  vector<int> P;

  cin >> N >> K;
  for(int i=0;i<N;i++){
    int p;
    cin >> p;
    P.push_back(p);
  }
  double max=0.;
  double sum_expected=0.;
  for(int j=0;j<N-K+1;j++){
    if(j==0){
      for(int k=j;k<j+K;k++){
        sum_expected += calc_exp(P[k]);
      }
    }
    else {
      sum_expected += calc_exp(P[j+K-1]) - calc_exp(P[j-1]);
    }
    if(sum_expected>max) max=sum_expected;
  }
  cout << setprecision(10) << max << endl;
  return 0;
}

Measured memory_bytes: 1400
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define EVEL 1

#ifndef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;

    ll A,B,C;
    int N,M,K,X,Y,W,H;
    ll ans;
    string S;
    ll a[100010];
    int temp[100]={0};
    bool f=false;
    bool fir=true;
    ll sum[10000];

int main(){
    cin>>A>>B>>C;
    cout<<A+B+C-max({A,B,C});
    return 0;

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
ai=a[0::2]
aii=a[1::2]
tmp=sum(ai)-sum(aii)
print(tmp,end=" ")
for i in range(1,n):
  tmp=-tmp+2*a[i-1]
  print(tmp,end=" ")

Measured memory_bytes: 14028
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0


int main(){
  int n,a,s,i;
  scanf("%d",&n);
  s=-n;
  for(i=0;i<n;i++){
    scanf("%d",&a);
    s+=a;
  }

  printf("%d\n",s);
  return 0;
}


/// confirm df==0 ///

Measured memory_bytes: 128
import sys
from collections import deque

def solve():
    def rec(v, d, i):
        if dp[v][d]:
            return

        dp[v][d] = i

        if d == 0:
            return

        rec(v, d - 1, i)

        for u in Adj[v]:
            rec(u, d - 1, i)


    N, M = map(int, sys.stdin.readline().split())

    Adj = [[] for i in range(N)]

    for i in range(M):
        a, b = map(int, sys.stdin.readline().split())
        a, b = a - 1, b - 1
        Adj[a].append(b)
        Adj[b].append(a)

    Q = int(sys.stdin.readline())

    v = [0] * Q
    d = [0] * Q
    c = [0] * Q

    for i in range(Q - 1, -1, -1):
        v[i], d[i], c[i] = map(int, sys.stdin.readline().split())
        v[i] -= 1

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

    for i in range(Q):
        rec(v[i], d[i], i + 1)

        # for i in range(N):
            # print(*dp[i])

        # print()

    for i in range(N):
        if dp[i][0] > 0:
            print(c[dp[i][0] - 1])
        else:
            print(0)

if __name__ == '__main__':
    solve()

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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template<typename T>
ostream& operator << (ostream& os, vector<T> v)
{
  os << "(";
  each (i, v) os << i << ",";
  os << ")";
  return os;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b;
  while (cin >> a >> b) {
    swap(a, b);
    
    const int N = 100;
    int g[N][N];
    fill(&g[0][0], &g[N - 1][N - 1] + 1, '.');

    vector<pair<int, int>> v;
    vector<pair<int, int>> u;

    set<pair<int, int>> taboo;
    taboo.insert(make_pair(0, 0));
    taboo.insert(make_pair(N-1, N-1));
    taboo.insert(make_pair(0, N-1));
    taboo.insert(make_pair(N-1, 0));
    
    int di[] = {0, +1, 0, -1};
    int dj[] = {+1, 0, -1, 0};
    {
      int dir = 0;
      int len = N;
      int i = 0;
      int j = -1;
      while (len) {
        for (int k = 0; k < len; ++k) {
          i += di[dir];
          j += dj[dir];
          g[i][j] = '#';
          unless (taboo.count(make_pair(i, j))) v.push_back(make_pair(i, j));
        }
        dir = (dir + 1) % 4;
        --len;
      }
    }

    {
      int dir = 3;
      int len = N - 1;
      int i = N;
      int j = 0;
      while (len) {
        for (int k = 0; k < len; ++k) {
          i += di[dir];
          j += dj[dir];
          g[i][j] = '.';
          unless (taboo.count(make_pair(i, j))) u.push_back(make_pair(i, j));
        }
        dir = (dir + 1) % 4;
        --len;
      }
    }

    each (i, v) {
      g[i.first][i.second] = '#';
    }
    each (i, u) {
      g[i.first][i.second] = '.';
    }
    reverse(u.begin(), u.end());

    for (int i = 0; i < a - 1; ++i) {
      int j = 2 * i + 1;
      g[v[j].first][v[j].second] = '.';
    }
    for (int i = 0; i < b - 1; ++i) {
      int j = 2 * i + 1;
      g[u[j].first][u[j].second] = '#';
    }

    cout << N << ' ' << N << endl;
    for (int i = 0; i < N; ++i) {
      for (int j = 0; j < N; ++j) {
        cout << (char)g[i][j];
      }
      cout << endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.S;
		Console.WriteLine("{0}",s=="ABC"?"ARC":"ABC");
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 25720
# -*- coding: utf-8 -*-
"""
Permutation/Path - Traveling Salesman Problem
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_2_A&lang=jp

"""


V, E = map(int, input().split())

d = [[float('inf')]*V for _ in range(V)]
for _ in range(E):
    f, t, dist = map(int, input().split())
    d[f][t] = dist
dp = [[-1]*V for _ in range(2**V)]


def solve(S, v):
    if dp[S][v] >= 0:
        return dp[S][v]
    if (S == 2**V-1) and (v == 0):
        dp[S][v] = 0
        return 0
    res = float('inf')
    for u in range(V):
        if not ((S >> u) & 1):
            res = min(res, solve(S | (1 << u), u) + d[v][u])
    dp[S][v] = res
    return res

ans = solve(0, 0)
if ans == float('inf'):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 18792
#include<iostream>
#include<set>
using namespace std;main(){for(int n,t;cin>>n;cout<<++n<<endl){multiset<int>m;for(;n-->0;m.insert(t))cin>>t;t=0;for(multiset<int>::iterator i=m.begin();i!=m.end();n+=t)t+=*i++;}}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}
	public Main() {
		new AOJ0057();
	}
	
	class AOJ0057{
		public AOJ0057() {
			int[] ans = new int[100001];
			for(int i=1;i<=100000;i++)ans[i] = ((i+1)*i)/2+1;
			while(in.hasNext())System.out.println(ans[in.nextInt()]);
		}
	}
}

Measured memory_bytes: 19676
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main() {
	vector<int> bingo(9, 0);
	vector<bool> hit(9, 0);
	for (int i = 0; i < 9; i++) {
		cin >> bingo.at(i);
	}
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		for (int j = 0; j < 9; j++) {
			if (bingo.at(j) == x) hit.at(j) = true;
		}
	}
	string ans = "No";
	if (hit.at(0)) {
		if (hit.at(1) && hit.at(2)) ans = "Yes";
		else if (hit.at(4) && hit.at(8)) ans = "Yes";
		else if (hit.at(3) && hit.at(6)) ans = "Yes";
	}

	if (hit.at(1) && hit.at(4) && hit.at(7)) ans = "Yes";

	if (hit.at(2)) {
		if (hit.at(5) && hit.at(8)) ans = "Yes";
		else if (hit.at(4) && hit.at(6)) ans = "Yes";
	}

	if (hit.at(3) && hit.at(4) && hit.at(5)) ans = "Yes";

	if (hit.at(6) && hit.at(7) && hit.at(8)) ans = "Yes";

	cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int n,m,A[15],B[101];

int mem[101][1<<15],used[101][1<<15];
int dfs(int idx,int sta,int sum){
  if(idx==m) return 0;
  if(used[idx][sta]++)return mem[idx][sta];
  int &res=mem[idx][sta]=abs(sum-B[idx])+dfs(idx+1,sta,sum);
  for(int i=0;i<n;i++)
    if((sta>>i)&1)res=min(res,dfs(idx,~((~sta)|(1<<i)),sum-A[i]));
  return res;
}

int main(){
  while(1){
  cin>>n>>m;
  if(!n&&!m)break;
  int sum=0;
  for(int i=0;i<n;i++)cin>>A[i],sum+=A[i];
  for(int i=0;i<m;i++)cin>>B[i];
  sort(B,B+m,greater<int>());
  memset(used,0,sizeof(used));
  cout<<dfs(0,(1<<n)-1,sum)<<endl;
  }
  return 0;
}

Measured memory_bytes: 28856
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll A;
    cin >> A;
    int B = sqrt((double)A);
    for(int i = B; i > 1; i--){
        if(A % i == 0){
            cout << i + A/i - 2 << endl;
            return 0;
        }
    }
    cout << A-1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    int a[n];
    int minP = 0, maxP = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        minP = max(minP, a[i]);
        maxP += a[i];
    }
    int left = minP, right = maxP;
    while(left < right){
        int mid = (left + right) >> 1;
        int t = 0;
        int cnt = 0;// 装好一辆车的数量
        for(int i = 0; i < n; i++){
            if(t + a[i] <= mid){
                t += a[i];
            }else{
                cnt++;
                if(cnt > k)break;
                t = a[i];
            }
        }
        if(t)cnt++;// 未装满的货也需要一辆车
        // cout << "left = " << left << ", right = " << right << ", mid = "<< mid << ", cnt = " <<cnt << endl;
        if(cnt <= k){
            right = mid;
        }else{
            left = mid + 1;
        }
    }
    cout << left << endl;
}


Measured memory_bytes: 3472
def main():
    from collections import defaultdict, deque
    import sys
    input = sys.stdin.readline

    N, M, K = map(int, input().split())

    g = tuple(set() for _ in range(N))
    direct_friend = [0] * N
    for _ in range(M):
        a, b = (int(x) - 1 for x in input().split())

        g[a].add(b)
        g[b].add(a)

        direct_friend[a] += 1
        direct_friend[b] += 1

    bk = tuple(set() for _ in range(N))
    for _ in range(K):
        c, d = (int(x) - 1 for x in input().split())
        bk[c].add(d)
        bk[d].add(c)

    dq = deque()
    checked = [-1] * N
    for v in range(N):
        if ~checked[v]: continue

        dq.append(v)  # v
        checked[v] = v
        root = v
        while dq:
            v = dq.pop()
            for u in g[v]:
                if ~checked[u]: continue
                checked[u] = root
                dq.append(u)

    ctr = defaultdict(int)
    for v in range(N):
        root = checked[v]
        ctr[root] += 1

    ret = []
    for v in range(N):
        root = checked[v]
        t = ctr[root] - direct_friend[v] - 1 - sum(checked[u] == root for u in bk[v])
        ret.append(t)

    print(*ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 87148
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int N, Q; cin >> N >> Q; 
	int A[3010]; 
	for(int i = 0; i < N; i++) cin >> A[i]; 
	long long mod = 1000000007; 
	long long half = 500000004; 
	long long P[3010][3010] = {}; 
	long long S[3010] = {}; 
	long long T[3010] = {}; 
	long long pow2[3010] = {}; 
	pow2[0] = 1; 
	for(int i = 1; i < 3005; i++) pow2[i] = pow2[i-1] * 2 % mod; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			if(A[i] > A[j]) P[i][j] = 1; 
		}
	}
	int R = Q; 
	while(Q--){
		int X, Y; cin >> X >> Y; 
		X--; Y--; 
		if(X > Y) swap(X, Y); 
		for(int i = 0; i < N; i++){
			S[i] = (P[i][X] + P[i][Y]) * half % mod; 
			T[i] = (P[X][i] + P[Y][i]) * half % mod; 
		}
		for(int i = 0; i < N; i++){
			if(i == X || i == Y) continue;
			P[i][X] = S[i]; P[i][Y] = S[i]; 
			P[X][i] = T[i]; P[Y][i] = T[i]; 
		}
		long long mid = (P[X][Y] + P[Y][X]) * half % mod; 
		P[X][Y] = mid; P[Y][X] = mid;  
	}
	long long ans = 0; 
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			ans += P[i][j]; 
		}
	}
	ans %= mod; 
	cout << ans * pow2[R] % mod << "\n"; 
}

Measured memory_bytes: 74480
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] x = new int[N];

    for (int i = 0; i < N; i++) {
      x[i] = sc.nextInt();
    }

    sc.close();

    long min = Long.MAX_VALUE;

    for (int i = 0; i < N - K+1; i++) {
      long distance = Math.abs(x[i] - x[i + K-1]);

      if (x[i] < 0 && x[i + K-1] < 0) {
        distance += Math.abs(x[i + K-1]);
      } else if (0 < x[i] && 0 < x[i + K-1]) {
        distance += Math.abs(x[i]);
      } else {
        if (Math.abs(x[i]) < Math.abs(x[i + K-1])) {
          distance += Math.abs(x[i]);
        } else {
          distance += Math.abs(x[i + K-1]);
        }
      }

      min = Math.min(min, distance);
    }

    System.out.println(min);

  }

}

Measured memory_bytes: 50116
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    if (s=="SSS")
    {
    	cout<<0<<endl;
	}
    if (s=="SSR")
    {
    	cout<<1<<endl;
	}
    if (s=="SRS")
    {
    	cout<<1<<endl;
	}
    if (s=="RSS")
    {
    	cout<<1<<endl;
	}
    if (s=="RSR")
    {
    	cout<<1<<endl;
	}
    if (s=="RRR")
    {
    	cout<<3<<endl;
	}
    if (s=="RRS")
    {
    	cout<<2<<endl;
	}
    if (s=="SRR")
    {
    	cout<<2<<endl;
	}
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
ll modpow(ll n, int k) {
	ll r = 1;
	while (k > 0) {
		if (k&1) (r *= n) %= mod;
		(n *= n) %= mod;
		k >>= 1;
	}
	return r;
}
int main() {
	int N, K;
	cin >> N >> K;
	vector<ll> a(K+1);
	ll res = 0;
	for (int k = K; k >= 1; -- k) {
		ll r = modpow(K/k, N);
		for (int i = 2*k; i <= K; i += k) {
			r = (r+mod-a[i])%mod;
		}
		a[k] = r;
		res = (res + r * k) % mod;
	}
	cout << res << endl;
}


Measured memory_bytes: 3984
#include <iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
typedef long long int ll;
using namespace std;

int main(){
    int N,A;
    int x[50];
    cin >> N >> A;
    for(int i=0;i<N;i++){
        cin >> x[i];
    }
    ll dp[51][2501];
    for(int a=0;a<51;a++){
        for(int b=0;b<2501;b++){
            dp[a][b]=0;
        }
    }
    for(int i=0;i<N;i++){//i枚目のカードを使うor not
        for(int a=49 ; a>=1 ; a--){
            for(int b=2500 ; b>=1 ; b--){
                if(dp[a][b] !=0 && b+x[i] <= 2500){
                    dp[a+1][b+x[i]] += dp[a][b];
                }
            }
        }
        dp[1][x[i]]++;
    }
    ll ans = 0;
    for(int i=1;i<=N;i++){
        ans += dp[i][A*i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1280