akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

struct UnionFind {
  vector<int> parent, rank;
  UnionFind(int N = 1) {
    init(N);
  }
  void init(int N = 1) {
    parent.resize(N);
    rank.resize(N);
    for (int i = 0; i < N; i++) {
      parent.at(i) = i;
      rank.at(i) = 0;
    }
  }
  int root(int x) {
    if (parent.at(x) == x) return x;
    else {
      int r = root(parent.at(x));
      parent.at(x) = r;
      return r;
    }
  }
  bool issame(int x, int y) {
    return root(x) == root(y);
  }
  void merge(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return;
    if (rank.at(x) < rank.at(y)) swap(x, y);
    if (rank.at(x) == rank.at(y)) rank.at(x)++;
    parent.at(y) = x;
  }
};

int main() {
  int N, M; cin >> N >> M;
  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int x, y, z; cin >> x >> y >> z;
    x--; y--;
    uf.merge(x, y);
  }
  set<int> s;
  for (int i = 0; i < N; i++) s.insert(uf.root(i));
  cout << s.size() << endl;
}

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

#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 3005;
int dp[N][N];

signed main(){
	fastio
	int n;
	cin >> n;
	int a[n];
	for(auto &x : a) cin >> x;
	for(int i = n-1;i >= 0;i--){
		for(int j = i;j < n;j++){
			if(i==j) dp[i][j] = a[i];
			else dp[i][j] = max(a[i]-dp[i+1][j], a[j]-dp[i][j-1]);
		}
	}
	cout << dp[0][n-1] << "\n";
}

Measured memory_bytes: 49628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iomanip>
#define faster       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define f(i,a,b) for(ll i=a;i<b;i++)
#define r(i,a,b) for(ll i=a;i>b;i--)
using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1000000000000000000;

int main(){
  int n;
    cin >> n;
    ll ans = 1;
    bool tr = false;
    f(i,0,n){
        ll a;
        cin >> a;

        if (a == 0) {
            cout << 0 << endl;
            return 0;
        }

        if (tr || INF / ans < a) {
            tr = true;
        }

        ans *= a;
    }
    if (tr){
      cout << -1 << endl;
      }else{
         cout << ans << endl;
         }
 
    return 0;

}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;


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


Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int c[5][5], a[5], b[5];

bool check(){
    for(int i = 1; i <= 3; ++i){
        for(int j = 1; j <= 3; ++j){
            if(a[i] + b[j] != c[i][j]) return 0;
        }
    }
    return 1;
}

string solve(){
    for(int i = 1; i <= 3; ++i){
        for(int j = 1; j <= 3; ++j){
            cin >> c[i][j];
        }
    }

    for(int a1 = 0; a1 < int(1e6); ++a1){
        a[1] = a1;
        int b1 = c[1][1] - a1;
        b[1] = b1;
        b[2] = c[1][2] - a1;
        b[3] = c[1][3] - a1;
        a[2] = c[2][1] - b1;
        a[3] = c[3][1] - b1;
        if(check()) return "Yes";
    }
    return "No";
}

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

    cout << solve() << "\n";   
    
    return 0;
}

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

using namespace std;
//DAG DP(Topological Sort), Tree DP

//State
//dp[i]: The length of the largest path in DAG (G_dash) 
// containing first i vertices in the topological sort order of G

//Initialization
//For all nodes i whose indegree is 0 set dp[i] = 0 and put them in a queue

//Transitions //Forward DP
//For all v E children(i): dp[v] = max(dp[v], dp[i]+w(i->v))

//Order of evaluation
//Topological sort order

//Answer 
//max(dp[0...n-1])

int main(){
	int N, M;
	cin >> N >> M;
	vector<vector<int>> adjList(N,vector<int>(0));
	vector<int> inDegree(N, 0);
	vector<int> dp(N,0);
	int x, y;
	for(int i=0; i<M; i++){
		cin >> x >> y;
		x = x-1;
		y = y-1;
		adjList[x].push_back(y);
		inDegree[y] = inDegree[y]+1;
	}
	queue<int> q;
	for(int i=0; i<N; i++){
		if(inDegree[i]==0){
			q.push(i);
		}
	}
	while(!q.empty()){
		int parent = q.front();
		q.pop();
		vector<int> children = adjList[parent];
		for(int v: children){
			dp[v] = max(dp[v], dp[parent]+1);
			inDegree[v] = inDegree[v]-1;
			if(inDegree[v]==0) q.push(v);
		}
	}

	int result = 0;
	for(int i=0; i<N; i++){
		result = max(result, dp[i]);
	}
	cout << result << endl;

}


Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>
#include <functional>
#include <bitset>
#include <limits>
#include <cstdio>
#include <cmath>
#include <cassert>
#include <random>

#ifdef DEBUG
#include "library/Utility/debug.cpp"
#else
#define debug(...)
#endif

#define rep(i,n) for(int i=0;i<(n);++i)
#define EL '\n'
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
using lnt = long long;
constexpr lnt INF = 2e18;
struct FIO{FIO(){std::cin.tie(0);std::cout.tie(0);std::ios_base::sync_with_stdio(0);std::cout<<std::fixed<<std::setprecision(15);}}fIO;
/*-*/
template<typename U, typename T> bool chmax(U& a,T b) { if(a<b) { a=b; return 1; } return 0; }

