akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define Would
#define you
#define please

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

	string S, T;
	cin >> S >> T;
	vector<int> SV[26], TV[26];
	rep(i, S.length()) SV[S[i] - 'a'].push_back(i);
	rep(i, T.length()) TV[T[i] - 'a'].push_back(i);

	int kotae = 1;
	rep(i, 26) {
		char kari = 0;
		char kari2;
		while (SV[i].empty() != true) {
			kari2 = T[SV[i][SV[i].size() - 1]];
			if (kari) {
				if (kari != kari2) kotae = 0;  
			}
			kari = kari2;
			SV[i].pop_back();
		}
		kari = 0;
		while (TV[i].empty() != true) {
			kari2 = S[TV[i][TV[i].size() - 1]];
			if (kari) {
				if (kari != kari2) kotae = 0;
			}
			kari = kari2;
			TV[i].pop_back();
		}
	}

	if (kotae) co("Yes");
	else co("No");

	Would you please return 0;

}

Measured memory_bytes: 2836
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define Max 100005
using namespace std;
typedef long long LL;
const int Mod = 1000000007;
char s[Max];
LL dp[4][Max];///0 '?' 1 'A' 2 'B' 3 'C'
int a,b;
int main() {
    scanf("%s",s + 1);
    dp[0][0] = 1;
    int n = strlen(s + 1);
    for(int i = 1;i <= n;i ++) {
        for(int j = 0;j <= 3;j ++) {
            dp[j][i] = dp[j][i - 1];
            if(s[i] == '?')dp[j][i] = (dp[j][i] * 3) % Mod;
            if(j && (s[i] == '?' || s[i] - 'A' + 1 == j)) {
                dp[j][i] = (dp[j][i] + dp[j - 1][i - 1]) % Mod;
            }
        }
    }
    printf("%lld",dp[3][n]);
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

const long long maxn=400005,mod=1e9+7;
typedef long long ll;

int n;
ll a[maxn];

ll dp[maxn][3];
ll ans=-(1ll<<62);

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int lim;
	if(n%2==1) lim=2;
	else lim=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=lim;j++)
		{
			dp[i][j]=-(1ll<<62);
			if(i==j+1) dp[i][j]=a[i];
			for(int k=0;k<=j;k++)
			{
				if(i-k-2>=1)
					dp[i][j]=max(dp[i][j],dp[i-k-2][j-k]+a[i]);
			}
			//cout<<"dp "<<i<<' '<<j<<' '<<dp[i][j]<<endl;
			if((lim-j)+i==n)
				ans=max(ans,dp[i][j]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9892
($a,$b)=<>=~/../g;
print
	1<=$a&&$a<=12
	?
		1<=$b&&$b<=12
		?
			'AMBIGUOUS'
		:
			'MMYY'
	:
		1<=$b&&$b<=12
		?
			'YYMM'
		:
			'NA'


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

int main() {
    int A, B, C;
    std::cin >> A >> B >> C;

    if ((A == B && B != C) || (B == C && C != A) || (A == C && C != B)) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }

    return 0;
}


Measured memory_bytes: 764
#include<cstdio>

using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	int z=1;
	while(z*2<=n)z*=2;
	if(n==z){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	for(int i=2;i<n;i+=2){
		printf("%d %d\n",1,i);
		printf("%d %d\n",i,i+1+n);
		printf("%d %d\n",1,i+1);
		printf("%d %d\n",i+1,i+n);
	}
	printf("%d %d\n",n+1,2+n);
	if(n%2==0){
		printf("%d %d\n",z+1,n);
		printf("%d %d\n",n-z,2*n);
	}
}

Measured memory_bytes: 2360
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace workspace
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] A = Console.ReadLine()
                .Split(' ')
                .Select(int.Parse)
                .ToArray();
            Array.Sort(A);

            int cost = Math.Abs(A[1] - A[0]) + Math.Abs(A[2] - A[1]);

            Console.WriteLine(cost);
        }
    }
}


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

int main(){

  int64_t n, p=1;
  int64_t MAX =1000000007;
  cin >> n;
  
  for(int i=1; i<=n; i++) {
  	p = (i * p) % MAX;
  }
	cout << p << endl;
}

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

using namespace std;
using ll = long long;

void init();
void solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007

signed main()
{
	init();
	solve();
}

ll N;
vector<int> v;

void init()
{
	cin >> N;
	rep(i, N) {
		CIN(int, t);
		v.PB(t);
	}
	UNIQUE(v);
}

