akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    string g;
    cin >> g;
    if (g == "#"){
      break;
    }
    int y, m, d;
    cin >> y >> m >> d;
    if(y <= 30 || y == 31 && m <= 4){
      cout << g << ' ' << y << ' ' << m << ' ' << d << endl;
    } else {
      cout << '?' << ' ' << y - 30 << ' ' << m << ' ' << d << endl;
    }
  }
}


Measured memory_bytes: 3144
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main() {
    int n;
    string ans;
    cin >> n;
    if (n % 10 == 3) {
        ans = "bon";
    }
    else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
        ans = "pon";
    }
    else {
        ans = "hon";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
N = int(input())
A = [int(input()) for _ in range(N)][::-1]

if A[-1] != 0:
    print(-1)
else:
    bef = A[0]
    c, ans = 0, 0
    for i in A:
        if bef!=i:
            if bef-i > 1:
                print(-1)
                break
            ans += bef*c
            c = 1 if bef<i else 0
        else:
            c += 1
        bef = i
    else:
        print(ans)

Measured memory_bytes: 59364
N,M=map(int,input().split())
A=[int(i) for i in input().split()]
A.insert(0,0)
for n in range(N):
  A[n+1]+=A[n]
  A[n+1]=A[n+1]%M
A.sort(key=lambda x:x)
ans=0
B=[1]*(N+1)
for n in range(1,N+1):
  if A[n]==A[n-1]:
    B[n]=B[n-1]+1
    if n==N:
      ans+=B[n]*(B[n]-1)//2
  else:
    B[n]=1
    ans+=B[n-1]*(B[n-1]-1)//2
print(ans)
  

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

typedef long long ll;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  int n;
  string s;
  vector<int> mss(26, 100);
  cin >> n;

  rep(i, 0, n) {
    vector<int> ss(26);
    cin >> s;
    rep(j, 0, s.length()) {
      ss[s[j] - 97]++;
    }
    rep(j, 0, 26) {
      mss[j] = min(mss[j], ss[j]);
    }
  }

  rep(i, 0, 26) {
    if(mss[i] && mss[i] != 100) rep(j, 0, mss[i]) cout << (char)(97 + i);
  }
  cout << endl;
}


Measured memory_bytes: 256
import math
N, M = map(int, input().split())

if int(math.sqrt(M)) > N:
    divlist = []
    for i in range (N, int(math.sqrt(M))):
        if M%i == 0:
            divlist.append(i)
    
    if divlist != []:
        for i in range(N, int(math.sqrt(M))):
            if M%i == 0:
                ans = M//i
                break
    else:
        for i in range(N,0,-1):
            if M%i == 0:
                ans = i
                break
else:
    for i in range(M//N,0,-1):
        if M%i == 0:
            ans = i
            break
            
print(ans)

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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  cout << (n + 1) / 2 << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));



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



	string s;
	cin >> s;
	if (s[0] == s[2]) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;
	return 0;
}



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

using namespace std;

