akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (u == s)
    a--;
  else
    b--;
  cout << a << ' ' << b << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>
#include <math.h>
int main(){

	int sn;
	double xa,ya,ra,xb,yb,rb;
	int i;
	int judge;
	
	double Rab;
	
	scanf("%d",&sn);

	for(i=1;i<=sn;i++){
		scanf("%lf %lf %lf %lf %lf %lf",
		       &xa,&ya,&ra,&xb,&yb,&rb);
		
		Rab=sqrt( (xa-xb)*(xa-xb) + (ya-yb)*(ya-yb) );
		
		if(Rab<=ra){
			if(rb<ra-Rab)judge=2;
			if(ra-Rab<=rb && rb<=ra+Rab) judge=1;
			if(rb>ra+Rab) judge=-2;
		}
		if(Rab>ra){
			if(rb<Rab-ra)judge=0;
			if(Rab-ra<=rb && rb<=ra+Rab) judge=1;
			if(rb>ra+Rab) judge=-2;
		}
		
		printf("%d\n",judge);
	}



	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
int a[1000000] , p[1000000] ;
signed main()
{
	int n;
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		p[a[i]]++;
	}
	int ans=0;
	for (int i=0;i<1000000;i++){
		ans+=p[i]*(p[i]-1)/2;
	}
	for (int i=0;i<n;i++){
		cout<<ans-p[a[i]]+1<<endl;
	}
	re 0;
}

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



int main(){
    ll n,w;
    cin >> n >> w;
    ll i,j;
    ll warr[n];
    ll varr[n];
    ll V=0;
    for(i=0;i<n;i++){
        cin >> warr[i];
        cin >> varr[i];
        V+=varr[i];
    }
    vector<ll> dp(V+1,1e18);
    dp[0]=0;
    for(i=0;i<n;i++){
        for(j=V;j>=varr[i];j--){
            dp[j]=min(dp[j],dp[j-varr[i]]+warr[i]);
        }
    }
    ll ans;
    for(i=V;i>=0;i--){
        if(dp[i] <= w){
            ans=i;
            break;
        }
    }
    cout << ans << endl;
    
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;

ll pw(ll x, ll y) {
  ll res = 1;

  while (y) {
    if (y%2) {
      res = res * x % mod;
    }
    y = y / 2;
    x = x * x % mod;
  }
  res %= mod;
  res += mod;
  res %= mod;
  return res;
}


ll nck(ll n, ll k) {
  ll res = 1;
  for (ll i=n; i>n-k; i--) {
    res = res * i % mod;
  }
  ll denom = 1;
  for (ll i=1; i<=k; i++) {
    denom = denom * i % mod;
  }

  res = res * pw(denom, mod-2) % mod;
  res %= mod;
  res += mod;
  res %= mod;
  return res;
}

ll n,a,b;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  assert(pw(2,5)==32);
  cin>>n>>a>>b;

  ll res = pw(2,n) - 1;
  res -= nck(n, a);
  res -= nck(n, b);
  res %= mod;
  res += mod;
  res %= mod;
  cout<<res<<endl;
  return 0;
}
// don't forget to read in the input :^)


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

typedef long long ll;

const int INF = 2e9 + 5;
const int alength=100100;

int main() {
	int n,k;
	cin>>n>>k;
	int p[1100];
	fori(n){cin>>p[i];}
	sort(p,p+n);
	int ans=0;
	fori(k){ans+=p[i];}
	cout<<ans;
}

Measured memory_bytes: 3640
(t_hp, t_atk, a_hp, a_atk) = map(int, input().split())

turn = "t"
while (t_hp > 0) and (a_hp > 0):
    if turn == "t":
        a_hp -= t_atk
        if a_hp > 0:
            turn = "a"
    else:
        t_hp -= a_atk
        if t_hp > 0:
            turn = "t"
if turn == "t":
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9092
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// データ構造
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 小数のときは，精度の設定する．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int N; cin >> N;
VI ans;

int n = 0;
for (int i = 1; n < N; ++i){
    n += i;
    ans.push_back(i);
}

int d = accumulate(ALL(ans), 0) - N;
rep(i, 0, ans.size()){
    if (ans[i] != d) cout << ans[i] << "\n";
}

}

// 境界，出力文字列 チェック



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

int main(){
  string S, T, U;
  int A , B;
  
  cin >> S >> T;
  
  cin >> A >> B;
  
  cin >> U;
  
  if(S == U)
    A--;
  else
    B--;
  
  cout <<  A << " " << B << endl;
  
  
  return 0;

}

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