void solve()
{
	int cnt = N - v.size();
	cout << N - 2 * ((cnt+1) / 2) << endl;
}



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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
using namespace std;
typedef long long ll;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	ll n;
	cin >> n;
	vector<ll> v(n);
	vector<ll> count(100001,0);
	ll sum=0;
	for (ll i = 0; i < n; i++) {
		cin >> v[i];
		count[v[i]]++;
		sum+=v[i];
	}
	ll k;
	cin >> k;
	while (k--) {
		ll a,c;
		cin>>a>>c;
		sum-=count[a]*a;
		sum+=count[a]*c;
		count[c]+=count[a];
		count[a]=0;
		cout<<sum<<"\n";
	}

}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    ll t,n,item,temp=1,h,flag1=0,flag2=0,cost=100000000000,sum=0,k,avg=0,x,y,z;
    vector<ll>v1;
    vector<ll>v2;
    map<ll,ll>mp;
    ll L,R,d;
    cin>>n;
    for(ll i=1; i<=105; i++)
    {
        sum=0;

        for(ll j=1;j<=105;j++)
        {
            for(ll k=1;k<=105;k++)
            {



                sum=i*i + j*j + k*k + i*j +j*k +k*i;
             mp[sum]++;
            }

        }

    }
    for(int i=1;i<=n;i++)
        cout<<mp[i]<<endl;

    return 0;
}


Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mod=1e9+7;

ll modinv(ll a, ll m) {
  ll b=m, u=1, v=0;
  while(b) {
    ll t=a/b;
    a -= t*b; swap(a, b);
    u -= t*v; swap(u, v);
  }
  u %= m;
  if(u<0)
    u += m;
  return u;
}

ll cmb(ll K) {
  return K*(K-1)%mod * modinv(2,mod) % mod;
}

int main() {
  int N, i, j;
  ll K, r, t=0, s=0;
  cin >> N >> K;
  vector<int> A(N);
  
  for(i=0; i<N; i++)
    cin >> A.at(i);
  
  for(i=0; i<N-1; i++)
    for(j=i+1; j<N; j++)
      if(A.at(i)>A.at(j)) {
        t++; t%=mod;
      }
  
  for(i=0; i<N; i++)
    for(j=0; j<N; j++)
      if(A.at(i)>A.at(j)) {
        s++; s%=mod;
      }
  
  r = t*K % mod + cmb(K)*s % mod;
  cout << r%mod << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  int ans = 0;
  FOR(i, 0, 3) ans += s[i]-'0';
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define erep(i, n) for (int i = 0; i <= (n); i++)
#define erep1(i, n) for (int i = 1; i <= (n); i++)
using namespace std;
using ll = long long;

ll choose2(ll n){
    return n * (n - 1) / 2;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n), d(n);
    rep(i, n) {
        cin >> a[i];
        a[i]--;
    }
    rep(i, n){
        d[a[i]]++;
    }
    ll tot = 0;
    rep(i, n) tot += choose2(d[i]);
    rep(i, n){
        ll ans = tot;
        ans -= choose2(d[a[i]]);
        ans += choose2(d[a[i]] - 1);
        cout << ans << endl;
    }
}

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

