akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc089/tasks/abc089_b

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n;
  set<char> s;

  cin >> n;
  REP(i, n)
  {
    char si;
    cin >> si;
    s.insert(si);
  }

  string r = s.size() == 3 ? "Three" : "Four";

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }


void solve(long long A, long long B){
	if (A<10 && B<10) cout << A*B << "\n";
	else cout << -1 << "\n";
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define L long
#define t first
#define u second
#define M push_back(make_pair(c(
using namespace std;L R,C,N,a[9<<14],b,i;vector<pair<L,L>> p;bool s(L x,L y){return !(x^0&&x^R&&y^0&&y^C);}L c(L x,L y){return L(atan2(x-R/2,y-C/2)*(1<<30));}main(){cin>>R>>C>>N;for(;i<N;++i){cin>>*a>>a[1]>>a[2]>>a[3];if(s(*a,a[1])&&s(a[2],a[3])){p.M*a,a[1]),i));p.M a[2],a[3]),i));}}sort(p.begin(), p.end());fill(a,a+114514,0);stack<L> s;for(auto P : p){if(s.empty()||s.top()^P.u)s.push(P.u);else s.pop();}puts(s.size()?"NO":"YES");}

Measured memory_bytes: 6256
X = [int(input()) for i in range(5)]
XX = []

ans = 0

deff = 0


def define(x):
    return ((x + 9) // 10) * 10 - x


for i in X:
    # // で切り捨てできるっぽい
    f = (i + 9) // 10
    f *= 10
    XX.append(f)


deff = max(define(int(X[0])), define(int(X[1])), define(int(X[2])), define(int(X[3])), define(int(X[4])))


for i in XX:
    ans += i


print(ans - deff)



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

typedef long long ll;

int main()	
{
	string s;
	map<string,int> mp;
	int n;
	cin>>n;
	while(n--){
		cin>>s;
		mp[s]++;
	}
	for(string S:{"AC","WA","TLE","RE"}){
		cout<<S<<" x "<<mp[S]<<'\n';
	}
}

Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())

int n;
int a[200010];

void init() {

}

void input() {
	cin >> n;
	REP(i, n) cin >> a[i];
}

void solve() {
	int l = 0, r = 0;
	LL sm = a[l], xr = a[l];
	LL res = 0;
	while(1) {
		if (r == n) break;
		if (sm == xr) {
			res += r-l+1;
			r++;
			if (r < n) {
				sm += a[r];
				xr ^= a[r];
			}
		} else {
			sm -= a[l];
			xr ^= a[l];
			l++;
		}
	}
	cout << res << endl;
}

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


Measured memory_bytes: 1024
L,R=map(int, input().split())

if R-L+1>=2019:
  print(0)
else:
  L %= 2019
  R %= 2019
  if L<R: 
    m = 2019
    for i in range(L,R+1):
      for j in range(i+1,R+1):
        m = min(m, (i*j)%2019)
    print(m)
  else:
    print(0)


Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};



int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n;
    cin>>n;
    vector<P> a(n);
    vector<int> x={0,1,2,3,4,5,6,7};
    auto y=x;
    int s,t;
    rep(i,n) {
        cin>>s>>t;
        a[i]=P(s,t);
    }
    sort(all(a));
     do{
        int cnt=0;
        bool f=1;
        vector<bool> p(15,0),q(15,0);//p:x-y,q:(7-x)-(7-y)
        rep(i,8){
            if(cnt<n && a[cnt].first==i){
                if(a[cnt].second!=x[i]){f=0;break;}
                cnt ++;
            }
             if(p[i-x[i]+7] || q[i+x[i]]){f=0;break;}
             p[i-x[i]+7]=q[i+x[i]]=true;
        }
         if(f) break;
    } while (next_permutation(all(x)));
    vector<vector<char>> ans(8,vector<char>(8,'.'));
    rep(i,8) ans[i][x[i]]='Q';
    rep(i,8){
        rep(j,8) cout<<ans[i][j];
        cout<<'\n';
    }
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  int N, K;
  cin >> N;
  cin >> K;
  int ans = 1;
  rep(i, 0, N) {
    ans = min(ans * 2, ans + K);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def xxor(N: int, K: int, A: list) -> int:
    opt = 0
    num_digit_2 = 0  # binary 表示での桁数
    while 2 ** num_digit_2 < K:
        num_digit_2 += 1

    # 範囲関係なく最適解(opt)を計算する
    mask = 1
    for _ in range(num_digit_2):
        count_0, count_1 = 0, 0
        for a in A:
            if a & mask > 0:
                count_1 += 1
            else:
                count_0 += 1

        if count_0 > count_1:
            opt = opt | mask

        mask <<= 1

    # 上で求めた最適解を範囲内に落とし込む
    max_ret = 0
    x = opt
    # 以下、X = (X40 X39 ... X0)2, K+1 = (K40 K39 ... K0)2 として考える。
    #
    for i in range(40):
        mask = 1 << (40 - i - 1)

        if x < K + 1:
            temp = sum(a ^ x for a in A)
            max_ret = max(temp, max_ret)

        x2 = (x & ~mask)  # Xi = 0 とする
        if x2 < K + 1:
            temp = sum(a ^ x2 for a in A)
            max_ret = max(temp, max_ret)

        x = ((K + 1) & ~(mask - 1)) | (opt & (mask - 1))

    return max_ret


if __name__ == "__main__":
    N, K = [int(s) for s in input().split()]
    A = [int(s) for s in input().split()]

    ans = xxor(N, K, A)
    print(ans)


Measured memory_bytes: 14980
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    vector<int> h(n + 1);

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

    vector<int> cost(n + 1);

    h[0] = 1001001001;
    cost[0] = 0;
    cost[1] = 0;

    for (int i = 0; i < n - 1; i++)
    {
        cost[i + 2] = min(cost[i + 1] + abs(h[i + 2] - h[i + 1]), cost[i] + abs(h[i + 2] - h[i]));
    }

    cout << cost[n] << endl;
    return 0;
}


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

