akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) 998244353;
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

//------------------------------------------------------
vector<pll> v;
vector<ll> va, vb, sva, svb;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);

    int n, m;

    while (cin >> n >> m) {
        if (n == 0 && m == 0) break;

        int cost[110][110], time[110][110];

        rep(i, 110) rep(j, 110) {
            cost[i][j] = time[i][j] = (i == j ? 0 : INF);
        }

        rep(i, n) {
            int a, b, c, t;
            cin >> a >> b >> c >> t;
            cost[a][b] = cost[b][a] = c;
            time[a][b] = time[b][a] = t;
        }

        rep(k, 110) rep(i, 110) rep(j, 110) {
            cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
        }

        int k;
        cin >> k;

        rep(i, k) {
            int p, q, r;
            cin >> p >> q >> r;
            if (r == 0) cout << cost[p][q] << endl;
            else cout << time[p][q] << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, x, n) for (int i = x; i < (n); i++)
#define ALL(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N, K;
    cin >> N >> K;
    vector<long long> H;
    REP(i, N)
    {
        long long x;
        cin >> x;
        H.push_back(x);
    }

    sort(H.begin(), H.end());
    if (N < K)
        K = N;
    REP(i, K)
        H.pop_back();

    long long m = 0;
    REP(i,H.size()) {
        m += H.at(i);
    }
    cout << m << endl;

    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <algorithm>
#include <assert.h>

#define MAX_PAIRS 100005

using namespace std;

vector<int> edges[MAX_PAIRS];
bool visited[MAX_PAIRS];
int dp[MAX_PAIRS];
int in[MAX_PAIRS];

void depthSearch(int vertex)
{   
    assert(!visited[vertex]);
    visited[vertex] = true;
    for(int i: edges[vertex])
    {
        dp[i] = max(dp[i], dp[vertex] + 1);
        in[i]--;
        if(!in[i])
            depthSearch(i);
    }
}

int main()
{
    int n, m, start, end, maximum = 0;
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        cin >> start >> end;
        edges[start].push_back(end);
        in[end]++;
    }
    for(int i = 1; i <= n; i++)
    {
        if(!visited[i] && !in[i])
            depthSearch(i);
    }
    for(int i = 1; i <=n; i++)
    {
        if(dp[i] > maximum)
            maximum = dp[i];
    }
    cout << maximum;
}

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

int main(){
 int a, b, c; cin >> a >> b >> c;
 bool flag = false;
 for(int i = 1; i <=b; ++i){
   if((a*i)%b == c%b){
     flag = true;
     break;
   }
 }
 cout << (flag?"YES":"NO") << '\n';
}

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

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

    ll ans = pow(3, N);
    ll temp = 1;
    for (int i=0; i<N; i++){
        if (!(A.at(i) % 2)) temp *= 2;
    }

    cout << ans - temp << endl;
}

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

int main(){
  int N,M;
  map<string,int> mp;
  cin >> N;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    auto itr=mp.find(s);
    if(itr==mp.end()){
      mp[s]=1;
    }else{
      mp[s]++;
    }
  }
  cin >> M;
    for(int i=0;i<M;i++){
    string s;
    cin >> s;
    auto itr=mp.find(s);
    if(itr==mp.end()){
      mp[s]=-1;
    }else{
      mp[s]--;
    }
  }
  int max = 0;
  for(auto it = mp.begin(); it!=mp.end(); it++ ) {
    if( max < it->second ) max = it->second;
  }
  cout<<max<<endl;
  return 0;
}

Measured memory_bytes: 256
s_dash = input()
t = input()
n = len(s_dash)
m = len(t)

s = "UNRESTORABLE"
cnt = 0
for i in range(n - m + 1):
    cnt = 0
    for j in range(m):
      if s_dash[i+j] == t[j] or s_dash[i+j] == "?":
        cnt += 1
      else:
        break
    if cnt == m:
      s = s_dash[:i] + t + s_dash[i+m:]
      s = s.replace("?", "a")

      
print(s)
      

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

using namespace std;

typedef long long ll;

int k, length, pointer;
string S, str[100005];

