akhauriyash/Code-Regression huggingface dataset:
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>


#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#ifdef LOCAL
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)
#else
#define show(...)
#define showlr(n,l,r)
#endif

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;
/*------------end of definitions------------*/

vector<string> V(3);

signed main(){

    in(V);
    vi index(3);
    auto cur=make_pair(0,0);
    while(true){
        if(index[cur.fs]==V[cur.fs].size()){
            out((char)(cur.fs+'A'));
            return 0;
        }
        show(cur.fs,cur.sc,V[cur.fs][cur.sc]);
        auto tmp=cur.fs;
        if(V[cur.fs][cur.sc]=='a'){
            cur.fs=0;
        }else if(V[cur.fs][cur.sc]=='b'){
            cur.fs=1;
        }else{
            cur.fs=2;
        }
        index[tmp]++;
        cur.sc=index[cur.fs];
    }

    return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

using namespace std;
int main(void)
{
  int n;
  cin >> n;
  REP(_,n){
    int h,w;
    cin >> h >> w;
    if(!h) return 0;
    vector<string> sc;
    sc.resize(h);
    REP(i,h) cin >> sc[i];
    set<char> car;
    car.clear();
    REP(i,h) REP(j,w) if(sc[i][j]!='.') car.insert(sc[i][j]);
    vector<char> carv(car.begin(),car.end());
    string answer="SUSPICIOUS";
    map<char,int> u,d,l,r;
    REP(dep,carv.size()){
      u[carv[dep]]=100;
      d[carv[dep]]=-1;
      l[carv[dep]]=100;
      r[carv[dep]]=-1;
    }
    REP(dep,carv.size()) REP(i,h) REP(j,w) if(sc[i][j]==carv[dep]){
      u[carv[dep]]=min(u[carv[dep]],i);
      d[carv[dep]]=max(d[carv[dep]],i);
      l[carv[dep]]=min(l[carv[dep]],j);
      r[carv[dep]]=max(r[carv[dep]],j);
    }
    do{
      vector<string> prob;
      prob.resize(h);
      REP(i,h) prob[i].assign(w,'.');
      REP(dep,carv.size()){
	FOR(i,u[carv[dep]],d[carv[dep]]+1) FOR(j,l[carv[dep]],r[carv[dep]]+1){
	  prob[i][j]=carv[dep];
	}
      }
      bool flag=true;
      REP(i,h) if(sc[i]!=prob[i]) flag=false;
      if(flag){
	answer="SAFE";
	break;
      }
    }while(next_permutation(carv.begin(),carv.end()));
    cout << answer << endl;
  }
}

Measured memory_bytes: 3032
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  short int N,sum=1;
  cin >> N;
  vector<short int> d(N);
  short int i;
  for(i=0;i<N;++i)
    cin >> d.at(i);
  sort(d.begin(), d.end(), greater<int>());
  for(i=0;i<(N-1);++i){
    if(d.at(i)>d.at(i+1))
      ++sum;
  }
  cout << sum << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 2e5 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;cin>>n;
	set<string>q;
	for(int i=1;i<=n;i++){
		string s;cin>>s;
		q.insert(s);
	}
	cout<<q.size();
	return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> vec(n + 1);
  vec[0] = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> vec[i];
    vec[i] += vec[i-1];
  }
  
  vector<int> subt(n - k + 1);
  for (int i = 0; i < n - k + 1; i++) {
    subt[i] = vec[i+k] - vec[i];
  }
  double ans = 0;
  for (int i = 0; i < n - k + 1; i++) {
    double ave = (subt[i] + k) / 2.0;
    if (ans < ave) {
      ans = ave;
    }
  }
  printf("%lf", ans);
}


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

#define ll long long

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

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

    ll a,b,c;
    cin >> a >> b >> c;

    ll x = b/a;

    ll ans = min(x,c);

    cout << ans << endl;
}


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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int x3, y3, x4, y4;
    x3 = y1+x2-y2;
    y3 = -x1+x2+y2;
    x4 = x1+y1-y2;
    y4 = -x1+y1+x2;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}


Measured memory_bytes: 256
I = lambda : list(map(int,input().split()))
ans=1
n,=I()
l=I()
if 0 in l:
	print(0)
else:
	ans=1
	f=1
	for i in l:
		ans=ans*i
		if ans>10**18:
			f=0
			break
	print(ans if f else -1)

Measured memory_bytes: 84868
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<=n;++i)
int mapa[100][100];
int mapb[100][100];
int map[100][100];
bool dp[100][100][6500];

