akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
vector<int> G[100010];
queue<pair<int,int>> que;
int pre[100010];
void bfs(int s){
    que.push({s,0});
    while(que.size()){
        auto p = que.front(); que.pop();
        if(pre[p.first]!=-1) continue;
        pre[p.first] = p.second;
        for(int v:G[p.first]){
            if(v==p.second) continue;
            que.push({v,p.first});
        }
    }
}

int main(){
    int i,n,m; cin >> n >>m;
    for(i=0;i<m;i++){
        int a,b; cin >> a >> b; a--; b--;
        G[a].push_back(b); G[b].push_back(a);
    }
    for(i=0;i<n;i++){
        pre[i] = -1;
    }
    bfs(0);
    cout << "Yes" << endl;
    for(i=1;i<n;i++){
        cout << pre[i] + 1<< endl;
    }
}

Measured memory_bytes: 11316
n,m,q=map(int,input().split())
from itertools import combinations_with_replacement as com
li = list(range(1,m+1))

abcds = [list(map(int,input().split()))for _ in range(q)]
ans = 0
for lis in com(li,n):
    res = 0
    for i in range(q):
        a,b,c,d = abcds[i][0],abcds[i][1],abcds[i][2],abcds[i][3]
        if lis[b-1] - lis[a-1] == c:
            res += d
    ans = max(ans,res)
print(ans)

Measured memory_bytes: 68156
#include<bits/stdc++.h>
#define INF 2000000000
#define int long long int
#define MOD 1000000007
#define pb push_back
#define cin1(n) (cin >> n)
#define cin2(a,b) (cin >> a >> b)
#define cin3(a,b,c) (cin >> a >> b >> c)
#define cout(n) (cout << n << endl)
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define fr first 
#define sc second 
#define EPS (1e-10)




using namespace std;

typedef vector<int> vi;
typedef vector< vector<int> > vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<string> vs;
typedef vector<vector<string>> vss;
typedef pair<int,int> pii;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int n,m;
int a,b;
int p,q;


signed main() {
	cin2(n,m);
	cout << (n + m) % 24 << endl;

	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
const int mod = 1e9 + 7;
ll int INF = 1e17;
 
int dp[3005][3005];
string s1, s2;
 
int kil(int idx1, int idx2)
{
  if(idx1 == s1.length() || idx2 == s2.length())
    return 0;
 
  if(dp[idx1][idx2] != -1)
    return dp[idx1][idx2];
 
  if(s1[idx1] == s2[idx2])
    dp[idx1][idx2] = max(dp[idx1][idx2], kil(idx1+1, idx2+1) + 1);
  else
  {
    dp[idx1][idx2] = max(dp[idx1][idx2], kil(idx1, idx2+1));
    dp[idx1][idx2] = max(dp[idx1][idx2], kil(idx1+1, idx2));
  }
  return dp[idx1][idx2];
}
 
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 
  string res="";
 
  memset(dp, -1, sizeof dp);
  cin>>s1>>s2;
 
  // recursive
  // kil(0, 0);
 
  // iterative
  memset(dp, 0, sizeof dp);
 
  for(int idx1 = s1.length()-1; idx1>=0; idx1--)
    for(int idx2 = s2.length()-1; idx2>=0; idx2--)
    {
      if(s1[idx1] == s2[idx2])
        dp[idx1][idx2] =  dp[idx1+1][idx2+1] + 1;
      else
      {
        dp[idx1][idx2] = max(dp[idx1+1][idx2], dp[idx1][idx2+1]);
      }
    }
 
 
 
  int idx1=0, idx2=0;
 
  while(idx1 != s1.length() && idx2 != s2.length())
  {
    if(s1[idx1] == s2[idx2])
    {
      res += s1[idx1];
      idx1 += 1;
      idx2 += 1;
    }
    else
    {
      if(dp[idx1][idx2] == dp[idx1+1][idx2])
        idx1 += 1;
      if(dp[idx1][idx2] == dp[idx1][idx2+1])
        idx2 += 1;
    }
  }
 
  cout<<res<<endl;
  return 0;
}

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

string s;
int n;

