akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
using namespace std;
int a[10];
bool solve()
{
    if(a[1]==a[2]&&a[2]==a[3]) return true;
    if(a[2]==a[3]&&a[3]==a[4]) return true;
    return false;
}
int main()
{
    int n;
    cin>>n;
    int t=0;
    while(n)
    {
        a[++t]=n%10;
        n=n/10;
    }
    if(solve()) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <time.h>
#include <string>

using namespace std;


int main()
{
	long N;
	long min;
	long a[5];
	cin >> N;
	for (int i = 0;i < 5;i++)
	{
		cin >> a[i];
	}
	min = 0;
	for (int i = 0;i < 5;i++)
	{//最小
		if (a[min] > a[i])
		{
			min = i;
		}
	}
	long wari;long pers;
	wari = N / a[min];
	pers = N%a[min];
	if (!pers)
	{
		wari -= 1;
	}
	cout << 5 + wari;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
using namespace std;
#define FREE -1
#define NOT_FREE 1
#define N 8

int row[N], col[N], dpos[2 * N -1], dneg[2 * N -1];
bool X[N][N];

void initialize() {
    for (int i = 0; i < N; i++) {
        row[i] = FREE, col[i] = FREE;
    }
    for (int i = 0; i < N; i++) {
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

void printBoard() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (X[i][j]) {
                if(row[i] != j) return;
            }
        }
    }
    for(int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << ((row[i] == j) ? "Q" : "." );
        }
        cout << endl;
    }
}

void recursive(int i) {
    if (i == N) {
        printBoard();
        return;
    }
    for (int j = 0; j < N; j++) {
        if (NOT_FREE == col[j] || NOT_FREE == dpos[i + j] || NOT_FREE == dneg[i - j + N - 1]) continue;
        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
        recursive(i + 1);
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
}


int main() {
    initialize();
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) X[i][j] = false;
    }
    int k;
    cin >> k;
    for(int i = 0; i < k; i++) {
        int r, c;
        cin >> r >> c;
        X[r][c] = true;
    }
    recursive(0);
    return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i = 0;i < N;i++)cin >> L[i];
 
  sort(L.begin(),L.end());
 
  ll ans = 0;
 
  for(int i = 0;i < N - 1;i++){
    for(int j = i + 1;j < N;j++){
      int a = L[i];
      int b = L[j];
      auto itr_lower = lower_bound(L.begin(),L.end(),a+b);
      auto itr_upper = upper_bound(L.begin(),L.end(),b-a);
 
      ans += (ll)(itr_lower-itr_upper);
 
      if(2 * a > b)ans--;
 
      ans--;
    }
  }
 
  cout << ans / 3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