int N;
string v[200000];
vector<string> ans;
int main(){
  cin>>N;
  REP(i,N){
    cin >> v[i];
  }
  sort(v,v+N);
  ans.push_back(v[0]);
  int count=1,h=1;
  for(int i=1;i<N;++i){
    if(v[i]==v[i-1]){
      ++count;
      if(count==h){ans.push_back(v[i]);}
      else if(count>h){ans.clear();ans.push_back(v[i]);h=count;}
    }else{
      count=1;
      if(h==1){ans.push_back(v[i]);}
    }
  }
  sort(ALL(ans));
  for(string a:ans){cout<<a<<"\n";}
}

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

int main(){
	int n,i,j,minv,maxv;
	int *R;

	scanf("%d",&n);
	R = (int *)malloc(sizeof(int) * n);
	for(i = 0;i < n;i++)
		scanf("%d",&R[i]);

	maxv = R[1]-R[0];
	minv = R[0];
	for(j = 1;j < n;j++){
		if(R[j]-minv > maxv)
			maxv = R[j]-minv;
		if(R[j] < minv)
			minv = R[j];
	}

		printf("%d\n",maxv);

	free(R);
	return 0;
}


Measured memory_bytes: 2272
#include<bits/stdc++.h>
using namespace std ;
int main()
{
    int menu[5] = {0} ;
    for ( int i = 0 ; i < 5 ; i++ )
    {
        cin >> menu[i] ;
    }
    cout << min( min( menu[0],menu[1] ),menu[2] ) + min( menu[3],menu[4] ) - 50 << endl ;

    return 0 ;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
struct Node {
	Node* ch[26];
	int id;
	int spec;
	bool leaf;
};
char str[1000005];
ll ans;
int cnt[1000005][26];
void go(Node* x, int c = -1, Node* p = nullptr) {
	for (int i = 0; i < 26; ++i) {
		if (!x->ch[i]) continue;
		go(x->ch[i], i, x);
		cnt[x->id][i] += x->ch[i]->spec;
		for (int j = 0; j < 26; ++j) {
			cnt[x->id][j] += cnt[x->ch[i]->id][j];
		}
	}
	for (int i = 0; i < 26; ++i) {
		if (!x->ch[i]) continue;
		if (x->ch[i]->leaf) {
			assert(cnt[x->id][i] >= 1);
			ans += cnt[x->id][i] - 1;
		}
	}
}
int main() {
	int n;
	scanf("%d", &n);
	int nid = 1;
	Node* root = new Node();
	for (int i = 0; i < n; ++i) {
		scanf("%s", str);
		int len = strlen(str);
		reverse(str, str + len);
		Node* p = root;
		vector<bool> isLas(len), has(26);
		for (int j = len - 1; j >= 0; --j) {
			if (!has[str[j] - 'a']) {
				isLas[j] = true;
				has[str[j] - 'a'] = true;
			}
		}
		for (int j = 0; j < len; ++j) {
			int x = str[j] - 'a';
			if (!p->ch[x]) {
				p->ch[x] = new Node();
				p->ch[x]->id = nid++;
			}
			p = p->ch[x];
			if (isLas[j]) p->spec++;
		}
		p->leaf = true;
	}
	go(root);
	printf("%lld\n", ans);
}


Measured memory_bytes: 366756
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//int n = sc.nextInt();
		//String[][] array = new String[100][500];
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		int a = sc.nextInt();
		int b = sc.nextInt();

		int c = a*b;
		int d = a+b;
		int e = a-b;

		if(c<d) {
			c=d;
		}

		if(c<e) {
			c=e;
		}

		System.out.println(c);
	}

}

Measured memory_bytes: 22356
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

int dp[2010][2010];

typedef pair<char, int> C;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<char> c(2 * n);
	vector<int> a(2 * n);
	map<C, int> mp;
	rep(i, 2 * n) {
		cin >> c[i] >> a[i];
		mp[C(c[i], a[i])] = i;
	}
	vector<vector<int>> black(n + 1, vector<int>(2 * n));
	vector<vector<int>> white(n + 1, vector<int>(2 * n));
	for (int i = n - 1; i >= 0; i--) {
		bool flag = false;
		for (int j = 0; j < 2 * n; j++) {
			if (flag) {
				black[i][j] = black[i + 1][j] + 1;
			}
			else {
				black[i][j] = black[i + 1][j];
			}
			if (c[j] == 'B'&&a[j] == i + 1) flag = true;
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		bool flag = false;
		for (int j = 0; j < 2 * n; j++) {
			if (flag) {
				white[i][j] = white[i + 1][j] + 1;
			}
			else {
				white[i][j] = white[i + 1][j];
			}
			if (c[j] == 'W'&&a[j] == i + 1) flag = true;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (i != 0 || j != 0) dp[i][j] = INF;
			if (i != 0) {
				int pl = mp[C('B', i)];
				chmin(dp[i][j], dp[i - 1][j] + black[i][pl] + white[j][pl]);
			}
			if (j != 0) {
				int pl = mp[C('W', j)];
				chmin(dp[i][j], dp[i][j - 1] + black[i][pl] + white[j][pl]);
			}
		}
	}
	/*for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			cout << dp[i][j] << ' ';
		}
		cout << endl;
	}*/
	cout << dp[n][n] << endl;
}

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