int main() {
  int N, M; // [1, 100]
  cin >> N;

  map<string, int> s;
  for(int i=0;i<N;i++){
    string x;
    cin >> x;
    s[x] += 1;
  }

  cin >> M;
  map<string, int> t;
  for(int i=0;i<M;i++){
    string x;
    cin >> x;
    t[x] += 1;
  }

  int out = 0;
  for(auto sitr = s.begin(); sitr != s.end(); sitr++){
    string skey = sitr->first;
    int svalue = sitr->second;
    auto titr = t.find(skey);
    if (titr != end(t)){
      int tvalue = titr->second;
      out = max(svalue - tvalue, out);
    }else{
      out = max(svalue, out);
    }
  }
  cout << out << endl;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    // int ans = 0;
    if (a + b >= c) {
        cout << b + c << endl;
    } else {
        cout << a + 2 * b + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define ti3 tuple<int,int,int>
ll int MOD=998244353;
int INF=1e6;
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    int c=0;
    int k;
    cin>>k;
    rep(i,9){
        cout<<i+1<<endl;
        c++;
        if(c==k) return 0;
    }
    rep(i,9){
        cout<<i+1<<9<<endl;
        c++;
        if(c==k) return 0;
    }
    rep(i,9){
        cout<<i+1<<99<<endl;
        c++;
        if(c==k) return 0;
    }
    rep2(i,2,12){
        rep2(j,10,99){
            if(j==i*10){
            break;
        }
            cout<<j;
            rep(ii,i){
                cout<<9;
            }
            cout<<endl;
            c++;
        if(c==k) return 0;
        
        }
        rep2(j,i,9){
            cout<<j;
            rep(ii,i+1){
                cout<<9;
            }
            cout<<endl;
            c++;
        if(c==k) return 0;
        }
    }
    rep2(i,100,109){
        cout<<i;
        rep(j,12){
            cout<<9;
        }
        cout<<endl;
        c++;
        if(c==k) return 0;
    }
    rep2(i,11,99){
        cout<<i;
        rep(j,13){
            cout<<9;
        }
        cout<<endl;
        c++;
        if(c==k) return 0;
    }
}

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

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const ll INF = 20000000000;
typedef std::pair<int,int> P;


	ll ans=0;
	ll N,K,G,A[500010],B[500010];
	ll sum;
	string S;
ll gcd(ll a,ll b){
    if(b==0)return a;
    return gcd(b,a%b);
}
bool F=true;
int main(){
	ios_base::sync_with_stdio(false);
	cin>>S;
	int l=0,r=S.size()-1;
	while(l<r){
		DEB(l)DEB(r)END
		if(S[l]==S[r])l++,r--;
		else if(S[l]=='x')l++,ans++;
		else if(S[r]=='x')r--,ans++;
		else{F=false;break;}
	}
	cout<<(F?ans:-1)<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <map>
#include<algorithm>
using namespace std;

int a[200000],b[200000],go[200001]; 


int main(){
    long long a,b,N;
    cin >>N;
    long long L[2*N];
    for(int i=0;i<2*N;i++){
        scanf("%lld",&L[i]);
    }
    sort(L,L+2*N);
    long long c=0;
    for(int i=0;i<2*N;i+=2){
        c+=min(L[i],L[i+1]);
    }
    cout << c <<endl;


    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(s) for s in input().split()]
a.sort(key=int,reverse=True)
alice = 0
bob = 0
for i in range(n):
    if i % 2 == 0:
        alice += a[i]
    else:
        bob += a[i]
print(alice - bob)

Measured memory_bytes: 9180
def f(i, j):
    i1, j1 = i, j
    if i1 > 2*K:
        return 0
    if j1 > 2*K:
        return 0
    i2, j2 = min(i+K, 2*K), min(j+K, 2*K)
    if i < 0:
        if j < 0:
            r = R[i2][j2]
        else:
            r = R[i2][j2] - R[i2][j1]
    elif j<0:
        r = R[i2][j2] - R[i1][j2]
    else:
#        print(i1,j1,i2,j2)
        r = R[i2][j2] - R[i1][j2] - R[i2][j1] + R[i1][j1]
    return r

N, K = map(int, input().split())
B = [[0]*(2*K+1) for  _ in range(2*K+1)]
for _ in range(N):
    a, b, c = input().strip().split()
    a, b, c = int(a), int(b), 1 if c == 'W' else 0
    B[(a+K*c)%(2*K)+1][b%(2*K)+1] += 1
R = [[0]*(2*K+1) for  _ in range(2*K+1)]
for i in range(1, 2*K+1):
    for j in range(1, 2*K+1):
        R[i][j] = R[i-1][j] + R[i][j-1] - R[i-1][j-1] + B[i][j]
r = 0
for i in range(K):
    for j in range(K):
        t = f(i,j)+f(i-K, j-K)+f(i+K, j+K)+f(i-K, j+K)+f(i+K, j-K)
#        print(i,j, f(i,j),f(i-K, j-K),f(i+K, j+K),f(i-K, j+K),f(i-K, j+K))
#        print(i, j, t, f(i-K,j))
        r = max(r, t)
#        print(i, j, t0,t1,t2)
for i in range(K):
    for j in range(K):
        i += K
        t = f(i,j)+f(i-K, j-K)+f(i-K, j+K)+f(i-2*K, j)
        r = max(r, t)
for i in range(K):
    for j in range(K):
        j += K
        t = f(i,j)+f(i-K, j-K)+f(i+K, j-K)+f(i, j-2*K)
        r = max(r, t)
print(r)





Measured memory_bytes: 124380
#include <stdio.h>
#include <string.h>

int main()
{
    int n;
    long double x,ans = 0;
    char u[4];

    scanf("%d",&n);
    for (int i = 0; i < n; i++)
    {
        scanf("%llf %s",&x,u);

        if(strcmp(u,"JPY") == 0)
        {
            ans += x;
        }
        else
        {
            ans += x * 380000.0;
        }
    }

    printf("%llf\n",ans);
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> V(N,-1);
  int s, c, ans=0;
  
  for (int i=0; i<M; i++) {
    cin >> s >> c;
    if (s==1 && c==0) {
      if (N==1) {
        V[s-1]=c;
        continue;
      }
      ans=-1;
      break;
    }
    if (V[s-1]!=-1 && V[s-1]!=c) {
      ans=-1;
      break;
    }
    V[s-1]=c;
  }
  if (V[0]==-1 && N==1) {V[0]=0;}
  else if (V[0]==-1) {V[0]=1;}
  if (ans==-1) {cout << ans << endl;}
  else {
    for (int i=0; i<N; i++) {
      if (V[i]==-1) {V[i]=0;}
      cout << V[i];
    }
    cout << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = 10000000;
const long long INFL = (1LL<<50);
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int n;cin>>n;
    string s1,s2;cin>>s1;cin>>s2;
    
    ll count;
    
    if(s1[0] == s2[0]) count = 3;
    else count = 6;
    
    for(auto i = 1;i<s1.size();i++){
        
        if(s1[i]==s1[i-1]) continue;
        if(s1[i] == s2[i]){
            if(s1[i-1]==s2[i-1])count*=2;
        }else{
            if(s1[i-1]!=s2[i-1])count*=3;
            else count*=2;
        }
        
        count %=MOD;
    }
    
    cout<<count<<endl;
    
    return 0;
}










Measured memory_bytes: 256
#include <iostream>

using namespace std;

int
main (int argv, char **argc)
{
	int n, d, x;
	cin >> n >> d >> x;
	int A[n+1];
	A[0] = 0;
	for (int i = 1; i < n+1; i++)
	   cin >> A[i];	

	int cho = 0;
	for (int i = 1; i < n+1; i++)
	{
		int a = A[i];
		for (int day = 1; day <= d; day+=a)
		{
			cho++;
		}
	}
	cout << cho + x << endl;
}

Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll a, b;
	cin >> a >> b;
	ll n = b - a - 1;
	cout << n * (n + 1) / 2 - a << endl;
}

Measured memory_bytes: 256
function Main(input) {
	var data = input.split("\n")
	var count = 0;
	for(var i = 0; i <= 2; i++){
		if(data[0][i] == data[1][i]) {
			count++;
		}
	}
	console.log(count)
}
 
// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
a,b,c,d = map(int,input().split())

r = False
if -d<=a-c and a-c<=d:
	r =True
elif -d<=a-b and a-b<=d and -d<=b-c and b-c<=d:
	r =True
else:
	r =False
if r:
	print('Yes')
else:
	print('No')

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

#define REP(i,n) for (int i = 0; i < n; ++i)
using ll = long long;

int main() {
  int n; cin >> n;
  vector<int> a(3*n); REP(i,3*n) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  REP(i,n) {
    ans += a[n+i*2];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    string S, ct = "AKIHABARA", cr = "";
    cin >> S;

    int cts = 0;
    rep(i, 9) {
        //cout << i << " " << ct[i] << " " << cts << " " << S[cts] << endl;
        if (cts >= (int)S.size()) {
            cr += 'A';
        }
        else if (ct[i] != S[cts]) {
            cr += 'A';
        }
        else {
            cr += S[cts];
            cts++;
        }
    }
    if ((int)S.size() >= 10) cr = "";

    //cout << cr << endl;

    cout << (ct == cr ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 998244353;//1000 * 1000 * 1000 + 7;


void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        a[i] = s[i] - '1';
    }
    int sm = 0;
    for (int i = 0; i < n; ++i) {
        if ((i ^ (n - i - 1)) == n - 1)
            sm += a[i];
    }
    if (sm & 1) {
        cout << 1 << endl;
        return;
    }
    int one = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] == 1) {
            one = 1;
        }
        else {
            a[i] /= 2;
        }
    }
    if (one) {
        cout << 0 << endl;
        return;
    }
    sm = 0;
    for (int i = 0; i < n; ++i) {
        if ((i ^ (n - i - 1)) == n - 1)
            sm += a[i];
    }
    if (sm & 1) {
        cout << 2 << endl;
    }
    else {
        cout << 0 << endl;
    }


}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