int main() {
    int N, M;
    int sw;
    int ans = 0;

    cin >> N >> M;

    vector<vector<int> > lamp_con;
    vector<int> p(M);

    for (int i = 0; i < M; i++) {
	int k;
	cin >> k;

	vector<int> s(k);
	for (int j = 0; j < k; j++) {
            int x;
            cin >> s[j];
	}
        lamp_con.push_back(s);
    }

    for (int i = 0; i < M; i++) {
	cin >> p[i];
    }

    for (int sw = 0; sw < (1<<N); sw++) {
	bool flag = true;
	for (int i = 0; i < M; i++) {
            int cnt = 0;
            for (int j = 0; j < lamp_con[i].size(); j++) {
		if ( sw & (1 << (lamp_con[i][j]-1)) ) {
                    cnt++;
		}
            }
            if (cnt % 2 != p[i]) {
		flag = false;
		break;
            }
	}
        if (flag) {
            ans++;
	}
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
int main(void){
  
    long long  H,N;
	cin >> H >> N;
	vector<int> vec(N);
  long long sum = 0;
	for (auto& v : vec)
	{
		cin >> v;
        sum += v;
	}
    if (sum >= H) {cout << "Yes";}
    else {cout << "No";}
    
  
 return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	ll N, M;
	cin >> N >> M;

	ll rsl = 0;
	if(2 * N <= M) {
		rsl += N;
		M -= 2 * N;
		rsl += M / 4;
	} else {
		rsl += (M / 2);
	}
	cout << rsl << endl;


}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  
  val Array(n, t) = StdIn.readLine().split(" ").map(_.toInt)
  
  val r = (0 until n).map( _ => StdIn.readLine().split(" ").map(_.toInt))
    .filter(p => p(1) <= t)
    .sortBy(e => e(0))
 
  println(if(r.isEmpty) "TLE" else r(0)(0))
}


Measured memory_bytes: 26816
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
using Graph = vector<vector<int>>;
Graph G;
using Edge = pair<int,int>;
int main(void){
    // Your code here!
    int n,m;cin >> n >> m;
    vector<int> ans(n,INF);
    ans[0] = 0;
    G.resize(n);
    rep(i,m){
        int a,b;cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    queue<int> que;
    que.push(0);
    while(!que.empty()){
        int p = que.front();que.pop();
        int par = p+1;
        for(auto x:G[p]){
            if(ans[x]!=INF){
                continue;
            }
            ans[x] = par;
            que.push(x);
        }
    }
    if(MAX(ans) == INF) cout << "No" << endl;
    else {
        cout << "Yes" << endl;
        FOR(i,1,n-1){
            cout << ans[i] << endl;
        }
    }
}


Measured memory_bytes: 10348
#include<bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;


template <typename T>using ordered_set = tree<T, null_type, less<T>,rb_tree_tag, tree_order_statistics_node_update>;

#define PI              acos(-1.0)
#define en '\n'
#define Infi 0x3f3f3f3f
#define LInfi 0x3f3f3f3f3f3f3f3f



#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);


const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

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

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int  ll;
typedef unsigned long long int llu;

vector<int> cost;

int dp[1000005];
int k;
int make(int id){


    if(id>=cost.size()-1){
        return 0;
    }
    int p1=Infi,p2=Infi;

    if(dp[id]!=-1)return dp[id];

     for(int i=1;i<=k;i++){
        int a=Infi;

        if(id + i<cost.size()){
        a = abs(cost[id]-cost[id+i]) + make(id+i);
        }
        p1 = min(p1,a);

     }

    return dp[id] = p1;

}


int main(void){


    int n;
    cin >> n;
    cin >> k;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        cost.push_back(x);
    }

    for(int i=0;i<1000005;i++){
        dp[i]=-1;
    }
    //trace(cost);

    cout << make(0) << endl;

    return 0;
}


Measured memory_bytes: 12536
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int b,ten;
    int j=0;
    ten=0;
    while(1){
        if(j>=10){
            break;
        }
        cin>>b;
        ten+=b;
        j++;
    }
    cout<<ten<<endl;
    
}