using namespace std;

#define ll long long;
#define MOD 1000000007;
#define IO \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);

void solve()
{
    int x;
    cin >> x;
    if (x == 0) {
        cout << 1;
    }
    else {
        cout << 0;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    //int t;
    //cin >> t;
    //while (t--) {
        solve();
    //}
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <map>
#include <algorithm>
#include <functional>
#include <string>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
using namespace std;

#define REP(i,p,n) for(ll i=p;i<ll(n);++i)
#define rep(i,n) REP(i,0,n)

using ll = long long int;
using pll = pair<ll, ll>;

int main()
{
    ll X;
    cin >> X;

    ll x = 100, k = 0;
    while (x < X) { x += x / 100; ++k; }

    cout << k << endl;

    return 0;
}


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

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

    int n, k;
    cin >> n >> k;

    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());

    int res = 0;
    rep(i, k){
        res += p[i];
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<string.h>
char* reverse(char *x)
{
    int len = strlen(x);
    int i, n = len / 2;
    char tem;
    for (i = 0; i <= n; i++)
    {
        tem = x[i];
        x[i] = x[len - 1 - i];
        x[len - 1 - i] = tem;
    }
    return x;
}
int main(){
    char a[20];
    scanf("%s",a);
    int x;
    x=strlen(a);
    if(x==3){
        printf("%s\n",reverse(a));
    }
    if(x==2){
        printf("%s\n",a);
    }
    return 0;
}


Measured memory_bytes: 128
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int H, W;
  cin >> H >> W;
  int c[10][10];
  int A[H][W];
  rep(i, 10) rep(j, 10) cin >> c[i][j];
  
  
  rep(k, 10) rep(i, 10) rep(j, 10) 
    if (c[i][j] > c[i][k] + c[k][j]) c[i][j] = c[i][k]+c[k][j];
  int ans = 0;
  rep(i, H) rep(j, W) {
    cin >> A[i][j]; 
    if (A[i][j] == -1) continue;
    else (ans += c[A[i][j]][1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int w, a, b;
    cin >> w >> a >> b;
    int dist = b - a;
    if (dist > 0)
    {
        dist = abs(dist);
        if (dist - w > 0)
        {
            cout << dist - w << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }
    else
    {
        dist = abs(dist);
        if (dist - w > 0)
        {
            cout << dist - w << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6+7;
const int maxm = 2e6+7;
const ll mod = 1e9+7;
int n,m;
int ar[maxn];
int main()
{ 
    scanf("%d", &n);
    for(int i=0;i<n;i++)scanf("%d", ar+i);
    sort(ar, ar+n);
    int ans=0;
    ans = ar[n/2] - ar[n/2-1];
    printf("%d\n", ans);


    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  double dp[223][223];
  fill(dp[0],dp[223],-1e9);
  dp[0][0]=0;
  for(int i=0;i<N;i++){
    int K;
    cin>>K;
    int S[22],H[22];
    for(int j=0;j<K;j++){
      cin>>S[j]>>H[j];
    }
    for(int j=0;j<=M;j++){
      int x=0;
      int t=0;
      int h=0;
      for(int k=0;k+j<=M;k++){
	if(x==K){
	  dp[i+1][j+k]=max(dp[i+1][j+k],dp[i][j]+h);
	  break;
	}
	dp[i+1][j+k]=max(dp[i+1][j+k],dp[i][j]+h+t*1./S[x]);
	t++;
	if(t==H[x]*S[x]){
	  t=0;
	  h+=H[x];
	  x++;
	}
      }
    }
  }
  cout<<fixed<<*max_element(dp[0],dp[223])<<endl;
}
	
	  

Measured memory_bytes: 1628
package main

import "fmt"

func main() {
	var S string
  	fmt.Scan(&S)
  	
  	ans := "Yes"
    if S[0] == S[1] && S[1] == S[2] && S[2] == S[0] {
      ans = "No"
    }
  	fmt.Println(ans)
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

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

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string N; std::cin >> N;

  bool flag = false;
  rep(i, sz(N)) {
    int n = N[i] - '0';
    if ( n == 7 ) flag = true;
  }

  if ( flag ) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}



Measured memory_bytes: 3644
//#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 ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    auto merge = [&](vi &a, int left, int mid, int right) {
        int cnt = 0;
        int n1 = mid - left;
        int n2 = right - mid;
        vi l(n1+1), r(n2+1);
        rep(i, n1) {
            l[i] = a[left+i];
        }
        rep(i, n2) {
            r[i] = a[mid+i];
        }
        l[n1] = INT_MAX;
        r[n2] = INT_MAX;
        int i = 0;
        int j = 0;
        for(int k = left; k < right; k++) {
            if(l[i] <= r[j]) {
                a[k] = l[i++];
            }
            else {
                a[k] = r[j++];
            }
            cnt++;
        }
        return cnt;
    };

    function<int(vi&, int, int)> mergeSort = [&](vi &a, int left, int right) {
        int res = 0;
        if(left+1 < right) {
            int mid = (left + right)/2;
            res += mergeSort(a, left, mid);
            res += mergeSort(a, mid, right);
            res += merge(a, left, mid, right);
        }
        return res;
    };

    int n;
    cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];

    int ans = mergeSort(a, 0, n);
    rep(i, n) cout << a[i] << (i == n-1?'\n':' ');
    cout << ans << endl;

}


Measured memory_bytes: 6788
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v);
#ifdef APURBA
#define HERE cout<<"here - "<<__LINE__<<"\n";
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout<<endl;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cout << *it << " = " << a << " ";
    err(++it, args...);
}
#else
#define HERE
#define debug(args...)
#endif
const ll mod = 998244353 ;
const int N = 1e5+5;
typedef pair<int,int> pii;




void TEST_CASES(int cas)
{
    int n;
    scanf("%d",&n);
    vector<int>a(n);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a.begin(),a.end());
    int ans =0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            for(int k=j+1; k<n; k++)
            {
                if(a[i]!=a[j] && a[j]!=a[k] &&a[i]!=a[k]&& a[i]+a[j] > a[k])
                {
                    debug(i,j,k);
                    ans++;


                }
            }
        }
    }
    printf("%d\n",ans);
}


