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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

bool solve() {
	int H, W; cin >> W >> H;
	if (H == 0 && W == 0) return (false);
	vector<string> S(H); cin >> S;
	vector<vector<string>> dp(H, vector<string>(W));
	int length = 0;
	string maxv = "";
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (isdigit(S[i][j])) {
				string &t = dp[i][j];
				if (S[i][j] != '0') t += S[i][j];
				if (i > 0 && isdigit(S[i-1][j])) {
					string s = dp[i-1][j] + S[i][j];
					if (s.size() != 1 || S[i][j] != '0') {
						if (s.size() > t.size()) t = s;
						if (s.size() == t.size()) chmax(t, s);
					}
				}
				if (j > 0 && isdigit(S[i][j-1])) {
					string s = dp[i][j-1] + S[i][j];
					if (s.size() != 1 || S[i][j] != '0') {
						if (s.size() > t.size()) t = s;
						if (s.size() == t.size()) chmax(t, s);
					}
				}
					
				if (chmax(length, (int)t.size())) {
					maxv = t;
				} else if (length == (int)t.size()) chmax(maxv, t);
			}
		}
	}
	cout << maxv << el;
	return (true);
}

void Main() {
	while (solve());
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}



Measured memory_bytes: 3364
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define GODSPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;
int add(int a,int b){return (a%mod + b%mod)%mod;}
int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
int mul(int a,int b){return (a%mod * b%mod)%mod;}
int power(int a,int b,int MOD){int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
signed main()
{
    GODSPEED;
    string s;
    cin>>s;
    string res;
    for(auto x:s)
    {
         if(x=='0')
          res+='0';
        else if(x=='1')
          res+='1';
        else if((int)res.length()>0)
          res.pop_back();
    }
    cout<<res<<endl;
    return 0;
}

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

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int mod=1e9+7;
int add(int x,int y)
{
  x+=y;
  if(x>=mod) x-=mod;
  if(x<0) x+=mod;
  return x;
}
int mult(int x,int y)
{
  ll tmp=(ll)x*y;
  if(tmp>=mod) tmp%=mod;
  return tmp;
}
int pow1(int x,int y)
{
  int ans=1;
  while(y)
    {
      if(y&1) ans=mult(ans,x);
      x=mult(x,x);
      y>>=1;
    }
  return ans;
}
int s,ans;
int calc(int x)
{
  int cnt=0;
  while(x) x/=10,cnt++;
  return cnt;
}
const int N=25000000;
int sum[N];
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  cin>>s;
  //first take if range belongs to only within same digits
  int sq=sqrt(s);
  rep(i,1,sq+1)
    {
      if((s%i)!=0) continue;
      int x=s/i;
      int curr=mult(9,pow1(10,i-1));
      if(i>7) ans=add(ans,add(curr,-(x-1)));
      if(x==i) continue;
      if(s/i>7) ans=add(ans,add(mult(9,pow1(10,x-1)),-(i-1)));
    }
  //look for adjacent, there can;t be more than 2 adjacent if x>8
  /* ax+b(x+1)=S
     so a=(S-b)/x - b, where x is number of digits,
     so b will be of the form k*x+(S%x)
     so a = (S/x + k - (k*x + S%x)), it should be greater than 0,
     so k< (S/x - S%x) / (x-1)*/
  rep(i,8,s)
    {
      if(s%i==0)
	{
	  int tmp=s/i;
	  if(tmp%(i+1)==0) ans=add(ans,max(0,-1+tmp/(i+1)));
	  else ans=add(ans,tmp/(i+1));
	}
      else
	{
	  int k=s/i-(s%i);
	  if(k<0) continue;
	  if(k%(i+1)==0) ans=add(ans,k/(i+1));
	  else ans=add(ans,1+k/(i+1));
	}
    }
  //for first 7, there can be any number of adjacent
  rep(i,1,N)
    sum[i]=sum[i-1]+calc(i);
  int i=1,j=1;
  while(i<1e7)
    {
      while(j<N && sum[j]-sum[i-1]<s) j++;
      if(j<N && sum[j]-sum[i-1]==s) ans=add(ans,1);
      i++;
    }
  cout<<ans<<endl;
  return 0 ;
}


Measured memory_bytes: 97920
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			long k = sc.nextLong();
			
			long n = 50;
			long base = (k / n) + n-1;
			int x = (int) (k % n);
			
			System.out.println(n);
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < x;i++){
				sb.append(" ");
				sb.append(base + n  - x + 1);
			}
			for(int i = 0; i < n - x; i++){				
				sb.append(" ");
				sb.append(base - x);
			}
			System.out.println(sb.substring(1));
			
		}
	}


	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define F first 
#define S second 
#define endl "\n"
#define Endl "\n"
#define emdl "\n"
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
bool sortBy(const pair<int,int> &a,const pair<int,int> &b){
	if(a.F==b.F)
		return a.S<b.S;
	return a.F>b.F;
}