int main(){

    cin >> S >> k;
    length = S.size();

    for (int i = 1; i <= 5; i++){
        for (int j = 0; j <= length-i; j++){
            str[pointer++] = S.substr(j,i);
        }
    }

    sort(str, str+pointer);
    unique(str, str+pointer);

    cout << str[k-1] << endl;

    return 0;

}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int getComp(vector<int>& comp,int i){
  if(comp[i] != i) comp[i] = getComp(comp,comp[i]);
  return comp[i];
}
void merge(vector<int>& comp,vector<int>& level,int a,int b){
  a = getComp(comp,a);
  b = getComp(comp,b);
  if(level[a] > level[b]) swap(a,b);
  else if(level[a] == level[b]) ++level[b];
  comp[a] = b;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,m,x,y,z;
  cin >> n >> m;
  vector<int> comp(n+1),level(n+1);
  iota(begin(comp),end(comp),0);
  while(m--){
    cin >> x >> y >> z;
    merge(comp,level,x,y);
  }
  set<int> st;
  for(int i = 1; i <= n; ++i) st.insert(getComp(comp,i));
  cout << st.size();
  return 0;
}

Measured memory_bytes: 5760
hoge=input()
huga=input()
ans=0
for i in range(len(hoge)+1-len(huga)):
  tmp_ans=0
  for j in range(len(huga)):
    if(hoge[i+j]==huga[j]):
      tmp_ans+=1
  ans=max(ans,tmp_ans)

print(len(huga)-ans)

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a < b) {
    cout << "a < b" << endl;
  }
  else if (a > b) {
    cout << "a > b" << endl;
  }
  else {
    cout << "a == b" << endl;
  }
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  double a,b,x;
  double PI = acos(-1);
  cin >> a >> b >> x;
  x/=a;
  double  z;
  if(a*b<=2*x){
    double k=a*b-x;
    double y=k*2/a;
    z=atan(y/a)*180/PI;
  }
  else{
    double y=x*2/b;
    z=90-atan(y/b)*180/PI;
  }
  cout << fixed << setprecision(10);
  cout << z << endl;
}

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

int main(){
  ll K,count=1;
  cin>>K;
  ll mod=7%K;
  if(K%2==0||K%5==0){
    cout<<-1<<endl;
    return 0;
  }
  while(mod>0){
    mod=(mod*10+7)%K;
    count++;
  }
  cout<<count<<endl;
}

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

int main(){
  long n,m,i,l,r,a,b,zero=0;
  cin >> n >> m;
  l=1; r=n;
  for(i=0; i<m; i++){
    cin >> a >> b;
    l=max(l,a); r=min(r,b);
  }
  cout << max(r-l+1,zero);
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define L(i, m, n) for(int i(m);i < n;i++)
#define pb push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define in(x) cin >> x
#define SZ(X) int(X.size())
#define ff first
#define ss second
#define RF(X) freopen(X, "r", stdin)
#define WF(X) freopen(X, "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<int, string> pis;
typedef vector<string> vs;
typedef pair<pair<int, int>, pair<int, int > > piiii;

int a[200009];
int main(){
	int n,idx;in(n);L(i,0,n)in(a[i]);
	idx=n-1;
	if(n%2){
		while(idx>=0){
			cout << a[idx] <<" ";
			idx-=2;
		}
		idx=1;
		while(idx < n){
			cout << a[idx]<<" ";
			idx+=2;
		}
	}
	else{
		while(idx>=1){
			cout << a[idx] <<" ";
			idx-=2;
		}
		idx=0;
		while(idx < n){
			cout << a[idx]<<" ";
			idx+=2;
		}
	}
	
	printf("\n");
	return 0;
}


Measured memory_bytes: 2944
# 5
# 1 2 3 4 5
# 3
# 3 4 1

import copy

Sn = int(input())
S = list(map(int, input().split()))

Tn = int(input())
T = list(map(int, input().split()))

def binary_search(nums, n, v):
    left = 0
    right = n
    while left < right:
        mid = (left + right) // 2
        if nums[mid] == v:
            return True
        elif v < nums[mid]:
            right = mid
        elif nums[mid] < v:
            left = mid + 1
    return False


if __name__ == "__main__":
    count = 0 
    for t in T:
        if binary_search(S, Sn, t):
            count += 1

    print(count)
        

    




Measured memory_bytes: 17352
import sys
for i in sys.stdin:
    try:
        sidelen = [int(j) for j in i.split(" ")]
        sidelen.sort(reverse=True)
        if(sidelen[0]**2 == sidelen[1]**2 + sidelen[2]**2):
            print("YES")
        else:
            print("NO")
    except:
        continue

Measured memory_bytes: 7648
#include<bits/stdc++.h>
using namespace std;
const int maxx=1e3+10;
char graph[maxx][maxx];
long long dp[maxx][maxx];
const int t=1e9+7;
int h,w;
int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++){
		scanf("%s",graph[i]+1);
	}
	memset(dp,0,sizeof(dp));
	int flag=0;
	for(int i=h;i>0;i--){
		if(graph[i][w]=='#'){
			flag=1;
		}
		if(flag==0){
			dp[i][w]=1;
		}
		else dp[i][w]=0;
	}
	flag=0;
	for(int i=w;i>0;i--){
		if(graph[h][i]=='#'){
			flag=1;
		}
		if(flag==0){
			dp[h][i]=1;
		}
		else dp[h][i]=0;
	}
	for(int i=h-1;i>0;i--){
		for(int j=w-1;j>0;j--){
			if(graph[i][j]=='#'){
				dp[i][j]=0;
				continue;
			}
			dp[i][j]=(dp[i+1][j]+dp[i][j+1])%t;
		}
	}
	/*for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			printf("%d ",dp[i][j]);
		}
		printf("\n");
	}*/
	printf("%lld",dp[1][1]);
}

