akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
int gcd(int a, int b) { return a ? gcd(b % a, a) : b; }
#define def 0
template<class V, int NV> struct SegTree { //[l,r)
    V comp(V& l, V& r) { return gcd(l, r); };

    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int x, int y, int l = 0, int r = NV, int k = 1) {
        if (r <= x || y <= l)return def; if (x <= l && r <= y)return val[k];
        auto a = get(x, y, l, (l + r) / 2, k * 2); 
        auto b = get(x, y, (l + r) / 2, r, k * 2 + 1);
        return comp(a, b);
    }
    void update(int i, V v) {
        i += NV; val[i] = v;
        while (i>1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]);
    }
    void add(int i, V v) { update(i, val[i + NV] + v); }
    V operator[](int x) { return get(x, x + 1); }
};
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int N, A[101010];
SegTree<int, 1 << 17> st;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	rep(i, 0, N) st.update(i, A[i]);

	int ans = 0;
	rep(i, 0, N) {
		int g = 0;
		g = gcd(g, st.get(0, i));
		g = gcd(g, st.get(i + 1, N));
		chmax(ans, g);
	}
	cout << ans << endl;
}


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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void Main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<string> a(n);
  for (auto &i : a) cin >> i;
  vector<int> r(n);
  for (int i = 0; i < n; i++)
  for (int j = 0; j < m; j++) {
    if (a[i][j] == '#') r[i]++;
  }
  vector<vi> res(n, vi(m));
  int b = 0, c = 0;
  for (int i = 0; i < n; i++) {
    if (r[i] == 0) {
      if (i == b) b++;
      else {
        for (int j = 0; j < m; j++) {
          res[i][j] = res[i - 1][j];
        }
      }
    }
    else {
      c++;
      for (int j = 0; j < m; j++) {
        res[i][j] = c;
        if (a[i][j] == '#') {
          r[i]--;
          if (r[i]) c++;
        }
      }
    }
  }
  if (b) {
    for (int i = b - 1; i >= 0; i--)
    for (int j = 0; j < m; j++) {
      if (b == n) res[i][j] = 1;
      else res[i][j] = res[i + 1][j];
    }
  }
  for (auto &i : res) {
    for (auto &j : i) cout << j << ' ';
    cout << '\n';
  }
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  cerr << "- ---- -- ----- <3\n";
#endif
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