// #define MAXN 1001
// int pf[MAXN]; 
// void sieve(){
// 	long long int i,j; 
//     pf[1] = 1; 
//     for (i=2; i<MAXN; i++) 
//     pf[i] = i;   
//     for (i=2; i*i<MAXN; i++){ 
//         if (pf[i] == i){
//             for (j=i*i; j<MAXN; j+=i) 
//                 if (pf[j]==j) 
//                     pf[j] = i; 
//         } 
//     } 
// }
// vector<int> factors(int x){ 
//     vector<int> ret; 
//     while (x != 1){ 
// 		int fact=pf[x];
//         ret.push_back(pf[x]); 
// 		while(fac!=1&&x%fact==0)
//         x/=fact; 
//     } 
//     return ret; 
// } 
// set<long long int>poww;
// void init(){
// 	long long int temp=1;
// 	for(int i=1;i<43;i++){
// 		poww.insert(temp);
// 		temp*=2;
// 	}
// }  
// long long int power(long long int a,int n){
//     if(n==1)
//     return a;
//     if(n%2){
//         return power()
//     }
// }
int cnt=0;
set<int> v[200005];
int vis[200005];

void dfs(int u){
    vis[u]=1;
    cnt++;
    for(auto ch:v[u]){
        if(!vis[ch]){
            dfs(ch);
        }
    }

}
int main() {		
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	int qwe=1;
	//cin>>qwe;
	//init();
	// sieve();
	while(qwe--){
        int n,m,l,r;
        cin>>n>>m;
        int ans=0;
        for(int i=0;i<m;i++){
            cin>>l>>r;
            v[l].insert(r);
            v[r].insert(l);
        }
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                dfs(i);
                ans=max(ans,cnt);
                cnt=0;
            }
        }
        cout<<ans;




	}

	return 0;
}


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

using namespace std;

int main()
{
    int d,p;
    cin >> d >> p;
    char dp[d][p];
    bool a[d]={0},b[p]={0};
    for(int i=0;i<d;i++)
    {
        for(int j=0;j<p;j++)
        {
            cin >> dp[i][j];
            if(dp[i][j]=='#')
            {
                a[i]=1;
                b[j]=1;
            }
        }
    }
    bool h=0;
    for(int i=0;i<d;i++)
    {
        for(int j=0;j<p;j++)
        {
            if(a[i]==1&&b[j]==1)
            {
                cout << dp[i][j];
                h=1;
            }
        }
        if(h)
        {
            cout << endl;
            h=0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long  map[101][101];
long long INF = (1LL<<32);
int n;
int adjust = 0;
void solve(){
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (map[j][i] == INF) continue;
			for (int k = 0; k < n; k++) {
				if(map[i][k] == INF ) continue;
				map[j][k] = min(map[j][k], map[j][i] + map[i][k]);
			}
		}
	}
}
int main(void) {
	int m;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			map[i][j] = (i == j) ? 0 : INF;
		}
	}
	
	for (int i = 0; i < m; i++) {
		int a, b,c;
		cin >> a >> b>>c;
		map[a][b] = c;
	}
	solve();
	for (int i = 0; i < n; i++) if (map[i][i] < 0) adjust = 1;
	if (adjust) cout << "NEGATIVE CYCLE" << endl;
	else {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (j) cout << " ";
				if (map[i][j] == INF) cout << "INF";
				else { cout << map[i][j]; }
			}
			cout << endl;
		}
	}
}


Measured memory_bytes: 3180
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int ans = 0;
    auto rec = [&](auto &&rec, ll a, int b, int c, int d) -> void {
        if (a > n) return;
        if (b && c && d) ans++;
        rec(rec, a*10+3, b+1, c, d);
        rec(rec, a*10+5, b, c+1, d);
        rec(rec, a*10+7, b, c, d+1);
    };

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;
const ll MOD = 998244353;

ll N, A, B, K, a, b, x;
ll nCk[300010];

ll mp(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if (b % 2)
			ans *= a;
		a *= a;
		a %= MOD;
		ans %= MOD;
		b /= 2;
	}
	return ans;
}

//mod割り算
ll moddiv(ll a, ll b) {
	a %= MOD;
	return (a*mp(b, MOD - 2)) % MOD;
}

int main(){
	
	cin >> N >> A >> B >> K;

	nCk[0] = 1;
	for (int i = 1;i <= N;i++) {
		nCk[i] = moddiv(nCk[i - 1] * (N + 1 - i) % MOD, i);
	}

	ll ans = 0;
	for (int i = 0;i <= N;i++) {
		if ((K - i * A) % B == 0) {
			a = i, b = (K - i * A) / B;
			if (b > N || b < 0)continue;
			ans += nCk[a] * nCk[b];
			ans %= MOD;
		}
	}
	cout << ans << endl;
}

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