vector<int> PrimeFactoring(int N){
    vector<int> ans;
    while(N != 1){
        for(int a = 2;a <= N;a++){
            if(N%a == 0){
                N/=a;
                ans.push_back(a);
                break;
            }
        }
    }
    return ans;
}

void solve(long long N, long long M){
    vector<int> v = PrimeFactoring(M);
    COMinit();
    ll s = v.size();
    map<int, ll> mp;
    for(int i = 0;i < s;i++)mp[v[i]]++;
    ll ans = 1;
    for(auto a : mp){
        ans *= COM(a.second + N-1, a.second);
        ans %= MOD;
    }
    cout<<ans<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 12160
"use strict";
    
const main = arg => {
    const A = parseInt(arg.split("\n")[0].split(" ")[0]);
    const B = parseInt(arg.split("\n")[0].split(" ")[1]);
    
    console.log(B % A === 0 ? A + B : B - A);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[] s_hist = new int[26];
        int[] t_hist = new int[26];
        String s = scan.next();
        String t = scan.next();
        char[] s_d = s.toCharArray();
        char[] t_d = t.toCharArray();
        Map<Character, List<Integer>> map = new HashMap<>();
        for (int i = 0; i < s_d.length; i++) {
            if (!map.containsKey(s_d[i])) {
                map.put(s_d[i], new ArrayList());
            }
            map.get(s_d[i]).add(i);
        }
        Map<Character, Integer[]> search_map = new HashMap<>();
        for (char x : map.keySet()) {
            List<Integer> list = map.get(x);
            search_map.put(x, list.toArray(new Integer[list.size()]));
        }
        int search_target = 0;
        Comparator<Integer> c = new LowerBoundComparator<>();
        long turn = 0;
        long remain = 0;
        for (int i = 0; i < t_d.length; i++) {
            boolean found = false;
            remain = 0;
            while (!found) {
                Integer[] list = search_map.get(t_d[i]);
                if (list == null) {
                    System.out.println(-1);
                    return;
                }
                int search_index = ~Arrays.binarySearch(list, search_target, c);
                if (list.length <= search_index) {
                    search_target = 0;
                    turn += s_d.length;
                } else {
                    search_target = list[search_index] + 1;
                    remain = list[search_index];
                    found = true;
                }
            }
        }
        System.out.println(turn + remain + 1);
    }
    class LowerBoundComparator<T extends Comparable<? super T>> implements Comparator<T> {
        public int compare(T x, T y) {
            return (x.compareTo(y) >= 0) ? 1 : -1;
        }
    }
}