void solve(long long D, long long G, std::vector<long long> p, std::vector<long long> c){
    ll ans = 1e9;
    // {0, 1, ..., D-1}の部分集合の全探索
    for(ll mask = 0; mask < (1 << D); ++mask){
    /*
        // maskの表す集合を求める
        vector<int> S;
        for(int i = 0; i < D; ++i){
            if(mask & (1<<i)){
                S.push_back(i);
            }
        }
        // maskの表す集合を出力
        cout << mask << ": {";
        for(int i = 0; i < (int)S.size(); ++i){
            cout << S[i] << " ";
        }
        cout << "}" << endl;
    */
        ll s = 0, num = 0, rest_max = -1;
        for(ll i = 0; i < D; ++i){
            if(mask >> i & 1){
                s += 100 * (i+1) * p[i] + c[i];
                num += p[i];
            }else{
                rest_max = i;
            }
        }
        //cout << "s: " << s << ", num: " << num << ", rest_max:" << rest_max << endl;

        if(s < G){
            int s1 = 100 * (rest_max + 1);
            int need = (G - s + s1 - 1) / s1;
            if(need >= p[rest_max]){
                continue;
            }
            num += need;
            //cout << "need: " << need << ", num: " << need << endl; 
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
}

int main(){
    long long D;
    scanf("%lld",&D);
    long long G;
    scanf("%lld",&G);
    std::vector<long long> p(D);
    std::vector<long long> c(D);
    for(int i = 0 ; i < D ; i++){
        scanf("%lld",&p[i]);
        scanf("%lld",&c[i]);
    }
    solve(D, G, std::move(p), std::move(c));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
const double PI = acos(-1.0);
const string ALP = "abcdefghijklmnopqrstuvwxyz";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int main(){
  string s;
  vector<bool> v(26);
  cin >> s;
  REP(i,26){
    v[i] = false;
  }
  REP(i,s.length()){
    if(v[ALP.find(s[i])]){
      cout << "no";
      break;
    }
    v[ALP.find(s[i])] = true;
    if(i== s.length()-1){
      cout << "yes";
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0,-1,0}; //次に行くところ
int dx[] = {0,1,0,-1}; //s上に同じ

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,c,d,i = 0;
  cin >> a >> b >> c >> d;
  while (a > 0 && c > 0){
    if (i % 2 == 0){
      c -= b;
      i++;
    }else{
      a -= d;
      i++;
    } 
  }
  
  if (a <= 0){
    cout << "No\n";
  }else{
    cout << "Yes\n";
  }
  
  
  
  return 0;
}


Measured memory_bytes: 3616
n=int(input())
A=[int(i) for i in input().split()]

suma=0
for i in range(n):
    suma^=A[i]

B=[~suma&me for me in A]
B.sort(reverse=True)

cnt=0
for i in range(59,-1,-1):
    B.sort(reverse=True)
    if B[cnt]&(1<<i)>0:
        #print(i,"!")
        for q in range(cnt):
            if B[q]&(1<<i)>0:
                B[q]^=B[cnt]
        for q in range(cnt+1,n):
            if B[q]&(1<<i)>0:
                B[q]^=B[cnt]
            else:
                break          
        cnt+=1

ans=0
B.sort(reverse=True)
for i in range(n):
    ans^=B[i]

print(ans*2+suma)

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

int compression( int* a, int b )
{
    int sum = 0;
    for( int i = 0; i < b; i++ )
    {
        int j = i;
        while( j < b && a[j] >= 1 )
            j++;
        if( j - i >= 4 )
        {
            j--;
            sum += 3;
            while( j != i - 1 )
            {
                a[j]--;
                j--;
            }
            i--;
        }
    }
    return sum;
}

int main()
{
    int a[26] = {}, b[10] = {};
    string s;

    cin >> s;

    for( int i = 0; i < s.size(); i++ )
    {
        if( '0' <= s[i] && s[i] <= '9' )
            b[s[i]-'0']++;
        else
            a[s[i]-'a']++;
    }

    int sum = 0;
    int cnt = 100;
    while( cnt-- )
    {
        sum += compression( a, 26 );
        sum += compression( b, 10 );
    }

    for( int i = 0; i < 26; i++ )
    {
        if( a[i] >= 1 )
            sum += a[i];
        if( i < 10 && b[i] >= 1 )
            sum += b[i];
    }
    if( s.size() > sum )
        cout << sum << endl;
    else
        cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>

using namespace std;

int main(){
  int N;
  cin >> N;
  int ans = 0;

  int sum = 0;
  int x = N;
  for (int j = 0; j<9; j++){
    sum += x % 10;
    x /= 10;
  }

  if ( N % sum == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	ll n;
	cin >> n;
	string ans;
	while(1){
		if(n%26==0){
			ans.insert(ans.begin(),'z');
		}else{
			ans.insert(ans.begin(),'a'-1+n%26);
		}
		if(n<=26){
			break;
		}else{
			if(n%26==0){
				n-=26;
			}else{
				n-=n%26;
			}
			n=n/26;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3616
Option Strict On
Module Module1

    Sub Main()
        Dim S As String = Console.ReadLine()
        Dim mojisu As Integer = Strings.Len(S)
        Dim counter As Integer = 0
        Dim answer As Integer = 0
        For i As Integer = 1 To mojisu
            If Mid(S, i, 1) = "A" Or Mid(S, i, 1) = "C" Or Mid(S, i, 1) = "G" Or Mid(S, i, 1) = "G" Or Mid(S, i, 1) = "T" Then
                counter += 1
                If answer <= counter Then
                    answer = counter
                End If
            Else
                counter = 0
            End If
        Next
        Console.WriteLine(answer)
        Console.ReadLine()
    End Sub

End Module

Measured memory_bytes: 20432
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    ll h; cin >> h;

    ll ans = 0;
    ll cnt = 1;
    while (h > 0) {
        h /= 2;
        cnt *= 2;
        ans += cnt;
    }
    cout << ans/2 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
long long mod = (1e9)+7;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(N), B(M), C(N*M,-1), D(N*M,-1);
  for(int i = 0; i < N; ++i){
    cin >> A[i];
    --A[i];
    if(C[A[i]] >= 0){
      cout << 0 << endl;
      return 0;
    }
    C[A[i]] = i;
  }
  for(int i = 0; i < M; ++i){
    cin >> B[i];
    --B[i];
    if(D[B[i]] >= 0){
      cout << 0 << endl;
      return 0;
    }
    D[B[i]] = i;
  }
  long long ans = 1, r = 0, c = 0;
  for(int i = N*M-1; i >= 0; --i){
    //cerr << i << " " << ans << endl;
    if(C[i] >= 0 and D[i] >= 0){
      ++r;
      ++c;
      continue;
    }
    if(C[i] < 0 and D[i] < 0){
      ans *= r*c - (N*M-i-1);
      ans %= mod;
    }else if(C[i] < 0){
      ans *= r;
      ans %= mod;
      ++c;
    }else{
      ans *= c;
      ans %= mod;
      ++r;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 8064
#include<bits/stdc++.h>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main(){

  long long a,b,X;
  long long ans,ans1,ans2;
  cin >> a >> b >> X; 
  
  if(a==0){
    ans=b/X+1;
  }else{
    ans1 = (a-1)/X+1;
    ans2 = b/X+1;
    
      ans = ans2-ans1;
    
  }
 
  cout << ans << endl;

  return 0;
}
 

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

#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define rev(a) (a).rbegin(),(a).rend()
#define pll pair<ll,ll>
#define rep(i,a,b) for(long long i = (a); i <= (b); i++)

const int mod = 1e9+7;
const int N = 2e5+5;

ll arr[N];

int main(){
	fast;
	ll t = 1; 
// 	cin >> t;
	while(t--){
       ll n; cin >> n;
       rep(i,1,n-1){
           ll x; cin >> x;
           arr[x]++;
       }
        
       rep(i,1,n)  
       cout << arr[i] << endl;
	}
}

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

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

    vector<bool> is_good(n);
    rep(i, n) is_good[i] = true;
    rep(i, m)
    {
        if (h[a[i]] == h[b[i]])
        {
            is_good[a[i]] = false;
            is_good[b[i]] = false;
        }
        else if (h[a[i]] > h[b[i]])
            is_good[b[i]] = false;
        else
            is_good[a[i]] = false;
    }
    int cnt = 0;
    rep(i, n) if (is_good[i]) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4580
// Volume0 - 0042: A Thief
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
//#define DEBUG
 
// ??????????????°??? 1000 ??\????????????????????????10000 ??\???
// ???????????????????????§??????10^7
class Solver {
private:
    int caseNum; // ???????????????????????????
    int w; // ?¢¨??????????????????????????????W(1000 ??\???)
    int n; // ???????????° N
    vector<int> vv; // vector of value
    vector<int> vw; // vector of weight
    int maxValue;  // ?¢¨???????????\???????????????????????????
    int maxWeight; // ????????¨??????????????????????????????
public:
    Solver():caseNum(0){}
    bool input();
    void calc();
    void output();
};
bool Solver::input() {
    ++caseNum;
    cin >> w;
    if(w == 0) return false;
    cin >> n;
    vv.clear();
    vw.clear();
    for(int i=0; i<n; i++) {
        int value, weight;
        char ch;
        cin >> value >> ch >> weight;
        vv.push_back(value);
        vw.push_back(weight);
    }
    return true;
}
void Solver::calc() {
    vector<int> memo(w+1,0);
    for(unsigned int i=0; i<vv.size(); i++) {
        vector<int> temp = memo;
        for(unsigned int j=0; j+vw[i]<=memo.size(); j++) {
            temp[j+vw[i]] = std::max(memo[j+vw[i]], memo[j]+vv[i]);
        }
        memo = temp;
    }
    maxValue = 0;
    maxWeight = 0;
    for(int i=memo.size()-1; i>=0; --i) {
        if(maxValue <= memo[i]) {
            maxValue = memo[i];
            maxWeight = i;
        }
    }
}
void Solver::output() {
    cout << "Case " << caseNum << ":" << endl;
    cout << maxValue << endl;
    cout << maxWeight << endl;
}
 
int main(int argc, char** argv) {
    Solver solver;
    while(solver.input()) {
        solver.calc();
        solver.output();
    }
    return 0;
}

Measured memory_bytes: 3124
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

const ll INF = 1LL << 50;

const ll mod = 1000000007;

int main() {
  ll h, n;

  cin >> h >> n;

  vll a(n + 1);
  vll b(n + 1);
  rep(i, n) cin >> a[i + 1] >> b[i + 1];

  ll hpmax = 2 * 10000;

  vvll dp(hpmax + 1, vll(n + 1, INF));

  rep(j, n + 1) dp[0][j] = 0;
  for (ll i = 0; i <= hpmax; i++) {
    for (ll j = 1; j <= n; j++) {
      if (i - a[j] >= 0) chmin(dp[i][j], dp[i - a[j]][j] + b[j]);
      chmin(dp[i][j], dp[i][j - 1]);
    }  // j
  }    // i

  ll ans = LONG_LONG_MAX;
  for (ll i = h; i <= hpmax; i++) {
    chmin(ans, dp[i][n]);
  }

  cout << ans << endl;

  return 0;
}
 

Measured memory_bytes: 157312
#include<bits/stdc++.h>
using namespace std;
int main()
{

int ar[100][100];
char ch[100][100];
int a,b,c,d,e,i,j,k;
cin>>a>>b;
for(i=1;i<=a;i++)
{
for(j=1;j<=b;j++)
{
ar[i][j]=0;
}
}
for(i=1;i<=a;i++)
{
for(j=1;j<=b;j++)
{
 cin>>ch[i][j];
}
}
for(i=1;i<=a;i++)
{
for(j=1;j<=b;j++)
{
 if(ch[i][j]=='#')
 {
  if(ch[i-1][j-1]!='#')
  {
   ar[i-1][j-1]++;
// cout<<ar[i-1][j-1]<<endl;
  }

if(ch[i][j-1]!='#')
  {
   ar[i][j-1]++;
  }
if(ch[i-1][j]!='#')
  {
   ar[i-1][j]++;
  }

if(ch[i-1][j+1]!='#')
  {
   ar[i-1][j+1]++;
  }
if(ch[i][j+1]!='#')
  {
   ar[i][j+1]++;
  }

if(ch[i+1][j-1]!='#')
  {
   ar[i+1][j-1]++;
  }


if(ch[i+1][j]!='#')
  {
   ar[i+1][j]++;
  }

if(ch[i+1][j+1]!='#')
  {
   ar[i+1][j+1]++;
  }

 }
}
}
for(i=1;i<=a;i++)
{
 for(j=1;j<=b;j++)
 {
  if(ar[i][j]!=0)cout<<ar[i][j];
  else{if(ch[i][j]=='#') cout<<"#";
else cout<<"0";}
 }
cout<<endl;
}

}

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-1);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        cin >> b[i];
    }
    for(int i=0; i<n-1; i++){
        cin >> c[i];
    }

    int s = 0;
    for(int i=0; i<n; i++){
        s += b[i];
        //cout << s << endl;
    }
    for(int i=0; i<n-1; i++){
        if(a[i] + 1 == a[i+1]){
            s += c[a[i] - 1];
            //cout << s << endl;
        }
    }

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 310;
int a[N][N],b[N],c[N];
bool pd[N];
int n,m;
int main(){
	scanf("%d%d",&n,&m);
	for(int i =1;i<=n;i++){
		for(int j =1;j<=m;j++)scanf("%d",&a[i][j]);
	}
	int ans = n;
	for(int i =1;i<=n;i++) b[i] = 1;
	for(int k = 1;k<=m;k++){
		memset(c,0,sizeof(c));
		for(int i =1;i<=n;i++) c[a[i][b[i]]]++;
		int mx = 0,pos = -1;
		for(int i =1;i<=m;i++){
			if(c[i]>mx){
				mx = c[i];
				pos = i;
			}
		}
		ans = min(ans,mx);
		pd[pos] =1;
		for(int i  = 1;i<=n;i++){
			while(b[i]<=m && pd[a[i][b[i]]]) b[i]++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
 

int main(){
    ll X;
    cin >> X;
    
    ll n = 0;
    int i = 1;
    while(1){
        n += i; 
        if(n >= X) break;
        i++;
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<58;
const ll mod=1e9+7;


int main(){
  int i,j;
  ll n;
  cin>>n;
  int a[n];
  for(i=0;i<n;i++) cin>>a[i];  
  VI cnt(n+1,0);
  VVI v(n);
  for(i=0;i<n;i++){
    cnt[a[i]]++;
    v[a[i]].pb(i);
  }
  ll ans=1;
  for(i=0;i<cnt[0];i++){
    ans*=(3-i);
  }
  for(i=0;i<n-1;i++){
    vector<P> w;
    for(j=0;j<v[i].size();j++){
      w.pb(P(v[i][j],i));
    }
    for(j=0;j<v[i+1].size();j++){
      w.pb(P(v[i+1][j],i+1));
    }
    sort(w.begin(),w.end());
    int l=0;
    ll mul=1;
    for(j=0;j<w.size();j++){
      if(w[j].se==i) l++;
      else {
        mul*=l;
        l--;
      }
    }
    ans=ans*mul%mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;
using namespace std;

typedef vector<vector<int>> vii;

vector<vector<bool>> graph = vector<vector<bool>>(50, vector<bool>(50, false));
vector<bool> visited(50, false);
int N;
int M;

int dfs(int v, int cnt){
    visited[v] = true;
    cnt ++;
    rep(i, N){
        if(graph[v][i] && ! visited[i]){
            cnt = dfs(i, cnt);
        }
    }
    return  cnt;
}



int main(){
    cin >> N >> M;
    rep(j, M){
        int a, b;
        cin >> a >> b;
        a --;
        b --;
        graph[a][b] = graph[b][a] = true;
    }

    int ans = 0;

    rep(i, N){
        for(int j = i; j < N ; j++){
            if(! graph[i][j]){
                continue;
            }
            graph[i][j] = graph[j][i] = false;
            int cnt = dfs(0, 0);
            if(cnt != N){
                ans ++;
            }
            graph[i][j] = graph[j][i] = true;
            rep(k, N){
                visited[k] = false;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main()
{
    int i;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='A' && s[i+1]=='B' ||s[i]=='B' &&s[i+1]=='A')
        {
            cout<<"Yes"<<endl;
            break;
        }
        else if(s[i]=='B' && s[i+1]=='B' || s[i]=='A' &&s[i+1]=='A')
        {
            continue;
        }
        else
        cout<<"No"<<endl;
    }
}

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

int main(){
  double f;
  int a, b, d, r;
  cin >> a >> b;
  d = a / b;
  r = a % b;
  f = (double)a / (double)b;
  cout << d << " " << r << " "; 
  cout << fixed << setprecision(6) << f << endl;
}


Measured memory_bytes: 3276
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner console = new Scanner(System.in);

		int a = console.nextInt();
		int b = console.nextInt();
		int c = console.nextInt();

		if(a == b)
		{
			System.out.print(c);
		}
		else if(a == c)
		{
			System.out.print(b);
		}
		else
		{
			System.out.print(a);
		}
	}
}

Measured memory_bytes: 35692
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

vector<char> t(2e5+10),d(2e5+10);
ll n,q;
string s;

bool front(ll f) {
  for(ll i=0;i<q;i++) {
    if(s[f]==t[i]) {
      if(d[i]=='L') {
        f--;
      }
      else {
        f++;
      }
      if(f<0) return true;
      if(f>=n) return false;
    }
  }
  return false;
}

bool back(ll f) {
  for(ll i=0;i<q;i++) {
    if(s[f]==t[i]) {
      if(d[i]=='L') {
        f--;
      }
      else {
        f++;
      }
      if(f<0) return false;
      if(f>=n) return true;
    }
  }
  return false;
}

int main() {
  cin >> n >> q;
  cin >> s;
  for(ll i=0;i<q;i++) cin >> t[i] >> d[i];
  ll l=-1,r=n;
  ll tmp=(l+r)/2;
  ll ans=n;
  while(l+1<r) {
    if(front(tmp)) {
      l=tmp;
    }
    else {
      r=tmp;
    }
    tmp=(l+r)/2;
  }
  ans-=(l+1);
  l=-1,r=n;
  tmp=(l+r)/2;
  while(l+1<r) {
    if(back(tmp)) {
      r=tmp;
    }
    else {
      l=tmp;
    }
    tmp=(l+r)/2;
  }
  ans-=(n-r);
  cout << ans << endl;
}

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

int main()
{
    int n, m; cin >> n >> m;
    vector<vector<int>> v(n);
    rep(i, m){
        int a, b; cin >> a >> b;
        a--; b--;
        v[a].emplace_back(b);
        v[b].emplace_back(a);
    }
    /*cout << endl;
    for(int i = 0; i < n; i++){
        for(auto x : v[i]){
            cout << x+1 << " ";
        }
        cout << endl;
    }*/
    vector<int> ans(n, -1);
    queue<int> q;
    q.push(0);
    ans[0] = 0;
    while(q.size()){
        int t = q.front(); q.pop();
        for(int i = 0; i < v[t].size(); i++){
            if(ans[v[t][i]] == -1){
                ans[v[t][i]] = t;
                q.push(v[t][i]);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < n; i++){
        cout << ans[i]+1 << endl;
    }

    system("pause");
}


Measured memory_bytes: 10244
#include<bits//stdc++.h>
using namespace std;
int main(){
    long long a;
    cin>>a;
    int b=a%10;
    int c=(a%100)/10;
    int d=(a%1000)/100;
    int e=(a%10000)/1000;
    int f=(a%100000)/10000;
    int g=(a%1000000)/100000;
    int h=(a%10000000)/1000000;
    int i=(a%100000000)/10000000;
    int j=(a%1000000000)/100000000;
    int k=(a%10000000000)/1000000000;
    int B=b+c*10+d*100;
    int C=c+d*10+e*100;
    int D=d+e*10+f*100;
    int E=e+f*10+g*100;
    int F=f+g*10+h*100;
    int G=g+h*10+i*100;
    int H=h+i*10+j*100;
    int I=i+j*10+k*100;
    cout<<min({abs(753-B),abs(753-C),abs(753-D),abs(753-E),abs(753-F),abs(753-G),abs(753-H),abs(753-I)})<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int enum_div(int n,int l[],bool include_self=true){
    l[0]=1;
    if(n==1)return 1;
    int itr=1;
    if(include_self){
        l[itr]=n;
        itr++;
    }
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            l[itr]=i;
            itr++;
            if(i*i!=n){
                l[itr]=n/i;
                itr++;
            }
        }
    }
    return itr;
}
int l[2000];
int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int k=enum_div(m,l);
    std::sort(l,l+k);
    for(int i=k-1;i>=0;i--){
        if(l[i]<=m/n){
            printf("%d",l[i]);
            return 0;
        }
    }
}

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

int main()
{
    int n;
    cin>>n;
    int x[n+2];
    long long sum = 0;
    long long min = INT_MAX;
    for(int i=0;i<n;i++){
        cin>>x[i];
    }
    for(int i=1;i<102;i++){
        sum = 0;
        for(int j=0;j<n;j++){
            sum+=pow(x[j]-i,2);
        }
        if(min>sum){
            min = sum;
        }
    }
    cout<<min<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<sstream>
using namespace std;
long rec(int lay, long res, long* l, long* p){
  if(lay==0){
    return res;
  }

  if(res == 1){
    return 0;
  } else if (res <= l[lay-1]+1){
    return rec(lay-1,res-1,l,p);
  } else if (res == l[lay-1]+2){
    return p[lay-1] + 1;
  } else if (res >= l[lay]-1){
    return p[lay];
  } else {
    return p[lay-1] + 1 + rec(lay-1,res-(l[lay-1]+2),l,p);
  }
}
int main() {
  long n,x;
  stringstream ss;
  cin >> n >> x;
  string b = "P";
  long* l = new long[51];
  l[0] = 1;
  for(int i=1;i<51;i++) l[i] = 2 * l[i-1] + 3;
  long* p = new long[51];
  p[0] = 1;
  for(int i=1;i<51;i++) p[i] = 2 * p[i-1] + 1;
  cout << rec(n,x,l,p)<< endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;
 
public class Main {
	private class LIS {
		LinkedList<Long> data = new LinkedList<Long>();
		boolean allowSameNumber = false;
		
		public LIS(long[] data) {
			for (int i=0; i<data.length; i++) {
				this.data.add(data[i]);
			}
		}

		private int searchUpdateIndex(long[] nums, int size, long num) {
			if (size == 0) {
				return 0;
			}
			if (allowSameNumber) {
				if (nums[size-1] <= num) {
					return size;
				} else if (num < nums[0]) {
					return 0;
				}
			} else {
				if (nums[size-1] < num) {
					return size;
				} else if (num < nums[0]) {
					return 0;
				}
			}
			int left = 0;
			int right = size-1;

			while(true) {
				int test = (right + left) / 2;
				
				if (allowSameNumber) {
					// search left <= num < right
					if (left+1 >= right) {
						return right;
					}
					if (num < nums[test]) {
						right = test;
					} else { //nums[test] <= num
						left = test;
					}
				} else {
					// search left < num < right
					if (left+1 >= right) {
						return right;
					}
					if (nums[test] == num) {
						return -1;
					} else if (num < nums[test]) {
						right = test;
					} else { //nums[test] < num
						left = test;
					}
				}
			}
		}
		
		public int getLIS() {
			if (this.data.size() == 0) {
				return 0;
			}
			int size = 0;
			long[] mins = new long[this.data.size()];
			Arrays.fill(mins, Long.MAX_VALUE);
			
			for (long n : this.data) {
				int updateIndex = searchUpdateIndex(mins, size, n);
				if (updateIndex == -1) {
					continue;
				} else {
					mins[updateIndex] = n;
					if (size < updateIndex+1) {
						size = updateIndex+1;
					}
				}
			}
			return size;
		}
	}
	
	public void solve() {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		long[] ds = new long[N];
		for (int i=0; i<N; i++) {
			ds[i] = 1_000_000_001 - in.nextLong();
		}
		in.close();
		
		LIS lis = new LIS(ds);
		lis.allowSameNumber = true;
		int num = lis.getLIS();
		
		System.out.println(num);
	}
	
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}
 
}


Measured memory_bytes: 60680
//
//  main.cpp
//  HelloWorld
//
//  Created by purple on 2020/04/13.
//  Copyright © 2020 Purple. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <cmath>

using namespace std;

int main(int argc, const char * argv[]) {



    string s;
    
  
    
    
    int tmp;
    
    int ans[26];
    
    for(int i=0; i<26; i++)
        ans[i] = 0;
    while(getline(cin, s)){
    for(int i=0; i<s.size(); i++){
        if(s[i]>='A' && s[i]<='Z'){
            tmp = s[i] - 'A';
            ans[tmp]++;
        }
        else if(s[i]>='a' && s[i]<='z'){
            tmp = s[i] - 'a';
            ans[tmp]++;
        }
    }
    }
    for(char i=0; i<26; i++){
        cout << (char)('a' +i) << " : " << ans[i] << endl;
        
    }
    
    
    return 0;
}



Measured memory_bytes: 3180
#include  <bits/stdc++.h>
using namespace std;
 
#define BUF_SIZE 1024
 
struct Node{
    int data;
    Node* prev;
    Node* next;
};
 
class ConnectedList{
public:
    ConnectedList(){
        motherNode = new Node();
        motherNode->data = -1;
        motherNode->prev = motherNode;   
        motherNode->next = motherNode;
    };
    ~ConnectedList(){
        Node* tmpNode = motherNode->next;
        Node* nextNode;
        while(tmpNode != motherNode){
            nextNode = tmpNode->next;
            delete tmpNode;
            tmpNode = nextNode;
        }
        delete motherNode;
    };
    void insertNode(int x){
        Node* tmpNode = motherNode->next;
        motherNode->next = new Node();
        motherNode->next->data = x;
        motherNode->next->next = tmpNode;
        motherNode->next->prev = motherNode;
        tmpNode->prev = motherNode->next;
    };
    void deleteNode(int x){
        Node* tmpNode = motherNode->next;
        while(tmpNode != motherNode && tmpNode->data != x){
            tmpNode = tmpNode->next;
        }
        if(tmpNode != motherNode){  
            tmpNode->prev->next = tmpNode->next;
            tmpNode->next->prev = tmpNode->prev;
            delete tmpNode;
        }
    };
 
    void deleteFirst(){
        Node* tmpNode = motherNode->next;
        motherNode->next = motherNode->next->next;
        motherNode->next->prev = motherNode;
        delete tmpNode; 
    };
 
    void deleteLast(){
        Node* tmpNode = motherNode->prev;
        motherNode->prev = motherNode->prev->prev;
        motherNode->prev->next = motherNode;
        delete tmpNode; 
    };
 
    void showList(){
        Node* tmpNode = motherNode->next;
        printf("%d",tmpNode->data);
        tmpNode = tmpNode->next;
        while(tmpNode != motherNode){
            printf(" %d",tmpNode->data);
            tmpNode = tmpNode->next;
        }
        printf("\n");
    }
 
private:
    Node* motherNode;
};
 
 
int main(){
 
    char buf[BUF_SIZE];
    int n = atoi(fgets(buf,BUF_SIZE,stdin));
 
    ConnectedList list;
 
    for(int i = 0; i < n; i++){
 
        fgets(buf,BUF_SIZE,stdin);
 
        if(buf[6] == 'F'){
            list.deleteFirst();
        }else if(buf[6] == 'L'){
            list.deleteLast();
        }else{
            int S = 0;
             
            if(buf[0] == 'i'){  //insert x
 
                for(int i = 0; buf[i] != '\0';i++){
                    if(buf[i] >= '0' && buf[i] <= '9'){
                        S = 10*S + (buf[i] - '0');
                    }
                }
                list.insertNode(S);
            }else{  
                for(int i = 0;buf[i] != '\0';i++){
                    if(buf[i] >= '0' && buf[i] <= '9'){
                        S = 10*S + (buf[i] - '0');
                    }
                }
                list.deleteNode(S);
            }
 
        }
 
    }
 
    list.showList();
 
}


Measured memory_bytes: 34372
import java.util.*;

public class Main {

	void insertionSort(int[] A) {
		for (int i = 1; i < A.length; i++) {
			int v = A[i];
			int j = i - 1;
			while (j >= 0 && A[j] > v) {
				A[j+1] = A[j];
				j--;
			}
			A[j+1] = v;
			printArray(A);
		}
	}

	void printArray(int[] A) {
		System.out.print(A[0]);
		for (int i = 1; i < A.length; i++) {
			System.out.print(" " + A[i]);
		}
		System.out.println();
	}

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] A = new int[n];
		for (int i = 0; i < A.length; i++) {
			A[i] = scan.nextInt();
		}
		printArray(A);
		insertionSort(A);
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().run();
	}

}



Measured memory_bytes: 31824
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define len(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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 (a > b) {
    a = b;
    return true;
  }
  return false;
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>

signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  vector<ll> food(m, 0);
  rep(i, n) {
    int k;
    cin >> k;
    rep(i, k) {
      int a;
      cin >> a;
      a--;
      food[a]++;
    }
  }
  int res = 0;
  rep(i, m) { res += food[i] == n; }
  cout << res << endl;
  ret;
}


Measured memory_bytes: 3620
#include <set>
#include <map>
#include <ctime>
#include <cmath>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define PII pair<LL,LL>
#define FOR(i,a,b) for (LL i=(a);i<=(b);++i)
#define ROF(i,b,a) for (LL i=(b);i>=(a);--i)
typedef long long LL;
inline LL read(){
	LL x=0,f=1; char ch=getchar();
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	while (ch>='0'&&ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	return x*f;
}

const LL MAXN=500005;
const double eps=1e-8,INF=1e20,PI=3.141592653589793238462;
int n,m,f[MAXN];
struct list{
	int l,lt[MAXN],nt[MAXN],x[MAXN];
	void clear(){ l=0; memset(lt,0,sizeof(lt)); }
	void addedge(int a,int b){ l++; nt[l]=lt[a]; lt[a]=l; x[l]=b; }
}E;
void dfs(int x,int fa){
	f[x]=0;
	for (int i=E.lt[x];i;i=E.nt[i]) {
		int j=E.x[i];
		if (j!=fa) {
			dfs(j,x);
			f[x]^=(f[j]+1);
		}
	}
}
int main(){
	n=read();
	FOR(i,1,n-1) {
		int x,y;
		x=read(); y=read();
		E.addedge(x,y);
		E.addedge(y,x);
	}
	dfs(1,0);
	if (f[1]) printf("Alice\n"); else printf("Bob\n");
	return 0;
}

/*
*/


Measured memory_bytes: 9600
n,m = map(int,input().split())
li = [input().split() for _ in range(m)]
ans = [0,0]

check = [[] for i in range(n)]

for i in range(m):
    s = int(li[i][0])
    check[s-1].append(li[i][1])
    
for i in range(n):
    if len(check[i]) > 0:
        for j in range(len(check[i])):
            if check[i][j] == "WA":
                ans[1] += 1
            elif check[i][j] == "AC":
                ans[0] += 1
                break
        else:
            ans[1] -= len(check[i])

print(*ans)

Measured memory_bytes: 44016
#include<stdio.h>

void mergeSort (int array[], int left, int right);
int n,count;

int main (void){
  int array[500000];
  int i;

    scanf("%d",&n);
    for (i = 0; i < n; i++)
    scanf("%d",&array[i]); 

  mergeSort(array, 0, n-1);

  for (i = 0; i < n; i++){
       printf("%d", array[i]);
       if(i < n-1)
       printf(" "); 
       }
  printf("\n");
  printf("%d\n",count);
  return 0;
}
void mergeSort (int array[], int left, int right){
  int i, j, k, mid;
  int work[n];  
  if(left < right){
    mid = (left + right)/2; 
    mergeSort(array, left, mid);  
    mergeSort(array, mid+1, right);  
    for(i = mid; i >= left; i--)
        work[i] = array[i];
    for(j = mid+1; j <= right; j++)
      work[right-(j-(mid+1))] = array[j]; 
    i = left;
    j = right;
    for(k = left; k <= right; k++){
        count++;
      if(work[i] < work[j]){ 
        array[k] = work[i++]; 
        }else{
          array[k] = work[j--];
            }
    }
  }
}


Measured memory_bytes: 40860
import java.math.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int num = 0;
        for(int i = 0; i < N; ++i) {
            String s;
            s = scan.next();
            if(new BigInteger(s).isProbablePrime(5)) ++num;
        }
        System.out.println(num);
    }
}



Measured memory_bytes: 56208
import java.util.Scanner;
import java.lang.String;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        while(in.hasNextLine()){
	        String str = in.nextLine();
	        String [] array = str.split(" ");
	        int x = Integer.parseInt(array[0]);
	        int y = Integer.parseInt(array[1]);
	        
	        if(x==0 && y==0){ break; }
	        
	        if(x < y){ 
	        	int tmp = x;
	        	x = y;
	        	y = tmp;
	        }
	        
			Euclid euqlid= new Euclid(x, y);
			while(!euqlid.isAns()){}
			System.out.println(String.valueOf(euqlid.getX()) + " " + String.valueOf(euqlid.getStep()));
        }
	}
}

class Euclid{
	private int x;
	private int y;
	private int step;
	
	public Euclid(int x, int y){
		this.x = x;
		this.y = y;
		this.step = 0;
	}
	
	public void show(){
		System.out.println(this.x);
		System.out.println(this.y);
	}
	
	public boolean isAns(){
		this.step++;
		int rem = this.x % this.y;
		this.x = this.y;
		this.y = rem;
		if(rem == 0){ return true; }
		return false;
	}
	
	public int getX(){
		return this.x;
	}
	
	public int getY(){
		return this.y;
	}
	
	public int getStep(){
		return this.step;
	}
}

Measured memory_bytes: 31676
lis = list(map(int, input().split(" ")))

tmp_dic = {}
for n in lis:
    if n not in tmp_dic:
        tmp_dic[n] = 1
    else:
        tmp_dic[n] += 1
        
if len(tmp_dic) == 2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define fi first
#define se second
#define lc T[p].l
#define rc T[p].r
#define mid (l+r>>1)
#define lson lc,l,mid
#define rson rc,mid+1,r
#define sum T[p].val
#define pii pair<int,int>
const int MX=2e6+7;
const int mod=998244353;
const double pi=3.1415926535897932384;
double isp=1e-13;
using namespace std;
ll qpow(ll a,ll b,ll MOD=mod){for(ll ans=1;;a=a*a%MOD,b>>=1){if(b&1)ans=ans*a%MOD;if(!b)return ans;}}
ll inv(ll a,ll MOD=mod){return qpow(a,MOD-2,MOD);}//要求MOD为质数
ll exgcd(ll a,ll b,ll &x,ll &y){if(b==0){x=1,y=0;return a;}ll ret=exgcd(b,a%b,y,x);y-=a/b*x;return ret;}
ll getInv(int a,int mod){ll x,y;ll d=exgcd(a,mod,x,y);return d==1?(x%mod+mod)%mod:-1;}//求a在mod下的逆元，不存在逆元返回-1，不要求MOD为质数
ll l[MX],r[MX];
void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        l[i+1]=l[i]+(s[i]=='W');
    }
    for(int i=n-1;i>=0;i--)
    {
        r[i+1]=r[i+2]+(s[i]=='R');
    }
    ll ans=n;
    for(int i=0;i<=n;i++)
    {
        //cout<<i<<" "<<l[i]<<" "<<r[i+1]<<endl;
        ans=min(ans,max(l[i],r[i+1]));
    }
    cout<<ans<<endl;
    return ;

}
int main()
{
  ios::sync_with_stdio(0),cin.tie(0);
  int t;
 // cin>>t;
  t=1;
  while(t--)
  {
      solve();
  }
}


Measured memory_bytes: 6900
#include <iostream>
#include <vector>
using namespace std;
int div2(int x){
    int ret = 0;
    while(x%2 == 0){
        ret++;
        x /= 2;
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N; cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; ++i) cin >> A[i];
    int cnt = 0;
    for(int i = 0; i < N; ++i){
        cnt += div2(A[i]);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3656
import java.util.*;
public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Set<Integer>[] s = new Set[M];
		int[] p = new int[M];
		int ans = 0;
		int i,j,r;
		for(i = 0;i < M;i++){
			int k = sc.nextInt();
			s[i] = new HashSet<Integer>();
			for(j = 0;j < k;j++){
				s[i].add(sc.nextInt() - 1);
			}
		}
		for(i = 0;i < M;i++){
			p[i] = sc.nextInt();
		}
		for(i = 0;i < (1 << N);i++){
			boolean flg = true;
			for(j = 0;j < M;j++){
				int count = 0;
				for(r = 0;r < N;r++){
					if((1 & i >> r) == 1 && s[j].contains(r)){
						count++;
					}
				}
				if(count % 2 != p[j]){
					flg = false;
					break;
				}
			}
			if(flg){
				ans++;
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
long long  i,count=0,ans=0;
    for(i=0; i<s.size(); i++)
    {
        if(s[i]=='B')
            count++;
        else if(s[i]=='W')
            ans=ans+count;
    }
    cout<<ans;
}

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

int main()
{
    int N;
    cin >> N;
    if (N % 2 == 0)
    {
        cout << N / 2 << endl;
    }
    else
    {
        cout << N / 2 + 1 << endl;
    }
}

Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t H, W, K;
  cin >> H >> W >> K;
  vector<vector<int64_t>> strawberry(H, vector<int64_t>(W, 0));
  int64_t id = 1;
  for (int64_t i = 0; i < H; ++i) {
    string s;
    cin >> s;
    for (int64_t j = 0; j < W; ++j) {
      if (s[j] == '#') {
        strawberry[i][j] = id;
        ++id;
      }
    }
  }
  vector<vector<int64_t>> cake(H, vector<int64_t>(W, 0));

  auto CountPerRow = [&](const int64_t row, const Pair start, const Pair end) {
    int64_t count = 0;
    for (int64_t c = start.second; c < end.second; ++c) {
      if (strawberry[row][c]) {
        ++count;
      }
    }
    return count;
  };
  auto CountPerCol = [&](const int64_t col, const Pair start, const Pair end) {
    int64_t count = 0;
    for (int64_t r = start.first; r < end.first; ++r) {
      if (strawberry[r][col]) {
        ++count;
      }
    }
    return count;
  };
  auto GetId = [&](const Pair start, const Pair end) -> int64_t {
    for (int64_t r = start.first; r < end.first; ++r) {
      for (int64_t c = start.second; c < end.second; ++c) {
        if (strawberry[r][c] > 0) {
          return strawberry[r][c];
        }
      }
    }
    return -1;
  };
  auto Fill = [&](const Pair start, const Pair end) {
    const int64_t value = GetId(start, end);
    for (int64_t r = start.first; r < end.first; ++r) {
      for (int64_t c = start.second; c < end.second; ++c) {
        cake[r][c] = value;
      }
    }
  };

  vector<int64_t> start_rows;
  start_rows.emplace_back(0);
  for (int64_t r = 0; r < H; ++r) {
    if (CountPerRow(r, Pair(0, 0), Pair(H, W))) {
      start_rows.emplace_back(r + 1);
    }
  }
  start_rows.pop_back();
  start_rows.emplace_back(H);

  for (int64_t i = 0; i <= static_cast<int64_t>(start_rows.size()) - 2; ++i) {
    const int64_t start_row = start_rows[i];
    vector<int64_t> start_cols;
    start_cols.emplace_back(0);
    for (int64_t c = 0; c < W; ++c) {
      if (CountPerCol(c, Pair(start_row, 0), Pair(start_rows[i + 1], W)) > 0) {
        start_cols.emplace_back(c + 1);
      }
    }
    start_cols.pop_back();
    start_cols.emplace_back(W);
    for (int64_t j = 0; j <= static_cast<int64_t>(start_cols.size()) - 2; ++j) {
      const int64_t start_col = start_cols[j];
      Fill(Pair(start_row, start_col), Pair(start_rows[i + 1], start_cols[j + 1]));
    }
  }
  for (int64_t r = 0; r < H; ++r) {
    for (int64_t c = 0; c < W; ++c) {
      if (c != 0) {
        cout << " ";
      }
      cout << cake[r][c];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 4748