int main(){
	cin >> s;
	n = s.length();
	if (s[0] == s[n-1]){
		if (n%2 == 0) cout << "First";
		else cout << "Second";
	}
	else{
		if (n%2 == 0) cout << "Second";
		else cout << "First";
	}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int a,b,c,some1,some2,some3;
	cin>>a>>b>>c;
	some1=a-b;
	some2=b-c;
	some3=a-c;
	if(some1==some2 && some2==some3){
		cout<<1<<endl;
	}
	else if(some1==0 || some2==0 || some3==0){
		cout<<2<<endl;
	}
	else{
		cout<<3<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
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() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int ans = 1;
    bool asc = false, desc = false;
    rep(i, n-1) {
        if (a[i] == a[i+1]) continue;
        if (a[i] > a[i+1]) desc = true;
        if (a[i] < a[i+1]) asc = true;
        if (asc && desc) {
            asc = false; desc = false;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> dp(n + 1);
    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            dp[j]++;
        }
    }
    // printde(dp);
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ans += 1ll * i * dp[i];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 41896
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>

using namespace std;

struct data {
  int x,h;
  data(){}
  data(int x,int h):x(x),h(h){}
  bool operator<(const data& e)const {
    if( h != e.h ) return h < e.h;
    return x < e.x;
  }
};

int n;
data a[55];
int dp[5][55];
int ma;

// kosu,bango
int solve(int p,int q)
{
  int s,t;
  ma = max(ma,q);
  if( q == n ) return a[q-1].x;
  if( dp[p][q] >= 0 ) return dp[p][q];
  s = 100*50000*3+100000;
  t = 100*50000*3+100000;
  if( (a[q].h-a[q-1].h) >= a[q].x+(p+1)*a[q-1].x ) {
    s = solve(1,q+1)+a[q].x+a[q-1].x;
    //if( q == 1 ) printf(";;%d\n",a[q].x+a[q-1].x);
  }
  if( p < 3 ) {
    //printf("::%d %d\n",a[q].h-a[q-1].h,abs(a[q-1].x-a[q].x)*(p+1));
    if( (a[q].h-a[q-1].h) >= abs(a[q-1].x-a[q].x)*(p+1) ) {
      t = solve(p+1,q+1)+abs(a[q-1].x-a[q].x);
      //printf("%d %d::%d\n",p,q,t);
    }
  }
  return dp[p][q] = min(s,t);
}

int main(void)
{
  int res;
  for(;;) {
    scanf("%d",&n); if(!n) break;
    memset(dp,-1,sizeof(dp));
    for( int i = 1; i <= n; i++ ) {
      scanf("%d%d",&a[i].x,&a[i].h);
    }
    ++n;
    ma = 0;
    a[0].x = 0;
    a[0].h = 0;
    sort(a,a+n);
    /*
    for( int i = 0; i < n; i++ ) {
      printf("%d %d\n",a[i].x,a[i].h);
    }
    */
    res = solve(0,1);
    if( ma != n ) {
      printf("NG %d\n",ma);
    } else {
      printf("OK %d\n",res);
    }
  }
  return 0;
}

Measured memory_bytes: 1028
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

int main(){
    std::ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int h[n] = {};
    for(int i=0;i<n;++i)
    {
        cin >> h[i];
    }
    int dp[n] = {};
    for(int i=0;i<n;++i)
    {
        dp[i] = 1 << 30;
    }

    dp[0] = 0;
    for(int i=0;i<n;++i)
    {
        for(int j=1;j<=k;++j)
        {
            if((i + j) < n)
            {
                dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
            }
        }
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,low=100001;
int n,a[N],b[N],c[N];
ll t[N<<1];
void add(int x)
{
    x+=low;
    assert(x!=0);
    while(x<=n+low)
        t[x]++,x+=x&-x;
}
int query(int x)
{
    int ans=0;
    x+=low;
    assert(x!=0);
    while(x)
        ans+=t[x],x-=x&-x;
    return ans;
}
bool judge(int m)
{
    memset(t,0,sizeof(t));
    for(int i=1;i<=n;i++)
        if(a[i]<b[m]) c[i]=-1;
    else c[i]=1;
    ll ans=0;
    add(0);
    for(int i=1;i<=n;i++)
    {
        c[i]+=c[i-1];
        ans+=query(c[i]);
        add(c[i]);
    }
    return ans>=(ll)n*(n+1)/2/2+n*(n+1)/2%2;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),b[i]=a[i];
    sort(b+1,b+1+n);
    int l=1,r=n,ans;
    while(l<=r)
    {
        int m=l+r>>1;
        if(judge(m)) ans=m,l=m+1;
        else r=m-1;
    }
    printf("%d\n",b[ans]);
}


Measured memory_bytes: 2944
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
const double PI = (acos(-1));
const long long MOD = pow(10, 9) + 7;
long long kaizyou(int N);
long long POW(int J);

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

    if (s[s.size() - 1] == 's')
    {
        cout << s << "es";
    }
    else
    {
        cout << s << 's';
    }
    
}


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(int i = (int)k; i < (int)n; i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, k, n) for(int i = (int)n-1; i > (int)k-1; i--)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl;

typedef long long ll;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int N, A;
int x[51];
long long dp[51][51][2600];

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

    cin >> N >> A;
    REP(i,1,N+1) cin >> x[i];

    // int X = max(*max_element(x+1,x+N+1), A);

    dp[0][0][0] = 1;
    REP(xi,1,N+1) {
        rep(ch_n,xi+1) {
            rep(sum,2501) {
                if(sum<x[xi])
                    dp[xi][ch_n][sum] = dp[xi-1][ch_n][sum];
                else if(ch_n>=1)
                    dp[xi][ch_n][sum] = dp[xi-1][ch_n][sum] + dp[xi-1][ch_n-1][sum-x[xi]];
            }
        }
    }
    // rep(xi,N) {
    //     rep(ch_n,N) {
    //         rep(sum,2500) {
    //             if(dp[xi][ch_n][sum]) {
    //                 dp[xi+1][ch_n][sum] += dp[xi][ch_n][sum];
    //                 dp[xi+1][ch_n+1][sum+x[xi+1]] += dp[xi][ch_n][sum];
    //             }
    //         }
    //     }
    // }

    // rep(i,N+1) {
    //     cout << i << ":" << endl;
    //     rep(j,N+1) {
    //         rep(k,25) {
    //             cout << dp[i][j][k] << " ";
    //         } cout << endl;
    //     } cout << endl << endl;
    // }

    ll ans = 0;
    REP(ch_n,1,N+1)
        ans += dp[N][ch_n][A*ch_n];

    cout << ans << endl;
}


Measured memory_bytes: 51072
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n,a,b = LI()
    print(min(n*a,b))
    return

#B
def B():
    return

#C
def C():
    n = I()
    f = LIR(n)
    po = [1]*11
    for i in range(n):
        k = 0
        p = 1
        for j in range(10):
            k += p*f[i][j]
            p *= 2
            po[j+1] = p
        f[i] = k
    p = LIR(n)
    ans = -float("inf")
    for i in range(1,1024):
        k = 0
        for j in range(n):
            c = i&f[j]
            s = 0
            for l in po:
                if c&l:s += 1
            k += p[j][s]
        ans = max(ans,k)
    print(ans)
#D
def D():
    n,C = LI()
    T = [[0 for i in range(100002)] for j in range(C)]
    for i in range(n):
        s,t,c = LI()
        c -= 1
        T[c][s] += 1
        T[c][t+1] -= 1
    for c in range(C):
        for i in range(100000):
            T[c][i+1] += T[c][i]
    ans = 0
    for i in range(100000):
        k = 0
        for c in range(C):
            if T[c][i]:k += 1
        ans = max(ans, k)
    print(ans)
#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    A()


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

#define MAXN 105

void print(int a[],int n)
{
    for(int i=1; i<n; i++)
        printf("%d ",a[i]);
    printf("%d\n",a[n]);
}

void insertion_sort(int a[],int n)
{
    int temp;
    for(int i=2; i<=n; i++)
    {
        temp=a[i];
        int j=i-1;
        while(j>=1 && a[j]>temp)
        {
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=temp;
        print(a,n);
    }
}

int main()
{
    int n;
    int a[MAXN];
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d",&a[i]);
    print(a,n);
    insertion_sort(a,n);
    return 0;
}

Measured memory_bytes: 3192
def main():
    import sys
    x=int(input())
    cnt=0
    if x==1:
        print(1)
        sys.exit()
    if x==2:
        print(2)
        sys.exit()
    for i in range(1,x):
        if cnt<x:
            cnt+=i
        else:
            t=i-1
            break
    print(t)

if __name__=='__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};


  
int main(){
  
  int n,m;
  cin>>n>>m;
  long long a;
  long long b;
  vector<pair<long long,long long>> ab;
  REP(i,n){
    cin>>a>>b;
    ab.push_back(make_pair(a,b));
  }
  sort(ab.begin(),ab.end());
  long long ans=0;
  REP(i,n){
    if(m>0){
      if(m>=ab[i].second){
        m -= ab[i].second;
        ans += ab[i].first*ab[i].second;
      }else{
        ans += ab[i].first*m;
        m = 0;
      }
    }else{
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2420
n=int(input())
c,s,f=[0]*(n-1),[0]*(n-1),[0]*(n-1)
for i in range(n-1):
    c[i],s[i],f[i]=map(int,input().split())
for j in range(n-1):
    t=s[j]+c[j]
    now=j+1
    while now<n-1:
        if s[now]<t:
            t=((-t)//f[now])*(-f[now])
        else:
            t=s[now]
        t+=c[now]
        now+=1
    print(t)
print(0)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  string tmp;
  REP(i, n - 2) {
    tmp = s.substr(i, 3);
    if (tmp == "ABC") cnt++;
  }
  cout << cnt << endl;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
int g[300][300];
int c[300][300];
using namespace std;

signed main(){
  int N;
  cin>>N;
  int ans=0;
  int out=0;
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)cin>>g[i][j];
  for(int i=0;i<N;i++)for(int j=0;j<N;j++)c[i][j]=0;
  for(int i=0;i<N;i++){
    for(int j=0;j<i;j++){
      ans+=g[i][j];
    }
  }
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<i;j++){
        if(g[i][j]>g[i][k]+g[k][j])out++;
        if(k!=i&&k!=j&&i!=j&&c[i][j]==0)if(g[i][j]==g[i][k]+g[k][j]){c[i][j]++;ans-=g[i][j];}
      }
    }
  }
  if(out)cout<<-1<<endl;
  else cout<<ans<<endl;
}


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

int main(){
    int N;
    cin >> N;
    int ans;
    ans = N % 1000;
    if(ans == 0){
        cout << "0" << endl;
    }else{
        ans = 1000 - ans;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using intpv=vector<intpair>;
using llpair=pair<ll,ll>;
using llpv=vector<llpair>;
using intvec=vector<int>;
using llvec=vector<ll>;
using intq=queue<int>;
using llq=queue<ll>;
using intmat=vector<intvec>;
using llmat=vector<llvec>;
using pairmat=vector<llpv>;
#define matrix(T) vector<vector<T>>
#define PI 3.141592653589793
#define INTINF 1<<30
#define LLINF 1LL<<60
#define MPRIME 1000000007
#define MPRIME9 998244353
#define pqueue priority_queue
#define pushb push_back
#define fi first
#define se second
#define setpr fixed<<setprecision(15)
#define all(name) name.begin(),name.end()
#define rall(name) name.rbegin(),name.rend()
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())
#define init(v,size) v.resize(size); for(auto &a__: v) cin>>a__
#define matin(mat,H,W) for(int i__=0; i__<H; i__++)for(int j__=0; j__<W; j__++) cin>>mat[i__][j__]
#define out(n) cout<<n<<endl

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

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

template<class T> inline void outmat(T& a, int y, int x) {
	for(int i=0; i<y; i++) {
		for(int j=0; j<x; j++) cout<<a[i][j]<<" ";
		cout<<endl;
	}
}

ll GCD(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll binpow(ll a, ll ex, ll p) { //繰り返し二乗法
	ll result=1;
	while(ex>0) {
		if(ex&1) result=result*a%p;
		ex>>=1;
		a=a*a%p;
	}
	return result;
}

ll Fact(ll x, ll p) { //階乗
	ll f=1;
	for(ll i=2; i<=x; i++) {
		f*=i;
		f%=p;
	}
	return f;
}

ll nPr(ll n, ll r) {
	if(n<r) return 0;

	ll result=1LL;
	for(ll i=0; i<r; i++) result*=n-i;
	return result;
}

ll nPrP(ll n, ll r, ll p) { // mod pにおけるnPr
	if(n<r) return 0;

	ll result=1LL;
	for(int i=0; i<r; i++) {
		result*=n-i;
		result%=p;
	}
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll div=1LL;
	while(n/div) {
		digit++;
		div*=10;
	}
	return digit;
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}


ll A,B;
ll res=0;

void input() {
	cin>>A>>B;
}

void solve() {
	A=max(0LL,A-1);
	ll r=2;
	while(r/2<=B) {
		ll tmp=B/r*(r/2)+max(0LL,B%r-(r/2-1)) - A/r*(r/2)+max(0LL,A%r-(r/2-1));
		res+=tmp%2*(r/2);
		r*=2;
	}

	cout<<res<<endl;
}

int main() {
	while(1) {
		input();
		solve();
		break;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() { 
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int sum=0;
  if(k>=a){
    if(k>=a+b){
      sum=a-(k-a-b);
      }
    else{
      sum=a;
      }
    
    }
  else{
    sum=k;
    }
  cout<<sum<<endl;
  return 0;
  }



Measured memory_bytes: 3596
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n, m; scanf("%d%d", &n, &m); std::vector<int> a(n), b(m);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < m; i++) scanf("%d", &b[i]);
	
	std::vector<int> X(n * m, -1), Y(n * m, -1);
	for(int i = 0; i < n; i++) X[--a[i]] = i;
	for(int i = 0; i < m; i++) Y[--b[i]] = i;
	
	std::vector<bool> ukunichia(n * m, false);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(a[i] == b[j]) {
				if(ukunichia[a[i]]) {
					printf("0\n");
					return 0;
				} else ukunichia[a[i]] = true;
			}
		}
	}
	
	std::vector<i64> li(n * m + 1, 0);
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			if(a[i] == b[j]) continue;
			int mi = std::min(a[i], b[j]);
			li[0]++;
			li[mi + 1]--;
		}
	}
	for(int i = 0; i < n * m; i++) li[i + 1] += li[i];
	
	i64 ans = 1, tmp = 0, all = n * m;
	std::vector<std::vector<int>> latte(n, std::vector<int>(m, -1));
	const int MOD = 1e9 + 7;
	for(int k = n * m - 1; k >= 0; k--) {
		if(X[k] != -1 and Y[k] != -1) {
			all--;
		} else if(X[k] == -1 and Y[k] == -1) {
			i64 count = li[k];
			if(count - tmp < 0) ans = 0;
			(ans *= count - tmp) %= MOD;
			tmp++;
		} else if(X[k] != -1 and Y[k] == -1) {
			i64 count = 0;
			for(int i = 0; i < m; i++) {
				if(latte[X[k]][i] != -1) continue;
				if(b[i] > k) count++;
			}
			(ans *= count) %= MOD;
			tmp++;
		} else if(X[k] == -1 and Y[k] != -1) {
			i64 count = 0;
			for(int i = 0; i < n; i++) {
				if(latte[i][Y[k]] != -1) continue;
				if(a[i] > k) count++;
			}
			(ans *= count) %= MOD;
			tmp++;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 19968
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    string t; cin >> t;
    ll S = s.size();
    ll T = t.size();
    vector <vector <int>> dp(S+1, vector<int>(T+1, 0));
    for(int i=1; i<S+1; i++){
        for(int j=1; j<T+1; j++){
            dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            if (s[i-1] == t[j-1]){
                dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
            }
        }
    }
    string ret_reverse = "";
    ll i = S;
    ll j = T;
    while(dp[i][j] > 0){
        if (dp[i][j-1] == dp[i][j]){
            j--;
            continue;
        }
        if (dp[i-1][j] == dp[i][j]){
            i--;
            continue;
        }
        ret_reverse.push_back(s[i-1]);
        j--;
        i--;
    }
    for(auto iter=ret_reverse.end()-1; iter>=ret_reverse.begin(); --iter){
        cout << *(iter);
    }
    if (!ret_reverse.empty()){
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 35584
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main() {

    string S;
    cin >> S;

    map<char, int> m;

    for (int i = 0; i < 4; ++i) {
        m[S[i]] += 1;
    }

    bool ok = true;
    int cnt = 0;
    for (pair<char, int> p : m) {
        if (p.second != 2) {
            ok = false;
        }
        cnt += 1;
    }
    if (cnt != 2) {
        ok = false;
    }

    if (ok) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

string s1, s2;
int dp[3005][3005];
stack<char>stk;

void initialize()
{
    for(int i=0;i<=3000;i++)
        for(int j=0;j<=3000;j++)
            dp[i][j] = -1;
}

int LCS(int i, int j)
{
    if(i<=0 or j<=0) return 0;

    if(dp[i][j]!=-1) return dp[i][j];

    int ret = max(LCS(i-1, j), LCS(i, j-1));

    if(s1[i-1]==s2[j-1])
        ret = max(ret, LCS(i-1, j-1)+1);

    dp[i][j] = ret;

    return ret;
}


void printChar(int i, int j)
{
    if(dp[i][j]<=0) return;

    if(dp[i][j]==dp[i-1][j]) printChar(i-1, j);
    else if(dp[i][j]==dp[i][j-1]) printChar(i, j-1);
    else
    {
        stk.push(s1[i-1]);
        printChar(i-1, j-1);
    }
}

int main()
{
    initialize();

    int n, m;
    cin>>s1>>s2;

    int retVal = LCS(s1.size(), s2.size());

    printChar(s1.size(), s2.size());
    //cout<<retVal<<endl;

    while(!stk.empty())
    {
        cout<<stk.top();
        stk.pop();
    }

    cout<<endl;

    return 0;
}


Measured memory_bytes: 39220
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int k;
    cin>>k;
    int j=0;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    
    for(int i=0;i<n;i++){
        if(k<=h[i]){
            j++;
        }
    }
    cout<<j;
    
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,B,N,M,K,X,Y,Z;
  cin >> N;
  vector<int> A(N);

  for(int i=0 ; i < N ; i++){
    cin >> A.at(i);
  }

  for(int i=0 ; i < N ; i++){
    if( (A.at(i) & 1) == 0){
      if(( (A.at(i) % 3) == 0)||
         ( (A.at(i) % 5) == 0)){
         //cout << (A.at(i) % 3) << (A.at(i) % 3) << endl;
      }else{ 
        cout << "DENIED"<< endl;
        return(0);
      }
    }
  }
  cout << "APPROVED"<< endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int card[4][13];
const char mark[]={'S','H','C','D'};

int main()
{
	int i,j,n;
	scanf("%d", &n);
	for(i=0; i<n; i++){
		char a;
		int x;
		scanf(" %c %d",&a,&x);
		if(a=='S') card[0][x-1]=1;
		else if(a=='H') card[1][x-1]=1;
		else if(a=='C') card[2][x-1]=1;
		else if(a=='D') card[3][x-1]=1;
	}
	for(i=0;i<4;i++){
		for(j=0;j<13;j++){
			if(card[i][j]==0){
				printf("%c %d\n",mark[i],j+1);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll GCD(ll a, ll b){ return a ? GCD(b % a, a) : b; }
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a.begin(),a.end(),greater<>());
    ll ans = 0;
    int cnt = 2;
    ans += a[0];
    for(int i=1; cnt<n; i++){
        ans += a[i];
        cnt++;
        if(cnt<n){
            ans+=a[i];
            cnt++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4848
import math

n,m = map(int,input().split())

q = int(math.sqrt(m))+1
li = [0 for i in range(10**6)]

for i in range(1,q):
    if (m%i) == 0:
        li[i] = 1
        
ans = 1
for i in range(1,q):
    if (li[i]==1) and (i*n<=m):
        ans = max(i,ans)
        
    if (li[i]==1) and (m*n<=m*i):
        ans = max((m/i),ans)
    

print(int(ans))
    

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b;
  cin>>a>>b;
  if(a+b==15)puts("+");
  else if(a*b==15)puts("*");
  else puts("x");
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()
#define DUMP(o) {cerr<<#o<<" "<<o<<endl;}
#define DUMPC(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	unordered_map<char, string> a;
	unordered_map<string, string> b;
	a[' '] = "101";
	a['\''] = "000000";
	a[','] = "000011";
	a['-'] = "10010001";
	a['.'] = "010001";
	a['?'] = "000001";
	a['A'] = "100101";
	a['B'] = "10011010";
	a['C'] = "0101";
	a['D'] = "0001";
	a['E'] = "110";
	a['F'] = "01001";
	a['G'] = "10011011";
	a['H'] = "010000";
	a['I'] = "0111";
	a['J'] = "10011000";
	a['K'] = "0110";
	a['L'] = "00100";
	a['M'] = "10011001";
	a['N'] = "10011110";
	a['O'] = "00101";
	a['P'] = "111";
	a['Q'] = "10011111";
	a['R'] = "1000";
	a['S'] = "00110";
	a['T'] = "00111";
	a['U'] = "10011100";
	a['V'] = "10011101";
	a['W'] = "000010";
	a['X'] = "10010010";
	a['Y'] = "10010011";
	a['Z'] = "10010000";
	b["00000"] = "A";
	b["00001"] = "B";
	b["00010"] = "C";
	b["00011"] = "D";
	b["00100"] = "E";
	b["00101"] = "F";
	b["00110"] = "G";
	b["00111"] = "H";
	b["01000"] = "I";
	b["01001"] = "J";
	b["01010"] = "K";
	b["01011"] = "L";
	b["01100"] = "M";
	b["01101"] = "N";
	b["01110"] = "O";
	b["01111"] = "P";
	b["10000"] = "Q";
	b["10001"] = "R";
	b["10010"] = "S";
	b["10011"] = "T";
	b["10100"] = "U";
	b["10101"] = "V";
	b["10110"] = "W";
	b["10111"] = "X";
	b["11000"] = "Y";
	b["11001"] = "Z";
	b["11010"] = " ";
	b["11011"] = ".";
	b["11100"] = ",";
	b["11101"] = "-";
	b["11110"] = "'";
	b["11111"] = "?";

	for (string s; getline(cin, s);) {
		string t = "";
		REP(i, s.size()) t += a[s[i]];
		int c = (5 - t.size() % 5) % 5;
		REP(i, c)t += "0";
		string ans = "";
		for (int i = 0; i < t.size(); i += 5) {
			ans += b[t.substr(i, 5)];
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<vector>
#include<queue>

int main(void){
    int n, m, a, b;
    std::cin >> n >> m;
    std::vector<int> c(n+1), d(n+1);
    std::vector<std::vector<int>> r;
    r.resize(n+1);
    std::queue<int> q;

    for(int i = 0; i < m; i++){
	std::cin >> a >> b;
	r[a].push_back(b);
	r[b].push_back(a);
    }

    // for(int i = 0; i < n+1; i++){
    //     std::cout << i;
    //     for(int j = 0; j < r[i].size(); j++){
    //         std::cout << " " << r[i][j];
    //     }
    //     std::cout << std::endl;
    // }

    q.push(1);
    while(!q.empty()){
	int cur = q.front();
	q.pop();
	for(int i = 0; i < r[cur].size(); i++){
	    int next = r[cur][i];
	    if(c[next] == 0){
		q.push(next);
		d[next] = cur;
		c[next] = 1;
	    }
	}
    }

    bool flag = 0;
    for(int i = 2; i < n + 1; i++){
	if(c[i] == 0){
	    flag = 1;
	    break;
	}
    }

    if(!flag) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;

    for(int i = 2; i < n+1; i++){
	std::cout << d[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 10580
AB = input().split()
A = int(AB[0])
B = int(AB[1])

def gcd(a, b):
  while b!=0:
    a, b = b, a%b
  return a

def lcm(a, b):
  return (a*b) / gcd(a, b)

print(int(lcm(A, B)))

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

int main()
{
	string deck;
	int m = 0;
	int d = 0;
	int h_sum = 0;
	int h;

	while (true) {
		cin >> deck;

		if (deck == "-")
			break;
		cin >> m;
		for (int i = 0; i < m; i++) {
			cin >> h;
			h_sum += h;
		}
		d = h_sum % ((int)deck.size());

	
		/*
		cout << "+++" << d << "+++\n";
		cout << "---" << deck.size() << "---\n";
		cout << "***" << h_sum << "***\n";
		*/

		for (int i = 0; i < d; i++) {
			deck.push_back(deck[i]);
		}

		deck.erase(deck.begin() + 0, deck.begin() + d);

		cout << deck << '\n';

		h_sum = 0;
		d = 0;
	}
	return 0;
}


Measured memory_bytes: 3180
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    for (int i = 1; i <= 3; i++)
    {
        if (a * b * i % 2 == 1)
        {
            printf("Yes");
            return 0;
        }
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint K;
	cin >> K;
	lint N = 7 % K;
	lint cnt = 0;
	while (1) {
		if (N == 0) {
			cout << cnt+1 << endl;
			return 0;
		}
		else if (cnt >= 10000000) {
			cout << -1 << endl;
			return 0;
		}
		else {
			N *= 10;
			N += 7;
			N %= K;
			cnt++;
		}
	}
}

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

int main(){

    int N;
    long long H;
    cin >> N >> H;
    long long a,b;
    vector<pair<long long,int>> vec;
    
    for(int i = 0; i < N;i++){
        cin >> a >> b;
        vec.push_back(make_pair(a,0));
        vec.push_back(make_pair(b,1));
    }
    
    sort(vec.begin(),vec.end(),greater<pair<long long,int>>());
    int index = 0;
    int cont = 0;
    while(H>0){
        //cout << vec[index].first <<" "<< vec[index].second << endl;
        if(vec[index].second == 0){
            while(H>0){H-=vec[index].first;cont++;}
        }else{
            H -= vec[index].first;
            cont++;
        }
        index++;
    }
    cout << cont << endl;
    
}



Measured memory_bytes: 6384
def main():
    N,M=map(int,input().split())
    H=list(map(int,input().split()))
    OK=[True]*N
    for _ in range(M):
        a,b=map(int, input().split())
        if H[a-1] <= H[b-1]: OK[a-1] = False
        if H[b-1] <= H[a-1]: OK[b-1] = False
    print(OK.count(True))

if __name__=='__main__':
    main()

Measured memory_bytes: 20136
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> a(13);
	a[0] = 1;
	rep(i, n) {
		int d;
		cin >> d;
		a[d]++;
	}
	if (a[0] >= 2 or a[12] >= 2) {
		cout << "0" << endl;
		return 0;
	}
	set<int> s;
	vector<int> p;
	s.insert(0);
	if (a[12]) s.insert(12);
	s.insert(24);
	repl(i, 1, 12) {
		if (a[i] >= 3) {
			cout << "0" << endl;
			return 0;
		} else if (a[i] == 2)
			s.insert(i), s.insert(24 - i);
		else if (a[i])
			p.push_back(i);
	}
	int sz = p.size(), ans = 0;
	rep(bit, 1 << sz) {
		set<int> ns = s;
		rep(i, sz) {
			if (bit >> i & 1)
				ns.insert(p[i]);
			else
				ns.insert(24 - p[i]);
		}
		int now = 24;
		auto itr = ns.begin();
		int t = ns.size();
		for (int i = 0; i < t - 1; i++, itr++) {
			int A = *++itr, B = *--itr;
			now = min(now, A - B);
		}
		ans = max(ans, now);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	private static final byte MASK_RIGHT = 0x0F;
	private static int[][] paper = new int[10][10];

	public static void main(String[] args) throws NumberFormatException, IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 128);
		String sLine;
		while ((sLine = reader.readLine()) != null) {
			droppingInk(sLine.charAt(0) & MASK_RIGHT, sLine.charAt(2) & MASK_RIGHT, sLine.charAt(4) & MASK_RIGHT);
		}
		calcResult();
	}

	private static void droppingInk(int x, int y, int size) {
		staining(x, y - 1);
		staining(x - 1, y);
		staining(x, y);
		staining(x + 1, y);
		staining(x, y + 1);
		if (size == 1) {
			return;
		}

		staining(x - 1, y - 1);
		staining(x + 1, y - 1);
		staining(x - 1, y + 1);
		staining(x + 1, y + 1);
		if (size == 2) {
			return;
		}

		staining(x, y - 2);
		staining(x - 2, y);
		staining(x + 2, y);
		staining(x, y + 2);
	}

	private static void staining(int x, int y) {
		if (x >= 0 && x < 10 && y >= 0 && y < 10) {
			paper[x][y]++;
		}
	}

	private static void calcResult() {
		int white = 0;
		int maxnoud = 0;
		for (int[] row : paper) {
			for (int colum : row) {
				if (colum == 0) {
					white++;
				} else if (colum > maxnoud) {
					maxnoud = colum;
				}
			}
		}
		System.out.println(white);
		System.out.println(maxnoud);
	}
}

Measured memory_bytes: 16848
s = input()
t = input()

ns = len(s)
nt = len(t)

for i in range(ns-nt, -1, -1):
   x = s[i:i+nt]
   for j in range(nt+1):
      if (j == nt):
         ss = s[:i] + t + s[i+nt:]
         print(ss.replace('?', 'a'))
         exit()

      if (x[j] == '?'):
         continue
      elif (x[j] != t[j]):
         break

print('UNRESTORABLE')


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

int main()
{
 string s,t;
 int c=0;
    cin>>s>>t;
    for(int i=0;i<s.size();i++){ 
        if(s[i]==t[i])c++;
    } 
    cout<<c;
    

    return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define mem(x, y) memset(x, y, sizeof(x))
#define mp make_pair
#define pb push_back

int main(){
    double R;
    cin >> R;
    printf("%.6f\n", 2 * M_PI * R);
    return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define mp          make_pair
#define pll         pair<long long,long long>
#define vll          vector<long long>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (long long)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main(){
	string s;
	int a;cin>>a>>s;
	if(a>=3200)cout<<s<<endl;
	else cout<<"red"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n;
    cin >> n;
    vector<int> a(n), pos(n);
    ll ans = 0;
    for(int i = 0; i < n; i++) cin >> a[i], a[i]--, pos[a[i]] = i;
    set<int> s;
    for(int i = n-1; i >= 0; i--) {
        int x = pos[i];
        s.insert(x);
        ll c = 0;
        vector<int> l(2, -1), r(2, n);
        {
            int f = 0;
            auto it = s.find(x);
            while(it!=s.begin()) {
                it--;
                l[f] = *it;
                f++;
                if(f == 2) break;
            }
        }
        {
            int f = 0;
            auto it = s.find(x);
            while(1) {
                it++;
                if(it == s.end()) break;
                r[f] = *it;
                f++;
                if(f == 2) break;
            }
        }

        vector<int> ls(2), rs(2);
        ls[0] = x - l[0];
        ls[1] = l[0] - l[1];
        rs[0] = r[0] - x;
        rs[1] = r[1] - r[0];
        c = (ll)rs[1]*ls[0]+(ll)rs[0]*ls[1];
        ans += c*(i+1);
    }

    cout << ans << endl;

}

Measured memory_bytes: 5760
// INCLUDE LIST
#include <cstdio>
#include <bitset>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
  double t, x;
  cin >> t >> x;
  printf("%.6f\n", t / x);
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return k*kk;
}using namespace std;
int n,f[10000];
struct lsg{int x,y;}a[1000000];
bool pd(lsg x,lsg y){return x.y+x.x<y.y+y.x;}
signed main(){
	n=read();for (int i=1;i<=n;i++)a[i].y=read(),a[i].x=read();
	sort(a+1,a+1+n,pd);memset(f,63,sizeof(f));f[0]=0;
	for (int i=1;i<=n;i++){
		for (int j=i;j>=1;j--)
			if (f[j-1]<=a[i].y)f[j]=min(f[j],f[j-1]+a[i].x);
	}for (int i=1;i<=n;i++)
		if (f[i]>1e18){cout<<i-1<<endl;return 0;}
	cout<<n<<endl;
}


Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    N = int(readline())
    A = [int(i) for i in readline().split()]
    SXOR = A[0]
    for i in range(1, N):
        SXOR ^= A[i]
    for a in A:
        print(SXOR^a, end=" ")
if __name__ == '__main__':
    main()


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

#define N 200123
#define mod 1000000007

long long weight[N];
vector<int> adj[N];

void dfs(int u, int par){
	weight[u] += weight[par];
	for(int v : adj[u])
		if(v != par)
			dfs(v , u);
}

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    int n, q, a;
    long long b;
    cin >> n >> q;

    for(int i = 1 ; i < n ; i++){
    	cin >> a >> b;
    	adj[a].push_back(b);
    	adj[b].push_back(a);
    }

    fill(weight, weight+N, 0);

    for(int i = 0 ; i < q; i++){
    	cin >> a >> b;
    	weight[a] += b;
    }
    dfs(1, 0);
    for(int i = 0 ; i < n ; i++){
    	if(i) cout << " ";
    	cout << weight[i+1];
    }
    return 0;
}

Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define sz(v) (int)(v.size())
#define all(x) x.begin(), x.end()
#define prec fixed << setprecision(12)
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define test int t; cin >> t; while(t--)

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef set<int> si;
typedef map<int, int> mii;
typedef vector<pii> vpi;

void solve() {
	int n, m;
	cin >> n >> m;
	int a;
	priority_queue<int> pq;
	rep(i, 1, n){
		cin >> a;
		pq.push(a);
	}
	rep(i, 1, m){
		if(sz(pq) == 0)
			break;
		int x = pq.top();
		pq.pop();
		if(x/2 >= 1){
			// cout << x;
			pq.push(x/2);
		}
	}
	int ans = 0;
	while(!pq.empty()){
		ans += pq.top();
		pq.pop();
	}
	cout << ans;
}

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

	// test
	solve();

	return 0;
}

Measured memory_bytes: 4292