int main(){
  int h,w;cin>>h>>w;
  rep1(i,h){
    rep1(j,w)cin>>mapa[i][j];
  }
  rep1(i,h){
    rep1(j,w){
      cin>>mapb[i][j];
      map[i][j]=mapb[i][j]-mapa[i][j];
      if(map[i][j]<0)map[i][j]*=(-1);
    }
  }
  rep(i,100){
    rep(j,100){
      rep(k,6400){
        dp[i][j][k]=false;
      }
    }
  }
  dp[1][1][map[1][1]]=true;
  rep1(i,h){
    rep1(j,w){
      rep(k,6401){
        //if(i==1&&j==1)break;
        /*
        if(i==1){
          if(k-map[i][j]<0){
            if(dp[i][j-1][k+map[i][j]])dp[i][j][k]=true;
          }
          else if(dp[i][j-1][k-map[i][j]]||dp[i][j-1][k+map[i][j]])dp[i][j][k]=true;
        }
        else if(j==1){
          if(k-map[i][j]<0){
            if(dp[i-1][j][k+map[i][j]])dp[i][j][k]=true;
          }
          else if(dp[i-1][j][k-map[i][j]]||dp[i-1][j][k+map[i][j]])dp[i][j][k]=true;
        }*/
        //else {
          if(k-map[i][j]<0){
            if(dp[i][j-1][map[i][j]-k]||dp[i][j-1][k+map[i][j]])dp[i][j][k]=true;
            if(dp[i-1][j][map[i][j]-k]||dp[i-1][j][k+map[i][j]])dp[i][j][k]=true;
          }
          else {
            if(dp[i][j-1][k-map[i][j]]||dp[i][j-1][k+map[i][j]])dp[i][j][k]=true;
            if(dp[i-1][j][k-map[i][j]]||dp[i-1][j][k+map[i][j]])dp[i][j][k]=true;
          }
        //}
      }
    }
  }
  int ans=10000000;
  rep(i,6401){
    if(dp[h][w][i]){
      //cout<<i<<" "<<dp[h][w][i]<<endl;
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
  return 0;
  }

Measured memory_bytes: 63872
#include <iostream>
std::string s;

long long unsigned solve(long long i){
    if(i >= s.size()) return 0;
    return std::max(s[i]-'0'+solve(i+1), (long long)s[i]-'1'+9*(s.size()-i-1));
}

int main() {
    int sum = 0;
    std::cin >> s;
    std::cout << solve(0);
}

Measured memory_bytes: 256
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define inf 1000000000

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

void solve(){

	string s;
	cin >> s;

	int n = s.size();

	int ans = 0;
			int m = n/2;
			for(int i = 0;i<m;i++){
				if(s[i]!=s[n-1-i])ans++;
			}
		
		cout << ans << endl;
	
}
	
	

signed main() 
{   
	IOS;
    int t = 1;
    //cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


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

void fnInput(int& rnAmount)
{
  cin >> rnAmount;
}

int fnAmtCheck(int nAmount)
{
  const int cnnCake = 4;
  const int cnnDonut = 7;

  int nCake = 0;
  while (true)
  {
    int nAmtCake = cnnCake * nCake;
    if (nAmtCake > nAmount)  return 0;

    int nRestAmt = nAmount - nAmtCake;
    if (nRestAmt % cnnDonut == 0) return 1;
    nCake++;
  }
}

int main()
{
  int nAmount;

  fnInput(nAmount);
  if (fnAmtCheck(nAmount)) cout << "Yes" << endl;
  else                       cout << "No"  << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
const ll mod=1e9+7;
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}
void solve(){
  ll n;
  cin>>n;
  if(n==1){
    cout<<0<<endl;
    return;
  }
  ll ans=power(10,n);
  // cout<<ans<<endl;
  ans=((ans-2*power(9,n))%mod+mod)%mod;
  ans=(ans+power(8,n))%mod;
  cout<<(ans+mod)%mod<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3652
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define mod 100000
int wh[101][101][4];
int main(){
	int w,h;
	while(cin>>w>>h&&w!=0&&h!=0){
		for(int i=0; i<h; ++i){
			wh[i][0][0]=1;
		}
		for(int i=0; i<w; ++i){
			wh[0][i][2]=1;
		}
		for(int i=1; i<h; ++i){
			for(int j=1; j<w;++j){
				wh[i][j][0]=(wh[i-1][j][0]+wh[i-1][j][1])%mod;
				wh[i][j][1]=wh[i-1][j][2]%mod;
				wh[i][j][2]=(wh[i][j-1][2]+wh[i][j-1][3])%mod;
				wh[i][j][3]=wh[i][j-1][0]%mod;
			}
		}
		cout << (wh[h-1][w-1][0]+wh[h-1][w-1][1]+wh[h-1][w-1][2]+wh[h-1][w-1][3])%mod << "\n";
	}
	return 0;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
#define ll long long int
#define fl(i,x,y) for( int i=x;i<y;i++)
#define w(t) while(t--)
#define vi vector<ll>
#define vvi vector< vi >
#define si set<ll>
#define msi multiset<ll>
#define si_d set<ll, greater<ll> >
#define mii map<ll,ll>
#define pb push_back
#define msi_it  multiset<ll> :: iterator
#define si_it set<ll> :: iterator
#define sort1(v) sort(v.begin(),v.end());
#define F first
#define S second
using namespace std;
#define N 1000000007
#define mod 15000000000031
int main()
{
	int l;cin>>l;
	float k=(float)l/3;
	float ans=k*k*k;
    cout<<fixed<<setprecision(6)<<ans;
}

Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

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

		int n = Integer.parseInt(sc.nextLine());

		int answer = Stream.of(sc.nextLine().split(" ", n))
				.map(s -> Integer.parseInt(s))
				.map(i -> getTimesDivBy2(i))
				.min(Comparator.naturalOrder())
				.get();

		System.out.println(answer);


	}

	private static int getTimesDivBy2(int num) {
		int divCount = 0;
		while (num % 2 == 0 ) {
			divCount++;
			num /= 2;
		}
		return divCount;
	}

}

Measured memory_bytes: 28492
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>

using namespace std;
//--------------------

int main() {
	long res[5][5]; 
	long A, B, C; cin >> A >> B >> C;
	long sum = 3 * C;

	res[1][1] = A;
	res[1][2] = B;
	res[1][3] = sum - A - B;
	res[3][1] = sum - res[1][3] - C;
	res[3][2] = sum - B - C;
	res[3][3] = sum - C - A;
	res[2][1] = sum - res[1][1] - res[3][1];
	res[2][2] = C;
	res[2][3] = sum - res[1][3] - res[3][3];

	for (int i = 1; i <= 3; i++) {for (int j = 1; j <= 3; j++) cout << res[i][j] << " "; cout << endl;}
}

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

int main() {
    int n, m, a, b, c, d, temp, minimum, index;
    cin >> n >> m;
    vector<pair<int, int>> student(n), place(m);
    rep(i, n) cin >> student.at(i).first >> student.at(i).second;
    rep(i, m) cin >> place.at(i).first >> place.at(i).second;
    rep(i, n) {
        minimum = INT_MAX;
        rep(j, m) if(minimum > (temp = abs(student.at(i).first - place.at(j).first) + abs(student.at(i).second - place.at(j).second))) {
            minimum = temp;
            index = j + 1;
        }
        cout << index << endl;
    } 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;

struct state{
    ll x,now,val,cnt;
    bool operator<(const state& r)const{
        return val < r.val;
    }
    void update(){
        if(now==0) return ;
        now = (x/(1<<(cnt+1)));
        cnt++;
        val = now;
    }
};

int main(){
    int N,M;
    cin >> N >> M;
    priority_queue<state> Q;
    for(int i=0;i<N;i++){
        ll a;
        cin >> a;
        Q.push((state){a,a,a,0});
    }
    for(int i=0;i<M;i++){
        state s = Q.top();
        Q.pop();
        s.update();
        Q.push(s);
    }
    ll ans = 0;
    while(!Q.empty()){
        ans += Q.top().now;
        Q.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 6384
#include<bits/stdc++.h>
using namespace std;
const int mxN = 1e2+5;
const int mxM = 1e5+5;
long long dp[mxN][mxM];
long long n,w,wei[mxN],val[mxN];
int main(){
	cin >> n >> w;
	for(int i = 1; i<=n; i++){
		cin >> wei[i] >> val[i];
	}
	for(int i = 0; i<=n; i++){
		for(int j = 0;j<=w; j++){
			dp[i][j] = 0;
		}
	}
	for(int i = 1; i<=n; i++){
		for(int j = 1;j<=w; j++){
			if(j-wei[i]>=0&&i-1>=0) dp[i][j] = max(dp[i-1][j],dp[i-1][j-wei[i]]+val[i]);
			else dp[i][j] = dp[i-1][j];
		}
	}
	long long ans = 0;
//	for(int i =1; i<=n; i++){
//		for(int j = 1; j<=w; j++){
//			cout << dp[i][j] << " ";
//		}
//		cout << endl;
//	}
	for(int i = 0; i<=n; i++){
		ans = max(ans,dp[i][w]);
	}
	cout << ans << endl;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl

const ll MOD = 1000000007;
const ll MN = 20000010;

ll powmod(ll x, ll k) {
    ll res = 1;
    for (; k > 0; k /= 2, x = x * x % MOD) {
        if (k & 1) {
            res = res * x % MOD;
        }
    }
    return res;
}


int main() {
    int H, W, K;
	cin >> H >> W >> K;

    ll ihw = powmod(H + W, MOD - 2);
    ll ihwd = powmod(H + W - 1, MOD - 2);

    //i != 0, j != 0
    ll sum2 = 0;
    for (int i = 1; i <= K; ++i) {
        ll c = (i - 1) * ihwd % MOD * ihw % MOD * (K + 1 - i) % MOD;
        sum2 = (sum2 + c) % MOD;
    }
    sum2 = sum2 * 2 * H % MOD * W % MOD;

    //i = 0 xor j = 0
    ll sum1 = 0;
    for (int i = 1; i <= K; ++i) {
        ll c = (K + 1 - i) * ihw % MOD;
        sum1 = (sum1 + c) % MOD;
    }
    sum1 = sum1 * (H + W) % MOD;

    ll fac = 1;
    ll ifac = 1;

    for (int i = 1; i <= H + W; ++i) {
        fac = fac * i % MOD;
        if (i == H + W - K) {
            ifac = powmod(fac, MOD - 2);
        }
    }

    //i = j = 0
    ll sum0 = K;
 
    ll ans = (sum2 + sum1 + sum0) % MOD * fac % MOD * ifac % MOD;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define   ll          long long int
#define   sz          200010
#define   sc(a)       scanf("%lld",&a)
#define   sc2(a,b)    scanf("%lld %lld",&a,&b)
#define   py          printf("Yes\n")
#define   pn          printf("No\n")
using namespace std;

int main()
{

    string s;
    cin>>s;

    if(s=="Sunny")cout<<"Cloudy"<<endl;
    else if(s=="Cloudy")cout<<"Rainy"<<endl;
    else if(s=="Rainy")cout<<"Sunny"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main()
{
    string s;
    cin>>s;
    rep(i,s.length())
    {
        if(s[i]=='1')s[i]='9';
        else if(s[i]=='9')s[i]='1';
    }
    cout<<s<<endl;

}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int a, b;
  cin >> a >> b;
  for (double i = 0; i < 1000000; i++) {
    if (int(i * 0.08) == a && int(i * 0.10) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static int n;
    public static int a[];
    public static int q;
    public static int m[];
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
        }
        q = sc.nextInt();
        m = new int[q];
        for(int i=0;i<q;i++){
            m[i] = sc.nextInt();
        }
        for(int k: m){
            if(dfs(0, 0, k)){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }
        }        
        sc.close();

    }
    public static boolean dfs (int i, int sum, int k){
        if(i == n){
            return sum == k;
        }
        if(dfs(i+1,sum,k)){
            return true;
        }
        if(dfs(i+1,sum + a[i], k)){
            return true;
        }
        return false;
    }
}


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

int main(void){
    while(1){
        int x,y;
        scanf("%d %d", &x,&y);
        if(x==0&&y==0) break;
        if(x<y) printf("%d %d\n", x,y);
        else printf("%d %d\n", y, x);
        if(x==0&&y==0) break;
    }
    return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <math.h>

using namespace std;

static const int COUNTER_CLOCKWISE = 1;
static const int CLOCKWISE = -1;
static const int ONLINE_BACK = 2;
static const int ONLINE_FRONT = -2;
static const int ON_SEGMENT = 0;


#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

class Point{
public:
	double x, y;
	Point(double _x = 0, double _y = 0) :x(_x), y(_y){};

	Point operator+(const Point &p){ return Point(x + p.x, y + p.y); }
	Point operator-(const Point &p){ return Point(x - p.x, y - p.y); }
	Point operator*(const Point &p){ return Point(x * p.x, y * p.y); }
	Point operator*(double k){ return Point(x * k, y * k); }
	Point operator/(const Point &p){ return Point(x / p.x, y / p.y); }

	double norm() { return x*x + y*y; }
	double abs() { return sqrt(norm()); }

	bool operator<(const Point &p) const{
		return (x != p.x) ? (x < p.x) : (y < p.y);
	}

	bool operator==(const Point &p){
		return equals(x, p.x) && equals(y, p.y);
	}
};

typedef Point Vector;
struct Segment{
	Point p1, p2;
};

double dot(Vector a, Vector b){
	double res = a.x*b.x + a.y*b.y;
	return res;
}

double cross(Vector a, Vector b){
	double res = a.x*b.y - a.y*b.x;
	return res;
}

bool isOrthogonal(Vector a, Vector b){
	return equals(dot(a, b), 0.0);
}

bool isParallel(Vector a, Vector b){
	return equals(cross(a, b), 0.0);
}

Point project(Segment s, Point p){
	Vector base = s.p2 - s.p1;
	Vector v = p - s.p1;
	double l = dot(v, base) / base.norm();
	return s.p1 + base * l;
}

int ccw(Point p0, Point p1, Point p2){
	Vector a = p1 - p0;
	Vector b = p2 - p0;

	if (cross(a, b) < -EPS) return CLOCKWISE;
	if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
	if (dot(a, b) < -EPS) return ONLINE_BACK;
	if (a.norm() < b.norm()) return ONLINE_FRONT;
	return ON_SEGMENT;
}


int main(){
	Point p0, p1, p2;
	cin >> p0.x >> p0.y >> p1.x >> p1.y;
	int n; cin >> n;
	for (int i = 0; i < n; ++i){
		cin >> p2.x >> p2.y;
		int res = ccw(p0, p1, p2);
		switch (res)
		{
		case CLOCKWISE:
			cout << "CLOCKWISE" << endl;
			break;
		case COUNTER_CLOCKWISE:
			cout << "COUNTER_CLOCKWISE" << endl;
			break;
		case ONLINE_FRONT:
			cout << "ONLINE_FRONT" << endl;
			break;
		case ONLINE_BACK:
			cout << "ONLINE_BACK" << endl;
			break;
		case ON_SEGMENT:
			cout << "ON_SEGMENT" << endl;
			break;
		}
	}
	return 0;
}

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

using namespace std;

typedef long long lli;
typedef long double ld;
typedef pair<lli, lli > plli;
typedef vector<lli> vlli;
typedef vector<plli > vplli;

#define rep(i,a) for(i = 0 ; i < a ; i++)
#define repr(i,a) for(i = a ; i >= 0 ; i--)
#define REP(i,a,b) for(i = a ; i <= b ; i++)
#define REPR(i,a,b) for(i = a ; i >= b ; i--)

#define scan(N) scanf("%lld",&N)
#define print(N) printf("%lld",N)
#define scan2(N1,N2) scanf("%lld %lld",&N1,&N2)
#define print2(N1,N2) printf("%lld %lld",N1,N2)
#define scan3(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define print3(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define mem(a,b)memset(a,b,sizeof(a))
#define opt ios_base::sync_with_stdio(false);cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*((b)/gcd(a,b)))
#define sqr(x) (x)*(x)
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl

#define endl '\n'

const long long INF = 2000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;

template<class T> bool is_prime(T n)
{
	if((n%2 == 0 and n > 2) or n < 2 )
		return false;
	for(T i = 3; i*i <= n ; i += 2)
	{
		if( n % i == 0)
			return false;
	}
	return true;
}
lli power(lli a,lli b)
{
    lli value;
    if(!b)
    	return 1;
    else if(b%2==0) {
        value = power(a,b/2)%MOD;
        return (value * value)%MOD;
    }
    else {
        value = power(a,b/2)%MOD;
        return ((a*value)%MOD*(value))%MOD;
    }
}

int main()
{
	opt;
	lli n;
    lli p = 0,w = 0,g = 0,y = 0;
    cin >> n;
    char ch;
    lli i;
    rep(i,n)
    {
        cin >> ch;
        if(ch == 'P') p = 1;
        else if(ch == 'W') w = 1;
        else if(ch == 'G') g = 1;
        else if(ch == 'Y') y = 1;
    }
    if(p+g+w+y == 4)
        cout << "Four";
    else
        cout << "Three";
	return 0;
}










Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String s = sc.next();

        int red = 0;
        int blue = 0;
        for (char si : s.toCharArray()) {
            if (si == 'R') {
                red += 1;
            } else {
                blue += 1;
            }
        }

        if (red > blue) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}


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

typedef long double ld;

const int Maxn = 2000005;

int n, k;
int P[Maxn];

int main()
{
    scanf("%d %d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &P[i]);
        P[i] += P[i - 1];
    }
    int res = 0;
    for (int i = k; i <= n; i++)
        res = max(res, P[i] - P[i - k]);
    cout << fixed << setprecision(10) << ld(res + k) / 2.0l << endl;
    return 0;
}


Measured memory_bytes: 1024
//300
fun a020(args: Array<String>) {
    val (N, A, B) = args[0].split(" ").map { it.toInt() }
    when {
        A == 1 && B == 2 -> println("Borys")
        A == N && B == N - 1 -> println("Borys")
        Math.abs(A - B) % 2 == 1 -> println("Borys")
        else -> println("Alice")
    }
}

fun main(args: Array<String>) {
    a020(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 38056
#include<iostream>
using namespace std;
 
class Dice{
		int _num[6];
	public:
        void set(int num[6]){
            for(int i = 0; i < 6; i++) _num[i] = num[i];
        }
        void printTop(){
			cout << _num[0] << endl;
        }
        void printRight(){
			cout << _num[2] << endl;
        }
		void N(){
			swap(_num[0],_num[4]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[1]);
		}
		void S(){
			swap(_num[0],_num[1]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[4]);			
		}
		void W(){
			swap(_num[0],_num[3]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[2]);			
		}
		void E(){
			swap(_num[0],_num[2]);
			swap(_num[0],_num[5]);
			swap(_num[0],_num[3]);			
		}
		void SetTop(int n){
			if(_num[2] == n) W();
			else if(_num[3] == n) E();
			else{
				while(1){
					if(_num[0] == n) break;
				S();
				}
			}
		}
		void SetFront(int n){
			while(1){
				if(_num[1] == n) break;
				S(); W(); N();
			}
		}
};
 
int main(){
    int num[6];
    for(int i = 0; i < 6; i++) cin >> num[i];
     
    Dice d;
    d.set(num);
    
	int q, t, f;
	cin >> q;
	for(int i = 0; i < q; i++){
		cin >> t >> f;
		d.SetTop(t);
		d.SetFront(f);
		
		d.printRight();
	}
	return 0;
}

Measured memory_bytes: 1160
unittest
{
	assert( [ "4", "3 3 3 3" ].parse.expand.solve == 1 );
	assert( [ "5", "2 4 1 4 2" ].parse.expand.solve == 2 );
	assert( [ "1", "1000000000" ].parse.expand.solve == 1 );
	assert( [ "8", "2 7 1 8 2 8 1 8" ].parse.expand.solve == 5 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( as );
}

auto solve( long[] as )
{
	as.sort();
	as ~= 0L;		// 最後に集計したいので被らないやつを追加しておく
	
	auto r = 0L;
	auto d = 0L;
	auto x = as[ 0 ];
	
	foreach( i, a; as )
	{
		// 要素が変わったら集計
		if( a != x )
		{
			if( d < x ) r += d;			// 要素が少なかった場合は全部取り除く
			else        r += d - x;		// 要素が多かった場合は多い分だけ取り除く
			d = 0L;
			x = a;
		}

		// 同じ要素の数をカウント
		d++;
	}
	
	return r;
}


Measured memory_bytes: 7624
N = int(input())
A = list(map(int, input().split()))

# 正負が混在するか判定
plus = False
minus = False
for a in A:
    if a > 0:
        plus = True
    elif a < 0:
        minus = True

ans = []

# 正負が混在する場合、符号を揃える
if plus == True and minus == True:
    max_a = max(A)
    min_a = min(A)
    max_idx = A.index(max_a)
    min_idx = A.index(min_a)
    # 正に揃える
    if abs(max_a) >= abs(min_a):
        for i in range(N):
            A[i] += max_a
            ans.append([max_idx + 1, i + 1])
    # 負に揃える
    if abs(max_a) < abs(min_a):
        for i in range(N):
            A[i] += min_a
            ans.append([min_idx + 1, i + 1])
# print(A)

# 正に揃っている場合
if sum(A) >= 0:
    # 前から累積和
    for i in range(1, N):
        A[i] += A[i - 1]
        ans.append([i, i + 1])
# 負に揃っている場合
elif sum(A) < 0:
    # 後ろから累積和
    for i in range(N - 2, -1, -1):
        A[i] += A[i + 1]
        ans.append([i + 2, i + 1])

print(len(ans))
for a in ans:
    print(*a)
# print(A)


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

int main() {
	vector<int>a(2);
	while (cin>>a[0]>>a[1]) {
		while (1) {
			sort(a.begin(), a.end());
			if (a[1] % a[0] == 0) { cout << a[0] << endl; break; }
			int d = a[0];
			a[0] = a[1] % a[0];
			a[1] = d;
		}
	}
}

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

using namespace std;

int main(void) {
  int N, M;
  cin >> N >> M;
  
  vector<int> nums(N);
  int sum = 0;
  for (int i = 0;i < N;i++) {
    cin >> nums[i];
    sum += nums[i];
  }
  
  sort(nums.rbegin(), nums.rend());
  
  if (nums[M-1] * 4 * M >= sum) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import itertools

X, Y, Z, K = tuple([int(x) for x in str(input()).split(' ')])

A = sorted([int(x) for x in str(input()).split(' ')], reverse=True)
B = sorted([int(x) for x in str(input()).split(' ')], reverse=True)
C = sorted([int(x) for x in str(input()).split(' ')], reverse=True)

tmp = {(0, 0, 0) : A[0] + B[0] + C[0]}
tmp_keys = [(0, 0 ,0)]
out = []

for i in range(K):
    (a, b, c),  p = max(tmp.items(), key=lambda x : x[1])
    out.append(tmp.pop((a, b, c)))

    keys = []
    if a < X - 1:
        keys.append((a+1, b, c))
    if b < Y - 1:
        keys.append((a, b+1, c))
    if c < Z - 1:
        keys.append((a, b, c+1))
    
    for key in keys:
        if key not in tmp_keys:
            tmp[key] = A[key[0]] + B[key[1]] + C[key[2]]
            tmp_keys.append(key)

for x in out:
    print(x)

Measured memory_bytes: 4712
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pl = pair<ll,ll>;
using pi = pair<int,int>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;


class UnionFind
{
private:
    vector<ll> p;
    vector<ll> rank;
public:
    UnionFind(ll n){
        p.resize(n,-1);
        rank.resize(n,1);
    }
    ll find(ll x){
        if(p[x]<0)return x;
        return p[x]=find(p[x]);
    }
    void unite(ll x,ll y){
        x = find(x);
        y = find(y);
		if(x == y)return;
        if(rank[x] > rank[y])swap(x,y);
        if(rank[x] == rank[y])rank[y]++;
        p[y] += p[x];
        p[x] = y;
    }
    ll size(ll x){
        return -p[find(x)];
    }
};


signed main(){
	//cout << fixed << setprecision(10);
    int n,m,k; cin >> n >> m >> k;
    UnionFind uf(n);
    map<int , int> br , fr;
    rep(i,0,m){
        int a, b; cin >> a >> b;
        --a; --b;
        uf.unite(a , b);
        fr[a]++;
        fr[b]++;
    }
    rep(i,0,k){
        int c,d; cin >> c >> d;
        --c; --d;
        if(uf.find(c) == uf.find(d)){
            br[c]++;
            br[d]++;
        }
    }
    rep(i,0,n){
        cout << uf.size(i) - br[i] - fr[i] - 1 << endl;
    }

	return 0;
}

Measured memory_bytes: 14332
#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
  	int a,b,c,min=2019;
    cin >> a >> b;
  	if(b-a>2019){
    	cout << 0 <<endl;
      	return 0;
    }
  	for(int i=a;i<b;i++){
      	for(int k=i+1;k<b+1;k++){
			c = ((i%2019)*(k%2019))%2019;
  			if(c<min){
              min=c;
            }
		}
	}
	cout << min << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int w,h,x,y;
int sx,sy,gx,gy;
int dx[9] = { 1, 1, 1, 0, 0, 0,-1,-1,-1};
int dy[9] = {-1, 0, 1,-1, 0, 1,-1, 0, 1};

bool can(int y,int x) {
	if(0 <= y && y < h && 0 <= x && x < w) return true;
	return false;
}

int main() {
	while(cin >> h >> w) {
		if(h == 0 && w == 0) break;

		vector<string> s(h);
		rep(i, h) cin >> s[i];

		map<string, int> m;
		bool used[15][25];

		rep(i, h) {
			rep(j, w) {
				rep(k, 9) {
					int y = i, x = j;
					memset(used, 0, sizeof(used));
					string t = "";
					while(!used[y][x]) {
						used[y][x] = true;
						t += s[y][x];

						y = (y + h + dy[k]) % h;
						x = (x + w + dx[k]) % w;

						if(t.size() > 1) m[t]++;
					}
				}
			}
		}

		string ans = "";
		map<string, int>::iterator ite;
		for(ite = m.begin(); ite != m.end(); ite++) {
			if(ite->second < 2) continue;
			if(ite->first.size() > ans.size()) {
				ans = ite->first;
			} else if(ite->first.size() == ans.size()) {
				bool flag = true;
				rep(i, ans.size()) {
					if(ite->first[i] <= ans[i]) continue;
					flag = false;
				}

				if(flag) ans = ite->first;
			}
		}

		if(ans.size() == 0) cout << 0 << endl;
		else cout << ans << endl;
	}

	return 0;
}

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

using namespace std;

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

using _loop_int = 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 CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int n;
vi g[252521];

int dist[252521];
void dfs(int p, int bef){
    for(int to : g[p])if(to != bef){
        dist[to] = dist[p] + 1;
        dfs(to,p);
    }
}

int main(){
    scanf("%d",&n);
    REP(i,n-1){
        int a,b;
        scanf("%d%d",&a,&b);--a;--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    fill(dist,dist+n,0);
    dfs(0,-1);
    int u = max_element(dist,dist+n)-dist;
    fill(dist,dist+n,0);
    dfs(u,-1);
    int v = max_element(dist,dist+n)-dist;
    int rad = dist[v];
    if(rad%3==1){
        puts("Second");
    }else{
        puts("First");
    }
    return 0;
}


Measured memory_bytes: 22528
import java.util.*;
import java.io.*;

class Main {

	void solve() {

		int n = inint(), k = inint(), x = inint(), y = inint();
		
		if (n <= k) out.println(n * x);
		else {
			out.println(k * x + (n - k) * y);
		}

	}

	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}

	public int inint() {
		return in.nextInt();
	}

	public long inlong() {
		return in.nextLong();
	}

	public String instr() {
		return in.next();
	}

	public char inchar() {
		return in.next().charAt(0);
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}

	public char[] incharar() {
		return in.next().toCharArray();
	}

	public char[][] incharmap(int h, int w) {
		char[][] a = new char[h][w];
		for (int i=0; i<h; i++) {
			String temp = in.next();
			for (int j=0; j<w; j++) {
				a[i][j] = temp.charAt(j);
			}
		}
		return a;
	}

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main() {
	long int n; cin >> n;
	long int ans = 10000000;
	for(long int i=1;i<=n/2+1;i++){
		long int x = i;
		long int y = n-i;
		long int a = 0;
		long int b = 0;
		while(x!=0){
			a += x%10;
			x = x/10;
		}
		while(y!=0){
			b += y%10;
			y = y/10;
		}
		ans = min(ans, a+b);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
	int n;
	cin >> n;
	vector< pair<double,double> > p;
	double ans1 = 0;
	double ans2 = 0;
	for(int i = 0 ; i < n ; i++){
		double r;
		cin >> r;
		if( i == 0 ){
			p.push_back({r,0});
		}else{
			double mx = 0;
			for(int j = 0 ; j < i ; j++){
				double dx = sqrt( (r+p[j].first) * (r+p[j].first)  - (r-p[j].first) * (r-p[j].first) );
				mx = max(mx,p[j].second+dx);
			}
			p.push_back({r,mx});
		}
		ans1 = min(ans1,p.back().second - p.back().first);
		ans2 = max(ans2,p.back().second + p.back().first);
	}
	printf("%.10lf\n",ans2-ans1);
}

Measured memory_bytes: 3292
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	ll n, k;
	cin >> n >> k;
	vector<pair<ll, ll>> p(n);
	rep(i, n) cin >> p[i].fi >> p[i].se;
	int hk = 0; //highest bit in k
	for(int j = 31; j >= 0; j--){
		if(k & (1LL << j)){
			hk = j;
			break;
		}
	}
	ll ans = 0;
	rep(i, n){
		int h = 0; //highest bit
		for(int j = 31; j >= 0; j--){
			if((p[i].fi & (1LL << j))){
				h = j;
				break;
			}
		}
		if(h < hk) ans += p[i].se;
	}
	//debug(ans);
	repn(bit, 0, 32) if(bit <= hk && (k & (1LL << (hk - bit)))){
		ll ans1 = 0;
		rep(j, n){
			int f = 1, g = 0;
			for(int m = 31; m >= 0; m--){
				if((p[j].fi & (1LL << m))){
					if(!(k & (1LL << m)) && !g){
						f = 0;
						break;
					}
				}
				else if(k & (1LL << m)) g = 1;
			}
			if(!f) continue;
			for(int m = 31; m >= 0; m--) if((p[j].fi & (1LL << m))){
				if((m > (hk - bit) && !(k & (1LL << m))) || (m == (hk - bit))){
					f = 0;
					break;
				}
			}
			if(!f) continue;
			ans1 += p[j].se;
		}
		//debug(ans1);
		ans = max(ans, ans1);
	}
	ll ans2 = 0;
	rep(j, n){
		int f = 1;
		for(int m = 31; m >= 0; m--) if((p[j].fi & (1LL << m))){
			if(m > hk || (m <= hk && !(k & (1LL << m)))){
				f = 0;
				break;
			}
		}
		if(f) ans2 += p[j].se;
	}
	ans = max(ans, ans2);
	cout << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


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

int main()
{
    size_t N, M;
    long long K;
    cin >> N >> M >> K;

    vector<long long> A(N + 1, 0);
    for (size_t i = 1; i <= N; i++)
    {
        cin >> A[i];
        A[i] += A[i - 1];
    }

    vector<long long> B(M + 1, 0);
    for (size_t i = 1; i <= M; i++)
    {
        cin >> B[i];
        B[i] += B[i - 1];
    }

    size_t ans = 0;
    for (size_t i = 0; i <= N; i++)
    {
        long long k = K - A[i];
        if (k < 0)
        {
            break;
        }
        size_t idx = upper_bound(B.begin(), B.end(), k) - B.begin();
        ans = max(ans, i + idx - 1);
    }
    cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  if (S[0] == S[1] or S[1] == S[2] or S[2] == S[3]) {
    cout << "Bad\n";
  } else {
    cout << "Good\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int MAX_N = 100030;    // Change as necessary
const ll  MODD = 1000000009; //
 
int A[MAX_N];
 
vector<pair<int,int> > adj[MAX_N];
queue<int> q;
unordered_set<int> done[MAX_N];
 
void f(int v,int c,int d){
  if(0 <= A[v] && A[v] < d) return;
  if(done[v].count(c)) return;
  done[v].insert(c);
  if(A[v] == -1){
    A[v] = d;
    q.push(v);
  }
  
  for(auto& x : adj[v])
    if(x.second == c)
      f(x.first,c,d);
}
 
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  int n,m;
  cin >> n >> m;
  
  for(int i=0;i<m;i++){
    int u,v,c;
    cin >> u >> v >> c; u--; v--;
    
    adj[u].emplace_back(v,c);
    adj[v].emplace_back(u,c);
  }
  
  for(int i=0;i<n;i++) A[i] = -1;
  
  q.push(0);
  A[0] = 0;
  while(!q.empty()){
    if(A[n-1] != -1) break;
    int v = q.front(); q.pop();
    
    for(auto& x : adj[v])
      f(x.first,x.second,A[v]+1);
  }
  
  cout << A[n-1] << endl;
  
  return 0;
}


Measured memory_bytes: 23296
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  int q;
  cin>>q;
  int64_t v=0;
  REP(i,q) {
    int p,n;
    char c;
    cin>>p>>c>>n;
    if(c=='(')
      v+=n;
    else
      v-=n;
    if (v==0)
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
  }
  return 0;
}

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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<ll> vecl;
typedef pair<ll, ll> pairl;

template<typename T, typename U>
using mapv = map<T,vector<U>>;

#define ALL(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

#define MOD097 1000000007

///// For Debug

#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

// 提出時はコメントアウト
// #define LOCAL
#define DEBUG_

#ifndef LOCAL
#undef DEBUG_
#endif

#ifdef DEBUG_

#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)

#endif

//////////

int main() {
    #ifdef LOCAL
    ifstream in("../../Atcoder/input.txt");
    cin.rdbuf(in.rdbuf());
    #endif

    double pi = acos(-1);
    double A,B,H,M;
    cin>>A>>B>>H>>M;

    double h = H+M/60;
    double c = cos(11*pi*h/6);

    // if (c < 0) c *= -1;
    double x2 = pow(A,2) + pow(B,2) - 2 * A * B * c;

    double ans = sqrt(x2);
    cout << fixed << setprecision(11) << ans << endl;

    return 0;
}


Measured memory_bytes: 4164
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons, std.datetime;

void main() {
    const S = readln.chomp;
    auto d = Date.fromISOString(S.replace("/", ""));

    if (d <= Date(2019, 4, 30)) {
        writeln("Heisei");
    } else {
        writeln("TBD");
    }
}



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

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

fn main() {
    let chars: Vec<String> = (0..2).map(|_| read()).collect();
    let mut nums: Vec<u32> = (0..2).map(|_| read()).collect();
    let u: String = read();

    if chars[0] == u {
        nums[0] = nums[0] - 1
    } else if chars[1] == u {
        nums[1] = nums[1] - 1
    }

    println!("{} {}", nums[0], nums[1]);
}


Measured memory_bytes: 4352
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var k = long.Parse(line[1]);
        var d = (int)(Log10(k) / Log10(2)) + 1;
        var a = new int[d, n];
        line = Console.ReadLine().Trim().Split(' ');
        for (int i = 0; i < n; i++) a[0, i] = int.Parse(line[i]) - 1;
        for (int i = 1; i < d; i++)
            for (int j = 0; j < n; j++)
                a[i, j] = a[i - 1, a[i - 1, j]];
        getAns(n, k, d, a);
    }
    static void getAns(int n, long k, int d, int[,] a)
    {
        var p = 0;
        for (int i = 0; i <= d; i++)
        {
            var t = (k >> i) & 1;
            if (t == 1) p = a[i, p];
        }
        Console.WriteLine(p + 1);
    }
}



Measured memory_bytes: 90664