int ac[100000][26][26]={};
int main() {
	int n;
	std::cin >> n;
	std::vector<std::string> s(n);
	rep(i,n) std::cin >> s[i];
	// construct matrix
	// std::vector<std::vector<std::vector<int> > > ac(n,std::vector<std::vector<int> >(26,std::vector<int>(26,0)));
	std::vector<int> acc(n,0);
	{
		int sm = 0;
		rep(i,n) chmax(sm,s[i].size());
		// std::vector<std::vector<std::vector<int> > > cnt(sm,std::vector<std::vector<int> >(27) );
		std::vector<int> nev(sm); // hold the ne count
		// non empty starts from here
		int ne=0;
		// indices
		std::vector<int> in(n);
		std::iota(all(in),0);
		std::vector<int> l(n,0),r(n,n);
		rep(ic,sm) {
			std::vector<std::vector<int> > cnt(27);
			std::vector<std::vector<int> > rsort(27);
			rep(xx,27) cnt[xx].emplace_back(0);
			for(int ii=ne;ii<n;ii++) {
				int i=in[ii];
				if(s[i].size()==ic) rsort[26].emplace_back(i);
				else rsort[s[i][ic]-'a'].emplace_back(i);
				rep(xx,27) cnt[xx].emplace_back(rsort[xx].size());
			}
			for(int ii=ne;ii<n;ii++) {
				int i=in[ii];
				if(ic<s[i].size()) {
					int idk = s[i][ic]-'a';
					rep(xx,26) ac[i][idk][xx] += cnt[xx][r[i]] - cnt[xx][l[i]];
					acc[i] += cnt[26][r[i]] - cnt[26][l[i]];
					// move l and r
					int count=0;
					rep(xx,idk) count+=cnt[xx].back();
					// count of idx before l
					l[i] = count+cnt[idk][l[i]];
					r[i] = count+cnt[idk][r[i]];
				}
			}
			ne+=rsort[26].size();
			int ii=ne;
			rep(xx,26) for(int x:rsort[xx]) in[ii++]=x;
			nev[ic]=ne;
			// rep(xx,27) cnt[xx].shrink_to_fit();
		}
		/*
		rep(k,n) {
			int l=0,r=n;
			rep(ic,s[k].size()) {
				int idk = s[k][ic]-'a';
				rep(xx,26) ac[k][idk][xx] += cnt[ic][xx][r] - cnt[ic][xx][l];
				acc[k] += cnt[ic][26][r] - cnt[ic][26][l];
				// move l and r
				int count=0;
				rep(xx,idk) count+=cnt[ic][xx].back();
				// count of idx before l
				l = count+cnt[ic][idk][l];
				r = count+cnt[ic][idk][r];
			}
		}
		*/
	}
	int q;
	std::cin >> q;
	rep(qq,q) {
		int k; std::cin >> k; k--;
		std::string ord; std::cin >> ord;
		std::vector<int> idx(26);
		std::iota(idx.begin(), idx.end(), 0);
		std::sort(idx.begin(), idx.end(), [&ord](int i1, int i2) {return ord[i1] < ord[i2];});
		int ans=acc[k];
		rep(idk,26) {
			rep(xx,26) {
				if(idx[xx]<idx[idk]) ans += ac[k][idk][xx];
			}
		}
		print(ans+1);
	}
}


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