/*

*/

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        TEST_CASES(++cas);
    }
    return 0;
}



template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}
template <class T1, class T2>
ostream &operator <<(ostream &os, map<T1,T2>&v)
{
    for(auto i:v)
    {
        os<<"Key : "<<i.first<<" , Value : "<<i.second<<endl;
    }
    return os;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=1;
const ll MOD = 1000000007;

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

void Main(){
    ll n;cin>>n;
    vector<ll> a(n),b(n);
    map<pair<ll,ll>,ll> ab;
    ll anszero=0;
    For(i,0,n) {
        cin >> a[i] >> b[i];
        if(a[i]!=0LL && b[i]!=0LL){
            ll sign=1;
            if((a[i]>0LL && b[i]<0LL) || (a[i]<0LL && b[i]>0LL)){//片方だけ負
                sign=-1;
            }
            a[i]=abs(a[i]);
            b[i]=abs(b[i]);
            ll GCD = gcd(a[i],b[i]);
            a[i]/=GCD;
            b[i]/=GCD;
            ab[make_pair(a[i],b[i]*sign)]++;//符号はbに入れる
        }
        else if(a[i]==0LL && b[i]!=0LL){
            ab[make_pair(0,1)]++;
        }
        else if(a[i]!=0LL && b[i]==0LL){
            ab[make_pair(1,0)]++;
        }
        else{
            anszero++;
        }
    }
    for(auto p:ab){
        if(p.second==-1) continue;
        ll A=p.first.first;
        ll B=p.first.second;
        pair<ll,ll> opp;
        if(B<0LL){
            opp = make_pair(-B,A);
        }
        else{
            opp = make_pair(B,-A);
        }
        ll num1=p.second;
        ll num2=ab[opp];
        ll num=modpow(2,num1)+modpow(2,num2)-1;
        num%=MOD;
        ans*=num;
        ans%=MOD;
        ab[p.first]=-1;
        ab[opp]=-1;
    }
    ans--;
    ans+=anszero+MOD;
    ans%=MOD;
    cout << ans << endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 31448
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define P(S) cout<<S<<endl;
#define ll long long
using namespace std;

ll n;
ll d[1010];
vector<ll> num;
int main() {
    cin>>n;
    REP(i, 0, n) cin>>d[i];

    ll size=min(n+1, (ll)7);
    REP(i, 1, size){ // 部分列の大きさ
        REP(j, 0, n-i+1){
            string str="";
            if(i!=1 && d[j]==0) continue; // 2つ以上の文字列で先頭が0

            REP(k, 0, size-i) str+="0";
            REP(k, j, j+i){
                str+=to_string(d[k]);
            }

            num.emplace_back(stoll(str));
        }
    }

    sort(num.begin(), num.end());
    num.erase(unique(num.begin(), num.end()), num.end());
    
    bool flag=false;
    REP(i, 0, num.size()){
        if(num[i]!=i){
            cout<<i<<endl;
            flag=true;
            break;
        }
    }
    if(!flag) cout<<num.size()+1<<endl;
    return 0;
}


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

int main(){
	double w,h,x,y;
    double res;
	cin >> w >> h >> x >> y;
  	res = w*h / 2;
    cout << fixed << setprecision(10) << res << ' ' << (x == w/2 && y == h/2) << endl;
    return 0;
}

Measured memory_bytes: 256
func readArrayInt() -> [Int] {
    readLine()!.split(separator: " ").map({Int($0)!})
}

let line = readArrayInt()
let (N, K) = (line[0], line[1])
var sunukes: Set<Int> = []
(1...N).forEach({sunukes.insert($0)})
for _ in 1...K {
    _ = readLine()
    readArrayInt().forEach({sunukes.remove($0)})
}
print(sunukes.count)


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

const int INF = 1 << 30;
#define SQR(x) ((x)*(x))
int main(){
  int N, W, bm[12], bw[12];

  while(cin >> N >> W, N){
    for(int i = 0; i < N; i++){
      cin >> bm[i];
    }
    for(int i = 0; i < W; i++){
      cin >> bw[i];
    }
    vector< int > dp( 1 << W, -1);
    dp[0] = 0;
    for(int i = 0; i < N; i++){
      for(int j = (1 << W) - 1; j >= 0; j--){
        if(dp[j] == -1) continue;
        for(int k = 0; k < W; k++){
          if((j >> k) & 1) continue;
          dp[j|(1 << k)] = max( dp[j|(1 << k)], dp[j] + abs(bm[i] - bw[k]) * SQR(abs(bm[i] - bw[k]) - 30));
        }
      }
    }
    cout << *max_element( dp.begin(), dp.end()) << endl;
  }
}

Measured memory_bytes: 1212
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Reflection.Metadata;

namespace AtCoder
{
    class Program
    {

        const int BiggestMod = 1000000007;

        public static void Main()
        {

            var num = int.Parse(Console.ReadLine());
            var res = new int[num + 1];

            for (int i = 1; i <= num; i++)
                res[i] = 0;

            for (int i = 1; (i * i + 2 * i) < num; i++)
            {

                for (int j = i; (i * i + j * j + i * j + i + j) < 10000; j++)
                    for (int k = j; k < 10000; k++)
                    {

                        var buf = i * i + j * j + k * k + i * j + j * k + k * i;
                        if (buf > num) break;
                        else
                        {

                            if (i == k) res[buf]++;
                            else if (i == j || j == k) res[buf] += 3;
                            else res[buf] += 6;

                        }


                    }

            }

            for (int i = 1; i <= num; i++)
                Console.WriteLine(res[i]);

        }
    }

}

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

using namespace std;

int main() {
  string S;
  char c = -1;
  bool ans = false;
  
  cin >> S;
  
  c = S.at(0);
  
  for (int i = 0; i < 3; i++) {
    if (c != S.at(i)) {
      ans = true;
    }
  }
  
  cout << (ans ? "Yes" : "No") << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
#define sz(x) (lli)(x.size())
const lli MOD = 1e9 + 7;
// cout << fixed << setprecision(0) << pi <<endl;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// for multiset
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

void solve() {
    lli n, a;
    string st;
    cin >> st;
    if (st[2] == st[3] && st[4] == st[5]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    // lli t; cin >> t; while(t--)
    solve();
    rt;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const int N=100005;
int vis[N],n;
vector<int> v[N];
void dfs(int p,int fa){
	int sum=0;
	for(unsigned i=0;i<v[p].size();i++)if(v[p][i]!=fa){
		dfs(v[p][i],p);
		sum+=vis[v[p][i]];
	}
	if(sum==0)vis[p]=1; else if(sum>1){
		puts("First"); exit(0);
	}
}
int main(){
	n=read();
	for(int i=1;i<n;i++){
		int s=read(),t=read();
		v[s].push_back(t);
		v[t].push_back(s);
	}
	dfs(1,0);
	if(vis[1])puts("First"); else puts("Second");
}


Measured memory_bytes: 6144
#include <stdio.h>
 
int main(){
  int N;
  
  scanf("%d",&N);
  
  if(N >= 100){
    N %= 100;
    if(N >= 10) N %= 10;
  }else if(N >= 10) N %= 10;
  
  if(N == 3) printf("bon\n");
  else if(N == 0 || N == 1 || N == 6 || N == 8) printf("pon\n");
  else printf("hon\n");
  
  return 0;
}

Measured memory_bytes: 1644
import math
n = int(input())
while n != 0:
	s = list(map(float, input().split()))
	m = 0
	for i in range(n):
		m += s[i]
	m /= n
	sd = 0
	for i in range(n):
		sd += (s[i] - m) **2
	sd = math.sqrt(sd / n)
	print('%f' % sd)
	n = int(input())



Measured memory_bytes: 5772
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	int n = read.to!int;
	int m = read.to!int;
	
	bool[][] xs = new bool[][](m, n); // xs[i][j]: 電球iはスイッチjに制御される
	foreach(i; 0 .. m){
		int k = read.to!int;
		foreach(j; 0 .. k){
			int s = read.to!int - 1;
			xs[i][s] = 1;
		}
	}
	int[] ps;
	foreach(i; 0 .. m) ps ~= read.to!int;
	
	int cnt;
	foreach(t; 0 .. 1L<<n){
		bool flag = 1;
		foreach(i; 0 .. m){
			int q;
			foreach(j; 0 .. n){
				if(xs[i][j] && (1L<<j & t)) q += 1;
			}
			if(q % 2 != ps[i]) flag = 0;
		}
		if(flag) cnt += 1;
	}
	
	cnt.writeln;
}


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

using ll=long long;
ll solve(int n,vector<int> &a){
    ll res=0;
    ll seql=n;
    for(int i=n-1;i>=0;i--){
        int x=(i<seql) ? 0 : i-seql;

        if(a[i]==x) continue;
        if(a[i]<x) throw "excep";
        res+=a[i];
        seql=i-a[i];
        if(seql<0){
            throw "excep2";
        }
    }
    return res;
}
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    try{
        cout<<solve(n,a)<<endl;
    }catch(const char *msg){
        cout<<-1<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b){
  if(a < b){ a = b; return true;} return false;
}

int main(){
  int n,we;
  cin >> n >> we;
  vector<long long> w(n);
  vector<long long> v(n);
  for(int i=0;i < n;i++){
    cin >> w.at(i) >> v.at(i);
  }
  vector<vector<long long>> dp(n+1,vector<long long>(we+1,0));
  for(int i=0;i < n;i++){
    for(int j=0;j <= we;j++){
      if(j - w.at(i) >= 0){
        chmax(dp.at(i+1).at(j),dp.at(i).at(j-w.at(i))+v.at(i));
      }
      chmax(dp.at(i+1).at(j),dp.at(i).at(j));
    }
  }
  
   cout << dp.at(n).at(we) << endl;     
      
}

Measured memory_bytes: 80256
N,M = map(int, input().split())
h = list(map(int, input().split()))
ma = [0]*N
for i in range(M):
    a,b = map(int,input().split())
    ma[a-1] = max(ma[a-1],h[b-1])
    ma[b-1] = max(ma[b-1],h[a-1])
ans = 0
for a in range(N):
    if h[a] > ma[a]:
        ans = ans + 1

print(ans)

Measured memory_bytes: 20116
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

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

	int N, Y;
	cin >> N >> Y;

	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
			if(i+j>N){
				break;
			}
			int now = 10000 * i + 5000 * j + (N - i - j) * 1000;
			if(now==Y){
				cout << i << " " << j << " " << N - i - j << endl;
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");

	return 0;
}

Measured memory_bytes: 256
#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.at(i);
  }
  
  sort(P.begin(), P.end());
  
  int ans = 0;
  
  for(int i = 0; i < K; i++) {
    ans += P.at(i);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	string s; cin >> s;
	if( s[0] == s[1] || s[1] == s[2] || s[2] == s[3] ) cout << "Bad" << endl;
	else cout << "Good" << 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 all(x) (x).begin(),(x).end()
typedef long long lint;

#define N 6208
 
int main() {
  lint x;
  cin >> x;
  
  lint a,b,c;
  rep(i,N){
    rep(j,N){
      if(i*i*i*i*i-j*j*j*j*j == x){
        cout << i << " " << j << endl;
        return 0;
      }
      if(i*i*i*i*i+j*j*j*j*j == x){
        cout << i << " " << -j << endl;
        return 0;
      }
      
    }
  }
  
  rep(i,N){
    rep(j,N){
      if(-i*i*i*i*i+j*j*j*j*j == x){
        cout << -i << " " << -j << endl;
        return 0;
      }
      
    }
  }
}



Measured memory_bytes: 3636
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : m : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    r :: Int
    r = n - sum as
  print $ if r < 0 then -1 else r

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


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

int main(){
  int n, m;
  int num = 0;
  ll sum = 0;
  cin >> n >> m;
  std::priority_queue<int> q;
  rep(i,n) {
    cin >> num;
    q.push(num);
  }
  rep(i, m){
    num = q.top();
    q.pop();
    num /= 2;
    q.push(num);
  }
  rep(i, n) {
    sum += q.top();
    q.pop();
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace std;
using namespace chrono;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
mt19937 rng(high_resolution_clock::now().time_since_epoch().count());
mt19937_64 rngll(high_resolution_clock::now().time_since_epoch().count());
template<typename T> T ctmax(T &x, const T &y){ return x = max(x, y); }
template<typename T> T ctmin(T &x, const T &y){ return x = min(x, y); }
template<typename T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for(auto i = 0; i < n; ++ i){
		cin >> h[i];
	}
	const int inf = numeric_limits<int>::max() / 2;
	vector<int> dp(n, inf);
	dp[0] = 0;
	for(auto i = 1; i < n; ++ i){
		for(auto j = 1; j <= min(k, i); ++ j){
			ctmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
		}
	}
	cout << dp.back();
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod = 1e9+7;

ll a,b;

ll f(ll x){
	int r = (x+1) % 4;
	if(r == 0)return 0;
	if(r == 1)return x;
	if(r == 2)return 1;
	else return x+1;
}


int main(){
	cin >> a >> b;
	ll ans = f(a-1)^f(b);
	cout << ans << endl;
}

Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

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

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll k; cin >> k;
    if(k == 7 || k == 1){
        cout << 1 << "\n";
        return 0;
    }
    if(k % 7 == 0) k /= 7;
    ll t = 1;
    rep(i,1,k+100){
        if(t == 0){
            cout << i << "\n";
            return 0;
        }
        t = t * 10 + 1;
        t %= k;
    }

    cout << -1 << "\n";
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

    int s, w;
    cin >> s >> w;

    cout << ((s > w) ? "safe":"unsafe");


    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1061109567
#define pb push_back
#define in(s) freopen(s,"r",stdin);
#define out(s) freopen(s,"w",stdout);
#define fi first
#define se second
#define bw(i,r,l) for (int i=r-1;i>=l;i--)
#define fw(i,l,r) for (int i=l;i<r;i++)
#define fa(i,x) for (auto i:x)
using namespace std;
const int N=205;
struct dinic {
	int s,t,d[N];
	vector<int> G[N];
	dinic(int s=0,int t=0): s(s),t(t) {};
	struct edge {
		int u,v,c,f,rev;
		edge(int u,int v,int c,int f,int rev): u(u),v(v),c(c),f(f),rev(rev) {};
	};
	vector<edge> e;
	void addEdge(int u,int v,int w) {
		G[u].pb(e.size()); e.pb(edge(u,v,w,0,e.size()+1));
		G[v].pb(e.size()); e.pb(edge(v,u,0,0,e.size()-1));
	}
	bool bfs() {
		memset(d,63,sizeof(d));
		d[s]=0;
		queue<int> q; q.push(s);
		while (!q.empty()) {
			int u=q.front(); q.pop();
			fa (i,G[u]) if (d[e[i].v]==INF&&e[i].f<e[i].c) d[e[i].v]=d[u]+1,q.push(e[i].v);
		}
		return d[t]!=INF;
	}
	void modify(int val,int id) {e[id].f+=val; e[e[id].rev].f-=val;}
	int dfs(int u,int flow) {
		if (u==t||!flow) return flow;
		fa (i,G[u]) {
			if (e[i].f>=e[i].c||d[e[i].v]!=d[u]+1) continue;
			int nxt=dfs(e[i].v,min(flow,e[i].c-e[i].f));
			if (nxt) {
				modify(nxt,i);
				return nxt;
			}
		}
		return 0;
	}
	int get() {
		while (bfs()) while (dfs(s,INF));
		int ans=0;
		fa (v,G[s]) {
			ans+=e[v].f;
		}
		return ans;
	}
} mf;
int n,a[N],b[N],c[N],d[N];
signed main() {
	//in("aome.inp");
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin>>n;
	mf=dinic(0,2*n+1);
	fw (i,1,n+1) cin>>a[i]>>b[i];
	fw (i,1,n+1) cin>>c[i]>>d[i];
	fw (i,1,n+1) {
		mf.addEdge(0,i,1);
		mf.addEdge(i+n,2*n+1,1);
	}
	fw (i,1,n+1) {
		fw (j,1,n+1) if (a[i]<c[j]&&b[i]<d[j]) {
			mf.addEdge(i,j+n,1);
			//cout<<"Edge is made between "<<i<<" and "<<j+n<<"\n";
		}
	}
	cout<<mf.get();
	return 0;
}

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

int main(){
  vector<int> a(100000);
  int n; cin >> n;
  map<int, int> mp;
  rep(i,n) cin >> a.at(i);
  rep(i,n) mp[a[i]]++;

  int count = 0;

  for(auto p : mp){
    int x = p.first;
    int y = p.second;

    if(x < y) {
      count += y - x;
    }
    if(x > y) {
      count += y;
    }
  }

  cout << count << endl;
}



Measured memory_bytes: 5120
N = int(input())
ans = list(map(int, input().split()))
for _ in range(1, N):
    a, b, c = map(int, input().split())
    tmpa, tmpb, tmpc = ans
    ans[0] = a + max(tmpb, tmpc)
    ans[1] = b + max(tmpa, tmpc)
    ans[2] = c + max(tmpa, tmpb)

print(max(ans))

Measured memory_bytes: 3060
#include <cstdio>

#define MAX_N 100000
#define MAX_NAME 10

typedef struct Queue {
	char name[MAX_NAME];
	int time;
	struct Queue *qnext;
	struct Queue *qprev;
}Queue;

int main() {
	int n, q;
	int sum = 0;
	Queue *pPoint;
	int sTime = 0;

	scanf("%d %d", &n, &q);

	Queue *queue = new Queue[n];
	if (NULL == queue) {
		return -1;
	}

	//　Queueの初期化処理
	for (int i = 0; i < n; i++) {
		if (i == 0) {
			if (n > 1) {
				queue[i].qprev = queue + (n - 1);
				queue[i].qnext = queue + (i + 1);
			}
			else {
				queue[i].qprev = NULL;
				queue[i].qnext = NULL;
			}
		}
		else if (i == (n - 1)) {
			queue[i].qnext = queue;
			queue[i].qprev = queue + (i - 1);
		}
		else {
			queue[i].qprev = queue + (i - 1);
			queue[i].qnext = queue + (i + 1);
		}
		scanf("%s", &(queue[i].name));
		scanf("%d", &(queue[i].time));
		sum += queue[i].time;
	}

	Queue *tmpQ;
	pPoint = queue;
	while (sum > 0) {
		if (pPoint->time <= q) {
			sTime += pPoint->time;
			printf("%s %d\n", pPoint->name, sTime);
			sum -= pPoint->time;
			// prev, next を外す
			tmpQ = pPoint;
			if (tmpQ->qnext != NULL) {
				pPoint = tmpQ->qnext;
				pPoint->qprev = tmpQ->qprev;
				pPoint->qprev->qnext = pPoint;
			}
		}
		else {
			pPoint->time -= q;
			sTime += q;
			sum -= q;
			if (pPoint->qnext != NULL) {
				pPoint = pPoint->qnext;
			}
		}
	}
	delete[] queue;
	return 0;
}



Measured memory_bytes: 3876
#include <stdio.h>
#include <iostream>
using namespace std;

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

Measured memory_bytes: 1156
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    ld kek = 0;
    while (n--) {
        ld a;
        cin >> a;
        kek += 1 / a;
    }
    cout << fixed << setprecision(20) << 1 / kek;
    return 0;
}

Measured memory_bytes: 256
<?php

$count = trim(fgets(STDIN));
$a = strlen($count);//文字列の長さ
$c = str_split($count);//一文字ずつ区切った

//Aの位置とZの位置を求めてZ-Aをすれば長さが出てきそう
$str = strpos($count, "A");
$str =  $str+1;
// var_dump($str);//Aの位置
// echo $str;
//検索をA以降のカウントにしたら行けそう
for($i=0; $i< $a; $i++){
    if($count[$i] == "Z"){
        $g = $i;
    }
}

$g =  $g+1;

echo $g - $str+1;

Measured memory_bytes: 38828