int main() {
  int R = 0, G =0;
  cin >> R >> G;
 // (r + x)/2 = g xはとるべきパフォーマンス
 // r + x =2g
 // x = 2g - r
  cout << 2 * G -R << endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << "\n"
using namespace std;
using ll = long long;

signed main() {
    IO;
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll xor_val = 0, and_val;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        if(i > 1) xor_val ^= a[i];
    }
    if((a[0] + a[1] - xor_val < 0) || (a[0] + a[1] - xor_val) % 2 == 1) {cout << -1; return 0;}
    and_val = (a[0] + a[1] - xor_val) / 2;
    if((and_val & xor_val) != 0) {cout << -1; return 0;}
    
    ll a0 = 0, a1 = 0;
    bool pos = true;
    for(ll i = 40; i >= 0; --i) {
        ll two = 1ll << i;
        if(and_val & two) {
            a0 |= two; a1 |= two;
        }
    }
    for(ll i = 40; i >= 0; --i) {
        ll two = 1ll << i;
        if(xor_val & two) {
            ll new_a0 = a0 | two;
            if(new_a0 < a[0]) a0 = new_a0;
            else a1 |= two;
        }
    }

    if(a0 == 0) pos = false;
    if(a0 > a[0]) pos = false;

    if(!pos) cout << -1;
    else cout << a[0] - a0;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>

int search(int A[], int n, int key) {
  int i = 0;
  A[n] = key;
  while ( A[i] != key ) i++;
  return i != n;
  }
  
  int main(){
   int i, n, A[10000+1], q, key, sum = 0;
  
   scanf("%d", &n);
   for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
   
   scanf("%d", &q);
   for ( i = 0; i < q; i++ ){
    scanf("%d", &key);
    if ( search(A, n, key) ) sum++;
    }
    printf("%d\n", sum);
    
    return 0;
   }
    
    


Measured memory_bytes: 2056
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

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

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void judgement(bool a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,j,N,H,W,ans;
  cin>>N;
  rep1(i,10){
    if(N%i==0&&N/i<10){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;

    vector<int> arr;
    int cur;
    for (int i = 0; i < N; i++) {
        cin >> cur;
        arr.push_back(cur);
    }

    vector<int> distarr(200001, 0);
    for (int j = 0; j < N; j++) {
        distarr[arr[j]]++;
    }

    int ans = INT_MIN;
    for (int k = 0; k < N; k++) {
        int one = arr[k];
        ans = max(distarr[one] + distarr[one - 1] + distarr[one + 1], ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1528
#include <stdio.h>

int main(void)
{
    char A, B, C;
    
    
    scanf("%c%c%c", &A, &B, &C);
    
    if(A == '9')
    {
        A = '1';
    }
    else
    {
        A = '9';
    }
    if(B == '9')
    {
        B = '1';
    }
    else
    {
        B = '9';
    }
    if(C == '9')
    {
        C = '1';
    }
    else
    {
        C = '9';
    }
    
    printf("%c%c%c\n", A, B, C);
    
    //system("pause");
    
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int x,a,b;
    cin >> x >> a >> b;
    
    cout << ( abs( x - a ) < abs( x - b ) ? "A":"B") << endl;
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> void pr_vec(vector<T> &v, char ep=' '){int n=v.size();REP(ni,n){cout<<v[ni];if(ni!=n-1)cout<<ep;}cout<<endl;};
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int X,Y;
    cin >> X >> Y;
    REP(i, X+1){
        if(i*2+(X-i)*4 == Y){
            pr("Yes");
            return 0;
        }
    }
    pr("No");
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

using mat = vector<vecll>;
constexpr ll MOD = 1000000007;

mat operator*(const mat& lhs, const mat& rhs) {
  int n = lhs.size();
  mat res(n, vecll(n, 0));
  for(auto&& i:irange(0,n)) {
    for(auto&& j:irange(0,n)) {
      for(auto&& k:irange(0,n)) {
        res[i][j] += lhs[i][k] * rhs[k][j];
        res[i][j] %= MOD;
      }
    }
  }
  return res;
}

mat powmod(const mat& base, ll index) {
  if (index == 0) {
    int n = base.size();
    mat res(n, vecll(n, 0));
    for(auto&& i:irange(0,n)) res[i][i] = 1;
    return res;
  } else if ((index % 2) == 1) {
    return base * powmod(base, index-1);
  } else {
    auto h = powmod(base, index/2);
    return h * h;
  }
}

int main()
{
  ll n,k;
  cin>>n>>k;
  mat m(n, vecll(n));
  for(auto&& l:m)for(auto&& e:l)cin>>e;
  mat res = powmod(m, k);
  ll ans = 0;
  for(auto&& l:res)for(auto&& e:l) {
    ans += e;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
using System;

class Test{
 public static void Main(){
   var str = Console.ReadLine().Split(' ');
   long N   = long.Parse(str[0]);
   long blue = long.Parse(str[1]);
   long red = long.Parse(str[2]);
   long sumBlue = 0;
   
   sumBlue = N / (blue + red) * blue;
   if(N % (blue + red)>=blue){
     sumBlue += blue;
   }else{
     sumBlue += N % (blue + red);
   }
   Console.WriteLine(sumBlue);
 }
}


Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    long long n;
    long long ans=10,tmp;
    scanf("%lld",&n);
    for (long long i=1; i<100000; i++){
        if (n%i==0){
            long long j=n/i,i2=i,count=0;
            tmp=0;
            while (j>0){
                j/=10;
                count++;
            }
            while (i2>0){
                i2/=10;
                tmp++;
            }
            if (count>tmp){
                tmp=count;
            }
        }
        if (ans>tmp){
        ans=tmp;
        }
    }
    printf ("%lld\n",ans);
	return 0 ;
}

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

int main(void){
  int n; cin >> n;
  int res = n%10;
  
  if(res==2 || res==4 || res==5 || res==7 || res==9) cout << "hon" << endl;
  else if(res==0 || res==1 || res==6 || res==8) cout << "pon" << endl;
  else cout << "bon" << endl;
  
  return 0;
}


Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define NOT_FOUND -1

int GetContainsElement(const vector<pair<int, int>> v, int target)
{
    int i = 0;
    for (vector<pair<int, int>>::const_iterator it = v.begin(); it != v.end(); it++) {
        if (it->first == target) {
            return i;
        }
        i++;
    }

    return NOT_FOUND;
}

int GetMostfrequentlyNumber(const vector<pair<int, int>> v)
{
    int ret = v[0].second;
    for (vector<pair<int, int>>::const_iterator it = (v.begin() + 1); it != v.end(); it++) {
        if (ret < it->second) {
            ret = it->second;
        }
    }

    return ret;
}

int main()
{
    int n = 0;
    vector<pair<int, int>> vec;

    while (scanf("%d", &n) != EOF) {
        int idx = GetContainsElement(vec, n);
        if (NOT_FOUND == idx) {
            vec.push_back(make_pair(n, 0));
        }
        else {
            vec[idx].second++;
        }
    }

    sort(vec.begin(), vec.end());
    int mostFrequently = GetMostfrequentlyNumber(vec);

    for (vector<pair<int, int>>::const_iterator it = vec.begin(); it != vec.end(); it++) {
        if (mostFrequently == it->second) {
            printf("%d\n", it->first);
        }
    }

    return 0;
}



Measured memory_bytes: 2584
#include<iostream>
#include<algorithm>
#include<stack>
#include<cstring>
using namespace std;

struct rect { int height; int pos; };

int solve(int Size, int buffer[]) {
	stack<rect>S;
	int maxv = 0;
	buffer[Size] = 0;

	for (int i = 0; i <= Size; i++) {
		rect Rect;
		Rect.height = buffer[i];
		Rect.pos = i;
		if (S.empty()) {
			S.push(Rect);
		}
		else {
			if (S.top().height < Rect.height) {
				S.push(Rect);
			}
			else if (S.top().height>Rect.height) {
				int TARGET = i;
				while (!S.empty() && S.top().height >= Rect.height) {
					rect pre = S.top(); S.pop();
					int area = pre.height*(i - pre.pos);
					maxv = max(maxv, area);
					TARGET = pre.pos;
				}
				Rect.pos = TARGET;
				S.push(Rect);
			}
		}
	}
	return maxv;
}

#define MAX 2000

int H, W;
int buffer[MAX][MAX];
int T[MAX][MAX];

int hantei() {
	for (int j = 0; j < W; j++) {
		for (int i = 0; i < H; i++) {
			if (buffer[i][j] == 1) {
				T[i][j] = 0;
			}
			else {
				T[i][j] = (i>0) ? T[i - 1][j] + 1 : 1;
			}
		}
	}
	int maxv = 0;
	for (int i = 0; i < H; i++) {
		maxv = max(maxv, solve(W, T[i]));
	}
	return maxv;
}

int main() {
	while (true) {
		memset(buffer, 0, sizeof(buffer));
		memset(T, 0, sizeof(T));
		cin >> H >> W;
		if (H == 0 && W == 0) { break; }
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				char c;
				cin >> c;
				if (c == '.') { buffer[i][j] = 0; }
				else { buffer[i][j] = 1; }
			}
		}
		cout << hantei() << endl;
	}
}

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

int main() {
  string w;
  cin >> w;

  for(int i = 0; i < w.size(); i++) {
    int cnt = 0;
    for(int j = 0; j < w.size(); j++) {
      if(w[i] == w[j]) cnt++;
    }
    if(cnt % 2 != 0) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
set<pair<string, string>>s;
map<pair<string, string>, int>m;
int n, k;
string a[12];
vector<pair<string, string>>ans;
signed main() {
	cin >> n >> k;
	for1(hoge, n) {
		int p; cin >> p;
		for0(i, p)cin >> a[i];
		sort(a, a + p);
		for0(i, p) {
			for (int j = i + 1; j < p; j++) {
				pair<string, string>pr = make_pair(a[i], a[j]);
				if (find(s.begin(), s.end(), pr) == s.end()) {
					s.insert(pr);
					m[pr] = 1;
				}
				else m[pr]++;
			}
		}
	}
	for (pair<string, string>p : s)
		if (m[p] >= k)ans.push_back(p);
	cout << ans.size() << endl;
	for (pair<string, string>p : ans)cout << p.first << ' ' << p.second << endl;
}


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

namespace tes
{
	class contest
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine();
            Console.WriteLine(s.Substring(0,4)+" "+s.Substring(4));
            
		}		
		 
	}
}

Measured memory_bytes: 2648
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<vector<Int> > G(n*2+1);
  Int idx=n-1;
  for(Int i=0;i<n-1;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    if(x==n-1) G[i].emplace_back(idx++);
    else G[i].emplace_back(x);
    if(y==n-1) G[i].emplace_back(idx++);
    else G[i].emplace_back(y);    
  }
  vector<Int> dep(n*2+1,0),sum(n*2+1,0),cnt(n*2+1,0);
  function<void(Int, Int)> dfs1=
    [&](Int v,Int d){
      dep[v]=d;
      if(G[v].empty()){
        sum[v]=d;
        cnt[v]=1;
      }
      for(Int u:G[v]){
        dfs1(u,d+1);
        sum[v]+=sum[u];
        cnt[v]+=cnt[u];
      }
    };
  
  dfs1(0,0);

  auto calc=[&](Int v){return sum[v]-dep[v]*cnt[v];};
  const Int INF = 1e15;
  vector<Int> dp(n*2+1,INF);
  function<void(Int)> dfs2=
    [&](Int v){
      for(Int u:G[v]) dfs2(u);
      chmin(dp[v],calc(v)+dep[v]);      
      if(G[v].empty()) return;
      assert(G[v].size()==2u);
      Int x=G[v][0],y=G[v][1];
      chmin(dp[v],dp[x]+calc(y)+cnt[y]);      
      chmin(dp[v],dp[y]+calc(x)+cnt[x]);      
      chmin(dp[v],dp[x]+dp[y]);
      //cout<<v<<":"<<dp[v]<<endl;
    };

  dfs2(0);
  cout<<dp[0]<<endl;
  return 0;
}



Measured memory_bytes: 112084
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define deb(x) cout << #x << " => " << x << endl

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

    ll n, w;
    cin >> n >> w;
    int val, weight;
    ll dp[w + 1];
    memset(dp, 0, sizeof dp);

    for (ll i = 0; i < n; i++) {
        cin >> weight >> val;
        for (int j = w; j >= weight; j--) {
            dp[j] = max(dp[j], dp[j - weight] + val);
        }
    }
    cout << *max_element(dp, dp + w + 1) << endl;

    return 0;
}

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

int main(){
	ll K;
	string S;
	cin >> S;
	cin >> K;
	ll ss = S.size();
	bool m = 1;
	for (int i = 1;i < ss;i++) {
		if (S[i] != S[i - 1])m = 0;
	}
	if (m) {
		cout << ss * K / 2 << endl;
	}
	else {
		ll st = 1, go = 1, ans = 0, cnt = 1;

		for (int i = ss - 2;i >= 0;i--) {
			if (S[i] == S[i + 1])go++;
			else break;
		}

		for (int i = 1;i < ss;i++) {
			if (S[i] == S[i - 1])st++;
			else break;
		}

		ans += st / 2 + go / 2;
		if (S[ss - 1] == S[0]) {
			ans += (st + go) / 2 * (K - 1);
		}
		else {
			ans += (st / 2 + go / 2)*(K - 1);
		}

		for (int i = st;i < ss - go;i++) {
			if (S[i - 1] == S[i])
				cnt++;
			else {
				ans += cnt / 2 * K;
				cnt = 1;
			}
		}
		ans += cnt / 2 * K;
		cout << ans << endl;
	}
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a; cin >> a;
  int b; cin >> b;

  for(int i = 1;i<=3;i++){
    if(i != a && i != b){
      cout << i << endl;
      return 0;
    }
  }
    
  return 0;
}


Measured memory_bytes: 3560
#include <iostream>
#include <cstdint>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <vector>

struct Vector {
	int64_t x, y;
	Vector(int64_t x = 0, int64_t y = 0): x(x), y(y) {}
	int64_t mag_sq() const {
		return x * x + y * y;
	}

	friend Vector operator+ (const Vector &a, const Vector &b) {
		return Vector(a.x + b.x, a.y + b.y);
	}
	friend int64_t operator^ (const Vector &a, const Vector &b) {
		return a.x * b.y - a.y * b.x;
	}

	static bool angle_cmp(const Vector &a, const Vector &b) {
		return std::atan2(a.y, a.x) < std::atan2(b.y, b.x);
		if ((a.x == 0) && (b.x == 0)) {
			return a.y < b.y;
		} else if ((a.x < 0) && (b.x > 0)) {
			return false;
		} else if ((a.x > 0) && (b.x < 0)) {
			return false;
		} else {
			return (a ^ b) > 0;
		}
	}
};

std::vector<Vector> vList;

void input() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	uint32_t n;
	std::cin >> n;

	for (uint32_t i = 0;i < n;i++) {
		Vector v;
		std::cin >> v.x >> v.y;
		if ((v.x != 0) || (v.y != 0)) {
			vList.push_back(v);
		}
	}
}

long double solve() {
	int64_t best = 0;
	std::sort(vList.begin(), vList.end(), Vector::angle_cmp);
//	for (uint32_t i = 0;i < vList.size();i++) {
//		std::cerr << vList[i].x << " " << vList[i].y << "\n";
//	}
	for (uint32_t i = 0;i < vList.size();i++) {
		Vector cur(0, 0);
		uint32_t j = i;
		for (uint32_t k = 0;k < vList.size();k++) {
			cur = cur + vList[j];
			best = std::max(best, cur.mag_sq());
			j = (j + 1) % vList.size();
		}
	}
	return sqrtl((long double) (best));
}


int main() {
	input();
	std::cout << std::fixed << std::setprecision(50) << solve() << "\n";
}


Measured memory_bytes: 384
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            l = 500*i + 100*j + 50*k
            if l == X:
                count += 1

print(count)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
//#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 3000000;
int mod = 1000003;
int f[N], invf[N], lg[N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int cnk(int n, int k){
    return f[n] * invf[n - k] % mod * invf[k] % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int q;
    cin >> q;
    int b = 2;
    int p = 1;
    for (int i = 0; i < mod - 1; i++){
        lg[p] = i;
        p = p * b % mod;
    }
    f[0] = 1;
    for (int i = 1; i < mod; i++) f[i] = f[i - 1] * i % mod;
    while(q--){
        int x, d, n;
        cin >> x >> d >> n;
        int y = (mod - x) * binpow(d, mod - 2) % mod;
        if (d == 0){
            cout << binpow(x, n) % mod << endl;
            continue;
        }
        if (y <= n - 1 || x == 0){
            cout << 0 << endl;
            continue;
        }
        int z = binpow(d, mod - 2) * x % mod;
        int t;
        if (z == 1) t = lg[f[n] * binpow(d, n) % mod]; else
        t = (lg[f[n + z - 1] * binpow(d, n + z - 1) % mod] - lg[f[z - 1] *binpow(d, z - 1)  % mod] + mod - 1) % (mod - 1);
        cout << binpow(2, t) << endl;
    }
}


Measured memory_bytes: 19328
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints


if A <= 5
  puts '0'
elsif A <= 12
  puts B / 2
else
  puts B
end


Measured memory_bytes: 14416
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll N; cin >> N;
  string s; cin >> s;
  ll ok = 0, ng = N/2+1;
  map<string, ll> mpmin, mpmax;
  while(ok+1<ng){
    ll m = (ok+ng)/2;
    //DUMP(m);
    REP(i,N-m+1){
      string t= s.substr(i,m);
      if(mpmin.find(t) == mpmin.end()) mpmin[t] = i;
      mpmax[t] = max(mpmax[t],i);
    } 
    bool f = false;
    FOREACH(x,mpmin){
      string t = x.first;
      ll k = x.second;
      //DUMP(k);
      if(k+m-1<mpmax[t]){
        // DUMP(t);
        // DUMP(k);
        // DUMP(mpmax[t]);
        f = true;
      }
    }
    if(f) ok = m;
    else ng = m;
    mpmin.clear();
    mpmax.clear();
  }
  cout << ok << endl;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
int n;
void solve()
{
    int i,ans=0,len=n;
    vector < int > inp(n);
    for (i=0;i<n;i++)
        cin>>inp[i];
    for (i=1;i<n;i++)
        if (inp[i]==inp[i-1])
        {
            inp[i]=len--;
            ans++;
        }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>n)
        solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
   using namespace std;
   vector<int> l[100005];
   int dp[100005];
   int visited[100005];
   long long int mod=1000000000+7;
  int main()
  {   
     long long int n;
     cin>>n;
     long long int a[n];

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

     pair<long long int,long long int> dp[n][n]; 
     for(int i=0;i<n;i++)
     {
        dp[i][i].first=a[i];
        dp[i][i].second=0;
     }
     for(int i=0;i<n-1;i++)
     {
        dp[i][i+1].first=max(a[i],a[i+1]);
        dp[i][i+1].second=min(a[i],a[i+1]);
     }
    for(int l=3;l<=n;l++)
    {
       for(int i=0;i<n-l+1;i++)
       {
          int j=i+l-1;
          
          if(a[i]+dp[i+1][j].second < a[j]+dp[i][j-1].second)
          {
             dp[i][j].first =a[j]+dp[i][j-1].second;
             dp[i][j].second=dp[i][j-1].first;
          }
          else
          {
             dp[i][j].first =a[i]+dp[i+1][j].second;
             dp[i][j].second=dp[i+1][j].first;
          }
       }
    }
   //  for(int i=0;i<n;i++)
   //  {
   //     for(int j=0;j<n;j++)
   //     {
   //        cout<<"("<<dp[i][j].first<<" ,"<<dp[i][j].second<<" ) ";
   //       }
   //       cout<<"\n";

   //  }

     cout<<dp[0][n-1].first-dp[0][n-1].second;

   
  }



Measured memory_bytes: 143232
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int n;
    cin>>n;
    vi p(n);
    rep(i,n) {
        cin>>p.at(i);
    }
    int counter=0;
    rep(i,n-2) {
        if(p.at(i)<p.at(i+1)&&p.at(i+1)<p.at(i+2)) counter++;
        else if(p.at(i)>p.at(i+1)&&p.at(i+1)>p.at(i+2)) counter++;
    }
    cout<<counter<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{
	int N=0;int a=0;
	scanf("%d",&N);
	int p[N][3]={0};
	for(int i=0;i<N;i++)
	{
	scanf("%d %d %d",&p[i][0],&p[i][1],&p[i][2]);
	}
	for(int i=0;i<N-1;i++)
	{if(p[i][0]!=0)
	{
		for(int j=i+1;j<N;j++)
		{
			if(p[i][0]==p[j][0]||p[i][0]==p[j][1]||p[i][0]==p[j][2])
			{
				if(p[i][1]==p[j][0]||p[i][1]==p[j][1]||p[i][1]==p[j][2])
				{
					if(p[i][2]==p[j][0]||p[i][2]==p[j][1]||p[i][2]==p[j][2]){a=a+1;p[j][0]=0;}
				}
			}
		}
	}
	}
	printf("%d\n",a);
	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template< typename Data, typename T >
struct ReRooting {

  struct Node {
    Int to, rev;
    Data data;
  };

  using F1 = function< T(T, T) >;
  using F2 = function< T(T, Int, Int, Data) >; // ret, src, to, data

  vector< vector< Node > > g;
  vector< vector< T > > ldp, rdp;
  vector< Int > lptr, rptr;
  const F1 f1;
  const F2 f2;
  const T ident;

  ReRooting(Int n, const F1 &f1, const F2 &f2, const T &ident) :
      g(n), ldp(n), rdp(n), lptr(n), rptr(n), f1(f1), f2(f2), ident(ident) {}

  void add_edge(Int u, Int v, const Data &d) {
    g[u].emplace_back((Node) {v, (Int) g[v].size(), d});
    g[v].emplace_back((Node) {u, (Int) g[u].size() - 1, d});
  }

  T dfs(Int idx, Int par) {
    while(lptr[idx] != par && lptr[idx] < (Int)g[idx].size()) {
      auto &e = g[idx][lptr[idx]];
      ldp[idx][lptr[idx] + 1] = f1(ldp[idx][lptr[idx]], f2(dfs(e.to, e.rev), idx, e.to, e.data));
      ++lptr[idx];
    }
    while(rptr[idx] != par && rptr[idx] >= 0) {
      auto &e = g[idx][rptr[idx]];
      rdp[idx][rptr[idx]] = f1(rdp[idx][rptr[idx] + 1], f2(dfs(e.to, e.rev), idx, e.to, e.data));
      --rptr[idx];
    }
    if(par < 0) return rdp[idx][0];
    return f1(ldp[idx][par], rdp[idx][par + 1]);
  }

  vector< T > solve() {
    for(Int i = 0; i < (Int)g.size(); i++) {
      ldp[i].assign(g[i].size() + 1, ident);
      rdp[i].assign(g[i].size() + 1, ident);
      lptr[i] = 0;
      rptr[i] = (Int) g[i].size() - 1;
    }
    vector< T > ret;
    for(Int i = 0; i < (Int)g.size(); i++) {
      ret.push_back(dfs(i, -1));
    }
    return ret;
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  auto f1=[m](Int a,Int b){return a*b%m;};
  auto f2=[m](Int res,Int a,Int b,Int d){a++;b++;d++;return (res+1)%m;};
  ReRooting<Int, Int> G(n,f1,f2,1);
  for(Int i=1;i<n;i++){
    Int x,y;
    cin>>x>>y;
    x--;y--;
    G.add_edge(x,y,1);
  }
  auto ans=G.solve();
  for(Int x:ans) cout<<x<<endl;
  return 0;
}


Measured memory_bytes: 39796
#include "bits/stdc++.h"
#define esc(ret) cout << (ret) << endl,quick_exit(0)
#define fcout(d) cout << fixed << setprecision(d)
#define repU(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define repD(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) repU(i,0,(n) - 1)
#define rep1(i,n) repU(i,1,(n))
#define all(v) begin(v),end(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define qceil(n,d) ((n) > 0 ? ((n) - 1) / (d) + 1 : (n) / (d))
#define parity(a,b) ((a) & 1 == (b) & 1)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair<int,int> pii;
typedef pair<db,int> pdi;

const pii dir[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int mod = 1e9 + 7;
const int inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;

int N,M;
set<pii> eg[100010];
map<pii,int> dist;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> N >> M;
	rep(i,M){
		int p,q,c;
		cin >> p >> q >> c;
		eg[p].insert({c,q});
		eg[q].insert({c,p});
	}
	deque<pair<pii,int>> deq;
	deq.pub({{1,0},0});
	dist[{1,0}] = 0;
	while(!deq.empty()){
		int t = deq.front().fir.fir;
		int u = deq.front().fir.sec;
		int d = deq.front().sec;
		deq.pof();
		if(dist[{t,u}] < d) continue;
		if(u){
			if(!dist.count({t,0}) || dist[{t,0}] > d) deq.puf({{t,0},d}),dist[{t,0}] = d;
			auto it = eg[t].l_bnd({u,0});
			auto it2 = eg[t].l_bnd({u + 1,0});
			for(auto i = it; i != it2; ++i){
				int v = i -> sec;
				if(!dist.count({v,u}) || dist[{v,u}] > d) deq.puf({{v,u},d}),dist[{v,u}] = d;
			}	
		}else{
			for(auto e : eg[t]){
				int v = e.sec;
				u = e.fir;
				if(!dist.count({v,u}) || dist[{v,u}] > 1 + d) deq.pub({{v,u},1 + d}),dist[{v,u}] = d + 1;
			}
		}
	}
	if(dist.count({N,0})) cout << dist[{N,0}] << endl;
	else esc(-1);
}




Measured memory_bytes: 55296
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

v = []
for i in range(5):
    v.append(I())

# 全探索？
# 1の位が一に一番近いものを求める
str_v = [str(i) for i in v]
min_first_digit = None
for sidx, s in enumerate(str_v):
    if s[-1] == '0':
        continue
    if min_first_digit == None:
        min_first_digit = [sidx , s[-1]]
        continue
    if s[-1] < min_first_digit[1]:
        min_first_digit = [sidx, s[-1]]

if min_first_digit == None:
    print(sum(v))
else:
    result = 0
    for vidx, item in enumerate(v):
        if vidx != min_first_digit[0]:
            result += item
            if item % 10 != 0:
                result += 10 - item % 10
    result += v[min_first_digit[0]]
    print(result)


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

struct Node {
	int key;
	Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k)
{
	Node *y = NIL;
	Node *x = root;
	Node *z = new Node;
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while (x != NIL){
		y = x;
		if (z->key < x->key){
			x = x->left;
		}
		else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if (y == NIL){
		root = z;
	}
	else {
		if (z->key < y->key){
			y->left = z;
		}
		else {
			y->right = z;
		}
	}
}

void inorder(Node *u)
{
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node *u)
{
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}

Node *find(Node *u, int key)
{
	while (u != NIL && key != u->key){
		if (key < u->key) u = u->left;
		else u = u->right;
	}
	return u;
}

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		string com;
		cin >> com;
		if (com == "insert"){
			int x;
			scanf("%d", &x);
			insert(x);
		}
		else if (com == "find"){
			int x;
			scanf("%d", &x);
			if (find(root, x) != NIL) puts("yes");
			else puts("no");
		}
		else if (com == "print"){
			inorder(root);
			puts("");
			preorder(root);
			puts("");
		}
	}
	
	return 0;
}

Measured memory_bytes: 20004
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc=new Scanner(System.in);
		String str=sc.nextLine();
	    String	str1="ABC";
		if(str.equals(str1))
		System.out.println("ARC");
		else
		System.out.println("ABC");
	}
}

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

string N;

bool comp(string s1, string s2)
{
    if (s1.length() < s2.length()) return(true);
    if (s1.length() > s2.length()) return(false);
    return(s1 < s2);
}

bool check(string s)
{
    int f = 0;
    for (int i = 0; i < s.length(); i++)
    {
        int c = s[i] - '0';
        if (c == 3) f |= 1;
        else if (c == 5) f |= 2;
        else if (c == 7) f |= 4;
    }
    return(f == 7);
}

int dfs(string s)
{
    if (comp(N, s)) return(0);
    int res = check(s);
    res += dfs(s + "7") + dfs(s + "5") + dfs(s + "3");
    return(res);
}

int main()
{
    cin >> N;
    cout << dfs("") << '\n';
    return(0);
}

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

using namespace std;

int main() {
    long long int n, dap=0, k, t, x;
    
     
    scanf("%lld", &n);
    k=int(sqrt(n));
    t=int(sqrt(n-1));
    x=0;
    for(long long int i=2;i<=t;i++)
        {
            if((n-1)%i==0)
                x++;
        }
    if(t*t==(n-1))
        dap+=2*x;
    else
        dap+=2*x+1;
    x=0;
    for(long long int i=2;i<=k;i++)
        {
            if((n)%i==0)
            {
                long long int y;
                y=n;
                while(y%i==0)
                    y/=i;
                if(y%i==1)
                    x++;
            }
        }
        x++;
        dap+=x;
    printf("%lld", dap);
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    ll n;
    cin >> n;
    ll ans = 1e18;
    for (ll i = 1; i*i <= n; i++) {
        if (n%i != 0) continue;
        ll j = n/i;
        ans = min(ans, i+j-2);
    }
    cout << ans << endl;

    return 0;
}

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

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

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

  vector<int> l(n + 1);
  vector<int> r(n + 1);
  for (int i = 0; i < n; i++) {
    l[i + 1] = gcd(a[i], l[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    r[i] = gcd(a[i], r[i + 1]);
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    mx = max(mx, gcd(l[i], r[i + 1]));
  }
  cout << mx << endl;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
	set<int> S;
	int q;
	cin >> q;
	Rep(i, q) {
		int n, x;
		cin >> n >> x;
		if (n == 0) {
			S.insert(x);
			cout << S.size() << endl;
		}
		else if (n == 1) {
			if (S.find(x) != S.end()) cout << 1 << endl;
			else cout << 0 << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 12440
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define fill(c,v) memset(c,v,sizeof(c));
#define prarr(a,n) rep(n) cout<<a[i]<<" \n"[i==n-1]; 
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define ff first
#define ss second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,m,c;
    cin>>n>>m>>c;
    int a[50][50];
    int b[30];
    rep(m)
    cin>>b[i];
    rep(n)
    {
    	for(int j = 0 ; j < m; j++)
    	{
    		cin>>a[i][j];
    	}
    }
    int ans = 0;
    rep(n)
    {
    	ll tmp = c;
    	for(int j = 0 ; j < m; j++)
		{
			tmp+=a[i][j]*b[j];
		}    	
		if(tmp>0)ans++;
    }
    cout<<ans<<endl;
    return 0;

}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

fn main() {
    let n: usize = read();
    let k: usize = read();
    let a: Vec<usize> = (0..n).map(|_| read()).collect();

    let mut rui = vec![0; n+1];
    for i in 0..n {
        rui[i+1] = rui[i] + a[i] - 1;
        rui[i+1] %= k;
    }

    let mut ans: usize = 0;
    let mut map = HashMap::new();
    for i in 0..n+1 {
        {
            let score = map.entry(&rui[i]).or_insert(0);
            ans += *score;
            *score += 1;
        }
        if i + 1 >= k {
           let po = map.get_mut(&rui[i+1-k]).unwrap();
           *po -= 1;
        }
    }
    println!("{}", ans);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 19224
def sum(A):
    a=0
    for num in range(len(A)):
        a=a+A[num]
    return a
             


N,M=input().split()
N=int(N)
M=int(M)
K=[100]*(M+1)
for num in range(M+1):
    K[num]=input().split()
    for num2 in range(len(K[num])):
        K[num][num2]=int(K[num][num2])

a=[0]*N
cnt=0
for num in range(pow(2,N)):
    flag=0
    n=num
    i=0
    while(N>i):
        a[N-1-i]=n//pow(2,N-1-i)
        if(a[N-1-i]==1):
            n=n-pow(2,N-1-i)
        i=i+1
    for num2 in range(M):
        b=0
        for num3 in range(len(K[num2])-1):
            b=b+a[K[num2][num3+1]-1]
        if(b%2!=K[M][num2]):
            flag=1
    if(flag==0):
        cnt=cnt+1
print(cnt)


Measured memory_bytes: 3064
using System;

namespace Codes
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int answer = 0;

            if(n%2==1){
                answer = (n-1)/2+1;
            }
            else{
                answer = n/2;
            }

            Console.WriteLine(answer);


        }
    }
}


Measured memory_bytes: 11092