Measured memory_bytes: 3096
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
typedef priority_queue<ll,vector<ll>,greater<ll>> PQIG;
typedef priority_queue<P,vector<P>,greater<P>> PQPG;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30); // 1073741824
const int INF = (1LL << 60); // 1152921504606846976
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}
template< typename T1, typename T2 > istream &operator>>(istream &is, pair< T1, T2 > &p) { is >> p.first >> p.second; return is; }



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];
    ll ans=0;
    ll s=0,x=0,r=0;
    rep(l,n){
        while(r<n && (s+a[r])==(x^a[r])){
            s+=a[r];
            x^=a[r];
            r++;
        }
        ans+=(r-l);

        if(r==l) r++;
        else{
            s-=a[l];
            x^=a[l];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef bool boool;
typedef long long ll;
#define vl vector<ll>
#define vb vector<boool>
#define vs vector<string>
#define vp vector<pair<ll, ll>>
#define vvl vector<vector<ll>>
#define vvp vector<vector<pair<ll, ll>>>
#define mod 1000000007
#define all(x) x.begin(), x.end()
#define rep1(i, n) for (long long i=0; i<(long long)(n); i++)
#define rep2(i, s, e) for (long long i=(s); i<(long long)(e); i++)
#define GET_MACRO(_1,_2,_3,NAME,...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

int main() {
    int x;
    cin >> x;
    if(x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3620
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n,length,sum;char ans[10000005];
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(n);
	printf("%d\n",n+n*n+n*n*n); 
	return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a, b;
  for (int i = 0; i < n; i++) {
    ll c, d;
    cin >> c >> d;
    a.push_back(c+d);
    b.push_back(c-d);
  }
  
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  ll ans = max((a[n-1] - a[0]), (b[n-1] - b[0]));
  cout << ans;
}

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

int main() {
  int D, G;
  cin >> D >> G;

  vector<long long> p(D);
  vector<long long> c(D);
  for (int i = 0; i < D; i++) {
    cin >> p.at(i) >> c.at(i);
  }

  long long res = 1 << 29;
  for (int bit = 0; bit < (1 << D); bit++) {
    long long sum = 0;
    long long num = 0;
    for (int i = 0; i < D; i++) {
      if (bit & (1 << i)) {
        sum += p.at(i) * (i + 1) * 100 + c.at(i);
        num += p.at(i);
      }
    }
    if (sum >= G)
      res = min(res, num);
    else {
      for (int i = D - 1; i >= 0; i--) {
        if (bit & (1 << i)) continue;
        for (int j = 0; j < p.at(i); j++) {
          if (sum >= G) break;
          sum += 100 * (i + 1);
          num++;
        }
      }
      res = min(res, num);
    }
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<23;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using IO::read;
using IO::write;
using IO::getc;
using IO::flush;

inline void Chkmin(int&u,int v){u>v?u=v:0;}

inline void Chkmax(int&u,int v){u<v?u=v:0;}

inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("water.in","r",stdin);
	freopen("water.out","w",stdout);
#endif
}

const int MAXN=3111;

static int n,a[MAXN];

vector<int>ed[MAXN];

static int d[MAXN];

inline void init()
{
	read(n);
	Rep(i,1,n)read(a[i]);
	static int u,v;
	Rep(i,1,n-1)
	{
		read(u),read(v);
		if(a[u]>a[v])ed[u].pb(v),++d[v];
		else if(a[v]>a[u])ed[v].pb(u),++d[u];
	}
}

static vector<int>ans;

void dfs(int u)
{
	if(a[u]<0)return;
	for(int v:ed[u])
	{
		dfs(v);
		if(a[v]^-1)a[u]=-1;
	}
	if(a[u]==-1)ans.pb(u);
	else a[u]=-2;
}

inline void solve()
{
	Rep(i,1,n)if(!d[i])dfs(i);
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();++i)
		printf("%d%c",ans[i],i==ans.size()-1?'\n':' ');
}

int main()
{
    init();
    solve();
	return 0;
}


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

using namespace std;

#define pb push_back
#define eb emplace_back
#define ll long long
#define pii pair < int, int >
#define fr first
#define sc second
#define mk make_pair
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()
#define ok puts("ok");
#define whatis(x) cerr << #x << " = " << x << endl;

const int N = (int)2e3 + 7;
const int inf = (int)1e9 + 7;
int mod = inf;

int pr[N];
vector < pii > gr[N];
vector < pair < int, pii > > edges;
bool edgeinmst[N];

int getpar(int a) {
  if (pr[a] == a) return a;
  return pr[a] = getpar(pr[a]);
}

void connect(int a, int b) {
  a = getpar(a);
  b = getpar(b);
  if (a != b) {
    pr[a] = b;
  }
}

int dfs(int v, int pr, int finish) {
  if (v == finish) {
    return 0;
  }
  for (auto to : gr[v]) {
    if (to.fr == pr)
      continue;
    int V = dfs(to.fr, v, finish);
    if (~V) return max(V, to.sc);
  }
  return -1;
}

ll pw[N];

main() {
  int n, m;
  pw[0] = 1;
  for (int i = 1; i < N; i++) {
    pw[i] = pw[i - 1] * 2LL % mod;
    pr[i] = i;
  }
  scanf("%d %d", &n, &m);
  ll x;
  scanf("%lld", &x);
  int a, b, c;
  for (int i = 1; i <= m; i++) {
    scanf("%d %d %d", &a, &b, &c);
    edges.pb(mk(c, mk(a, b)));
  }
  sort(all(edges));
  ll sum = 0;
  for (int i = 0; i < sz(edges); i++) {
    tie(a, b) = edges[i].sc;
    c = edges[i].fr;
    if (getpar(a) != getpar(b)) {
      connect(a, b);
      sum += c;
      gr[a].pb(mk(b, c));
      gr[b].pb(mk(a, c));
      edgeinmst[i] = 1;
    }
  }
  vector < int > vec;
  for (int i = 0; i < sz(edges); i++) {
    if (edgeinmst[i]) continue;
    vec.pb(edges[i].fr - dfs(edges[i].sc.fr, 0, edges[i].sc.sc));
  }
  int v1, v2;
  v1 = v2 = 0;
  for (int i : vec) {
    if (sum + i > x) {
      v1++;
    } else if (sum + i == x) {
      v2++;
    }
  }
  ll ans = 2ll * (pw[v2] + mod - 1) * pw[v1] % mod;
  if (sum == x) {
    ans = (ans + ((pw[n - 1] + mod - 2) * pw[m - n + 1] % mod)) % mod;
  }
  cout << ans;
}


Measured memory_bytes: 384
gets
d = [gets, gets].map{|v| v.split.map(&:to_f)}.transpose.map{|c| c.inject(:-).abs}
(1..4).each do |i|
  puts ((i == 4) ? d.max : d.map{|c| c**(i)}.inject(:+)**(1.0/i))
end

Measured memory_bytes: 8780
#include <iostream>

using namespace std;

typedef long long ll;

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

int main(void)
{
    ll N;
    ll A[100000];
    cin >> N;
    for (ll i = 0; i <= N; i++) {
        cin >> A[i];
    }

    ll L[N], R[N];
    L[0] = 0;
    for (ll i = 1; i < N; i++) {
        L[i] = gcd(L[i - 1], A[i - 1]);
    }
    R[N - 1] = 0;
    for (ll i = N - 2; i >= 0; i--) {
        R[i] = gcd(R[i + 1], A[i + 1]);
    }

    ll ans = -1;
    for (ll i = 0; i < N; i++) {
        ll d = gcd(L[i], R[i]);
        ans = ans < d ? d : ans;
    }
    cout << ans << endl;
}


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

#define ran 101101

int n, k;
char s[ran];
int ans[ran], la;

int main() {
	scanf("%d%d", &n, &k);
	scanf("%s", s);
	
	la = 0;
	int it = n, cnt = 0;
	while(it>0) {
		int last = it;
		it=max(0, it-k);
		while(s[it]=='1') it++;
		if(it>=last) {
			puts("-1");
			return 0;
		}
		ans[la++] = last - it;
	}
	for(int i=la-1;i>=0;i--)
		printf("%d%c", ans[i], i>0 ? ' ' : '\n');
	
	return 0;
}


Measured memory_bytes: 896
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> al = new ArrayList<Integer>();
        List<Integer> bl = new ArrayList<Integer>();
        List<Integer> cl = new ArrayList<Integer>();
        for(int i = 0; i < n; i++){
            al.add(sc.nextInt());
        }
        for(int i = 0; i < n; i++){
            bl.add(sc.nextInt());
        }
        for(int i = 0; i < n; i++){
            cl.add(sc.nextInt());
        }
        Collections.sort(al);
        Collections.sort(bl);
        Collections.sort(cl);
        int t = 0;
        int d = 0;
        long ans = 0;
        for(int i = 0; i < n; i++){
            while(t < n && al.get(t) < bl.get(i)){
                t++;
            }
            while(d < n && bl.get(i) >= cl.get(d) ){
                d++;
            }
            ans += (long)t * (long)(n-d);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 100268
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;

const int inf = numeric_limits<int>::max();


int main(){
    long int n;
    cin>>n;
    int ip[n];
    for(long int i = 0;i<n;i++){
        cin>>ip[i];
    }
    int cost[n] = { };
    cost[0] = 0;
    cost[1] = abs(ip[0]-ip[1]);
    for(long int i = 2;i<n;i++){
        cost[i] = min(cost[i-1] +(abs(ip[i]-ip[i-1])) ,cost[i-2]+(abs(ip[i]-ip[i-2])));
        
    }
    cout<<cost[n-1]<<"\n";
    

    
}


















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

deque<string> split_words(string s){
	bool flag = false;
	deque<string> words;
	string str;
	s.push_back(' ');

	for(unsigned int i=0 ; i < s.size() ; ++i ){
		char c = s[i];
		if( flag == false ){
			if( c != ' ' ){
				flag = true;
				str.clear();
				str.push_back( c );
			}
		}else{
			if( c != ' ' ){
				str.push_back( c );
			}
			if( c == ' ' ){
				flag = false;
				words.push_back( str );
				str.clear();
			}
		}
	}
	return words;
}

bool isOperator(string s){
	return ( s == "+" || s == "-" || s == "*" || s == "/" )? true : false ;
}

int s_to_i(string s){
	bool flag = false;
	int n = 0;

	for(unsigned int i=0 ; i < s.size() ; ++i ){
		if( i == 0 && s[i] == '-'){
			flag = true;
		}else{
			n *= 10;
			n += s[i] - '0';
		}
	}
	return (flag)? -n : n ;
}

double accum(double a, double b, string s){
	if( s == "+" )
		return a+b;
	else if( s == "-" )
		return a-b;
	else if( s == "*" )
		return a*b;
	else if( s == "/" )
		return a/b;
	return 0;
}


int main(){
	string s;
	while( getline( cin , s ) ){
		deque<string> words = split_words( s );
		stack<double> n;

		while( !words.empty() ){
			deque<string>::iterator it = words.begin();
			string str = *it;
			words.erase(it);
			if( isOperator( str ) ){
				double a = n.top();
				n.pop();
				double b = n.top();
				n.pop();
				n.push( accum( b , a , str ) );
			}else{
				n.push( s_to_i( str ) );
			}
		}
		//cout.setf( ios::showpoint );
		//cout.precision( 8 );
		printf("%.6lf\n", n.top() );
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define INF (int)1e9+1

using namespace std;

signed main() {
  IOS;
  int N,A,i,minuscnt=0,minval=INF,sum=0; //[100001]
  cin >> N;
  for (i = 0; i < N; i++) {
    cin >> A;
    sum += abs(A);
    minval = min(minval, abs(A));
    if (A < 0) minuscnt++;
  }

  cout << sum - ((minuscnt % 2) > 0 ? minval*2 : 0) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n,a,b,c;
  int G[200][200];

  cin >> n;
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      G[i][j] = 0;
    }
  }
  for(int i = 0 ; i < n ; i++){
    cin >> a >> b;
    a--;
    for(int i = 0 ; i < b ; i++){
      cin >> c;
      c--;
      G[a][c] = 1;
    }
  }
  for(int i = 0 ; i < n ; i++){
    for(int j = 0 ; j < n ; j++){
      if(j == 0)cout << G[i][j];
      else cout <<" "<< G[i][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1244
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner scan = new Scanner(System.in);
		int count = scan.nextInt();
		int min = 1000000;
		int max = -1000000;
		long sum = 0;
		int num = 0;
		for(int i = 0;i < count;i++)
		{
			num = scan.nextInt();
			sum = sum + num;
			if(num < min)
			{
				min = num;
			}
			if(num > max)
			{
				max = num;
			}
		}
		System.out.println(min + " " + max + " " + sum);
	}
}

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

int main()
{
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++)
	{
		cin >> v[i];
	}
	vector<int>v1(n);
	int ans = 0;

	for (int i = 0; i < n; i++)
	{
		cin >> v1[i];
		ans += v1[i];
	}
	vector<int>v2(n - 1);

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

	for (int i = 1; i < n; i++)
	{
		if (v[i] == v[i - 1] + 1)
		{
			ans += v2[v[i-1]-1];
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
lis = []
for i in range(2 ** 10):
    openls = []
    for j in range(10):
        if ((i >> j) & 1) == 1:
            openls.append(j)
    lis.append(openls)

f = []
for i in range(n):
    tmp = list(map(int, input().split()))
    f.append(tmp)

p = []
for i in range(n):
    tmp = list(map(int, input().split()))
    p.append(tmp)

ret = - 10 ** 1000

for item in lis:
    if sum(item) == 0:
        continue
    tmp = 0
    for i in range(n):
        same = 0
        for val in item:
            if f[i][val] == 1:
                same += 1
        tmp += p[i][same]
    ret = max(ret, tmp)

print(ret)


Measured memory_bytes: 43372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repi(i,x,n) for(ll i=x;i<(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1e18;
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};

ll BF(ll s,vector<vector<PL>>& v ,ll V){
  vector<ll> d(V,INF);
  d[s]=0;
  ll cnt=0;
  bool update=false;

  while(1){
    update=false;
    for(int i=0;i < V;i++)
    {
      for(int j=0;j < siz(v[i]);j++)
      {
        if(d[i] != INF && d[v[i][j].fi]> d[i]+v[i][j].se){
          update=true;
          d[v[i][j].fi]=d[i]+v[i][j].se;
          if(cnt==V-1){
              d[v[i][j].fi]=-INF;
          }
        }
      }
    }
    
    if(!update)break;
    cnt++;

    if(cnt>2*V){
        break;
    }
  }
  if(d[V-1]<-1e12){
      return INF;
  }else{
      return d[V-1];
  }
}

ll n,m,p,ans;
vector<vector<PL>> v(2510,vector<PL>(0));

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

    cin>>n>>m>>p;
    
    ll a,b,c;
    rep(i,m){//here?kasukasukasu
        cin>>a>>b>>c;
        a--;b--;
        v.at(a).pb({b,-(c-p)});
    }

    ans=BF(0,v,n);

    if(ans==INF){
        cout<<-1<<endl;
    }else{
        cout<<max(-ans,0ll)<<endl;
    }
}


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

int main() {
    unsigned long int n,a,b,sum=0;
    cin >> n;
    cin >> b;
    for (int i = 1; i < n; i++) {
        cin >> a;
        if (b >= a) {
            sum += b - a;
        } else {
            b = a;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <stack>
#include <algorithm>

using namespace std;

struct Channel{
	int channels[2];
	Channel(){
		channels[0] = -1;
		channels[1] = -1;
	}
	bool update(int index, int number){
		if(number > channels[index]){
			channels[index] = number;
			return true;
		}
		else
			return false;
	}
};

int number[10];
int n;

bool dfs(Channel c, int depth){
	if(depth == 10)
			return true;
	Channel c_tmp = c;
	return (c.update(0, number[depth]) && dfs(c, depth+1))
			|| (c_tmp.update(1, number[depth]) && dfs(c_tmp, depth+1));

}

void solve(){
	if(dfs(Channel(), 0))
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}

int main(){
	cin >> n;
	while(n--){		
		for(int i=0; i<10; ++i){
			cin >> number[i];
		}
		solve();
	}
	return 0;
}


Measured memory_bytes: 3008
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(key=lambda ab: -ab[1])
deadline = AB[0][1]
for a, b in AB:
  if b < deadline:
    deadline = b
  deadline -= a
if deadline < 0:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 61032
while True:
    try:
        a, b = list(map(int,input().split())), list(map(int, input().split()))
        print(sum([1 for i in range(4) if a[i] == b[i]]),
              sum([1 for i in range(4) for j in range(4) if i != j and a[i] == b[j]]))
    except:
        break

Measured memory_bytes: 7712
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(12)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
ll MOD=1000000007;
 
void solve()
{
	string s,t,u;
	cin>>s;
	ll n=s.size();
	for(ll i=0;i<n;i++)
	cout<<"x";
}
int main()
{
	solve();
}

Measured memory_bytes: 256
x = int(input())

def is_prime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return n != 1 # 1のときは例外


while True:
	if is_prime(x):
		print(x)
		break
	x += 1

Measured memory_bytes: 38384
#include<stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define chmax(p,q)(p=max(p,q))

ll dp[200010][3];//dp[i][j]=i番目まで見てi/2-1+j個取った
ll a[200010];
int main(){
	int n;
	scanf("%d",&n);
	rep(i,0,n)scanf("%lld",a+i);
	rep(i,0,n+1)rep(j,0,3)dp[i][j]=-INF;
	dp[0][1]=0;
	dp[1][1]=0;
	dp[1][2]=a[0];
	rep(i,1,n)rep(j,0,3){
		chmax(dp[i+1][j],dp[i-1][j]+a[i]);//a[i]をとる
		if(j-i%2>=0)chmax(dp[i+1][j-i%2],dp[i][j]);//a[i]をとらない
	}
	printf("%lld\n",dp[n][1]);
}


Measured memory_bytes: 7980
#include <stdio.h>
int main(void){
  int long long X,Y,Z;
  
  scanf("%lld",&X);
  Y=X/100;
  Z=100*Y+5*Y;
  if(X<=Z){
	printf("1");
  }
  else{
	printf("0");
  }
  return 0;
}

Measured memory_bytes: 128
# coding: utf-8
n,a_,b_=map(int,input().split())
l=[min(a_,n-a_),min(b_,n-b_)]
a,b=min(l),max(l)
mod=10**9+7
def pow_k(x,n):#いらない
    k=1
    #kは漏れたやつ
    while n>1:
        if n%2==1:
            k*=x
            n-=1
            k=k%mod
        x**=2
        x=x%mod
        n//=2
    
    return (k * x) % mod
    
#ans=pow_k(2,1000000000)
def modcomb(n,r,mod):
    X, Y =  1, 1
    r = min(r, n-r)
    for i in range(1,r+1):
        X = X * (n-i+1) % mod
        Y = Y * i % mod
    
    return X * pow(Y,mod-2,mod) % mod
ans=pow(2,n,mod)-1-modcomb(n,a,mod)-modcomb(n,b,mod)
print(ans%mod)

Measured memory_bytes: 38608
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

template<class T>bool chmax(T &a, const T &b) {
   if (a < b) {
      a = b;
      return 1;
   }
   return 0;
}
template<class T>bool chmin(T &a, const T &b) {
   if (a > b) {
      a = b;
      return 1;
   }
   return 0;
}

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

const ll kMod = 998244353;
ll N;
ll num[100010];

int main()
{
   cout << fixed << setprecision(10);
   cin >> N;
   int D;
   bool first = true;
   REP(i, N) {
      cin >> D;
      if (first) {
         if (D) {
            cout << 0 << endl;
            return 0;
         }
         first = false;
      } 
      num[D]++;
      eprintf("num[%d]=%d\n", D, num[D]);
   }
   if (num[0] > 1) {
      cout << 0 << endl;
      return 0;
   }
   ll ans = 1;
   bool zero = false;
   REP(i, N) {
      REP(j, num[i + 1]) {
         ans = ans * num[i] % kMod;
      }
      if (!num[i + 1]) {
         zero = true;
      } else if (zero) {
         cout << 0 << endl;
         return 0;
      }
   }
   cout << ans << endl;
   return 0;
}



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

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

    int start=0, miss=0, ans=1001;

    if(T.size()==S.size()){
        ans=0;
        start=0;
        for(int k=0; k<T.size(); k++){
            if(S[start++]!=T[k]){
                ans++;
            }
        }
    }

    else{
        for(int i=0; i<S.size()-T.size(); i++){
            start=i;
            miss=0;
            for(int k=0; k<T.size(); k++){
                if(S[start++]!=T[k]){
                    miss++;
                }
            }
            if(ans>=miss)
                ans=miss;
        }
    }

    if(ans==1001){
        cout << 0 << endl;
    }
    else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
inline int getint() {
    register char ch;
    while(!isdigit(ch=getchar()));
    register int x=ch^'0';
    while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
    return x;
}
int main(){
    std::multiset<std::string> set;
    for(register int i=getint();i;i--) set.insert("a");
    for(register int i=getint();i;i--) set.insert("b");
    for(register int i=getint();i;i--) set.insert("c");
    while(set.size()>1) {
        std::string s=*set.begin(),t=*set.rbegin();
        set.erase(set.lower_bound(s));
        set.erase(set.lower_bound(t));
        set.insert(s+t);
    }
    printf("%s\n",(*set.begin()).c_str());
    return 0;
} 

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double length = 2*r*pi;
        System.out.printf("%f %f", area,length);
        sc.close();
    }
}


Measured memory_bytes: 28236
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fi first
#define se second
int n , m , maxi , dx[5] , dy[5];
char grid[2000][2000];
bool cek[2000][2000];
typedef pair<pair<int , int>,int> iii;
iii a;
queue<iii>q;
int main(){
	cin >> n >> m;
	for(int i = 1 ; i <= n ; i++){
		for(int j = 1 ; j <= m ; j++){
			cin >> grid[i][j];
			if(grid[i][j] == '#'){
				q.push(mp(mp(i , j) , 0));
			}
		}
	}
	dx[1] = 1;
	dx[2] = -1;
	dx[3] = 0;
	dx[4] = 0;
	dy[1] = 0;
	dy[2] = 0;
	dy[3] = 1;
	dy[4] = -1;
	maxi = 0;
	while(!q.empty()){
		a = q.front();
		int x = a.fi.fi;
		int y = a.fi.se;
		int z = a.se;
		maxi = max(maxi , z);
		q.pop();
		if(cek[x][y])continue;
		cek[x][y] = true;
		for(int i = 1 ; i <= 4 ; i++){
			if(x + dx[i] < 1 || x + dx[i] > n || y + dy[i] < 1  || y + dy[i] > m)continue;
			q.push(mp(mp(x + dx[i], y + dy[i]) , z + 1));
		}
	}
	maxi -= 1;
	if(maxi < 0)cout << 0 << endl;
	else cout << maxi << endl;
}

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


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

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

// Lib
//

int main(){
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    int N; cin >> N;
    vector<double> v(N);
    for(int i = 0; i < N; ++i){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    for(int i = 1; i < N; ++i){
        v[i] += v[i-1];
        v[i] /= 2.0;
    }
    cout << v[N-1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>

typedef struct _POINT
{
    double x1;
    double y1;
    double x2;
    double y2;
} Point;

class IRectangle
{
public:
    virtual double getLength(Point& target) = 0;
};

class RightTriangle final : public IRectangle
{
public:
    double getLength(Point& target);
};

class OtherTriangle final : public IRectangle
{
public:
    double getLength(Point& target);
};

class Distance
{
private:
    IRectangle* pTriangle;
    Point point;

public:
    Distance();
    virtual ~Distance();

public:
    void run();

private:
    void read();
    void write();
    
};
/**************************************************
 *  definition
 **************************************************/
double RightTriangle::getLength(Point& target)
{
    double len1 = target.x2 - target.x1;
    double len2 = target.y2 - target.y1;
    return sqrt((len1 * len1) + (len2 * len2));
}

double OtherTriangle::getLength(Point& target)
{
    return 0;
}

Distance::Distance()
    : pTriangle(NULL)
{
    //point.x1 = point.x2 = point.y1 = point.y2 = 0;
}

Distance::~Distance()
{
    delete pTriangle;
}

void Distance::run()
{
    read();

    //(point.x2 - point.x1 == point.y2 - point.y1) ? pTriangle = new RightTriangle : pTriangle = new OtherTriangle;
    pTriangle = new RightTriangle;
    if (NULL == pTriangle)
        return;

    write();
}

void Distance::read()
{
    scanf("%lf %lf %lf %lf", &point.x1, &point.y1, &point.x2, &point.y2);
}

void Distance::write()
{
    printf("%f\n", pTriangle->getLength(point));
}

int main()
{
    Distance().run();
}


Measured memory_bytes: 2700
//AtCoder ABC100 B - Ringo's Favorite Numbers
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    ll D,N; cin>>D>>N;
    ll v=1;
    while(D>0){
        v*=100;
        --D;
    }
    if(N==100)++N; //100だと次へ
    ll ans=v*N;
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;

    int ans = a + b + c + d - min(min(a, b), min(c, d)) + max(e, f);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int N, M;
    cin >> N >> M;
 
    string A[50], B[50];
    for (int i = 0; i < N; i++)
        cin >> A[i];
 
    for (int i = 0; i < M; i++)
        cin >> B[i];
 
    for (int i = 0; i + M <= N; i++) {
        for (int j = 0; j + M <= N; j++) {
            bool flag = true;
            for (int k = 0; k < M; k++) {
                if (A[i + k].substr(j, M) != B[k]) {
                    flag = false;
                }
            }
            if (flag) {
                puts("Yes");
                return 0;
            }
        }
    }
    puts("No");
 
    return 0;
}

Measured memory_bytes: 256
# import itertools
# import pprint
import copy
from collections import deque

gem,ope = map(int,input().split())
vlist = deque(map(int,input().split()))

ans = 0

for l in range(ope+1):
  for r in range(ope-l+1):
    if l+r>ope or l+r>gem:
      break

    x   = ope-l-r
    now = []
    deq = copy.copy(vlist) 

    for i in range(l):
      now.append(deq.popleft())
    for j in range(r):
      now.append(deq.pop())
    for k in range(x):
      if now==[]:
        break
      if min(now)<0:
        now.remove(min(now))
    
    if ans<sum(now):
      ans = sum(now)

print(ans)


Measured memory_bytes: 3572
#include <stdio.h>
#define maxn 100010
#define LL long long
LL rd[maxn]={1,2,3,4,5,6,7,8,9};
int main(){
	int i,id,k;
	scanf("%d",&k);
	i=9,id=0;
	while(i<k){
		if(rd[id]%10==0){//10生成的2位数有100,101
			rd[i]=rd[id]*10;
			rd[i+1]=rd[id]*10+1;
			i+=2;
		}else if(rd[id]%10==9){//9生成的2位数有98,99
			rd[i]=rd[id]*10+8;
			rd[i+1]=rd[id]*10+9;
			i+=2;
		}else{//8生成的2位数有87,88,89
			rd[i]=rd[id]*10+rd[id]%10-1;
			rd[i+1]=rd[id]*10+rd[id]%10;
			rd[i+2]=rd[id]*10+rd[id]%10+1;
			i+=3;
		}
		id++;
	}
	printf("%lld\n",rd[k-1]);
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

bool prime(int p){
    int t = (int)sqrt(p);
    for(int i = 2; i <= t; i++){
        if(p % i == 0) return false;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    vector<int> ans;
    int x = 11;
    while(cnt < n){
        if(prime(x)){
            ans.push_back(x);
            cnt++;
        }
        x += 10;
    }
    for(int i = 0; i < n; i++){
        cout << ans[i];
        if(i < n - 1) cout << " ";
        else cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
X = int(input())

if(0 <= X and X <500):
    q,mod = divmod(X,5)
    Q1 = 5*q
    print(Q1)
if(500 <= X):
    q,mod = divmod(X,500)
    if(5 <= mod):
        q1,mod1 = divmod(mod,5)
    else:
        q1 = 0
    Q = 1000*q + 5*q1
    print(Q)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
ll arr[200005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string a,b;
    cin>>a>>b;
    ll x,y;
    cin>>x>>y;
    string ch;
    cin>>ch;
    if(ch==a)
    {
        x--;
    }
    else y--;
    cout<<x<<" "<<y<<endl;
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

ll mod_pow(ll x, ll n, ll mod) {
	if (n == 0) return 1;
	ll res = mod_pow(x * x % mod, n / 2, mod);
	if (n & 1) res = res * x % mod;
	
	return res;
}

vector<ll> fact, inv;
void fact_inv(int n, ll mod) {
	fact.resize(n + 1);
	inv.resize(n + 1);
	
	fact[0] = 1;
	FOR(i, 1, n + 1) fact[i] = fact[i - 1] * i % mod;
	inv[n] = mod_pow(fact[n], mod - 2, mod);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % mod;
}

ll ncr(ll n, ll r, ll mod) {
	if (n < r || r < 0 || n < 0) return 0;
	return fact[n] * inv[r] % mod * inv[n - r] % mod;
}

int n;
int a[112345];
bool done[112345];

int main() {
	cin >> n;
	REP(i, n + 1) scanf("%d", a + i);
	
	fact_inv(212345, MOD);
	
	int db = -1;
	REP(i, n + 1) {
		if (done[a[i]]) db = a[i];
		done[a[i]] = true;
	}
	
	int l = -1, r = -1;
	REP(i, n + 1) {
		if (a[i] == db) {
			if (l == -1) l = i;
			else r = i;
		}
	}
	
	FOR(k, 1, n + 2) {
		ll ans = 0;
		// (l),(r)
		if (n - 1 >= k) ans += ncr(n - 1, k, MOD);
		// l, rを取る
		if (n - 1 >= k - 2) ans += ncr(n - 1, k - 2, MOD);

		// lを取りrを取らない
		if (n - 1 >= k - 1) ans += ncr(n - 1, k - 1, MOD);
		
		// lを取らずrを取る
		if (n - 1 >= k - 1) ans += ncr(n - 1, k - 1, MOD);
		
		ll c2 = r - l - 1;
		if (n - 1 >= k - 1) ans -= ncr(n - 1 - c2, k - 1, MOD);
		
		ans = ((ans % MOD) + MOD) % MOD;
		
		printf("%lld\n", ans);
	}
	
	return 0;
}


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

int main() {
    int k;
    cin >> k;
    int ans = 0;
    for(int a = 1; a <= k; a++){
        for(int b = 1; b <= k; b++){
            for(int c = 1; c <= k; c++){
                ans += gcd(gcd(a, b), c);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
import sys
import math
def i():return int(sys.stdin.readline().replace("\n",""))
def i2():return map(int,sys.stdin.readline().replace("\n","").split())
def s():return str(sys.stdin.readline().replace("\n",""))
def l():return list(sys.stdin.readline().replace("\n",""))
def intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def lx():return list(map(lambda x:int(x)*-1,sys.stdin.readline().replace("\n","").split()))
def t():return tuple(map(int,sys.stdin.readline().replace("\n","").split()))

def main():
    n,m = i2()
    a = intl()
    print(n-sum(a) if n - sum(a) >= 0 else -1)
if __name__ == "__main__":
    main()

Measured memory_bytes: 10096
#include<stdio.h>
#include<string.h>
int main()
{
    long int i, a=0, l, count=0;
    char str[200000];
    scanf("%s", str);
    l=strlen(str);
    for(i=0; i<l; i++)
    {
        if(str[i]=='A')
        {
            count++;
        }
        else if (str[i] == 'B' && str[i+1] == 'C')
        {
            a+=count;
            i++;
        }
        else
        {
            count=0;
        }
    }
    printf("%ld", a);
    return 0;
}

Measured memory_bytes: 384