Measured memory_bytes: 31804
#include <iostream>
#include <string>
#include <cstring>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <fstream>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>


int main() {
	ll a, b;
	cin >> a >> b;
	cout << 6 - a - b << endl;
}



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

int main(){
	string s;

	cin >> s;

	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == ',') {
			s[i] = ' ';
		}
	}

	cout << s;
}

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

int main(){
  int a,b,k;
  double x,y;

  cin >> a >> b;
  x = a * 2.0;
  y = b;
  k = a+b;
  for(int i=1;i<a;i++){
    for(double j=1.0;j<y;j++){
      if(i*2*(y/x) == j){
        k--;
        break;
      }
    }
  }
  cout << k << endl;
}




Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scan = new Scanner(System.in);

		int N = scan.nextInt();
		int a[] = new int[N];
		int max = 0;
		int min = 0;
		for (int i = 0; i < N; i++) {
			switch (i) {
			case 0:
				a[i] = scan.nextInt();
				min = a[i];
				max = a[i];
				break;
			default:
				a[i] = scan.nextInt();
				if (max < a[i]) {
					max = a[i];
				} else if (min > a[i]) {
					min = a[i];
				}
				break;
			}
		}
		int minCost = 0;
		for (int i = min; i <= max; i++) {
			int cost = 0;
			for (int j = 0; j < N; j++) {
				int dis = a[j] - i;
				cost += dis * dis;
			}
			if (i == min) {
				minCost = cost;
			} else {
				if (minCost > cost) {
					minCost = cost;
				}
			}
		}
		System.out.println(minCost);
	}

}


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

const ll INF = 1LL << 60;