Measured memory_bytes: 9216
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n, r, t;
int p[100];
int a[100];
int b[1000];

int main(){
  cin >> n >> r >> t;
  rep(i, n) cin >> p[i];
  int res = 0;
  rep(i, t){
    rep(j, n) (a[j] += p[j]) %= r;
    rep(j, n){
      if (b[a[j]] == 0) res++;
      else b[a[j]]--;
    }
    if (i > 0) rep(j, n) b[a[j]]++;
  }
  cout << res << endl;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
/*
    s.find_by_order(k) ---> returns iterator to the element at index(from 0) k
    s.order_of_key(val) ---> number of elements that are strictly smaller than the given value
*/
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int tc; cin >> tc; cin.ignore(); while(tc--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}

int main() {
	fast();
 
    /*NA – JEONG – MO – SA – JI – MI – DA – CHAE – TZU*/
    
    ll a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    inp(k);
    k--;
    cout << a[k] << endl;
}

Measured memory_bytes: 256
// A - Fifty-Fifty

#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <map>

using namespace std;

int main()
{
    string S;
    map<char, int> m;

    cin >> S;

    for (int i = 0; i < S.length(); i++) {
        int tmp = m[S.c_str()[i]];
        tmp++;
        m[S.c_str()[i]] = tmp;
    }
    for (auto iter = m.begin(); iter != m.end(); iter++) {
        if (iter->second == 2) {
            continue;
        }
        else {
            cout << "No";
            return 0;
        }
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void){
char s[7];
  scanf("%s",&s);
  //printf("%s\n",s);
  
  if(strcmp(s,"Sunny")==0)printf("Cloudy");
  if(strcmp(s,"Cloudy")==0)printf("Rainy");
  if(strcmp(s,"Rainy")==0)printf("Sunny");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

int main()
{
    vector<vector<int>> a(3, vector<int>(3));
    rep(i, 3)
    {
        rep(j, 3)
        {
            cin >> a.at(i).at(j);
        }
    }
    int n;
    cin >> n;
    set<int> st;
    rep(i, n)
    {
        int b;
        cin >> b;
        st.insert(b);
    }

    vector<vector<bool>> is_called(3, vector<bool>(3, false));
    rep(i, 3)
    {
        rep(j, 3)
        {
            if (st.count(a.at(i).at(j)) == 1)
            {
                is_called.at(i).at(j) = true;
            }
            // cout << is_called.at(i).at(j);
        }
        // cout << endl;
    }

    string answer = "No";
    rep(i, 3)
    {
        bool is_bingo = true;
        rep(j, 3)
        {
            if (is_called.at(i).at(j) == false)
            {
                is_bingo = false;
                break;
            }
        }
        if (is_bingo == true)
        {
            answer = "Yes";
            cout << answer << endl;
            return 0;
        }
    }

    rep(j, 3)
    {
        bool is_bingo = true;
        rep(i, 3)
        {
            if (is_called.at(i).at(j) == false)
            {
                is_bingo = false;
                break;
            }
        }
        if (is_bingo == true)
        {
            answer = "Yes";
            cout << answer << endl;
            return 0;
        }
    }

    bool is_bingo = is_called.at(0).at(0) & is_called.at(1).at(1) & is_called.at(2).at(2);
    if (is_bingo == true)
    {
        answer = "Yes";
        cout << answer << endl;
        return 0;
    }

    is_bingo = is_called.at(0).at(2) & is_called.at(1).at(1) & is_called.at(2).at(0);
    if (is_bingo == true)
    {
        answer = "Yes";
        cout << answer << endl;
        return 0;
    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main() {
  long long int n,i;
  scanf("%lld",&n);
  int s[n];
  char a;
  for(i=0;i<n;i++) {
    scanf("%c",&a);
    if(a=='Y') {
      s[i]=1;
    } else {
      s[i]=0;
    }
  }
  int counter = 0;
  for(i=0;i<n;i++) {
    if(s[i]==1) {
      counter = 1;
      goto LABEL;
    }
  }
  LABEL:
  if (counter == 0) {
    printf("Three\n");
  } else {
    printf("Four\n");
  }
  return 0;
}


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

using namespace std;

int main () {
  ios::sync_with_stdio(false);

  string s;
  cin >> s;

  deque<char> arr;
  for (char c : s) {
    arr.push_back(c);
  }

  int rev = 0;
  int qc;
  cin >> qc;

  for (int i = 0; i < qc; i++) {
    int t;
    cin >> t;

    if (t == 1) {
      rev = !rev;
    } else {
      int f;
      cin >> f;

      char c;
      cin >> c;

      if ((f == 1) ^ (rev)) {
        arr.push_front(c);
      } else {
        arr.push_back(c);
      }
    }
  }

  if (rev) {
    reverse(arr.begin(), arr.end());
  }

  for (char c : arr) {
    cout << c;
  }
  cout << endl;
}


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

ll INF=1e18+1;

int main(void){
    int a, b, q;
    cin>>a>>b>>q;
    vector<ll> s(a+2);
    vector<ll> t(b+2);
    vector<ll> x(q);
    rep(i, a) cin>>s[i+1]; 
    rep(i, b) cin>>t[i+1];
    rep(i, q) cin>>x[i];
    s[0]=-INF;
    s[a+1]=INF;
    t[0]=-INF;
    t[b+1]=INF;
    rep(i, q){
        ll start=x[i];
        ll s1, s2, t1, t2;
        /*二分探索してstartの西と東を求める*/

        int lefts=0;
        int rights=a+1;
        while(rights-lefts>1){
            if(s[(lefts+rights)/2]>start) rights=(lefts+rights)/2;
            else lefts=(lefts+rights)/2;
        }
        int s1_idx=lefts;
        int s2_idx=rights;

        int leftt=0;
        int rightt=b+1;
        while(rightt-leftt>1){
            if(t[(leftt+rightt)/2]>start) rightt=(leftt+rightt)/2;
            else leftt=(leftt+rightt)/2;
        }
        int t1_idx=leftt;
        int t2_idx=rightt;
        vector<ll> kouho(4);
        s1=s[s1_idx];
        s2=s[s2_idx];
        t1=t[t1_idx];
        t2=t[t2_idx];
        //cout<<s1<<", "<<s2<<", "<<t1<<", "<<t2<<endl;
        kouho[0]=max(start-t1, start-s1);
        kouho[1]=min(-2*s1+t2+start, 2*t2-s1-start);
        kouho[2]=max(s2-start, t2-start);
        kouho[3]=min(2*s2-t1-start, s2-2*t1+start);
        ll ans=INF;
        rep(j, 4){
            //cout<<"kouho : "<<kouho[j]<<endl;
            ans=min(kouho[j], ans);
        }

        cout<<ans<<endl;
    }

    return 0;

}

Measured memory_bytes: 3712
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;

int N, M;

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    vector<vector<int> > war;
    vector<int> v(2,0);
    vector<int> bridge;
    int a,b;
    REP(i,M){
        cin >> a >> b;
        v[0] = a;
        v[1] = b;
        war.push_back(v);
    }
    // REP(j,war.size()-1){
    //     REP(i,war.size()-1){
    //         if(war[i][1]> war[i+1][1]){
    //             v[0] = war[i][0];
    //             v[1] = war[i][1];
    //             war[i][0] = war[i+1][0];
    //             war[i][1] = war[i+1][1];
    //             war[i+1][0] = v[0];
    //             war[i+1][1] = v[1];
    //         }
    //     }
    // }
    sort(war.begin(),war.end());
    // REP(i,war.size()) cout << war[i][0] << "  " << war[i][1] << endl;
    int temp_bri  = war[M-1][0];
    int count = 1;
    for(int i = M-1;i>=0;--i){
        if(war[i][1] <= temp_bri){
            temp_bri = war[i][0];
            count++;
        }

    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 6964
#include<bits/stdc++.h>
#define int long long
using namespace std ;
int read() {
  int x = 0 , f = 1 ;
  char c = getchar() ;
  while(c < 48 || c > 57) {
    if(c == '-') f = -1 ;
    c = getchar() ;
  }
  while(c > 47 && c < 58) {
    x = (x << 1) + (x << 3) + (c & 15) ;
    c = getchar() ;
  }
  return x * f ;
}
void print(int x) {
  if(x < 0) x = -x , putchar('-') ;
  if(! x) { putchar('0') ; }
  static char st[30] ; int stp = 0 ;
  while(x) { st[++ stp] = x % 10 ^ 48 ; x /= 10 ;}
  while(stp) { putchar(st[stp --]) ; }
  putchar('\n') ;
}
int n , m ;
const int N = 100 ;
int a[N][N] , b[N][N] , c[N][N] ;
bool dp[81][81][12801] ;
signed main() {
  n = read() ; m = read() ;
  for(int i = 1 ; i <= n ; i ++) {
    for(int j = 1 ; j <= m ; j ++) {
      a[i][j] = read() ;
    }
  }
  for(int i = 1 ; i <= n ; i ++) {
    for(int j = 1 ; j <= m ; j ++) {
      b[i][j] = read() ;
    }
  }
  for(int i = 1 ; i <= n ; i ++)
    for(int j = 1 ; j <= m ; j ++) c[i][j] = abs(a[i][j] - b[i][j]) ;
  dp[1][1][c[1][1] + 6400] = 1 ;
  dp[1][1][-c[1][1] + 6400] = 1 ;
  for(int i = 1 ; i <= n ; i ++) {
    for(int j = 1 ; j <= m ; j ++){
      if(i == 1 && j == 1) continue ;
      for(int k = 0 ; k <= 12800 ; k ++) {
        if(dp[i - 1][j][k]){
          if(k - c[i][j] > 0) dp[i][j][k - c[i][j]] = 1 ;
          if(k + c[i][j] < 12800) dp[i][j][k + c[i][j]] = 1 ;
        }
        if(dp[i][j - 1][k]){
          if(k - c[i][j] > 0) dp[i][j][k - c[i][j]] = 1 ;
          if(k + c[i][j] < 12800) dp[i][j][k + c[i][j]] = 1 ;
        }
      }
    }
  }
  for(int i = 6400 ; i <= 12800 ; i ++)
    if(dp[n][m][i]) { print(i - 6400) ; return 0 ; }
  return 0 ;
}

Measured memory_bytes: 81152
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<LP> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-8;

struct SegT {
private:
	int sz; vector<int> node;
	const int init_c = 0;
public:
	SegT(int n) {
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, init_c);
	}
	int f(int a, int b) {
		return max(a, b);
	}
	void update(int k, int a) {
		k += sz - 1;
		node[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = f(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	int query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = sz;
		if (r <= a || b <= l)return init_c;
		else if (a <= l && r <= b)return node[k];
		else {
			int vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			int vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return f(vl, vr);
		}
	}
};

void solve() {
	int n; cin >> n;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	{
		vector<int> v;
		rep(i, n)v.push_back(a[i]);
		sort(v.begin(), v.end());
		v.erase(unique(v.begin(), v.end()), v.end());
		map<int, int> mp;
		rep(i, v.size()) {
			mp[v[i]] = i;
		}
		rep(i, n)a[i] = mp[a[i]];
	}
	int ma = 0;
	SegT st(n);
	rep(i, n) {
		int z = st.query(a[i], n);
		st.update(a[i], z + 1);
	}
	cout << st.query(0,n) << endl;
}

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

	//cout << fixed << setprecision(10);
	//init();
	solve();
	//stop
		return 0;
}



Measured memory_bytes: 5624
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class tenka1_2018_d {
public:
    void solve(istream &in, ostream &out) {
        int N;
        in >> N;
        for (int m = 1; m * (m + 1) / 2 <= N; ++m) {
            if (m * (m + 1) / 2 == N) {
                out << "Yes\n" << m + 1 << "\n";
                vector<set<int>> res(m + 1);
                out << m << " ";
                for (int i = 1; i <= m; ++i) {
                    res[0].insert(i);
                    out << i << " ";
                }
                out << "\n";
                int upto = m;
                for (int i = 1; i < m + 1; ++i) {
                    for (int j = 0; j < i; ++j) {
                        res[i].insert(*res[j].begin());
                        res[j].erase(res[j].begin());
                    }
                    while ((int)res[i].size() < m) {
                        res[i].insert(++upto);
                    }
                    out << m << " ";
                    for (int x : res[i]) {
                        out << x << " ";
                    }
                    out << "\n";
                    for (int j = 0; j < i; ++j) {
                        res[i].erase(res[i].begin());
                    }
                }
                return;
            }
        }
        out << "No\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	tenka1_2018_d solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3840
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long M, long D) {
    int ans;
    foreach (m; 1 .. M + 1) foreach (d; 1 .. D + 1) {
        auto d1 = d % 10;
        auto d10 = d / 10;
        if (d1 >= 2 && d10 >= 2 && d1 * d10 == m)
            ans++;
    }
    return ans;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long M;
    M = input.front.to!long;
    input.popFront;

    long D;
    D = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(M, D);
    else
        solve(M, D).writeln;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;
const int T = 1e4 + 3;
const int N = 1e3 + 2;
const int OK = 1e6 + 10;

bitset<N> crivo;
int maxDiv[OK];
vector<int> primes;
ll v[T];

void init() {
    for(int i = 2; i < N; i++) {
        if(!crivo[i]) {
            primes.pb(i);
            for(int j = i+i; j < N; j += i) crivo[j] = 1;
        }
    }
}

ll expo(ll base, ll e) {
    ll ans = 1;
    while(e) {
        if(e&1) ans = (ans * base) % MOD;
        base = (base * base) % MOD;
        e >>= 1;
    }
    return ans;
}

void decop(int x) {
    for(int i = 0; i < primes.size() and primes[i]*primes[i] <= x; i++) {
        int d = 0;
        while(x % primes[i] == 0) d++, x /= primes[i];
        maxDiv[primes[i]] = max(maxDiv[primes[i]], d);
    }
    if(x > 1) maxDiv[x] = max(maxDiv[x],1);
}

int main() {
    ios_base::sync_with_stdio(false);
    init();
    int n; cin >> n;
    ll tira = 0;

    for(int i = 0; i < n; i++) {
        cin >> v[i];
        decop(v[i]);
    }

    ll acum = 1;
    for(ll i = 0; i < OK; i++) {
        ll ok = 1;
        while(maxDiv[i]) ok = (ok * i) % MOD, maxDiv[i]--;
        if(ok > 1) acum = (acum * ok)%MOD;
    }

    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ll ok = (acum*expo(v[i],MOD-2))%MOD;
        ans = (ans + ok) % MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2944
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		double x1,y1,x2,y2;
		double num;
		//????????\???
		x1 = Double.parseDouble(scan.next());
		y1 = Double.parseDouble(scan.next());
		x2 = Double.parseDouble(scan.next());
		y2 = Double.parseDouble(scan.next());
		
		//?¨??????? ???(x2-x1)????????????(y2-y1)?????????
		num = Math.sqrt(Math.pow((x2-x1), 2) + Math.pow((y2-y1), 2));
		
		BigDecimal bd = new BigDecimal(num);
		 BigDecimal bd1 = bd.setScale(8, BigDecimal.ROUND_HALF_UP);
			System.out.println(bd1.doubleValue());
		
	}
}

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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int x, y; scan(x, y);
      Int t = x;
      Int res = 0;
      while( t <= y ) {
         res += 1;
         t *= 2;
      }
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 764
from heapq import*
f=lambda*z:map(int,raw_input().split())
X,Y,Z=f()
N=X+Y+Z
P=[]
Q=[]
L=[0]
R=[0]
A=sorted(map(f,[0]*N),key=lambda a:a[0]-a[1])
for i in range(N):L+=[L[i]+A[i][1]];heappush(P,A[i][1]-A[i][2]);R+=[R[i]+A[~i][0]];heappush(Q,A[~i][0]-A[~i][2]);L[-1]-=i>=Y and heappop(P);R[-1]-=i>=X and heappop(Q)
print max(L[i]+R[~i]for i in range(Y,Y+Z+1))

Measured memory_bytes: 35172
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    s = S()

    for i in range(len(s)):
        if s[i] == '7':
            print('Yes')
            return

    print('No')


if __name__ == '__main__':
    main()


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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    int N;
    std::cin >> N;
    std::vector<int> A(N);
    REP(i, N) {
        std::cin >> A[i];
    }
    std::vector<int> B(N);
    REP(i, N) {
        std::cin >> B[i];
    }
    std::vector<int> C(N);
    REP(i, N) {
        std::cin >> C[i];
    }
    SORT(A);
    SORT(B);
    SORT(C);

    ll ans = 0;
    REP(i, N) {
        auto a_itr = lower_bound(ALL(A), B[i]);
        auto c_itr = upper_bound(ALL(C), B[i]);
        if(a_itr == A.begin() || c_itr == C.end()) continue;
        ans += distance(A.begin(), a_itr) * distance(c_itr, C.end());
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int atCoderCracker = sc.nextInt();
		int atCoderParticipants = sc.nextInt();
		
		Person takahashi = new Person();
		takahashi.shoutInjusticeToTheWorld(atCoderCracker, atCoderParticipants);
	}
}

class Person {
	public void shoutInjusticeToTheWorld(int atCoderCracker, int atCoderParticipants) {
		int volumeOfInjustice = atCoderCracker % atCoderParticipants == 0 ? 0 : 1;
		System.out.println(volumeOfInjustice);
	}
}

Measured memory_bytes: 21972
import java.util.*;

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

    int n = sc.nextInt();
    int[] d1 = new int[n];
    int[] d2 = new int[n];

    for (int i = 0; i < n; i++) {
      d1[i] = sc.nextInt();
      d2[i] = d1[i];
    }

    Arrays.sort(d2);
    int x = d2[n / 2 - 1];
    int y = d2[n / 2];

    System.out.println(d2[n / 2] - d2[n / 2 - 1]);
  }
}


Measured memory_bytes: 61432
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
  string s,t;
  cin >> s;
  cin >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline

N, K, *A = map(int, read().split())
A = [i - 1 for i in A]

check = [False] * N
seq = []
here = 0
while True:
    if K == 0:
        print(here + 1)
        exit()
    if check[here]:
        break
    seq.append(here)
    check[here] = True
    here = A[here]
    K -= 1

seq = seq[seq.index(here):]
circ = len(seq)
K %= circ
print(seq[K] + 1)


Measured memory_bytes: 32516
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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 T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;
vector<int> A;
vector<bool> res;

void input() {
  cin >>N;
  A.assign(N, 0); rep(i, N) cin >>A[i];
  res.assign(N, false);
}

int main() {
  input();
  for (int i=N; i>0; i--){
    // 1-indexedに注意
    // iの倍数が書かれた箱に入っているボールの和がA[i-1]となるように、後ろから番号を決定していく
    if (i*2 > N){
      // iの倍数が自分自身しかいないなら、条件をそのまま自分に反映させる
      res[i-1] = A[i-1];
    }else{
      // iの倍数が自分以外にいるなら、自分以外のiの倍数の箱のボールの個数の和を計算する
      // 計算結果を2で割った余りがA[i-1]に一致するなら自分自身は0、一致しなければ自分自身は1とすればよい
      int sum = 0;
      for (int j=2*i; j<=N; j+=i) if (res[j-1]) sum++;
      sum %= 2;
      if (sum != A[i-1]) res[i-1] = true;
    }
  }
  int M = 0;
  rep(i, N) if (res[i]) M++;
  cout <<M <<endl;

  if (M > 0){
    rep(i, N) if (res[i]) cout <<i+1 <<" ";
    cout <<endl;
  }
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


const ll mx = 1e5+9;
ll dp[mx][2];
int main(){
	
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;cin>>n;
    vector< pair<pair<string,ll>,ll> > ps(n);
    REP(i,n){
        string s; ll num;cin>>s>>num;
        ps[i] = {{s,-num},i+1};
    }
    
    sort(ALL(ps));
    REP(i,n) cout<<ps[i].second<<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 REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
int main() {
    int n, m, x, t;
    cin >> n >> m >> x;
    set<int> st;
    REP(i, m) {
        cin >> t;
        st.insert(t);
    }
    auto it = lower_bound(ALL(st), x);
    int dist = distance(st.begin(), it);
    cout << min(dist, m - dist) << endl;

    return 0;
}

Measured memory_bytes: 256
import itertools

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

N_list = []
for i in range(N):
    N_list.append(i+1)

database = list(itertools.permutations(N_list))

print(abs(database.index(P)-database.index(Q)))

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

int dp[105][4][2];

int main() {
    string s;
    cin >> s;
    int n = s.size();
    int K;
    cin >> K;

    dp[0][0][0] = 1;
    for(int i=0; i<n; i++) {
        for(int j=0; j<4; j++) {
            for(int k=0; k<2; k++) {
                int nd = s[i] - '0';
                for(int d=0; d<10; d++) {
                    int ni = i+1, nj = j, nk = k;
                    if (d != 0) nj++;
                    if (nj > K) continue;
                    if (k == 0) {
                        if (d > nd) continue;
                        if (d < nd) nk = 1;
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }

    int ans = dp[n][K][0] + dp[n][K][1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll N;
  cin >> N;
  FOR(h,1,3501){
    FOR(n,1,3501){
      if(4*h*n-h*N-N*n>0&&(N*h*n)%(4*h*n-h*N-N*n)==0){
        ll w=(N*h*n)/(4*n*h-h*N-n*N);
        cout << h << " " << n << " " << w;
        return 0;
      }
    }
  }
}

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

int main()
{
	int n, l;
	cin >> n >> l;
	
	int left = l, right = l + n - 1, eat = 0;;
	
	if (right <= 0)
	{
		eat = right;
	}
	else if (left >= 0)
	{
		eat = left;
	}
	else
	{
		eat = 0;
	}
	
	cout << ((right + left) * (right - left + 1)) / 2 - eat << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int flag;
char s[20], t[20];
int main(){
	cin>> s>> t;
	for(int i=0; i<strlen(s); i++){
		if(s[i]!=t[i]){
			flag=1;
			break;
		}
	}
	if(flag) cout<< "No";
	else cout<< "Yes";
	return 0;
}

Measured memory_bytes: 3632
n,m=list(map(int,input().split()))
x=0
if n<2 and m<2:
    x=0
elif n<2 :
    x=int(m*(m-1)/2)
elif m<2:
    x=int(n*(n-1)/2)
else:
    x=int(m*(m-1)/2+n*(n-1)/2)
print(x)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		sc.close();

		if (s * t >= d) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 35652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

template< typename T >
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< Edges< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

template< typename T >
void warshall_floyd(Matrix< T > &g, T INF) {
  for(int k = 0; k < g.size(); k++) {
    for(int i = 0; i < g.size(); i++) {
      for(int j = 0; j < g.size(); j++) {
        if(g[i][k] == INF || g[k][j] == INF) continue;
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);

    int N,M; LL L;
    cin >> N >> M >> L;
    Matrix<LL> mat(N,vector<LL>(N,LINF)),mat2(N,vector<LL>(N,LINF));

    REP(i,M){
        LL A,B,C;
        cin >> A >> B >> C;
        A--; B--;
        mat[A][B] = C;
        mat[B][A] = C;
    }
    warshall_floyd(mat, LINF);
    REP(i,N) REP(j,N){
        if(mat[i][j] <= L){
            mat2[i][j] = 1;
        }
    }
    warshall_floyd(mat2,LINF);
    int Q; cin >> Q;
    REP(i,Q){
        LL S,T; cin >> S >> T;
        S--; T--;
        if(mat2[S][T] == LINF){
            cout << -1 << endl;
        }else{
            cout << mat2[S][T] - 1 << endl;
        }
    }


}


Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;

int main() {
	int a, b, t; cin >> a >> b >> t;
	cout << t/a * b << endl;
	return 0;
}

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


int main () {
    ll h;
    cin>>h;
    vector<ll> pw;
    for(ll i=1;i<=1e18;i*=2)
        pw.push_back(i);
    ll pos = upper_bound(pw.begin(),pw.end(),h)-pw.begin();
    ll ans=1;
    //cout<<pos;
    cout<<(ll)pow(2,pos)-1;
}

Measured memory_bytes: 256