int main() {
  int n,d,x;
  cin >> n >> d >> x;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int cnt = x;
  for(int i=0;i<n;i++){
    for(int j=0;j<=100;j++){
      if( a.at(i)*j + 1> d ){
        cnt += j;
        break;
      }
    }
  }
  
  cout << cnt << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INTINF = 2147483647;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int a[N]; rep(i, N) cin >> a[i];

  map<int, int> a_dict;
  rep(i, N) {
    a_dict[a[i]-1]++;
    a_dict[a[i]]++;
    a_dict[a[i]+1]++;
  }

  int result = 0;
  for (auto x : a_dict) result = max(result, x.second);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;
int main() {
  int64_t N,K;
  cin>>N>>K;
  vector<int64_t>P(N+1),C(N+1);
  for(int i=1;i<=N;i++){cin>>P[i];}
  for(int i=1;i<=N;i++){cin>>C[i];}
 
  vector<int64_t>mx(N+1);
  int64_t ans=-INF;
  for(int i=1;i<=N;i++){
    int64_t r=i,MAX=-INF,cost=0;
    vector<int64_t>d(N+1); 
    vector<bool>seen(N+1,false);
    for(int64_t j=1;j<=K;j++){
       if(seen[r]){
         if(cost>=0){
           int64_t x=cost*(K/(j-1))+d[K%(j-1)];
           int64_t y=cost*(K/(j-1)-1)+MAX;
           mx[i]=max(x,y);
         }
         break;
       }
       else{
         cost+=C[P[r]];
         chmax(MAX,cost);
         seen[r]=true;
         r=P[r];
         mx[i]=MAX;
         d[j]=MAX;
       }
       
    }
    chmax(ans,mx[i]);
  }cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3752
[N, K, Q] = [int(i) for i in input().split()]
P = [0] * N

for i in range(Q):
    a = int(input())
    P[a-1] += 1

for i in range(N):
    if P[i] > Q - K:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9832
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const double pi = acos(-1);

int main() {
    ll n, k;
    cin >> n >> k;

    vl v(n);
    rep(i, n) {
        cin >> v[i];
    }

    ll ans = -INF;
    exrep(L, 0, n) {
        exrep(R, 0, n) {
            if(L+R > k || L+R > n) {
                continue;
            }
            ll x = k - (L+R);
            vl w;
            rep(i, L) {
                w.pb(v[i]);
            }
            for(ll i = n-1; i >= n-R; i--) {
                w.pb(v[i]);
            }
            sort(all(w));
            ll now = 0;
            rep(i, w.size()) {
                if(i < x && w[i] < 0) {
                    continue;
                }
                now += w[i];
            }
            chmax(ans, now);
        }
    }

    out(ans);
    re0;
}

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

int main()
{
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  string firstd="",firstu="",tempd="";
  int diff=ty-sy;
  while(diff--)
   firstd+='D',firstu+='U';
  diff = tx-sx;
  while(diff--)
    firstd+='L',firstu+='R';
  cout<<firstu<<firstd<<"LU";
  //reverse(firstd.begin(),firstd.end());
  //reverse(firstu.begin(),firstu.end());
  cout<<firstu<<"RDRD"<<firstd<<"LU\n";
  return 0;
}


Measured memory_bytes: 256
import java.lang.Math

val MOD: Int = 1000000000 + 7
val MODL: Long = MOD.toLong()

var H = IntArray(1)

fun main(args: Array<String>)
{
    val n = readLine()!!.toInt()
    H = readLine()!!.split(" ").map{it.toInt()}.toIntArray()

    var ans = water(0, n-1)
    println(ans)
}

fun water(from: Int, to: Int): Int {
    var dec = false
    var div = -1
    for (i in from until to) {
        if (H[i] > H[i+1] && !dec) {
            dec = true
            continue
        }
        if (dec && H[i] < H[i+1]) {
            dec = false
            if (div == -1) {
                div = i
            } else {
                div = if (H[i] > H[div]) div else i
            }
        }
    }

    var cnt: Int
    if (div != -1) {
        for (i in from..to) {
            H[i] -= H[div]
            if (H[i] < 0) H[i] = 0
        }
        cnt = H[div] + water(from, div-1) + water(div+1, to)
    } else {
        var n = -1
        for (i in from..to) {
            n = if (H[i] > n) H[i] else n
        }
        cnt = n
    }
    return cnt
}


Measured memory_bytes: 37860
#include <bits/stdc++.h>
using namespace std;
int main() {	
	int t=1;
	//cin >> t;
	while (t--) {
	   
	    int n;
       cin>>n;
       int*arr=new int[n];
       for(int i=0;i<n;i++)
       {
       	cin>>arr[i];
	   }
	    long long dp[100001];
	   for(int i=0;i<n;i++)
	   {
	   	dp[i]=INT_MAX;
	   }
	   dp[0]=0;
	   int l;
	   int r;
	   long long a,b;
	   for(int i=0;i<n;i++)
	   {
	   	l=i+1;
	   	r=i+2;
	   	if(l<=n)
	   	{ 
	   	   	a=dp[i]+abs(arr[i]-arr[l]);
	   	   	 if(dp[l]>a)
	   	   	 {
	   	   	 	dp[l]=a;
				}
		   }
	  
	   	if(r<=n)
		   { 
		     b=dp[i]+abs(arr[i]-arr[r]);
		     if(dp[r]>b)
	   	   	 {
	   	   	 	dp[r]=b;
				}
         	}
	   }
	   cout<<dp[n-1];
	   
      }
	} 
	
	
	

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

using namespace std;

int main() {

	long n;
	cin >> n;

	for (long i = 1; i <= 9; i++) {
		for(long j=i;j<=9;j++){
			if (j*i == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	
	cout << "No" << endl;
}

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

int n,m; ll a[N],q[N],tg[N];
void solve(ll x,ll y){
	if (x<q[1]){
		if (x) a[x]+=y; return;
	}
	int l=1,r=n,mid;
	while (l<r){
		mid=l+r+1>>1;
		if (q[mid]<=x) l=mid; else r=mid-1;
	}
	tg[l]+=x/q[l]*y; solve(x%q[l],y);
}
int main(){
	scanf("%lld%d",&q[n=1],&m); q[0]=q[1];
	int i; ll x;
	for (i=1; i<=m; i++){
		scanf("%lld",&x);
		while (n && x<=q[n]) n--; q[++n]=x;
	}
	for (i=n,tg[i]=1; i>1; i--){
		tg[i-1]+=q[i]/q[i-1]*tg[i];
		solve(q[i]%q[i-1],tg[i]);
	}
	a[q[1]]+=tg[1];
	for (i=q[0]; i; i--) a[i]+=a[i+1];
	for (i=1; i<=q[0]; i++) printf("%lld\n",a[i]);
	return 0;
}


Measured memory_bytes: 4096
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long li;

const int maxn = 1e5;

int main(void) {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if (a == b && a == c && (~a & 1)) {
    puts("-1");
    return 0;
  }

  int ans = 0;
  while ((~a & 1) && (~b & 1) && (~c & 1)) {
    int A = b + c >> 1;
    int B = c + a >> 1;
    int C = a + b >> 1;
    a = A, b = B, c = C;
    ++ans;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define bitsz(x) int(__builtin_popcount(x))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb(x) push_back(x)
#define INF 1e9
#define LINF 1e18
#define mod 1000000007
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
const int di[4] = {1,0,-1,0};
const int dj[4] = {0,1,0,-1};

int a[3005][3005];
ll dp[3005][3005][4];

int main() {
    int R,C,n; cin >> R >> C >> n;
    rep(i,n) {
        int r,c,v; cin >> r >> c >> v;
        a[r-1][c-1] = v;
    }

    rep(i,R)rep(j,C) {
        for (int k=2; k>=0; k--) {
            chmax(dp[i][j][k+1], dp[i][j][k]+a[i][j]);
        }
        rep(k,4) {
            chmax(dp[i+1][j][0], dp[i][j][k]);
            chmax(dp[i][j+1][k], dp[i][j][k]);
        }
    }
    ll ans = 0;
    rep(k,4) chmax(ans, dp[R-1][C-1][k]);
    cout << ans << endl;
}

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


void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    pair<long long,long long> p[M];
    
    for(int i = 0;i < M; i++){
        if(a[i] > b[i]) swap(a[i],b[i]);
        p[i].first = b[i];
        p[i].second = a[i];
    }
    
    sort(p,p + M);
    
    int t = 0;
    int ans = 0;
    for(int i = 0;i < M;i++){
        if(t <= p[i].second){
            t = p[i].first;
            ans += 1;
        } 
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
    }
    solve(N, M, std::move(a), std::move(b));
    return 0;
}


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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

constexpr int dx[] = {0, -1, 1, 0, -1, 1, -1, 1};
constexpr int dy[] = {-1, 0, 0, 1, -1, -1, 1, 1};

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    int N = input(), R = input();

    cout << R + (100 * max(0, 10 - N)) << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
import math
N = 5000000000000000
S = input()
K = math.log(int(input()))
for i in S:
  num = int(i)
  if num == 1:
    if num == int(math.exp(K)):
      print(num)
      break
    else:
      K = math.log(int(math.exp(K)-1))
      continue
  kk = N * math.log(num)
  if kk >= K:
    print(num)
    break
  else:
    K -= kk

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <map>
#include <set>
using namespace std;
map<int,int> mp;
int a[100001];
int main()
{
    int n,m;
    while(cin>>n>>m){
        if(n%3==0||m%3==0||(m+n)%3==0)
            cout<<"Possible"<<endl;
        else cout<<"Impossible"<<endl;
    }
    return 0;
}



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

const int MAXM = 100003;
const int MAXN = 103;
long long dp[MAXM];
int w[MAXN];
int v[MAXN];
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m; cin >> n >> m;
	
	for (int i = 0; i < n; ++i) {
		cin >> w[i] >> v[i];
	}
	for (int i = 0; i < n; ++i) {
		for (int j = m; j >= 0; --j) {
			if (j - w[i] < 0) break;
			dp[j] = max(dp[j], dp[j - w[i]] + (long long) v[i]);
		}
	}
	
	cout << dp[m] << '\n';
}


Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vi = vector<ll>;
using vvi = vector<vi>;



int main() {
    int n;
    cin >> n;
    vi a(n);
    vi b(n);

    rep(i, n) {
        int a_, b_; 
        cin >> a_ >> b_;
        b[i] = b_;
        a[i] = a_+b_;
    }

    sort(rall(a));

    ll ans = 0LL;
    rep(i, n) {
        if(!(i&1)) {
            ans += a[i];
        }
        ans -= b[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, M; cin >> N >> M;

	ll res = 1900 * M + 100 * (N - M);
	res *= pow(2, M);
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 384
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
#[fastout]
fn main() {
  input! {
    N:usize,
    A:[usize;N]
  }
  let N: usize = N;
  let mut nmax = 0usize;
  let mut cmax = 0usize;
  let mut h: HashMap<&usize, usize> = HashMap::new();
  for i in 0..N {
    *h.entry(&A[i]).or_insert(0usize) += 1usize;
    nmax = max(nmax, A[i]);
    cmax = max(cmax, *h.get(&A[i]).unwrap());
  }
  debug!(h, nmax, cmax);
  let mut mx = 0;
  //let N: usize = A.len();
  //let mut isprime = vec![true; nmax + 1];
  //let mut f = vec![0usize; nmax + 1];
  //isprime[0] = false;
  //isprime[1] = false;
  //let mut i = 2;
  //while i * i <= nmax {
  //  if isprime[i] {
  //    let mut j = 2;
  //    while i * j <= nmax {
  //      isprime[i * j] = false;
  //      j += 1;
  //    }
  //  }
  //  i += 1;
  //}
  let mut pflag = true;
  for p in 2..=nmax {
    debug!(p);
    //if isprime[p] {
    let mut f = 0usize;
    for q in 1..=nmax / p {
      let a = p * q;
      f += *h.get(&a).unwrap_or(&0);
    }
    mx = max(mx, f);
    //}
  }
  if mx <= 1 {
    println!("pairwise coprime");
    return;
  } else if mx < N {
    println!("setwise coprime");
  } else {
    println!("not coprime")
  }
}
fn gcd(a: usize, b: usize) -> usize {
  if b == 0 {
    a
  } else {
    gcd(b, a % b)
  }
}
fn issetwise(A: Vec<usize>) -> bool {
  let mut a = A[0];
  for i in 1..A.len() {
    a = gcd(a, A[i]);
    if a == 1 {
      return true;
    }
  }
  return false;
}


Measured memory_bytes: 68732
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <cstdio>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
using ll = long long;
using pi = pair<int,int>;
using ld = long double;
int main()
{
  int n,k; cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int lb = 0, ub = 1e+9+1;
  while(ub - lb > 1) {
    int mid = (ub + lb) / 2;
    int cnt = 0;
    rep(i,n) {
      cnt += (a[i] - 1) / mid;
    }
    (cnt <= k ? ub : lb) = mid;
  }
  cout << ub << "\n";
  return 0;
}


Measured memory_bytes: 4040
n,q=map(int,input().split())
s=input()
Sum=[0]
sum=0
stack="Q"
for i in range(n):
  if stack=="A" and s[i]=="C":
    sum+=1
  stack=s[i]
  Sum.append(sum)
for i in range(q):
  l,r=map(int,input().split())
  print(Sum[r]-Sum[l])

Measured memory_bytes: 6124
def main():
    H, W = map(int, input().split())
    A = [input() for i in range(H)]

    cnt = 0
    for a in A:
        cnt += a.count("#")

    if cnt == H + W - 1:
        print("Possible")
    else:
        print("Impossible")


if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
c = 0

def merge(a,l,m,r):
    global c
    n1 = m-l
    n2 = r-m
    L = a[l:m]
    R = a[m:r]
    L.append(1000000009)
    R.append(1000000009)
    i,j = 0,0
    for k in range(l,r):
        if L[i]<=R[j]:
            a[k] = L[i]
            i += 1
        else :
            a[k] = R[j]
            j += 1
        c+=1

def mergeSort(a,l,r):
    if l+1<r:
        m = (l+r)//2
        mergeSort(a,l,m)
        mergeSort(a,m,r)
        merge(a,l,m,r)

def main():
    n = int(input())
    a = list(map(int,input().split()))
    mergeSort(a,0,n)
    print (' '.join(map(str,a)))
    print (c)

if __name__ == '__main__':
    main()




Measured memory_bytes: 66776
'''
問題の条件でAを追加できるとなっているので、
A以外の文字は無関係。公式解説を読んで、
単純に、秋葉原のローマ字の文字をBitで消した文字列と
入力文字列との比較をしたが、それでは、Aと関係のない
文字を削除・追加したものもOKと判定してしまう。
秋葉原の文字列でAとなっているところに限定して
Bit探索をする。
'''
S=input()
AKI='AKIHABARA'
AKI=list(AKI)
List=[0,4,6,8]#秋葉原の文字列でAとなっている場所に着目
for i in range(1<<4):#Bit全探索
  for j in range(4):
    if i&(1<<j):#Bitが立っていれば
      AKI[List[j]]='A'#Listのj番目の文字はAにする
    else:#そうでなければ
      AKI[List[j]]=''#Aとせず、飛ばす
    if S==''.join(AKI):#上の操作で作られた文字と入力を比較
      print('YES')
      exit()
else:
  print('NO')

Measured memory_bytes: 9080
def is_a?(s)
  s =~ /^>'(=+)#(=+)~$/
  unless $1 == nil || $2 == nil
    return s && $1.size == $2.size
  end
  false
end

def is_b?(s)
  s =~ /^>\^(Q=)+~~$/
end

n = gets.chomp.to_i

n.times do
  s = gets.chomp
  if is_a?(s)
    puts :A
  elsif is_b?(s)
    puts :B
  else
    puts :NA
  end
end

Measured memory_bytes: 8940
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S, T;
  cin >> S >> T;
  vector<int> sdata(S.size()), tdata(T.size());
  for(int i = 0; i < S.size(); i++) {
    sdata.at(i) = S.at(i) - 'a';
  }
  for(int i = 0; i < T.size(); i++) {
    tdata.at(i) = T.at(i) - 'a';
  }
  sort(sdata.begin(),sdata.end());
  sort(tdata.begin(),tdata.end());
  if(sdata.at(0) < tdata.at(tdata.size() - 1) || (sdata.size() < tdata.size() && sdata.at(sdata.size() - 1) == tdata.at(tdata.size() - 1)))cout << "Yes" << endl;
  else cout << "No" << 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 pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  double a, b, x;
  cin >> a >> b >> x;
  x /= a;
  if(x > a * b / 2){
    x = (a * b - x) / a * 2 / a;
  }else{
    x = b / (x / b * 2);
  }
  printf("%.10f\n", atan(x) * 180 / M_PI);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;

    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;

        ans += a - 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define SIZE 1e+200000
int main(void)
{
    char c;
    ll i = 0, count = 0;
    while (1)
    {
        scanf("%c", &c);
        if (c == '\0' || c == '\n')
            break;
        count += (c - 48);
    }
    if (count % 9 == 0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

Measured memory_bytes: 1584
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 105;
pr p[N];
int n;
bool angle(pr a, pr b){
	return atan2(a.first, a.second) < atan2(b.first, b.second);
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i=0;i<n;++i) cin >> p[i].first >> p[i].second;
	sort(p, p+n, angle);
	long long ans = 0;
	for(int i=0;i<n;++i){
		long long curX = 0, curY = 0;
		for(int j=0;j<n;++j){
			int pi = (i + j) % n;
			curX += p[pi].first;
			curY += p[pi].second;
			ans = max(ans, curX * curX + curY * curY);
		}
	}
	// cout << ans << '\n';
	cout << setprecision(15) << sqrt(ans);
}

Measured memory_bytes: 4184
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define pb(a) push_back(a)

typedef long long ll;
using namespace std;

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; }

//const int dy[] = { 0, 0, 1, -1 };
//const int dx[] = { 1, -1, 0, 0 };
const int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
const int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
ll gcd(ll a, ll b);
ll lcm(ll x, ll y);

vector<ll> a;


int main()
{
	ll r;
	double ans;
	cin >> r;

	ans = r * 2 * PI;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3772
//Utkarsh.25dec
#include <bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,k;
    cin>>n>>k;
    vl h;
    h.pb(0);
    rep(i,n)
    {
        ll c;
        cin>>c;
        h.pb(c);
    }
    ll dp[n+1];
    dp[1]=0;
    for(int i=2;i<=n;i++)
    {
        dp[i]=INT_MAX;
        for(int j=i-1;j>=max((ll)1,i-k);j--)
        {
            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
        }
    }
    cout<<dp[n];
}
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
}

Measured memory_bytes: 13684
#include<bits/stdc++.h>
using namespace std;
int main(){
    double w,h,x,y;
    cin >> w >> h >> x >> y;
    bool k = false;
    if(x * 2 == w && y * 2 == h)
    k = true;
    cout << setprecision(10) << w * h / 2 << " " << (k ? 1 : 0) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<iterator>
#include<utility>
using namespace std;
using p = pair<int,int>;
int main()
{
	int n,m;
	cin >> n >> m;
	vector<p> ab(n,make_pair(0,0));
	
	for(int i=0; i<n;i++){
	    cin >> ab[i].first >> ab[i].second;
	}
  
    sort(ab.begin(),ab.end());
    
    int re_m=m;
    long long sum = 0;
    bool flag = false;
    for(int i=0;i<n;i++){
        for(int j=0;j<ab[i].second;j++){
            if(re_m > 0){
                sum += ab[i].first; 
                re_m--;
            }else{
                 flag = true;
                 break;
            }  
        }
        if(re_m == 0 || flag)
            break;
    }
    cout << sum; 	
}

Measured memory_bytes: 1024
N, K = map(int, input().split())

arr = []
for i in range(N):
    arr.append(0)

for i in range(K):
    _ = input()
    a = list(map(int, input().split()))
    for j in a:
        arr[j - 1] += 1

print(len(list(filter(lambda x: x == 0, arr))))



Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string ans;
  cin >> n;
  int l;
  int check = 0,count = 0;
  vector<int> L(n);
  for(int i=0; i<n; i++){
    cin >> L.at(i);
  }
  sort(L.begin(), L.end());

  for(int i=0; i<n; i++){
    for(int j=0; j<i; j++){
      for(int k=0; k<j; k++){
        if(L.at(k) != L.at(j) and L.at(i) != L.at(j) and L.at(j)+L.at(k) > L.at(i)){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int dp[2][1 << 16],*now = dp[0],*nxt = dp[1];
	int h,w;
	string s[130];
	cin >> h >> w;
	for(int i = 0;i < h;i++) cin >> s[i];
	for(int i = 0;i < (1 << w);i++) now[i] = nxt[i] = -INF;
	now[0] = 0;
	int popcount[1 << 16];
	for(int i = 0;i < (1 << w);i++) popcount[i] = __builtin_popcountll(i);
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			for(int k = 0;k < (1 << w);k++) nxt[k] = -INF;
			for(int k = 0;k < (1 << w);k++){
				int l = popcount[k % (1 << j)];
				if(now[k] < 0) continue;
				int up = s[i-1].length()-popcount[k >> j];
				int add = (((k>>j)&1) && i && s[i-1][up]==s[i][l])
				+ (l && ((k>>(j-1))&1) && s[i][l-1]==s[i][l]);
				chmax(nxt[k | (1 << j)],now[k] + 2 * add);
				chmax(nxt[k & ~(1 << j)],now[k]);
			}
			swap(now,nxt);
		}
		for(int k = 0;k < (1 << w);k++){
			if(popcount[k] != s[i].length()) now[k] = -INF;
		}
	}
	int ans = -INF;
	for(int i = 0;i < (1 << w);i++) chmax(ans,now[i]);
	cout << ans << endl;
}


Measured memory_bytes: 4756
#include <iostream>

using namespace std;

int a[105];

int main() {
    int n;
    cin >> n;

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

    int cnt = 1;
    int ans = 0;
    for (int i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1]) {
            cnt++;
        } else {
            ans += cnt / 2;
            // cout << cnt << cnt / 2 << endl;
            cnt = 1;
        }
    }
    ans += cnt / 2;
    // cout << cnt << cnt / 2 << endl;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 1000000010;

int main(){
    int n;
    cin >>n;
    vector<int> h(n);
    rep(i,n) cin >>h[i];

    vector<int> dp(n,INF);
    dp[0] = 0;
    rep(i,n){
        for(int j=1; j<=2; ++j)if(i+j<n){
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << dp[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
 
int main(void)
{   int a,b,i;
    char op;
    for(i=1;i>0;i++){
        scanf("%d %c %d",&a,&op,&b);
        if(op=='+')
        {printf("%d\n",a+b);
        }
        else if(op=='-')
        {printf("%d\n",a-b);
        }
        else if(op=='*')
        {printf("%d\n",a*b);
        }
        else if(op=='/'){
            printf("%d\n",a/b);
        }else if(op=='?') {
            break;
        }
    }
    return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> p(N);
    for (int i=0; i<N; i++) {
        cin >> p[i];
    }
    sort(p.begin(), p.end());
    int ans = 0;
    for (int i=0; i<K; i++) {
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
using namespace std;

using int64 = long long;

int64 solve(int64 n, int64 a, int64 b) {
  if (a > b)
    swap(a, b);
  if ((b - a) % 2 == 0)
    return (b - a) / 2;
  int64 win = a + (b - a - 1) / 2;
  a = n - a + 1;
  b = n - b + 1;
  int64 lose = b + (a - b - 1) / 2;
  return min(win, lose);
}

int main() {
  int64 n, a, b;
  cin >> n >> a >> b;
  cout << solve(n, a, b) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int ask(int i){
	printf("%d\n",i);fflush(stdout);
	char s[16];
	scanf("%s",s);
	if(s[0]=='V')exit(0);
	return s[0]=='M';
}

int n;

int main(){
	scanf("%d",&n);
	int a=ask(0);
	int s=1,e=n;
	while(e-s>1){
		int m=(s+e)/2;
		int t=ask(m);
		if((a+(m-s+1))%2==t){
			a=t;
			s=m+1;
		}
		else e=m;
	}
	assert(s+1==e);
	ask(s);
	assert(0);
	return 0;
}

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

bool graph[8][8];

int DFS(int x,int N,bool visited[8]){
  
  bool allvisited=true;
  for(int i=0;i<N;i++){
    if(visited[i]==false) allvisited=false;
  }
  if(allvisited==true) return 1;
  
  int ans=0;
  
  for(int i=0;i<N;i++){
    if(graph[x][i]==false) continue;
    if(visited[i]) continue;
    
    visited[i]=true;
    ans+=DFS(i,N,visited);
    visited[i]=false;
  }
  return ans;
}

int main(void){
  int N,M;
  cin >> N >> M;
  for(int i=0;i<M;i++){
    int A,B;
    cin >> A >> B;
    graph[A-1][B-1]=graph[B-1][A-1]=true;
  }
  
  bool visited[8];
  for(int i=0;i<N;i++){
    visited[i]=false;
  }
  visited[0]=true;
  
  cout << DFS(0,N,visited) << endl;
  return 0;
}


Measured memory_bytes: 256
import math , sys, bisect

N = int( input() )

A = sorted( list( map( int, input().split() ) ) )
B = sorted( list( map( int, input().split() ) ) )
C = sorted( list( map( int, input().split() ) ) )

Bc = []

for i in range(N):
    X = B[i]

    count = bisect.bisect_left( A , X )
    Bc.append( count )
#print(A, B, C)
#print(Bc)
s = 0
Ec = [0]
for i in range(N):
    s += Bc[i]
    Ec.append(s)
#print(Ec)
ans = 0
for i in range(N):
    X = C[i]
    ind = bisect.bisect_left( B , X )
    ans += Ec[ind]
    #print(ind)

print(ans)

Measured memory_bytes: 103408
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int W = in.nextInt();
        int H = in.nextInt();
        int x = in.nextInt();
        int y = in.nextInt();
        int r = in.nextInt();
        if(x + r > W || x - r < 0){
            System.out.println("No");
        }else if(y + r > H || y - r < 0){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }
    }
}


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

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define TRAV(a, x) for(const auto& a : x)
#define ALL(x) x.begin(), x.end()
#define NEXT_PERM(x) while(next_permutation(ALL(x))) // 순열 알고리즘(오름)
#define PREV_PERM(x) while(prev_permutation(ALL(x))) // 순열 알고리즘(내림)
#define PRINT(x) cout << x
#define PRINT_LN(x) cout << x << endl;
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<char> vc;

void solve() {
  ll k;
  cin >> k;
  FOR(i,-120,120) FOR(j,-120,120) {
    if(pow(i,5) - pow(j,5) == k) {
      cout << i << " " << j; 
      exit(0);
    }
  }
}
int main() {
  solve();
  return 0;
}


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

int main() {
  int N, total, count = 0, ans;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  total = a.at(0);
  for (int i = 1; i < N; i++){
    total = total^a.at(i);
  }
  for (int i = 0; i < N; i++){
    ans = total^a.at(i);
    cout << ans << ' ';
  }
  cout <<  endl;
}


Measured memory_bytes: 4052
import sys
from operator import itemgetter

mod = 10**9 + 7
inf = 1<<30

def solve():
    N, M = map(int, sys.stdin.readline().split())
    sects = []

    for i in range(N):
        li, ri = map(int, sys.stdin.readline().split())

        sects.append((li, ri + 1, ri - li + 1))

    sects.sort(key=itemgetter(2))

    print(N)

    left = 0
    ft = FenwickTree(M + 1)

    for d in range(2, M + 1):
        for j in range(left, N):
            if sects[j][2] >= d:
                left = j
                break
            else:
                ft.add(sects[j][0], 1)
                ft.add(sects[j][1], -1)
        else:
            left = N

        ans = N - left + sum(ft.get_sum(j) for j in range(d, M + 1, d))

        print(ans)


class FenwickTree:
    def __init__(self, size):
        self.n = size
        self.data = [0]*(size + 1)

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & (-i)

    def get_sum(self, r):
        res = 0

        while r > 0:
            res += self.data[r]
            r -= r & (-r)

        return res

if __name__ == '__main__':
    solve()

Measured memory_bytes: 114900
n, k = map(int, input().split())
dislikes = list(map(int, input().split()))
m = n
while True:
    m = list(str(m))
    l = []
    for p in m:
        if int(p) not in dislikes:
            l.append(p)
            continue
        else:
            m = int(''.join(m))+1
            break
    if len(l) >= len(str(n)):
        if int(''.join(l))>=n:
            break
print(''.join(m))

Measured memory_bytes: 3064
K = int(input())
r = [[] for _ in range(10)]
r[0] = list(range(1,10))

for i in range(9):
  for a in r[i]:
    s = str(a)
    d = a%10
    for j in range(d-1, d+2):
      if not 0 <= j <= 9: continue
      r[i+1].append(int(s+str(j)))

for i in range(10):
  if K >= len(r[i]):
    K -= len(r[i])
  else:
    print(r[i][K-1])
    break


Measured memory_bytes: 11036
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,i,j,a[500005],sum;
char s[500005];
int main(){
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;i++)
		a[i]=(s[n-i-1]-'0')*9;
	for(i=0;i<n||a[i]!=0;i++){
		a[i+1]+=a[i]/10;
		a[i]%=10;
		sum+=a[i];
	}
	n=i;
	for(j=1;;j++){
		a[0]++;
		sum++;
		i=0;
		while(a[i]>=10){
			a[i]-=10;
			sum-=9;
			a[i+1]++;
			i++;
		}
		if(j>=sum){
			pus((j-1)/9+1,2);
			return 0;
		}
	}
   	return 0;
}

Measured memory_bytes: 2688
import java.util.Scanner;

public class Main {

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

		char[] str = sc.next().toCharArray();
		int k = sc.nextInt();
		boolean oneChar = true;
		for(int i = 1; i < str.length; i++){
			if(str[i - 1] != str[i]){
				oneChar = false;
				break;
			}
		}

		if(oneChar){
			System.out.println((long)str.length*k/2);
			return;
		}

		int firstSeq = 0;
		int lastSeq = 0;
		int tmpCount = 0;
		int changeCount = 0;
		for(int i = 0; i < str.length; i++){
			tmpCount++;

			if(i == str.length - 1 || str[i] != str[i + 1]){
//				System.out.println("index " + i);
				changeCount += tmpCount/2;

				lastSeq = tmpCount;
				if(firstSeq == 0){
					firstSeq = tmpCount;
				}

				tmpCount = 0;
			}
		}

//		System.out.println(firstSeq + " " + lastSeq);
		long result = (long)changeCount*k;

		if(str[0] == str[str.length - 1]){
			result = result - (long)(firstSeq/2 + lastSeq/2 - (firstSeq + lastSeq)/2)*(k - 1);
		}

		System.out.println(result);
	}

}


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

int main(){
	int n;
	cin >> n;
	int a,count = 0;
	for(int i = 0; i < n; i++){
		cin >> a;
		int ok = 1;
		if(a % 2 == 0 && a != 2)ok = 0;
		else if(a % 2 != 0){
			for(int j = 2; j < a; j++){
				if(j * j > a)break;
				
				if(a % j == 0){
					ok = 0;
					break;
				}
			}
		}
		if(ok)count++;
	}

	cout << count << endl;
}



Measured memory_bytes: 3088
def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return n * 3 + 1


s = int(input())
i = 1
k = 0
old = [s]

while 1:
    k = f(s) if i == 1 else f(k)
    if k in old:
        break
    else:
        old.append(k)
        i += 1

print(i+1)

Measured memory_bytes: 3064