ll S, W;
int main() {
    cin >> S >> W;
    if (S <= W) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3636
s1 = gets.chomp.split('')
s2 = gets.chomp.split('')
l1 = s1.length
l2 = s2.length

dp = (l1 + 1).times.map{ [0] * (l2 + 1) }

(0..l1).each{ |y| dp[y][0] = y }
(0..l2).each{ |x| dp[0][x] = x }

for i in (1..l1)
    for j in (1..l2)
        cost = (s1[i-1] == s2[j-1]) ? 0 : 1
        dp[i][j] = [dp[i-1][j] + 1,          #insert
                    dp[i][j-1] + 1,          #delete
                    dp[i-1][j-1] + cost].min #replace
    end
end

puts dp[l1][l2]



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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    int d;
    cin >> d;
    if(d == 25)cout << "Christmas" << "\n";
    if(d == 24)cout << "Christmas Eve" << "\n";
    if(d == 23)  cout << "Christmas Eve Eve" <<  "\n";
    if(d == 22) cout << "Christmas Eve Eve Eve" << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int a,b,t;
  int bis;
  int time;
  
  scanf("%d%d%d",&a,&b,&t);

  time = t + 0.5;
  bis = time / a * b;
  
  printf("%d",bis);
  
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#include <iomanip>
#include <tuple>
#include <queue>
#include <numeric>
using namespace std;
typedef long long ll;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define repeq(i, a, n) for(int i=a;i<=n;++i)
#define repi(m, itr) for (auto itr = m.begin();itr != m.end();++itr)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// B - Frog 2
ll N, K;
ll ans = 0;
ll dp[105000];
ll h[105000];

int main(){
    cin >> N >> K;
    rep(i, 1, N+1){
        cin >> h[i];
    }
    rep(i, 0, 105000){
        dp[i] = 1000000000000;
    }
    dp[1] = 0;
    rep(i, 1, N+1){
        rep(j, 1, K+1){
            ll tmp = dp[i] + abs(h[i] - h[i + j]);
            dp[i + j] = min(dp[i + j], tmp);
        }
    }

    cout << dp[N] << endl;
    return 0;
}




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

using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int A,B,C;

    cin >> A >> B >> C;

    vector<int> v{A,B,C};

    if(count(v.begin(),v.end(),7) > 1)
        cout << "NO" << endl;
    else
        cout << "YES" << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String[] line = scanner.nextLine().split(" ");
		int numVertices = Integer.parseInt(line[0]);
		int numEdges = Integer.parseInt(line[1]);

		Map<Integer, List<Integer>> graph = new HashMap<>();
        for (int i = 0; i < numEdges; i++) {
            line = scanner.nextLine().split(" ");
            
            int from = Integer.parseInt(line[0]);
            int to = Integer.parseInt(line[1]);

            graph.putIfAbsent(from, new ArrayList<>());
            graph.get(from).add(to);
        }

        int[] dp = new int[numVertices + 1];
        boolean[] visited = new boolean[numVertices + 1];

        for(int i = 1; i <= numVertices; i++) {
        	if(!visited[i]) {
        		dfs(graph, i, dp, visited);
        	}
        }

        int result = 0;
        for(int num : dp) {
        	result = Math.max(result, num);
        }

        System.out.println(result);
	}

	private static void dfs(Map<Integer, List<Integer>> graph, int vertex, int[] dp, boolean[] visited) {
		visited[vertex] = true;
		if(graph.containsKey(vertex)) {
			for(int child : graph.get(vertex)) {
				if(!visited[child]) {
					dfs(graph, child, dp, visited);	
				}
				
				dp[vertex] = Math.max(dp[vertex], 1 + dp[child]);
			}
		}
	}
}

Measured memory_bytes: 85412
#include<iostream>

using namespace std;

int main(){
  int a,b;
  while(cin >> a >> b){
    int count = 0;
    int result = a + b;
    while(1){
      if(result == 0){
        cout << count << "\n";
        break;
      }
      result /= 10;
      count++;
    }
  }
  return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Here your code !
    long long int x,y;
    cin >> x >> y;
    
    if(x==y){
        cout << 0 << endl;
        return 0;
    }
    
    if( y == 0 ){
        if(x < 0)
        cout << -1*x << endl;
        else
        cout << 1+x << endl;
        return 0;
    }
    
    if(x < 0 && y < 0){
        if(y > x)
            cout << y-x << endl;
        else
            cout << 1+x-y+1 << endl;
    }else if(x < 0 && y >= 0){
        if(-1*x>y)
            cout << 1+abs(x+y) << endl;
        else
            cout << 1+y+x << endl;
    }else if(x >= 0 && y < 0){
        if(-1*y>x)
            cout << abs(y+x)+1 << endl;
        else
            cout << 1+y+x << endl;
    }else if(x >= 0 && y >= 0){
        if(y > x)
            cout << y-x << endl;
        else
            cout << 1+x-y+1 << endl;
    }
    
    
}


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