int rec(int n, int k, int s) {
  if (n == 1) {
    return 0;
  }
  int x = k % (n - 1);
  if (x == 0) {
    x = n - 1;
  }
  x += s;
  x %= n;
  x -= x > s;
  int r = rec(n - 1, k, x);
  if (r < s) {
    return r;
  } else {
    return r + 1;
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k, s;
  while (cin >> n >> k >> s, n) {
    --s;
    cout << rec(n, k, s) + 1 << '\n';
  }
}



Measured memory_bytes: 3288
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);

  for(int i = 0;i < N;i++)cin >> A[i];
  for(int i = 0;i < N;i++)cin >> B[i];

  for(int i = 1;i < N;i++)A[i] = A[i] + A[i-1];
  for(int i = N-2;i >= 0;i--)B[i] = B[i] + B[i+1];



  int ans = 0;
  for(int i = 0;i < N;i++)ans = max(ans,A[i]+B[i]);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll f(ll h) {
    if(h == 1) {
        return 1;
    }
    return 2*f(h/2) + 1;
}

int main() {
    ll h;
    cin >> h;
    out(f(h));
    re0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <istream>
#include <ostream>

#include <cstdlib>
#include <cmath>
#include <cstdio>

using namespace std;

#define fi first
#define se second
#define mkp make_pair
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define rep(i,n) for(ll i=0; i < (n); ++i)
#define rrep(i,n) for(ll i=((n)-1); i >= 0; --i)

#define OPLT(T) bool operator<(const T & lop_, const T & rop_)
#define OPEQ(T) bool operator==(const T & lop_, const T & rop_)

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

istream& operator>>(istream& istr, __float128& obj) { double d; istr >> d; obj = d; return istr; };
ostream& operator<<(ostream& ostr, __float128& obj) { ostr << static_cast<double>(obj); return ostr; };

ll cmb[60][60];

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	vector<ll> v(N);
	rep(i,N) { cin >> v[i]; }
	sort(all(v));
	reverse(all(v));
	ll sum = 0;
	bool flg = true;
	rep(i,A) {
		sum += v[i];
		if(i && v[i-1] != v[i]) flg = false;
	}
	printf("%.10f\n", 1.0 * sum / A);
	rep(i,60) cmb[i][0] = 1;
	for(int i = 1; i < 60; i++) {
		for(int j = 1; j < 60; j++) {
			cmb[i][j] = cmb[i-1][j] + cmb[i-1][j-1];
		}
	}
	ll res = 0;
	if(flg) {
		int cnt = 0;
		rep(i,N) {
			if(i && v[i-1] != v[i]) break;
			cnt++;
		}
		for(int i = A; i <= min(B,cnt); i++) {
			res += cmb[cnt][i];
		}
	}
	else {
		int cnt = 0;
		int cnt1 = 0;
		rep(i,N) {
			if(i < A) {
				if(i && v[i-1] == v[i])
					cnt1++;
				else
					cnt1 = 1;
			}
			if(i >= A && v[i-1] != v[i])
				break;
			if(i && v[i-1] == v[i])
				cnt++;
			else
				cnt = 1;
		}
		res = cmb[cnt][cnt1];
	}
	printf("%lld\n", res);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

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

    if (abs(c - a) <= d || (abs(c - b) <= d && abs(b - a) <= d)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

int compareTo(string s1,string s2)
{
	int len = min(s1.size(),s2.size());
	for(int i=0;i<len;i++)
	{
		if(s1[i] > s2[i])
		{
			return 1;
		}
		if(s1[i] < s2[i])
		{
			return -1;
		}
	}
	return 0;
}

void sort(string a[],int n)
{
	int i = 0,j=n-1;
	string pivot = a[(i+j)/2];

	while(true)
	{
		while( compareTo(a[i],pivot) == -1 )i++;
		while( compareTo(a[j],pivot) == 1 )j--;

		if( i >= j )break;

		string hold = a[i];
		a[i] = a[j];
		a[j] = hold;

		i++;
		j--;
	}

	if( i > 1 )sort(a,i);
	if( n-j-1 > 1 )sort(a+j+1,n-j-1);
}

int main()
{
	int N,L;
	string S[110];

	cin >> N >> L;

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

	sort(S,N);

	for(int i=0;i<N;i++)
	{
		cout << S[i];
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
int main(void){
  int k;
  char cha[100];
  
  scanf("%d",&k);
  scanf("%s",cha);
  
  if(strlen(cha)<=k){
   printf("%s",cha);
  }else{
  	for(int i=0;i<k;i++){
      printf("%c",cha[i]);
  }
    printf("...\n");
  return 0;
  }  
 
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct union_find {
    vector<int> data;
    int comp;
    union_find(int size) : data(size, -1), comp(size) {}
    void unite(int x, int y) {
        x = root(x); y = root(y);
        if(x != y) {
            if(data[y] < data[x]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
            comp--;
        }
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : (data[x] = root(data[x]));
    }
    int size(int x) {
        return -data[root(x)];
    }
    int components() { return comp; }
};

signed main() {
    int N, K, L;
    cin >> N >> K >> L;
    union_find road(N), railway(N);
    rep(i, 0, K) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        road.unite(a, b);
    }
    rep(i, 0, L) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        railway.unite(a, b);
    }
    map<pii, int> cnt;
    rep(i, 0, N) {
        int x = road.root(i);
        int y = railway.root(i);
        cnt[{x, y}]++;
    }
    rep(i, 0, N) {
        int x = road.root(i);
        int y = railway.root(i);
        cout << cnt[{x, y}] << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 15104
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let a: Vec<usize> = (0..N).map(|_| read()).collect();
    let mut max = 0;
    let mut ans = 0;
    for v in a {
        if max <= v {
            max = v;
        } else {
            ans += max - v;
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

string s;
int main() {
  cin >> s;
  sort(begin(s), end(s));
  if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) 
    cout << "Yes\n";
  else 
    cout << "No\n";
  return 0;
}



Measured memory_bytes: 764
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int a[n];
  int i, tmp, flag;
  int alice = 0;
  int bob = 0;
  
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
	
  do{
    flag = 0;
    for(i = 0; i < n - 1; i++){
      if(a[i] < a[i + 1]){
        tmp = a[i];
        a[i] = a[i + 1];
        a[i + 1] = tmp;
        flag = 1;
      }
    }
  }while(flag == 1);
  
  for(i = 0; i < (n / 2); i++){
    alice += a[2 * i];
    bob += a[2 * i + 1];
  }
  if(n % 2 == 1) alice += a[n - 1];
  
  printf("%d\n", alice - bob);
  return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, c, d, k;
  cin >> a >> b >> c >> d >> k;
  
  int be = 60 * a + b, en = 60 * c + d;
  
  cout << en - be - k << '\n';
}

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

int ret(int x){
    if(x >= 4) return 0;
    else if(x == 3){
        return 100000;
    }else if(x == 2){
        return 200000;
    }else{
        return 300000;
    }
}

int main(){
    int x,y; cin >> x >> y;
    int ans = 0;
    ans += ret(x);
    ans += ret(y);
    if(x == 1 && y == 1) ans += 400000;
    cout << ans << endl;
}

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

typedef long long ll;


int n, L;
int a[100000];


int main(){
    cin >> n >> L;
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    bool check = false;
    int index = -1;

    for (int i = 0; i < n-1; i++){
        if (a[i+1] + a[i] >= L){
            check = true;
            index = i;
            break;
        }
    }

    if (check){
        cout << "Possible" << endl;
        for (int i = 1; i <= index; i++){
            cout << i << endl;
        }
        for (int i = n-1; i > index; i--){
            cout << i << endl;
        }

    } else {
        cout << "Impossible" << endl;
    }
}


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

int main(){
    int a,b,k;
    cin>>a>>b>>k;
    for(int i=a;i<a+k&&i<=b;i++){
        cout<<i<<endl;
    }
    for(int i=a+k;i<=b;i++){
        if(i+k>b)cout<<i<<endl;
    }
}


Measured memory_bytes: 256
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 t = 1;
		int r = 1;
		int f = 0;
		while ( f == 0 ) {
			t = t * k;
			if ( n < t ) {
				f = 1;
			} else {
				r++;
			}
		}
		System.out.println(r);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vector<ll> a(n), b(n);
	for (ll i = 0; i < n; i++) cin >> a[i] >> b[i];
	sort(all(a));
	sort(all(b));

	ll l, r;
	if (n % 2) {
		l = a[n / 2] * 2;
		r = b[n / 2] * 2;
	}
	else {
		l = a[n / 2 - 1] + a[n / 2];
		r = b[n / 2 - 1] + b[n / 2];
	}

	if (n % 2) {
		cout << (r - l + 1) / 2 + 1 << endl;
	}
	else {
		cout << r - l + 1 << endl;
	}
}


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

bool isvowel(char c){
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o')return true;
  return false;
}

int main()
{
  int n;
  string s[101];

  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=0;i<n;i++)cin>>s[i];

    string t[101]={};
    for(int i=0;i<n;i++){
      t[i]+=s[i][0];
      for(int j=1;j<s[i].length();j++){
	if(isvowel(s[i][j-1]))t[i]+=s[i][j];
      }
    }
    int ans=-1;
    for(int k=1;k<51;k++){
      set<string> st;
      for(int i=0;i<n;i++)st.insert(t[i].substr(0,k));
      if(st.size()==n){
	ans=k;
	break;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1236
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
h = readints()

jmp = 0
ans = 0
for i in range(n-1):
    if h[i] >= h[i+1]:
        jmp += 1
    else:
        ans = max(ans, jmp)
        jmp = 0
ans = max(ans, jmp)
print(ans)


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

int main(){
	long double a, sum=0.0;
	
	while(1){
		cin>>a;
		if(cin.eof())break;
		sum=a;

		for(int i=2; i<=10; i++){
			if(i%2==0){
				a*=2;
				sum+=a;
			}else{
				a/=3;
				sum+=a;
			}
		}
		cout<<setprecision(10);
		cout<<sum<<"\n";
	}

	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define lld I64d
using namespace std ;
template < class R > inline void Readin( R &K ) {
	K = 0 ; bool F = false ; char C = getchar() ; while( C < '0' or C > '9' ) { if( C == '-' ) F = true ; C = getchar() ; }
	while( C <= '9' and C >= '0' ) K = ( K << 1 ) + ( K << 3 ) + C - '0' , C = getchar() ; if( F ) K = -K ;
}
const int Mod = 998244353 ;
const int Inv2 = Mod + 1 >> 1 ;
const int MaxN = 300 + 10 ;
int N , A[MaxN] , Dp[MaxN*MaxN] , S , Ans ;
inline void Moding( int &A ) {
	if( A >= Mod ) A -= Mod ;
	if( A < 0 ) A += Mod ;
}
inline int Pow( int A , int B ) {
	register int Ans = 1 ;
	while( B ) {
		if( B & 1 ) Ans = 1ll * Ans * A % Mod ;
		A = 1ll * A * A % Mod ;
		B >>= 1 ;
	}
	return Ans ;
}
inline int Simple() {
	S = 0 ;
	memset( Dp , 0 , sizeof Dp ) ;
	Dp[0] = 1 ;
	for(register int i = 0 ; ++i <= N ; ) {
		for(register int j = S ; j >= 0 ; --j )
			Moding( Dp[j+A[i]] += Dp[j] ) ;
		S += A[i] ;
	}
	return Dp[S>>1] ;
}
int main() {
	scanf( "%d" , &N ) ;
	for(register int i = 0 ; ++i <= N ; Readin( A[i] ) ) ;
	Dp[0] = Pow( 2 , N ) ;
	for(register int i = 0 ; ++i <= N ; ) {
		for(register int j = S ; j >= 0 ; --j )
			Moding( Dp[j+A[i]] += 1ll * Dp[j] * Inv2 % Mod ) ;
		S += A[i] ;
	}
	for(register int i = S - 1 >> 1 ; ++i <= S ; )
		Moding( Ans -= Dp[i] ) ;
	if( S % 2 == 0 ) Moding( Ans += Simple() ) ;
	Ans = 3ll * Ans % Mod ;
	Moding( Ans = Pow( 3 , N ) + Ans ) ;
	return not printf( "%d\n" , Ans ) ;
}

Measured memory_bytes: 640
program ccc
implicit none

integer :: n, k, i, j
integer,allocatable,dimension(:) :: m
real(8) :: res

read*, n, k
allocate(m(n))
m=0

do i=1,n
 j=i
 do while(j<k)
 j=j*2
 m(i)=m(i)+1
 end do
end do

res=0

do i=1,n
res=res+0.5D0**m(i)
end do

res=res*(1/dble(n))

write(*,*) res

end program

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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    set<string> s;
    for (int i = 0; i < n; i++) {
        string x;
        cin >> x;
        s.insert(x);
    }
    cout << s.size();

    return 0;
}

Measured memory_bytes: 19220
#include <stdio.h>

int p[1000000];

int main()
{
	int n;
	int i, j;
	
	for (i = 2; i < 1000000; i++){
		p[i] = 1;
	}
	
	for (i = 2; i * i < 1000000; i++){
		for (j = i * i; j < 1000000; j += i){
			p[j] = 0;
		}
	}
	
	for (i = 1; i < 1000000; i++){
		p[i] += p[i - 1];
	}
	
	while (scanf("%d", &n) != EOF){
		printf("%d\n", p[n]);
	}
	
	return (0);
}

Measured memory_bytes: 4500
use std::io::Read;

fn rec(v: usize, p: usize, g: &Vec<Vec<usize>>, visit: &mut Vec<i32>) -> usize {
    visit[v] = 1;
    let mut out_count = 0;
    for &w in g[v].iter() {
        if w == p || visit[w] == 2 {
            continue;
        } else if visit[w] == 1 {
            println!("{} {}", v + 1, w + 1);
            out_count += 1;
        } else {
            let subtree_oc = rec(w, v, g, visit);
            if subtree_oc % 2 == 0 {
                println!("{} {}", v + 1, w + 1);
                out_count += 1;
            } else {
                println!("{} {}", w + 1, v + 1);
            }
        }
    }
    visit[v] = 2;
    out_count
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n = iter.next().unwrap().parse().unwrap();
    let m = iter.next().unwrap().parse().unwrap();
    let mut g = vec![vec![]; n];
    for _ in 0..m {
        let mut a: usize = iter.next().unwrap().parse().unwrap();;
        let mut b: usize = iter.next().unwrap().parse().unwrap();;
        a -= 1;
        b -= 1;
        g[a].push(b);
        g[b].push(a);
    }

    if m % 2 == 1 {
        println!("-1");
    } else {
        let mut visit = vec![0; n];
        rec(0, 0, &g, &mut visit);
    }
}


Measured memory_bytes: 32380
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <functional>

using namespace std;



int main(void){
    int N;
    scanf("%d",&N);
    unordered_multiset<int> S;
    int a[N];
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
        S.insert(a[i]);
        
    }
    int ans=0;
    sort(a,a+N);
    for(int i=N-1;i>=0;i--){
        int atai = 1<<(32- __builtin_clz(a[i]) );
        //printf("%d\n",atai);
            if(S.find(a[i])!=S.end()&&S.find(atai-a[i])!=S.end()){
                if(a[i]!=atai-a[i]){
                    int kaisu=min(S.count(a[i]),S.count(atai-a[i]));
                    for(int j=0;j<kaisu;j++){
                    ans++;
                    S.erase(S.find(a[i]));
                    S.erase(S.find(atai-a[i]));
                    i--;
                    }
                    i++;
                }
                else{
                    if(S.count(a[i])>=2){
                        int kaisu=S.count(a[i])/2;
                        for(int j=0;j<kaisu;j++){
                        S.erase(S.find(a[i]));
                        S.erase(S.find(a[i]));
                        ans++;
                        i--;
                        }
                        i++;
                    }
                }
            }
        
    }
    printf("%d",ans);
    
    return 0;
}

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

int k,n;
string s;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>k>>s;
	n = s.length();
	if(n <= k){
		cout<<s<<endl;
	}else{
		for(int i = 0;i < k;i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(void){

    int N; cin>>N;
    vector<int> a(3*N);
    for (int i = 0; i < 3*N; ++i) {
        cin>>a[i];
    }
    sort(a.rbegin(), a.rend());
    ll sum=0;
    for (int i = 0; i < 2*N; ++i) {
        if(i%2!=0) sum+=a[i];
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
using namespace std;
int main(){
    string s,t,u;
    int a,b;
    cin>>s>>t>>a>>b>>u;
    if(s==u){
        a--;
    }
    if(t==u){
        b--;
    }
    cout<<a<<" "<<b;
}

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

using namespace std;


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

	  string s;
	  char v[2] = {'e','s'};

     cin >> s;

	 int len = s.size()-1;

     if(s[len]=='e')
      {
          s = s+v[1];
	  }
	 else if(s[len]=='s')
	 {
		 s = s+v[0]+v[1];
	 }
	 else
		 s = s+v[1];


	 cout << s ;
}


Measured memory_bytes: 3608
N = int(input())
P = list(map(int,input().split()))

ans = 0

if P[-1] == N:
  ans += 1
  P[-1] = -1
  if P[-2] == N - 1:
    P[-2] = -1

for i in range(N-1):
  if P[i] == i + 1:
    ans += 1
    if P[i+1] == i + 2:
      P[i+1] = -1
      
print(ans)

Measured memory_bytes: 20520
use std::io::*;

fn main() {
  let stdin = stdin();
  let mut lines = stdin.lock().lines();

  let n = lines.next().unwrap().unwrap().parse::<usize>().unwrap();
  let mut array = lines.take(n).map(|s| s.unwrap().parse::<u32>().unwrap()).collect::<Vec<_>>();
  array.sort();

  let mut vec = Vec::with_capacity(12);

  for a in array.iter().take(4) {
    for b in array.iter().take(4) {
      if a == b { continue; }

      let log = (*b as f64).log10() as u32;
      vec.push(a * 10u32.pow(log + 1) + b);
    }
  }

  vec.sort();

  println!("{}", vec[2]);
}



Measured memory_bytes: 5164
def r;gets.split.map &:to_i;end
class UnionFind
  def initialize(n, &block)
    @par = Array.new(n,&:itself)
    @rank = Array.new(n,1)
    instance_eval(&block) if block_given?
  end

  def root(a)
    par = @par[a]
    a == par ? a : @par[a] = root(par)
  end

  def unite(a,b)
    a = root(a); b = root(b)
    return if a == b

    @rank[a] < @rank[b] ? @par[a] = b : @par[b] = a
    @rank[a] += 1 if @rank[a] == @rank[b]
  end

  def same(a,b)
    root(a) == root(b)
  end

  def roots
    @par.map{|a|root(a)}
  end
end

# sample AB126_E
N,M = r

UnionFind.new(N) do
  M.times do
    a,b = r; a-=1; b-=1;
    unite(a,b)
  end
  UF = roots
end

p UF.uniq.size

Measured memory_bytes: 13436
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			int N = scan.nextInt();
			String[] S = new String[N];
			int[] count = new int[N];
			
			for(int i=0;i<N;i++) {
				S[i] =scan.next();
				count[i] = 1;
			}
			
			
			Arrays.sort(S);
			
			for(int i = 0;i<N-1;i++) {
				if(S[i].equals(S[i+1])) {
					count[i+1]  =count[i]+1;
				}
				
			}
			
			
			int max = 1;
			for(int i =0;i<N;i++) {
				if(max<count[i]) {
					max = count[i];
				}
			}
			
			for(int i = 0;i<N;i++) {
				if(count[i]==max) {
					System.out.println(S[i]);
				}
			}
			
			
			
			
			
			
			
			
			
			
			
			
			
		}
		
		
	}
		

}


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

int main()
{
	string s,t;
	cin>>s>>t;
	if(s.size()!=t.size())cout<<"No\n";
	else{
		int a[26]={0},b[26]={0};
		for(int i=0;i<t.size();i++){
			a[t[i]-'a']++;
		}
		for(int i=0;i<s.size();i++){
			b[s[i]-'a']++;
		}
		bool flag=true;
		for(int i=0;i<s.size();i++){
			if(a[t[i]-'a']!=b[s[i]-'a']){
				flag=false;
			}
		}
		if(flag)cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}


Measured memory_bytes: 776
def miller_rabin(n):
    """ primality Test
        if n < 3,825,123,056,546,413,051, it is enough to test 
        a = 2, 3, 5, 7, 11, 13, 17, 19, and 23.
        Complexity: O(log^3 n)
    """
    if n == 2: return True
    if n <= 1 or not n&1: return False

    primes = [2, 3, 5, 7, 11, 13, 17, 19, 23]

    d = n - 1
    s = 0
    while not d&1:
        d >>= 1
        s += 1

    for prime in primes:
        if prime >= n: break
        x = pow(prime, d, n)
        if x == 1: break
        for r in range(s):
            if x == n - 1: break
            if r + 1 == s: return False
            x = x * x % n
    return True

N = int(input())
print(sum(1 for _ in range(N) if miller_rabin(int(input()))))

Measured memory_bytes: 6724
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
  int ans=0;
  while(n>0){
      int tobesubtracted=2*d+1;
      n-=tobesubtracted;
      ans++;
  }
  cout<<ans<<endl;
}

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

#define loop(i,a,b) for(ll i=a; i<b; i++)
#define rloop(i,a,b) for(ll i=a; i>b; i--)
#define all(var) var.begin(), var.end()
#define eloop(var) for(auto elem : var)
#define debug(x) cerr<<#x<<" ----> "<<x<<endl;
#define PB push_back
#define MP make_pair
#define tt ll TT; cin>>TT; while(TT--)
#define F first
#define S second
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define INF 0x7fffffff
#define LINF 2000000000000000007
#define MOD 1000000007
#define MAX 100005
typedef long long ll;
typedef long double ld;

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

    //tt
    {
        ll n,m;
        cin>>n>>m;
        if(n==m)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[100005];
int len,ans;
int main(void){
	register int i,j;
	scanf("%s",s+1);
	ans=len=strlen(s+1);
	for(i=1;i<len;++i)if(s[i]!=s[i+1])ans=min(max(i,len-i),ans);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
# 0や1のケースに注意
# index out of range
# 貪欲

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    adj = [[] for _ in range(n)] #頂点数, 場合によって変える
    for _ in range(m):
        a,b = map(int, input().split())
        adj[a-1].append(b-1)
        adj[b-1].append(a-1)

    res = [-1]*n
    visited = [0]*n
    visited[0] = 1
    d = deque([0])
    while d:
        v = d.popleft()
        for nv in adj[v]:
            if visited[nv] == 0:
                d.append(nv)
                res[nv] = v+1
                visited[nv] = 1

    for i in visited:
        if i == 0:
            print('No')
            break
    else:
        print('Yes')
        for i in res[1:]:
            print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 92904
from collections import deque
a = input()
q = int(input())
key = [0]*len(a)
for i in range(len(a)):
    key[i] = a[i]

p = deque(key)
rev = False
for i in range(q):
    qinput = [str(x) for x in input().split()]
    if len(qinput) == 1:
        if rev:
            rev = False
        else:
            rev = True
    else:
        k = qinput[1]
        if k == "1":
            if rev:
                p.append(qinput[2])
            else:
                p.appendleft(qinput[2])
        else:
            if not rev:
                p.append(qinput[2])
            else:
                p.appendleft(qinput[2])
if rev:
    p.reverse()
print("".join(p))

Measured memory_bytes: 79308
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, k);
    Cins(int, n, a);
    DeSort(a);
    int d = a[0];
    For(i, n) d = gcd(d, a[i]);
    Cout((k <= a[0] && k % d == 0) ? "POSSIBLE" : "IMPOSSIBLE");
}


Measured memory_bytes: 640
use proconio::input;

fn main() {
    input! {
        n: usize,
        m: usize,
        x: usize,
        ca: [[usize; m + 1]; n]
    }

    // 分かりづらいので c_i, a_i の数列に分解
    let mut c: Vec<usize> = vec![0; n];
    let mut a: Vec<Vec<usize>> = vec![vec![0; m]; n];
    for i in 0..n {
        c[i] = ca[i][0];
        for j in 0..m {
            a[i][j] = ca[i][j + 1];
        }
    }

    let mut ans = 1000000000;
    for i in 0..1 << n {
        let mut cost = 0;
        let mut score_list = vec![0; m];
        for j in 0..n {
            if i & 1 << j > 0 {
                cost += c[j];
                for k in 0..m {
                    score_list[k] += a[j][k];
                }
            }
        }
        let ng = score_list.iter().any(|y| y < &x);
        if !ng {
            ans = std::cmp::min(ans, cost);
        }
    }

    match ans.cmp(&1000000000) {
        std::cmp::Ordering::Equal => println!("-1"),
        _ => println!("{}", ans),
    }
}


Measured memory_bytes: 2184
import sys
input = sys.stdin.readline
from collections import defaultdict

N,K = list(map(int,input().split()))
data = [list(map(int, input().split())) for _ in range(N)]

data.sort(key=lambda x:-x[1])
KISO = 0
EAT = defaultdict(int)
for i in range(K):
  t,v = data[i]
  EAT[t] += 1
  KISO += v
SHURUI = len(EAT)
l = K-1
r = K
MAX = KISO+SHURUI**2
while True:
  if l<0 or r>=N: break
  a,b = data[l]
  c,d = data[r]
  if EAT[a] == 1:
    l -= 1
    continue
  if EAT[c] != 0:
    r += 1
    continue
  EAT[a] -= 1
  EAT[c] += 1
  KISO -= b
  KISO += d
  SHURUI += 1
  l -= 1
  r += 1
  MAX = max(MAX,KISO+SHURUI**2)
print(MAX)

Measured memory_bytes: 101016
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>

using namespace std;

#define all(c) c.begin(),c.end()
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

typedef long long ll;
typedef vector<int> vi;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& val){
    os << "[ ";
    for(typename vector<T>::const_iterator it=val.begin();
        it != val.end();++it){
        os << *it << " ";
    }
    os << "]";
    return os;
}

const char bomb = '1';
const char emp = '0';
int N = 7;
void fire(int y,int x,vector<string> &f){
    if(f[y][x] == bomb){
        f[y][x] = emp;
        for(int i=-3;i<=3;i++){
            if(0 <= y + i and y + i <= N){
                fire(y+i,x,f);
            }
        }
        for(int i=-3;i<=3;i++){
            if(0 <= x + i and x + i <= N){
                fire(y,x+i,f);
            }
        }
    }
}
int main(){

    int n;
    cin >> n;
    for(int test=1;test<=n;test++){
        vector<string> field(8);
        rep(i,field.size()) cin >> field[i];
        int x,y;
        cin >> x >> y;
        x--;y--;
        fire(y,x,field);

        cout << "Data " << test << ":" << endl;
        for(int j=0;j<field.size();j++){
            cout << field[j] << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1212
n = int(input())
max_cake = n//4
max_donut = n//7
ans = "No"
if max_cake != 0 or max_donut != 0:
    for cake in range(0, max_cake+1):
        for donut in range(0, max_donut+1):
            if (cake != 0 or donut != 0):
                if n % (4*cake + 7*donut) == 0:
                   ans = "Yes"
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  int X;
  priority_queue<int> A;
  for(int i=0;i<N;i++){
    X=0;
    cin>>X;
    A.push(X);
  }
  int countA=0;
  int countB=0;
  if(N%2==0){
    for(int i=0;i<N/2;i++){
    countA+=A.top();
    A.pop();
    countB+=A.top();
    A.pop();
  }
  }
  if(N%2==1){
    for(int i=0;i<(N-1)/2;i++){
    countA+=A.top();
    A.pop();
    countB+=A.top();
    A.pop();
    }
    countA+=A.top();
  }
  int ans;
  ans=countA-countB;
  cout<<ans<<endl;
}
    
  
  


Measured memory_bytes: 256