Measured memory_bytes: 3952
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		int q = sc.nextInt();
		StringBuilder sb = new StringBuilder(s);
		StringBuilder head = new StringBuilder();
		StringBuilder tail = new StringBuilder();
		boolean flg = true;
		for(int i = 0; i < q; i++){
		    int type = sc.nextInt();
		    if(type == 1){
		        flg = !flg;
		    }else{
		        int f = sc.nextInt();
		        char c = sc.next().charAt(0);
		        if(f == 1){
		            if(flg){
		                head.append(c);
		            }else{
		                tail.append(c);
		            }
		        }else{
		            if(flg){
		                tail.append(c);
		            }else{
		                head.append(c);
		            }
		        }
		    }
		}
		// 計算
		String result = "";
		head.reverse().append(sb).append(tail);
		if(flg){
		    result = head.toString();
		}else{
		    result = head.reverse().toString();
		}
		
		
		// 出力
		System.out.println(result);
	}
}


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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N, A, B;
	cin >> N >> A >> B;

	if((N == 1 && A != B) || A > B)
		cout << 0 << endl;
	else if(N <= 2)
		cout << 1 << endl;
	else{
		cerr << (A + B*(N-1)) << " " <<  (A*(N-1)+B) << endl;
		cout << (A + B*(N-1)) - (A*(N-1)+B) + 1 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

void solve(vector<int> H, int begin, int end, int lower, int& ans) {
  if(end != begin) {
    vector<int>::iterator minItr = min_element(H.begin()+begin, H.begin()+end);
    int minH = *minItr;
    ans += minH - lower;
    int tmp = begin;
    for(int i=begin; i<end; i++) {
      if(H[i] == minH) {
	solve(H, tmp, i, minH, ans);
	while(i < end && H[i] == minH)
	  i++;
	tmp = i;
      }
    }
    solve(H, tmp, end, minH, ans);
  }
}

int main(){
  int N;
  cin >> N;
  vector<int> H(N);
  for(int i=0; i<N; i++)
    cin >> H[i];
  int ans = 0;
  solve(H, 0, N, 0, ans);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MOD 998244353LL

int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int> c(n);
  vector<vector<int>> a(n, vector<int>(m));
  for(int i = 0; n > i; i++){
    cin >> c[i];
    for(int j = 0; m > j; j++)
	    cin >> a[i][j];
  }
  
  int Min = INT_MAX;
  
  for(int b = 0; 1 << n > b; b++){
    int sum[13] = {}, cs = 0; 
  for(int i = 0; n > i; i++){
    if(!((b >> i) & 1)) continue;
    cs += c[i];
    for(int j = 0; m > j; j++){
      sum[j] += a[i][j];
    }
  }
    bool f = true;
    for(int j = 0; m > j; j++)
  		if(sum[j] < x) f = false;
    if(f) Min = min(Min,cs);
    
  }
  if(Min == INT_MAX) Min = -1;
  cout << Min << endl;
  return 0;
}


Measured memory_bytes: 3196
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int n;char s[4005];
ll ans=0,r,g,b;
int main()
{
	cin>>n;
	scanf("%s",s+1);
	F(i,1,n) {if(s[i]=='R')++r;if(s[i]=='G')++g;if(s[i]=='B')++b;}
	ans=r*g*b;
	F(i,1,n) F(j,1,(n-i)/2) if(s[i]!=s[i+j]&&s[i+j]!=s[i+j+j]&&s[i+j+j]!=s[i]) --ans;
	cout<<ans<<endl;
	return 0;
}
/////////////

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

typedef long long int llint;

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

  int mn = 0;
  
  mn += min(a, b);
  mn += min(c, d);

  cout<< mn <<endl;

  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) cin >> B.at(i);
  for (int i = 0; i < N; i++) cin >> C.at(i);
  sort(A.begin(), A.end());
  sort(C.begin(), C.end());
  long ans = 0;
  for (int i = 0; i < N; i++) {
    int X = lower_bound(A.begin(), A.end(), B.at(i)) - A.begin();
    int Y = N - (upper_bound(C.begin(), C.end(), B.at(i)) - C.begin());
    ans += (long) X * Y;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

const int64_t MOD = 1e9 + 7;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> a(h);
    rep(i, h)
    {
        cin >> a[i];
    }

    vector<vector<int64_t>> dp(h, vector<int64_t>(w));
    rep(i, h) rep(j, w)
    {
        dp[i][j] = (i == 0 && j == 0) ? 1 : 0;
        if (i > 0 && a[i - 1][j] == '.') {
            dp[i][j] += dp[i - 1][j];
        }
        if (j > 0 && a[i][j - 1] == '.') {
            dp[i][j] += dp[i][j - 1];
        }
        dp[i][j] %= MOD;
    }
    cout << dp[h - 1][w - 1] << endl;
    return 0;
}

Measured memory_bytes: 9216
w,h,n =[int(i) for i in input().split()]
x=[]
y=[]
a=[]
x_r=[0,w]
y_r=[0,h]
for q in range(n):
	X,Y,A=[int(i) for i in input().split()]
	x.append(X)
	y.append(Y)
	a.append(A)
for d in range(n):
	if a[d] == 1 and x_r[0] <= x[d]:
		x_r[0] = x[d]
	elif a[d] == 2 and x_r[1] >= x[d]:
		x_r[1] = x[d]
	elif a[d] == 3 and y_r[0] <= y[d]:
		y_r[0] = y[d]
	elif a[d] == 4 and y_r[1] >= y[d]:
		y_r[1] = y[d]
if x_r[1]-x_r[0] <=0 or y_r[1]-y_r[0] <=0:
	s = 0
else:
	s = (x_r[1]-x_r[0])*(y_r[1]-y_r[0])
print(s)

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int C[200010];
vector<int> G[200010];
vector<int> ET;