int main()
{
    ll n, k, q;
    cin >> n >> k >> q;
    ll p[n];
    rep(i, n) p[i] = k - q;
    rep(i, q)
    {
        ll a;
        cin >> a;
        p[a - 1]++;
        // rep(i, n)
        // {
        //     if (i + 1 == a)
        //         continue;
        //     p[i]--;
        // }
    }
    rep(i, n)
    {
        // cout << p[i] << endl;
        if (p[i] > 0)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    bool flag;
    flag=true;
    for(int i=0; i<S.size(); i++){
        int j;
        j=i%2;
        if(j==0){
            if( S[i]!='R' && S[i]!='U' && S[i]!='D' ){
                flag=false;
            }
        }else{
            if( S[i]!='L' && S[i]!='U' && S[i]!='D' ){
                flag=false;
            }            
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

void solve(long long N, long long C, long long K, std::vector<long long> T){
    sort(ALL(T));
    ll cnt = 0;
    queue<long long> myque;
    for(auto x: T){
        myque.push(x);
    }

    
    while(!myque.empty()){
        ll time = myque.front();
        cnt ++;
        REP(i, C){
            ll t = myque.front(); 
            if(t <= time + K){
                myque.pop();
                if(myque.empty())
                    break;
            }
                
        }
    }
    cout << cnt <<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long C;
    scanf("%lld",&C);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> T(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&T[i]);
    }
    solve(N, C, K, std::move(T));
    return 0;
}


Measured memory_bytes: 1792
n=int(input())
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
ans=0
for i in range(n):
    tmp=0
    tmp+=sum(a1[:i+1])
    tmp+=sum(a2[i:])
    ans=max(tmp,ans)
print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int x,y;
	cin>>x>>y;
	bool yn=false;
	for(int i=0;i<=x;i++){
		if(2*i+4*(x-i)==y)yn=true;
	}
	if(yn==true)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 3624
#coding:utf-8
# x=int(raw_input())  # 1 # 一つの数字のみ
# w, a, b =map(int,raw_input().split())  # 2 3  # 二つの数字

x =input()
sums=0
for i in range(44722):
    sums += i
    # if x == place:
    # print sum
    # print i
    if sums < x:
        pass
    elif sums >= x:
        print i
        break
    # print i
    # print "max",sums
    # print "i",i
# print pl?ace

Measured memory_bytes: 3972
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

struct Node{

	Node(int arg_to,int arg_cost){
		to = arg_to;
		cost = arg_cost;
	}
	bool operator<(const struct Node &arg) const{
			return cost > arg.cost;
	};

	int to,cost;
};

int main(){

	int N;
	scanf("%d",&N);

	vector<Node> V[N];

	int node,num,to,cost,D[N];;

	for(int loop = 0; loop < N; loop++){
		scanf("%d",&node);
		scanf("%d",&num);
		for(int i = 0; i < num; i++){
			scanf("%d %d",&to,&cost);
			V[node].push_back(Node(to,cost));
		}
		D[loop] = BIG_NUM;
	}

	D[0] = 0;

	priority_queue<Node> Q;

	for(int i = 0; i < V[0].size(); i++){
		D[V[0][i].to] = V[0][i].cost;
		Q.push(Node(V[0][i].to,V[0][i].cost));
	}

	int min_index;

	while(!Q.empty()){
		if(Q.top().cost == D[Q.top().to]){
			min_index = Q.top().to;
			Q.pop();
		}else{
			Q.pop();
			continue;
		}

		for(int k = 0; k < V[min_index].size(); k++){
			if(D[V[min_index][k].to] > D[min_index] + V[min_index][k].cost){
				D[V[min_index][k].to] = D[min_index] + V[min_index][k].cost;
				Q.push(Node(V[min_index][k].to,D[V[min_index][k].to]));
			}
		}
	}

	for(int i = 0; i < N; i++)printf("%d %d\n",i,D[i]);

    return 0;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  
  int d;
  vector<int>A(110);
  
  for(int i = 0;i < K ;i++){
    cin>>d;
    
    for(int j = 0;j < d ;j++){
      int tmp = 0;
      cin>>tmp;
      A[tmp] = 1;
    }
  }
  
  int res = 0;
  
  for(int i = 1;i < N+1 ;i++){
    if(A[i]==0)res++;
  }
  cout<<res;
  

return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll k;
    cin>>k;
    string s;
    cin>>s;
    if(s.size() <= k){
        cout<<s<<endl;
    }else{
        s = s.substr(0, k);
        cout<<s<<"..."<<endl;
    }
}

Measured memory_bytes: 3628
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
using namespace std;
#define FOR(i,a,n) for(int i=(ll)a;i<(ll)n;++i)
#define TFOR(i,n)FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	ll a;
	cin >> a;
	ll b = a;
	ll sum = 0;
	ll i = 9;
	while (a >= 10) {
		sum += a / pow(10, i);
		ll n = pow(10, i);
		a %= n;
		--i;
	}
	sum += a;
	cout <<(b%sum == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


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



    int n;
    cin >> n;
    cout << (double) (n / 2 + n % 2) / n;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int s[20],c[20];
	int n;
	while(true){
	    cin>>n;
		if(n==0)
			break;
	for(int i=0;i<n;i++)
		cin>>s[i];
	int d=0;
	while(true){
		for(int i=0;i<n;i++){
			int count=0;
			for(int j=0;j<n;j++){
				if(s[i]==s[j])
					count++;
			}
			c[i]=count;
		}
		bool t=true;
		for(int i=0;i<n;i++){
			if(s[i]!=c[i]){
				t=false;
				s[i]=c[i];
			}
		}
		if(t==true)
			break;
		d++;
	}
	cout<<d<<endl;
	for(int i=0;i<n-1;i++)
		cout<<s[i]<<" ";
	cout<<s[n-1]<<endl;
	}
    return 0;
}
 

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

int main() {
	int64_t k, q; cin >> k >> q;
	int64_t D[k]; for(int i = 0; i < k; ++i) cin >> D[i];
	while(q--) {
		int64_t n, x, m; cin >> n >> x >> m;
		int64_t d[k];
		int64_t cnteq = 0, sum = 0;
		for(int i = 0; i < k; ++i) {
			d[i] = D[i] % m;
			sum += d[i];
			if(d[i] == 0) ++cnteq;
		}
		int64_t loop = (n - 1) / k;
		cnteq *= loop;
		sum *= loop;
		int64_t mod = (n - 1) % k;
		for(int i = 0; i < mod; ++i) {
			sum += d[i];
			if(d[i] == 0) ++cnteq;
		}
		int64_t an = x + sum;
		cout << (n - 1) - cnteq - (an / m - x / m) << '\n';
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

int main(){
    int N;cin >> N;
    int X, Y;cin >> X >> Y;
    vivi G(N);
    for(int i = 0;i < N - 1;++i){
        G[i].push_back(i + 1);
        G[i + 1].push_back(i);
    }
    G[X - 1].push_back(Y - 1);
    G[Y - 1].push_back(X - 1);
    int ans[N][N];//node i to j 最短経路
    for(int i = 0;i < N;++i){
        for(int j = 0;j < N;++j){
            ans[i][j] = INF;
        }
    }
    for(int i = 0;i < N;++i){
        queue<int> Q;
        Q.push(i);
        bool visited[N];
        memset(visited, false, sizeof(visited));
        ans[i][i] = 0;
        while(!Q.empty()){
            int q = Q.front();Q.pop();
            visited[q] = true;
            for(int v : G[q]){
                if(!visited[v])Q.push(v);
                ans[i][v] = min(ans[i][v], ans[i][q] + 1);
            }
        }
    }
    int aaa[N + 1];
    memset(aaa, 0, sizeof(aaa));
    for(int i = 0;i < N;++i){
        for(int j = 0;j < i + 1;++j){
            aaa[ans[i][j]] += 1;
        }
    }
    for(int k = 0;k < N - 1;++k){
        cout << aaa[k + 1] << endl;
    }
}


Measured memory_bytes: 16128
import java.util.*;
class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        String[] S = new String [N+1];
        int [] C = {0,0,0,0};
        for(int i=0;i<N+1;i++){
            S[i] = scan.nextLine();
        }
        for(int i=0;i<N+1;i++){
            switch(S[i]){
                case "AC":
                    C[0] += 1;
                    break;
                case "WA":
                    C[1] += 1;
                    break;
                case "TLE":
                    C[2] += 1;
                    break;
                case "RE":
                    C[3] += 1;
                    break;
                default:
            }
        }
        System.out.println("AC x " + C[0] + "\n" + "WA x " + C[1] + "\n" + "TLE x " + C[2] + "\n" + "RE x " + C[3]);

        scan.close();
    }
}


Measured memory_bytes: 65632