void dfs(int idx,int par)
{
	bool ok=false;
	for(auto e:G[idx])
	{
		if(e==par)continue;
		ok=true;
		ET.push_back(idx);
		dfs(e,idx);
		ET.push_back(-idx);
	}
	if(!ok)
	{
		ET.push_back(idx);
		ET.push_back(-idx);
	}
}
 
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>N;
	rep(i,0,N)
	{
		cin>>C[i+1];
		C[i+1]--;
	}

	int a,b;
	rep(i,0,N-1)
	{
		cin>>a>>b;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	dfs(1,-1);

	vector<int> SSZ(SZ(ET));
	set<int> iset;
	vector<map<int,int>> STCM(N);
	vector<map<int,int>> PM(N);
	vector<stack<int>> CS(N);
	vector<int> NGC(N,0);

	rep(i,0,N)
	{
		STCM[i][0]=0;
		PM[i][0]=0;
		CS[i].push(0);
	}

	rep(i,0,SZ(ET))
	{
		if(ET[i]>0)
		{
			iset.insert(ET[i]);
		}
		SSZ[i]=SZ(iset);

		if(ET[i]>0)
		{
			CS[C[ET[i]]].push(ET[i]);
			PM[C[ET[i]]][ET[i]]=i;
			STCM[C[ET[i]]][ET[i]]=0;
		}
		else
		{
			CS[C[-ET[i]]].pop();
			int par=CS[C[-ET[i]]].top();
			int sz=SSZ[i-1]-SSZ[PM[C[-ET[i]]][-ET[i]]];
			int ngsz=sz-STCM[C[-ET[i]]][-ET[i]];
			NGC[C[-ET[i]]]+=ngsz*(ngsz+1)/2;
			if(i==SZ(ET)-1||ET[i+1]!=-ET[i])sz++;
			STCM[C[-ET[i]]][par]+=sz;
		}
	}

	rep(i,0,N)
	{
		int ngsz=N-STCM[i][0];
		NGC[i]+=ngsz*(ngsz+1)/2;

		int res=N*(N+1)/2-NGC[i];
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 253264
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	string s;
	cin>>s;
	int z = 0;
	for(int i=0;i<sz(s);i++)
		z += (int)(s[i]-'0');
	if(z%9==0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3764
#include<iostream>

using namespace std;

int main(){
	int n,m,p;
	int ans;

	while(true){
		cin >> n >> m >> p;
		if(n == 0 && m == 0 && p == 0){
			break;
		}
		int* data = new int[n];
		int count = 0;
		for(int i=0;i<n;i++){
			cin >> data[i];
			count += data[i];
		}

		ans = 100 * count - p * count;

		if(data[m-1]==0){
			ans = 0;
		}else{
			ans /= data[m-1];
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int x;
  cin>>x;
  if(x>=30) cout<<"Yes\n";
  else cout<<"No\n";
  return 0;
}


Measured memory_bytes: 3616
using System;

namespace B___Postal_Code
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            var s = Console.ReadLine();
            var c=s.Split('-');
            if(c[0].Length==a&&c[1].Length==b)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
#include<math.h>
      
long GCDisGOD(long n,long m){
  long a = n;
  long b = m;
  long c = 0;
  while(1){
    c = a%b;
    if(c==0){
      return b;
    }else{
      a=b;
      b=c;
    }
  }
}

int main(){
  long a = 0;
  long b = 0;
  long gcd = 0;
  long i = 0;
  long j = 0;
  long primecnt=0;
  int isprime = 0;
  int selfprime = 1;
  
  scanf("%ld %ld",&a,&b);
  gcd = GCDisGOD(a,b);
  for(i=2;i<=sqrt(gcd)+1&&gcd != 1;i++){
    if(gcd % i == 0){
      primecnt++;
      //printf("%d,",i);
      while(gcd % i == 0){
        gcd /= i;
      }
    }
  }
  if(gcd != 1){
    primecnt++;
  }
  printf("%ld",primecnt+1);

  return 0;
}
  
  

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int n,m;
  cin >> n >> m;
  vector<vector<int>> to(n, vector<int>(0));
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  vector<int> dist(n,inf);
  vector<int> parent(n,0);
  queue<int> q;
  q.push(0);
  dist[0] = 0;

  while(!q.empty()){
    int r = q.front();q.pop();
    for(int x : to[r]){
      if(dist[x] == inf){
        dist[x] = dist[r] + 1;
        parent[x] = r;
        q.push(x);
      }
    }
  }

  cout << "Yes" << endl;
  FOR(i,1,n){
    cout << parent[i]+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 10708
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){ 
    string S;
    cin >> S;
    ll sum = 0;
    for(auto &e: S){
        sum += e - '0';
    }
    if(sum % 9 == 0){
        print("Yes");
    }else{
        print("No");
    }
    

}

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

Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
vector<vector<vector<long long>>> dp(3010,vector<vector<long long>>(3010,vector<long long>(2,-1)));
vector<long long> x;
long long n,a;

long long ans(long long start , long long end , long long type){
    if(start == end+1){
        return 0;
    }
    if(dp[start][end][type] != -1){
        return dp[start][end][type];
    }
    long long ret = max(x[start] - ans(start+1,end,1-type) , x[end] - ans(start,end-1,1-type));
    dp[start][end][type] = ret;
    return ret;
}

int main()
{
    cin >> n;
    for(int i = 0 ; i < n ; i += 1){
        cin >> a;
        x.push_back(a);
    }
    cout << ans(0,n-1,0);
}

Measured memory_bytes: 496256
// 4_abc133_d
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);

    ll x0 = 0;
    rep(i, n){
        cin >> a[i];
        if(i % 2 == 0) x0 += a[i];
        else x0 -= a[i];
    }
    vector<int> x(n);
    x[0] = x0 / 2;
    for(int i = 1; i < n; i++){
        x[i] = a[i - 1] - x[i - 1];
    }

    rep(i, n){
        cout << x[i] * 2 << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

ll n,a,b;
ll h[100005];

bool check(ll x){
    ll res = 0;
    rep(i,n){
        res += (max(0ll, h[i] - x * b) + (a - b - 1)) / (a - b);
    }
    return (res <= x);
}

int main()
{
    cin >> n >> a >> b;
    rep(i, n) cin >> h[i];
    ll MIN = 0, MAX = infi;
    pll idx = mp(1, 2);
    while (1){
        if (MIN+1==MAX)
            break;
        ll x = infi * idx.F / idx.S;
        if (check(x)){
            MAX = x;
            idx = mp(idx.F * 2 - 1, idx.S * 2);
        }
        else
        {
            MIN = x;
            idx = mp(idx.F * 2 + 1, idx.S * 2);
        }
    }
    cout << MAX << endl;
}


Measured memory_bytes: 1024
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

n=int(input())
B=input_array()
A=[B[0]]
ans=B[0]

for i in range(1,n):
	if A[i-1] > B[i-1]:
		ans=ans-A[i-1]+B[i-1]
		A[i-1]=B[i-1]
	ans+=B[i-1]
	A.append(B[i-1])

print(ans)

Measured memory_bytes: 9028
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

bool is_prime(int x) {
    if (x == 2)
        return true;
    if (x < 2 || x % 2 == 0)
        return false;
    int i = 3;
    while (i * i <= x) {
        if (x % i == 0)
            return false;
        i += 2;
    }
    return true;
}

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &&i : A) {
        cin >> i;
    }
    int cnt = 0;
    for (auto &&i : A) {
        if (is_prime(i))
            cnt++;
    }
    std::cout << cnt << '\n';

    return 0;
}


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b && a!=c){
    cout << "Yes" << endl;
  }
  else if(b==c && b!=a){
    cout << "Yes" << endl;
  }
  else if(c==a && c!=b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string S;
    cin >> S;
    if(S[0] >= 'A' and S[0] <= 'Z') {
        cout << "A\n";
    } else {
        cout << "a\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){
    long H;
    int dannsu;
    long kazu=1;
    long ans=0;
    
    scanf("%ld",&H);

    dannsu = (int)log2l(H);

    for(int i=0;i<=dannsu;i++){
        ans+=kazu;
        H/=2;
        kazu*=2;
    }

    printf("%ld",ans);

    return 0;
}

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

using namespace std;

int kk[2019];

int main() {
	string s; cin >> s;
	int n = s.length();
	int x = 0;
	kk[x]++;
	for (int i = n - 1, p = 1; i >= 0; i--, p = p * 10 % 2019)
		kk[x = (x + (s[i] - '0') * p) % 2019]++;
	long long ans = 0;
	for (int r = 0; r < 2019; r++)
		ans += (long long) kk[r] * (kk[r] - 1) / 2;
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 3596
# -*- coding: utf-8 -*-
"""
https://abc088.contest.atcoder.jp/tasks/abc088_b

"""
import sys
from sys import stdin
input = stdin.readline


def solve(cards):
    score_a = 0
    score_b = 0
    cards.sort(reverse=True)
    for i, c in enumerate(cards):
        if i % 2 == 0:
            score_a += c
        else:
            score_b += c
    return score_a - score_b


def main(args):
    N = int(input())
    cards = [int(x) for x in input().split()]
    ans = solve(cards)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
    


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

#define maxn 100005

int n, s, t;
int ans;
vector<int> v[maxn];
int d[2][maxn];

void dfs(int k, int now, int dd, int fa)
{
    d[k][now] = dd;
    for (int x : v[now])
    {
        if (x == fa)
            continue;
        dfs(k, x, dd + 1, now);
    }
}

void search(int now, int fa)
{
    if (d[0][now] >= d[1][now])
        return;
    ans = max(ans, d[1][now] - 1);
    for (int x : v[now])
    {
        if (x == fa)
            continue;
        search(x, now);
    }
}

int main()
{
    cin >> n >> s >> t;
    for (int i = 0; i < n - 1; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(0, s, 0, s);
    dfs(1, t, 0, t);
    ans = 0;
    search(s, s);
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int solve(std::vector<int>&  ps) {
  std::sort(ps.rbegin(), ps.rend());
  ps[0] = ps[0] / 2;
  int ret = 0;
  for (auto const p : ps) {
    ret += p;
  }

  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::vector<int> ps(n);
  for (auto& p : ps) {
    std::cin >> p;
  }
  std::cout << solve(ps) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;

const ll mod = 2;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint add_inv() const{
        if(x==0) return 0;
        return mod-x;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

class matrix{
public:
    vector<vector<mint>> A;
    int N,M;
    matrix(int n,int m,vector<vector<mint>> v){
        N = n; M = m;
        A = v;
    }
    void row_reduction(){
        int p = 0;
        for(int j=0;j<M-1;j++){
            int row = p;
            while(row<N && !A[row][j].x) row++;
            if(row==N) continue;
            swap(A[p],A[row]);
            for(int i=p+1;i<N;i++){
                if(A[i][j].x){
                    mint a = A[i][j]/A[p][p];
                    for(int k=0;k<M;k++){
                        A[i][k] -= a*A[p][k];
                    }
                }
            }
            p++;
        }
    }
};

int main(){
    int M,N,D;
    while(cin >> M >> N >> D && M){
        vector<vector<mint>> v(N*M,vector<mint>(N*M+1));
        for(int i=0;i<N;i++) for(int j=0;j<M;j++){
            int a;
            cin >> a;
            if(a) v[i*M+j][N*M] = 1;
            for(int k=0;k<N;k++) for(int l=0;l<M;l++){
                int d = abs(i-k)+abs(j-l);
                if(d==0 || d==D) v[i*M+j][k*M+l] = 1;
            }        
        }
        matrix mat(N*M,N*M+1,v);
/*         for(int i=0;i<N*M;i++) for(int j=0;j<N*M+1;j++) cerr << mat.A[i][j].x << (j!=N*M? " ":"\n");
        cerr << endl;
*/        mat.row_reduction();
//        for(int i=0;i<N*M;i++) for(int j=0;j<N*M+1;j++) cerr << mat.A[i][j].x << (j!=N*M? " ":"\n");
        bool ok = true;
        for(int i=0;i<N*M;i++){
            if(!mat.A[i][N*M].x) continue;
            ok = false;
            for(int j=0;j<N*M;j++) if(mat.A[i][j].x) ok = true;
            if(!ok) break;
        }
        cout << ok << endl;
    }
}


Measured memory_bytes: 12060
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define ll long long
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
int gcd(int a, int b){
    if(a%b == 0){
        return b;
    }else{
    return gcd(b, a%b);
    }
}

int main(){
    string s;
    bool flag=true;
    cin >> s;
    rep0(i,s.length()/2){
        if(s[i]!=s[s.length()-i-1])  flag=false;
    }
    rep0(i,(s.length()-2)/2){
        if(s[i]!=s[(s.length()-1)/2-i-1]) flag=false;           
    }
    for(int i=(s.length()+3)/3-1;2*i<s.length()-1;i++){
        if(s[i]!=s[s.length()-i-1]) flag=false;           
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
/*input

*/


//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
#include<bits/stdc++.h>
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<ll int,ll int>
#define vpii        vector< pii >
#define vi          vector<ll int>
#define vs			vector< string >
#define vvi         vector< vector< ll > >
#define inf			(ll)1e18
#define all(it,a)   for(auto it=(a).begin();it!=(a).end();it++) 
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define repr(i,a,b) for(ll int i=a;i>b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define whatis(x)   cout << #x << " is " << x << "\n";
#define graph(n)    adj(n,vector< ll > () )
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int solve()
{
	ll n;cin>>n;
	vi p(n),q(n),a(n);
	rep(i,0,n) a[i]=i+1;
	rep(i,0,n) cin>>p[i];
	rep(i,0,n) cin>>q[i];

	ll cnt1=0;
	do{
		if(a==p) break;
		else cnt1++;
	}while(a!=p && next_permutation(a.begin(), a.end()));

	rep(i,0,n) a[i]=i+1;
	ll cnt2=0;
	do{
		if(a==q) break;
		else cnt2++;
	}while(a!=q && next_permutation(a.begin(), a.end()));
	// whatis(cnt2);
	cout<<abs(cnt1-cnt2);

	return 0;
}

int main()
{
	auto start = chrono::high_resolution_clock::now();

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll test_cases=1;
	//cin>>test_cases;
	while(test_cases--)
		solve();

	auto stop = chrono::high_resolution_clock::now();
	auto duration = chrono::duration_cast<chrono::milliseconds>(stop-start);
	// cout<<"\nduration: "<<(double)duration.count()<<" milliseconds";
}

Measured memory_bytes: 384
import collections
import itertools
import functools
import math

s = set([])
if __name__ == "__main__":
    n = int(input())
    m = math.factorial(n)
    res = 1
    for j in range(2, n + 1):
        tmp = 1
        while m % j == 0:
            m = m//j
            tmp += 1
        res *= tmp
    print(res % (10**9 + 7))

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
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; }
typedef long long ll;
int main()
{
  int n; cin >> n;
  vector<ll> a(n), b(n);
  rep(i,n) cin >> a[i] >> b[i];

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());  
  
  if(n % 2 == 0) {
    cout << b[n/2-1] + b[n/2] - a[n/2-1] - a[n/2] + 1 << "\n";
  }
  else {
    cout << b[n/2] - a[n/2] + 1 << "\n";
  }
  
  return 0;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
#define rep(i, ns, ne) for (int i = ns; i < ne; ++i)
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int N, K, k;
  cin >> N >> K;
  set<int> set;
  rep(i, 0, 10) { set.insert(i); }
 
  rep(i, 0, K) {
    cin >> k;
    set.erase(k);
  }
 
  bool ok;
  int ans = N;
 
  while (N < 10001) {
    string str = to_string(ans);
    ok = true;
    rep(i, 0, str.size()) {
      if (!set.count(str[i] - '0')) {
        ok = false;
        break;
      }
    }
    if (ok) {
      cout << ans << endl;
      break;
    }
    ans++;
  }
  getchar();
}

Measured memory_bytes: 3712
#coding:utf-8
D,G=map(int,input().split(" "))
Comp={}
for i in range(D):
  p,c=map(int,input().split(" "))
  Comp[i]=[p,c]
Min=1000000000
for i in range(2**(D)):
  answer=0
  score=0
  Clear=[]
  for j in range(D):
    if ((i>>j)&1):
      score+=(j+1)*100*Comp[j][0]
      score+=Comp[j][1]
      answer+=Comp[j][0]
      Clear.append(j+1)
  No=D
  Count=0
  while score<G and No>=1:
    if No in Clear or Count==Comp[No-1][0]:
      Count=0
      No-=1
    score+=100*No
    Count+=1
    answer+=1
  if score>=G:
    Min=min(Min,answer)
print(Min)  

Measured memory_bytes: 3192
def main():
    
    from collections import deque

    s = input()
    s1 = deque([])
    s2 = deque([])

    sum_ = 0
    
    for i, ch in enumerate(s):
        if ch == '\\' :
            s1.append(i)
            
        elif ch =='/' and len(s1) > 0:
            j = s1.pop()
            sum_ += i - j
            a = i- j
            while len(s2) > 0 and s2[-1][0] > j:
                a += s2.pop()[1]
            s2.append([j, a])
            
    ans = []
    
    while len(s2)>0:
        ans.append(s2.pop()[1])
        
    ans.reverse()
    print(sum(ans))
    ans.insert(0, len(ans))
    
    print(' '.join(map(str, ans)))

    
            
if __name__ == '__main__':
    main()


Measured memory_bytes: 6560
# -*- coding: utf-8 -*-
# template: v1.3.1

# 倍数問題では、N(i)%k は k 以内でループする...はず。実際している…
# 桁落としは、mod 途中実行でできる…了解...！！！！！合点！！！！

import io
import sys
import math

### DEBUG ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
999983
"""
_EXPECTED = """\
4

"""
if _DEB:
    sys.stdin = io.StringIO(_INPUT)
    print("!! Debug Mode !!")

def logd(str):
    if _DEB: print(f"[deb] {str}")


### INPUT ####
k = int(input())

### Solve ####
def solve():
    # Process
    ans=-1
    mod_set=set()
    modx=10**9+7
    i=1
    n7=7%k
    while True:
        if n7==0:
            ans=i
            break
        if n7 in mod_set:
            break
        mod_set.add(n7)
        # 7777... の連続生成は、こうすると合理的。桁あふれもここで防ぐ。
        n7=(n7*10+7)%k
        i+=1
    # OUPUT
    ans = str(ans)
    print(ans)
    return ans

### MAIN ###
if __name__ == "__main__":
    ans = solve()

    # Checker
    if _DEB:
        if _EXPECTED.strip() == ans.strip(): print("\n!! Success !!")
        else: print(f"\n!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Measured memory_bytes: 78080
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
  string s;
  int k;
  cin>>s>>k;
  int ans=0,ans2,u=0;
  while(s[u]==s[0]&&u<s.size())u++;
  if(u==s.size()){
    int p=s.size();
    p*=k;
    cout<<p/2;
    return 0;
  }
  for(int i=u;i<s.size()+u;i++){
    if(s[i%s.size()]==s[(i-1)%s.size()]){
      ans++;
      s[i%s.size()]='1';
    }
    if(i==s.size()-1)ans2=ans;
  }
  cout<<ans*(k-1)+ans2+ u/2;

  
  


  


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	char n[5];
	scanf("%s",n);
	bool j = 0;
	if(n[0]==n[1] && n[1]==n[2])
		j = 1;
	if(n[1]==n[2] && n[2]==n[3])
		j = 1;
	if(j)	printf("Yes\n");
	else	printf("No\n");
	return 0;
}

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

using namespace std;

int calc(int, int, int);

int for2(int x,int i,int count,int sum){
	return x == -1 ?0 : calc(i, count - 1, sum + x) + for2(x - 1, i, count, sum);
}

int calc(int i, int count,int sum){
	return count == 0 ? sum == i : for2(9, i, count, sum);
}

int main(){
	int i;
	while (cin >> i){
		cout << calc(i, 4, 0) << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)



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

  ll x;
  cin >> x;
  ll dis=0;
  ll i=1;
  while(1){
    dis+=i;
    if(dis>=x) break;
    i++;
  }
  cout << i << endl;
    
  
  
  return 0;
    

}


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

int main(){
  bool b=false;
  for(int i=0; i<3; i++){
    char s;
    cin >> s;
    if(s=='7') b=true;
  }
  if(b==true) cout << "Yes" << endl;
  else cout <<"No" << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool srt( pair < int , int > a, pair < int , int > b){
    return a.first != b.first ? a.first>b.first : a.second<b.second;
}
const ll oo=1e18;
int dx[8]={1,-1,0,0,1,-1,-1,1};
int dy[8]={0,0,1,-1,1,-1,1,-1};

int main(){
    int n;
    cin>>n;
    cout<<n/3;


    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

vector<int> g[100000];
bool use[100000];
int out[100000];
vector<P> ans;

void dfs1(int v, int p) {
  use[v] = true;
  REP(i, g[v].size()) {
    int to = g[v][i];
    if (to == p) continue;
    if (!use[to]) {
      dfs1(to, v);
    } else if (v < to) {
      ans.push_back(P(v, to));
      out[v]++;
    }
  }
}

void dfs2(int v, int p) {
  use[v] = true;
  REP(i, g[v].size()) {
    int to = g[v][i];
    if (to == p) continue;
    if (!use[to]) {
      dfs2(to, v);
    }
  }
  if (p != -1) {
    if (out[v] % 2) {
      ans.push_back(P(v, p));
      out[v]++;
    } else {
      ans.push_back(P(p, v));
      out[p]++;
    }
  }
}

int main() {
  int n, m;
  cin >> n >> m;
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (m % 2) {
    puts("-1");
    return 0;
  }
  dfs1(0, -1);
  REP(i, n) use[i] = false;
  dfs2(0, -1);
  REP(i, ans.size()) {
    cout << ans[i].first + 1 << " " << ans[i].second + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 16116
#include <iostream>

using namespace std;

int main()
{
    string s[3]={"Sunny", "Cloudy","Rainy" },x;
    int y;
    cin>>x;
    for(int i=0;i<3;i++){
        if(s[i]==x){
            y=i+1;
            break;
        }
    }
    y=y%3;
    cout<<s[y];
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static Scanner scan  = new Scanner(System.in);
    public static void main(String[]args){
        int n =nextInt();
        int con = 0;
        int[] arr = new int[n];
        for(int i=0;i<n;i++){
            arr[i] = nextInt();
        }
        for(int i=0;i<n;i++){
            if((i+1)%2==1){
                if(arr[i]%2==1){
                    con +=1;
                }
            }
        }
        print(con);
    }

    public static int nextInt(){
        return Integer.parseInt(scan.next());
    }
    public static long nextLong(){
        return Long.parseLong(scan.next());
    }
    public static String next(){
        return scan.next();
    }
    public static double nextDouble(){
        return Double.parseDouble(scan.next());
    }
    public static float nextFloat(){
        return Float.parseFloat(scan.next());
    }

    //Yes or No
    public static void yesNo(boolean flag){
        if(flag) System.out.println("Yes");
        else System.out.println("No");
    }

    //print
    public static void print(Object a){
        System.out.println(a);
    }


    //gcd
    public static int gcd (int a, int b){
        int tmp;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return b;
    }


    //lcm
    public static int lcm(int a,int b){
        int tmp;
        long c = a;
        c *= b;
        while((tmp = a%b) != 0){
            a = b;
            b = tmp;
        }
        return (int)(c/b);
    }
}

Measured memory_bytes: 35656
s = list(input())
na = []
for i in range(len(s)):
    if i%2 == 0:
        na.append("0")
    else:
        na.append("1")
count = 0
for i in range(len(s)):
    if na[i] == s[i]:
        count += 1
print(min(len(s)-count,count))

Measured memory_bytes: 4776
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(void){
	double x , h;
	while(1){
		scanf("%lf" , &x);
		scanf("%lf" , &h);
		if(x==0&&h==0) break;
		printf("%lf\n" , x*x + 2*x*sqrt(x*x/4 + h*h));
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n; scanf("%d",&n);
	int rs=0;
	for(int i=0;i<n;i++){
		int a; scanf("%d",&a);
		rs+=a-1;
	}
	printf("%d\n", rs);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

int cnt[10010];

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, P; cin >> N >> P;
    string S; cin >> S;
    if(P == 2 || P == 5) {
        int ans = 0;
        RREP(i, N - 1, 0) {
            int num = S[i] - '0';
            if(num % P == 0) ans += i + 1;
        }
        cout << ans << endl;
        return 0;
    }
    int sum = 0;
    int times = 1;
    rep(i, N) {
        sum += ((S[N - i - 1] - '0') * times) % P;
        sum %= P;
        cnt[sum]++;
        times = (times * 10) % P;
    }
    // rep(i, P) cout << cnt[i] << " ";
    // cout << endl;
    int ans = 0;
    int k = 0;
    times = 1;
    rep(i, N) {
        ans += cnt[k % P];
        int num = (S[N - i - 1] - '0') % P;
        k += num * times;
        k %= P;
        cnt[k % P]--;
        //cout << ans << " " <<k % P << " " << (-k + P * 10) % P<< endl;
        times = (times * 10) % P;
    }
    cout << ans << endl;


    return 0;
}
// 0 1 2 3 4 5 6
// 0

Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#define INF 100000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long
/* define/include */

int main(){
  int N,K;
  cin >> N >> K;
  int A=1;
  for(int i=0;i<N;i++){
    if(A<K) A*=2;
    else    A+=K;
  }
  cout << A;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{

    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string[] array = Console.ReadLine().Split();
        int[] v = new int[n];
        int[] e = new int[n / 2];
        int[] o = new int[n / 2];
        for (int i = 0; i < array.Length; i++)
        {
            v[i] = int.Parse(array[i]);
            if (i % 2 == 0) e[i / 2] = int.Parse(array[i]);
            else o[i / 2] = int.Parse(array[i]);
        }

        int e1 = -1;
        int e1_n = 0;
        int e2 = -1;
        int e2_n = 0;
        int o1 = -1;
        int o1_n = 0;
        int o2 = -1;
        int o2_n = 0;

        int[] line = new int[100001];

        for (int i = 0; i < e.Length; i++)
        {
            line[e[i]]++;
        }

        for (int i = 1; i < line.Length; i++)
        {
            if (e1_n < line[i])
            {
                e1 = i;
                e1_n = line[i];
            }
        }

        for (int i = 1; i < line.Length; i++)
        {
            if (i != e1 && e2_n < line[i])
            {
                e2 = i;
                e2_n = line[i];
            }
        }

        line = new int[100001];

        for (int i = 0; i < o.Length; i++)
        {
            line[o[i]]++;
        }

        for (int i = 1; i < line.Length; i++)
        {
            if (o1_n < line[i])
            {
                o1 = i;
                o1_n = line[i];
            }
        }

        for (int i = 1; i < line.Length; i++)
        {
            if (i != o1 && o2_n < line[i])
            {
                o2 = i;
                o2_n = line[i];
            }
        }

        if (e1 == o1)
        {
            Console.WriteLine(Math.Min(e.Length - e1_n + o.Length - o2_n, e.Length - e2_n + o.Length - o1_n));
        }
        else
        {
            Console.WriteLine(e.Length - e1_n + o.Length - o1_n);
        }
    }
}

Measured memory_bytes: 20064