akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int input_x[2999], input_y[2999];

small_replacement_output(int i) {
	if (input_x[i] > input_y[i])
		printf("%d %d\n", input_y[i], input_x[i]);
	else
		printf("%d %d\n", input_x[i], input_y[i]);
}

int main() {
	for (int set_num = 0; set_num < 3000; set_num++) {
		scanf("%d %d", &input_x[set_num], &input_y[set_num]);
		if (input_x[set_num] == 0 && input_y[set_num] == 0) break;
		small_replacement_output(set_num);
	}
	return 0;
}


Measured memory_bytes: 2060
#include <algorithm>
#include <vector>
#include <cfloat>
#include <string>
#include <cmath>
#include <set>
#include <cstdlib>
#include <map>
#include <ctime>
#include <iomanip>
#include <functional>
#include <deque>
#include <iostream>
#include <cstring>
#include <queue>
#include <cstdio>
#include <stack>
#include <climits>
#include <sys/time.h>
#include <cctype>

using namespace std;

typedef long long ll;


int main() {
  int r, n;
  while(true) {
    cin >> r >> n;
    if (r == 0 && n == 0) break;
    int x[42];
    memset(x, 0, sizeof(x));
    for (int i = 0; i < n; i++) {
      int xl, xr, h;
      cin >> xl >> xr >> h;
      for (int j = xl; j < xr; j++) {
        x[j+20] = max(x[j+20], h);
      }
    }


    double ans = 1000;
    for (int i = -r; i < r; i++) {
      int p;
      if (i < 0) {
        p = i+1;
      }else {
        p = i;
      }
      ans = min(ans, x[i+20]+r-sqrt(r*r-p*p));

    }
    printf("%.9lf\n", ans);
  }
}

Measured memory_bytes: 1196
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <ctime>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;

#define X first
#define Y second
#define Mod 1000000007
#define N 100010
#define M 101

typedef long long ll;

const int INF=1<<30;

int n;
int l[N],r[N];
priority_queue<ll, vector<ll>, greater<ll> > qr;
priority_queue<ll> ql;

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d%d",&l[i],&r[i]);
	
	ll dell=0,delr=0,ans=0;
	ql.push(l[1]); qr.push(l[1]);
	for (int i=2;i<=n;i++)
	{
		dell-=r[i]-l[i];
		delr+=r[i-1]-l[i-1];
		//cout<<i<<" "<<l[i]<<" "<<ql.top()+dell<<" "<<qr.top()+delr<<endl;
		if (l[i]>qr.top()+delr)
		{
			ans+=l[i]-qr.top()-delr;
			qr.push(l[i]-delr);
			qr.push(l[i]-delr);
			ql.push(qr.top()+delr-dell);
			qr.pop();
			//cout<<"case1"<<endl;
		}
		else if (l[i]<ql.top()+dell)
		{
			ans+=ql.top()+dell-l[i];
			ql.push(l[i]-dell);
			ql.push(l[i]-dell);
			qr.push(ql.top()+dell-delr);
			//cout<<"case2 "<<ql.top()+dell<<" "<<-delr<<endl;
			ql.pop();
		}
		else
		{
			ql.push(l[i]-dell);
			qr.push(l[i]-delr);
		}
		//cout<<i<<" "<<l[i]<<" "<<ql.top()+dell<<" "<<qr.top()+delr<<endl;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2804
#include <iostream>
#include <cstring>
#include <utility>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


int N, W;
vector<int> w;
vector<int> v;


long long memo[101][100001];
long long dp[101][100001];


long long get_max_value(int i, int maxW) {
    if (i == N) {
        return 0;
    } else {
        long long a = v[i] + get_max_value(i+1, maxW - w[i]);
        long long b = get_max_value(i+1, maxW);

        if (w[i] > maxW) {
            return b;
        } else {
            return max(a, b);
        }
    }
}



long long get_max_value_using_memo_cache(int i, int maxW) {
    if (memo[i][maxW] != -1) {
        return memo[i][maxW];
    }

    if (i == N) {
        return 0;
    } else {
        long long ans;
        long long b = get_max_value_using_memo_cache(i+1, maxW);

        if (w[i] > maxW) {
            ans = b;
        } else {
            long long a = v[i] + get_max_value_using_memo_cache(i+1, maxW - w[i]);
            ans = max(a, b);
        }

        memo[i][maxW] = ans;
        return ans;
    }
}



int main() {
    cin >> N >> W;
    w.resize(N);
    v.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> w[i] >> v[i];
    }

    // recursive
    // long long ans = get_max_value(0, W);

    // memo
    // memset(memo, -1, sizeof(memo));
    // long long ans = get_max_value_using_memo_cache(0, W);
   
    // DP
    //vector<long long> (W)
    //vector<long long> W(N, -1);
    //vector<T> dp(N, T(W));
    //vector<vector<long long>> dp(N+1, vector<long long> (W+1));

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            if (w[i-1] <= j) { // i-1が入りうるとき
                long long a = v[i-1] + dp[i-1][j-w[i-1]];
                dp[i][j] = max(a, dp[i-1][j]);
            } else {
                dp[i][j] = dp[i-1][j];
            }
        }
    }
    long long ans = dp[N][W];

    cout << ans;
    return 0;
}




Measured memory_bytes: 79360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 8005, mod = 1e9+7;
vector<int> vec[2];
int n, dest[2], dp[N][N][2], cur;
string s;
int sol(int i, int pos, int bit)
{
	if(i == vec[cur].size())
	{
		if(dest[cur] == pos * (bit? -1 : 1)) return 1;
		else return 0;
	}
	int &ret = dp[i][pos][bit];
	if(ret != -1) return ret;
	ret = sol(i+1, pos+vec[cur][i], bit);
	if(!cur && !i && s[0] != 'T') return ret;
	pos -= vec[cur][i];
	if(pos <= 0) pos = abs(pos), bit ^= 1;
	ret = max(ret, sol(i+1, pos, bit));
	return ret;
}
int main()
{
	memset(dp, -1, sizeof dp);
	cin >> s;
	cin >> dest[0] >> dest[1];
	n = s.size();
	int cnt = 0;
	for(int i=0; i<n; i++)
	{
	 	if(s[i] == 'T')
		{
			if(cnt) vec[cur].push_back(cnt), cnt = 0;
			cur ^= 1;
		}
		else cnt++;
	}
	if(cnt) vec[cur].push_back(cnt), cnt = 0;
	cur = 0;
	int tmp1 = sol(0, 0, 0);
	memset(dp, -1, sizeof dp);
	cur = 1;
	int tmp2 = sol(0, 0, 0);
	if(tmp1 && tmp2) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(){
    long long a, b;
    cin >> a >> b;
    long long ans = 0;
    for(long long i = a; i <= b; i++){
        string t = to_string(i);
        if((t.at(0) == t.at(4)) && (t.at(1) == t.at(3))){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int judge = sc.nextInt(); //整数の入力
		if (judge == 1) {
			System.out.println("Hello World");
		} else {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a + b);
		}
	}
}

Measured memory_bytes: 21716
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {

	reader := bufio.NewReader(os.Stdin)
	tmp, _ := reader.ReadString('\n')
	s := strings.Trim(tmp, "\n")

	for i := 0; i < len(s)-1; i++ {
		if s[i] == s[i+1] {
			fmt.Println("Bad")
			return
		}
	}
	fmt.Println("Good")

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	string s;
	cin >> s;
	int ans;
	if(s == "SUN") ans = 7;
	if(s[0] == 'M') ans = 6;
	if(s == "TUE") ans = 5;
	if(s[0] == 'W') ans = 4;
	if(s == "THU") ans = 3;
	if(s == "FRI") ans = 2;
	if(s == "SAT") ans = 1;
	cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
#include <map>


typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair
#define mkt make_tuple

using namespace std;
int const N = 200005;
int add[N]; bool was[N];
vector<vector<int>> v;

void dfs(int u) {
	was[u] = true;
	for (int i : v[u])
		if (!was[i]) {
			add[i] += add[u];
			dfs(i);
		}
}

int main()
{
	ll n, q;
	cin >> n >> q; 
	for (int i = 0; i < n; i++)
		v.push_back(vector<int>());
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	for (int i = 0; i < q; i++) {
		int p, x;
		cin >> p >> x; p--;
		add[p] += x;
	}

	dfs(0);

	for (int i = 0; i < n; i++)
		cout << add[i] << ' ';
}



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

int main()
{
    string s;
    int n,i,ans=0,res=0;
    cin>>s;
    n=s.size();
    for(i=0;i<n;i++){
        if(s[i]=='R')res++;
        else{
            ans=max(ans,res);
            res=0;
        }
    }
    cout<<max(ans,res);
}

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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll n, k;cin >> n >> k;
    vector<ll> h(n);rep(i,n)cin >> h[i];
    sort(h.rbegin(),h.rend());
    ll ans = 0;
    if(n<=k)
    {
        cout << 0 << endl;
        return 0;
    }
    for (int i = k; i < n; i++)
    {
        ans += h[i];
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4768
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  int T_HP, T_ATK, A_HP, A_ATK;
  scanf("%d %d %d %d", &T_HP, &T_ATK, &A_HP, &A_ATK);
  while( T_HP > 0 && A_HP > 0){
    A_HP -= T_ATK;
    if(A_HP <= 0){
      printf("Yes\n");
      break;
    }
    T_HP -= A_ATK;
    if(T_HP <= 0){
      printf("No\n");
      break;
    }

  }
  return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000001
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 1000001;
const ll M = 1;

struct point {
    ll x, y;
};

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    else if(n & 1)
        return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll tmp = fast_exp(x, n >> 1);
        return tmp * tmp % mod;
    }
}

bool c(string &s, ll l, ll r)
{
    ll n = r + l;
    for(int i = l; i <= r; i++)
    {
        if(s[i] != s[n - i]) return false;
    }
    return true;
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    while(_--)
    {
        ll n, m = 0, ans = 0, x, y, k, v;
        string s;
        cin >> s;
        n = s.size();
        if(c(s, 0, n - 1) && c(s, 0, n / 2 - 1) && c(s, n / 2 + 1, n - 1))
            cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <string>
    #include <set>  
    #include <algorithm>
    #include <vector>
    #include <cmath>
    #include <queue>
    #include <deque>
    #include <cstring>
    #include <cstdio>
    #include <map>
    #include <numeric>
	#include <cassert>
    #include <iomanip>
    #include <sstream>
using namespace std;
const int MAXN=1e6+10;
long long a[MAXN];
long long n,k;
int main()
{
	cin>>n>>k;
	cin>>a[0]>>a[1];
	long long Gcd=__gcd(a[0],a[1]);
	for(int i=2;i<n;i++)
	{
		cin>>a[i];
		Gcd=__gcd(a[i],Gcd);
	}
	sort(a,a+n);
	if(a[n-1]<k)cout<<"IMPOSSIBLE"<<endl;
	else if(Gcd==1)cout<<"POSSIBLE"<<endl;
	else cout<<((!(k%Gcd))?"POSSIBLE":"IMPOSSIBLE")<<endl;
	return 0;
}

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

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

using namespace std;

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

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

#define ALL(x) (x).begin(), (x).end()
template<class T>
using vc = vector<T>;
using vi = vc<int>;
using vvi = vc<vi>;

using ll = long long;


int main() {
    while (true) {
        string s;
        int    m;
        cin >> s >> m;
        if (s == "-") break;
        REP(i, m) {
            int h;
            cin >> h;
            s = s.substr(h) + s.substr(0, h);
        }
        cout << s << "\n";
    }
    return 0;
}



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

#ifdef ONLINE_JUDGE
#define freopen \
  if (0) freopen
#define cerr \
  if (0) cerr
#endif

#define fi first
#define se second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)

#define sqr(a) ((a)*1ll * (a))
#define sz(a) (int)a.size()
#define len(a) (int)a.length()
#define all(a) a.begin(), a.end()
#define nl '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pi;

const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

vector<int> z_func(string &s) {
  vector<int> z(len(s), 0);
  int l = 0, r = 1;

  rep(i, 1, sz(z) - 1) {
    if (i >= r) {
      l = r = i;
      while (i + z[i] < len(s) && s[z[i]] == s[i + z[i]]) z[i]++, r++;
    } else if (z[i - l] < r - i) {
      z[i] = z[i - l];
    } else {
      z[i] = r - i;
      l = i;
      while (i + z[i] < len(s) && s[z[i]] == s[i + z[i]]) z[i]++, r++;
    }
  }

  return z;
}

bool is_good(string s) {
  auto z = z_func(s);
  rep(i, 1, len(s) / 2) {
    bool can_divide = len(s) % i == 0 && z[i] == i * (len(s) / i - 1);
    if (can_divide) return false;
  }
  return true;
}

void solve() {
  string s;
  cin >> s;

  string rev_s = s;
  reverse(all(rev_s));

  auto z = z_func(s);
  auto rev_z = z_func(rev_s);

  rep(i, 1, len(s) / 2) {
    bool can_divide = len(s) % i == 0 && z[i] == i * (len(s) / i - 1);
    if (!can_divide) continue;

    if (i == 1) {
      cout << len(s) << nl << 1;
      return;
    } 

    vector<bool> can_divide_left(sz(z), true);
    can_divide_left[0] = false;
    rep(j, 1, sz(z) - 1) {
      if (z[j] >= j) {
        for (int k = j; k < j + z[j]; k += j)
          if (k + j < sz(z) && z[k] >= j)
            can_divide_left[k + j] = false;
          else
            break;
      }
    }

    vector<bool> can_divide_right(sz(z), true);
    can_divide_right[sz(z) - 1] = false;
    per(j, sz(z) - 2, 0) {
      int l = len(s) - j - 1;
      if (rev_z[l] >= l) {
        for (int k = j; k > j - rev_z[l]; k -= l)
          if (k - l >= 0 && rev_z[len(s) - k - 1] >= l)
            can_divide_right[k - l] = false;
          else
            break;
      }
    }

    int res = 0;
    rep(j, 1, len(s) - 1) {
      if (can_divide_left[j] && can_divide_right[j - 1]) {
        res++;
      }
    }

    cout << 2 << nl << res;
    return;
  }

  cout << 1 << nl << 1;
}

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

  freopen(".in", "r", stdin);

  solve();

  return 0;
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;

const double EPS = 1e-10;

const int M = 300;
const int T = 50;
const int P = 10;
const int R = 2000;
int m, t, p, r;

typedef struct team_def {
  int idx;  //index of the team
  int tac;  //total number of AC
  int tt;   //total time with penalty
  team_def() {idx = tac = tt = 0;}
  team_def(int _idx, int _tac, int _tt) {
    idx = _idx;
    tac = _tac;
    tt  = _tt;
  }
} team;

int my_compare(const void *pl, const void *pr) {
  team *tl = (team *)pl;
  team *tr = (team *)pr;
  
  if (tl->tac < tr->tac)
    return 1;
  else if (tl->tac > tr->tac)
    return -1;

  if (tl->tt < tr->tt)
    return -1;
  else if (tl->tt > tr->tt)
    return 1;

  if (tl->idx < tr->idx)
    return 1;
  else if (tl->idx > tr->idx)
    return -1;

  return 0;
}

int ac[T][P]; //1:AC, 0:not AC
int wa[T][P]; //time with penalty
team tms[T];

int main() {
  int i, j;

  while (1) {
    memset(ac, 0, sizeof(ac));
    memset(wa, 0, sizeof(wa));
    scanf("%d%d%d%d ", &m, &t, &p, &r);
    if (!m && !p && !t && !r) break;
    for (i=0; i<r; i++) {
      int mm, tt, pp, rr;
      scanf("%d%d%d%d ", &mm, &tt, &pp, &rr);
      tt--; pp--;
      if (!rr) {
        ac[tt][pp] = 1; 
        wa[tt][pp] += mm;
      } else
        wa[tt][pp] += 20;
    }

    for (i=0; i<t; i++) {
      tms[i].idx = i; 
      tms[i].tac = tms[i].tt = 0;
    }
    for (i=0; i<t; i++)
      for (j=0; j<p; j++) {
        if (ac[i][j]) {
          tms[i].tac++;
          tms[i].tt += wa[i][j];
        }
      }

    qsort(tms, t, sizeof(team), my_compare);

    printf("%d", tms[0].idx + 1);
    for (i=1; i<t; i++) {
      if (tms[i].tac == tms[i-1].tac && tms[i].tt == tms[i-1].tt)
        printf("=");
      else
        printf(",");
      printf("%d", tms[i].idx + 1);
    }
    printf("\n");
  }

  return 0;
}

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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(),vec.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define SZ(x) (int)x.size()

typedef  vector<string> vs;
typedef  vector<int> vi;


int main(){

	int x1 , y1 , x2 , y2 ; 

	cin >> x1 >> y1 >> x2 >> y2; 
	
	
	int x3  = y1 + x2 - y2 ; 
	
	int y3 =  x2 + y2 - x1 ; 
	
	int y4 = x3 + y2  - x1 ; 
	
	int x4 =  y1 + x2 - y3 ; 
	
	cout << x3 << " " << y3 <<" " << x4<< " " << y4 << endl;
 	

 return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)

int n;
vector<vector<pair<int,int>>> adj;
int tot_col;
vi deg;
vi col;
void dfs(int root,int prev,int prev_col)
{
    int cur = (prev_col + 1)%tot_col;
    for(auto x : adj[root])
    {
        if(x.ff != prev)
        {
           col[x.ss] = (cur)%tot_col;
           dfs(x.ff,root,(cur)%tot_col);
           cur++;
           cur %= tot_col;
        }
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    adj.resize(n);
    col.resize(n - 1);
    deg.resize(n);
    for(int i = 0; i < n - 1; ++i)
    {
        int x,y;
        cin >> x >> y;
        --x, --y;
        adj[x].push_back({y,i});
        adj[y].push_back({x,i});
        deg[x]++,deg[y]++;
    }
    tot_col = *max_element(all(deg));
    
    dfs(0,-1,-1);
    cout << tot_col << '\n';
    for(auto x : col)
    {
        cout << x + 1 << '\n';
    }
}

Measured memory_bytes: 9600
# B - Multiplication 2
N = int(input())
A = list(map(int,input().split()))

def ans():
    global N,A
    for i in range(N):
        if A[i]==0:
            return 0
    tmp = 1
    for i in range(N):
        tmp *= A[i]
        if tmp>10**18:
            return -1
    return tmp

print(ans())

Measured memory_bytes: 21696
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#ifdef LOCAL
#define debug(x) (cerr << "Line " <<  __LINE__ << ": " << #x << " = " << (x) << endl)
template<typename... Args> void print(Args... args) { ((cout << args << " "), ...); }
#endif
#define ls (i << 1)
#define rs (i << 1 | 1)
#define MID (l + ((r - l) >> 1))
void updateMax(int& a, int b) { if (a < b) a = b; }
void updateMin(int& a, int b) { if (a > b) a = b; }
void add(int& a, int b) { a += b; if (a >= MOD) a -= MOD; }
void sub(int& a, int b) { a -= b; if (a < 0) a += MOD; }
void updateMax(ll& a, ll b) { if (a < b) a = b; }
void updateMin(ll& a, ll b) { if (a > b) a = b; }

const int N = 16;
int n;

/*
    pre[mask]:
        the value we would get if we group rabbits that are in 
        'mask' into one group
 */
ll pre[1 << N];

/* 
    dp[mask]:
        the max value that we can obtain after having determined
        the grouping of rabbits that are in 'mask'
 */
ll dp[1 << N];

int a[N][N];

void dfs(const vector<int>& v, const int& mask, int sel, int i) {
    if (i == (int) v.size()) {
        updateMax(dp[mask | sel], dp[mask] + pre[sel]);
        return;
    }
    dfs(v, mask, sel, i + 1);
    dfs(v, mask, sel | (1 << v[i]), i + 1);
}

void solve() {
    memset(pre, 0, sizeof pre);
    memset(dp, 0, sizeof dp);

    // we first precalculate the 'pre' array
    for (int sel = 0; sel < (1 << n); ++sel) {
        for (int i = 0; i < n; ++i) {
            if (sel & (1 << i)) continue;
            if (pre[sel | (1 << i)]) continue;
            ll delta = 0;
            for (int j = 0; j < n; ++j) {
                if (sel & (1 << j)) {
                    delta += a[i][j];
                }
            }
            pre[sel | (1 << i)] = pre[sel] + delta;
        }
    }

    // then dp the solution
    for (int mask = 0; mask < (1 << n); ++mask) {
        vector<int> unused(n - __builtin_popcount(mask), 0);
        for (int i = 0, cnt = 0; i < n; ++i) {
            if (!(mask & (1 << i))) {
                unused[cnt++] = i;
            }
        }
        dfs(unused, mask, 0, 0);
    }

    printf("%lld\n", dp[(1 << n) - 1]);
}

int main() {
    // ios::sync_with_stdio(false);
    // cin.tie(nullptr);
    while (~scanf("%d", &n)) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                scanf("%d", a[i] + j);
            }
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
const int N=2e2+20;
const int inf=1e9;
int dist[N][N];//dist[u][v] u->v shortest path
struct edge{
	int a,b,c;
}e[1100];
int n,m;
void Floyd()
{
	for(int k=1;k<=n;k++)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=n;j++)
			{
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);		
			}
		}
	}
}
int main()
{
	while(cin>>n>>m)
	{
		for(int i=1;i<=n;i++)
		{	
			for(int j=1;j<=n;j++)
			{
				if(i==j)
				dist[i][j]=0;
				else
				dist[i][j]=inf;
			}
		}
		for(int i=0;i<m;i++)
		{
			cin>>e[i].a>>e[i].b>>e[i].c;	
			dist[e[i].a][e[i].b]=e[i].c;//无中间结点 
			dist[e[i].b][e[i].a]=e[i].c;
		}
		Floyd();
	
		int ans=m;   
		for(int i=0;i<m;i++)
		{
			bool flag=false;
			for(int s=1;s<=n;s++)
			{
				int u=e[i].a,v=e[i].b,w=e[i].c;
				if(dist[s][u]+w==dist[s][v])
				flag=true;
			}
			if(flag)
			ans--;
		} 
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
x,y,z,k=map(int,input().split())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
a.sort(reverse=True)
b.sort(reverse=True)
c.sort(reverse=True)

d=[]
for i in range(min(k,x)):
    for j in range(min(k,y)):
        d.append(a[i]+b[j])
d.sort(reverse=True)

e=[]
for i in range(min(k,x*y)):
    for j in range(min(k,z)):
        e.append(d[i]+c[j])
e.sort(reverse=True)

for i in range(min(k,x*y*z)):
    print(e[i])



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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	int w, a, b; cin >> w >> a >> b;
	if (a < b)
		cout << max(0, b-(a+w));
	else
		cout << max(0, a-(b+w));
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

using namespace std;

vector< vector<long> > g;
vector< vector<long> > dist;
long n,m,s,t;
long min_d = LONG_MAX;

void print_dist() {
	cout << "dist : " << endl;
	for (auto i : dist ) {
		for (auto j : i ) {
			cout << j << " ";
		}
		cout << endl;
	}
	cout << endl;
}


void bfs(queue<pair<long,long>>& q) {
	while( ! q.empty() ) {
		long i = q.front().first;
		long d = q.front().second;
		q.pop();

		//cout << i << " => " ;
		for (auto j : g[i]) {
		//	cout << j << " ";
			if( dist[j][(d+1)%3] == -1 ) {
				dist[j][(d+1)%3] = d+1;
				q.push( make_pair(j,d+1%3));
			}
		}
		//cout << endl;
		//print_dist();
	}
}

int main(void) {
	cin >> n >> m;
	dist = vector< vector<long> > (n+1, vector<long>(3,-1));
	g = vector< vector<long> >(n+1);

	for (long i=0; i<m; i++) {
		long u,v;
		cin >> u >> v;
		g[u].push_back(v);
	}

	cin >> s >> t;

	queue<pair<long,long>> q;
	q.push(make_pair(s,0));
	bfs(q);
	
//	for (long i=1; i<n; i++) {
//		cout << i << " => ";
//		for (auto j : g[i] ) {
//			cout << j << " ";
//		}
//		cout << endl;
//	}


	cout << (dist[t][0]>0 ? dist[t][0]/3 : -1) << endl;
}



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

int main() {
  
  int a, b, c;
  cin >> a >> b >> c;
  
  if(a == b && b == c) cout << "No" << endl; 
  else if(a != b && b != c && c != a) cout << "No" << endl; 
  else cout << "Yes" << endl; 
}

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

#define _CRT_SECURE_NO_WARNINGS

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

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

using LL = long long int;
using LD = long double;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

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

	string s;
	cin >> s;

	int c = 0, f = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'C') {
			c++;
		} else if (s[i] == 'F' && 0 < c) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<utility>
#include<vector>


using namespace std;

int main(void){
    int N,K;
    scanf("%d %d",&N,&K);
    int p[N];
    double c[N];

    for(int i=0;i<N;i++){
        scanf("%d",&p[i]);
        c[i] = (p[i]+1.0)/2;
    }
    double maxsum = 0;
    double sum = 0;
    for(int i=0;i<K;i++){
        maxsum += c[i];
        sum += c[i];
    }

    for(int i=K;i<N;i++){
        sum += c[i]-c[i-K];
        if(maxsum<sum){
            maxsum = sum;
        }
    }
    printf("%lf",maxsum);


    return 0;
}

Measured memory_bytes: 2560
n,m = map(int,input().split())
p_list = [input().split() for i in range(m)]

ans_list = [[0 for i in range(2)] for j in range(n)]
#print(ans_list[0])
for i in range(m):
    p_num = int(p_list[i][0])
    if ans_list[p_num-1][0] != 1:
        if p_list[i][1] == "WA":
            ans_list[p_num-1][1]  =  ans_list[p_num-1][1] + 1
        else:
            ans_list[p_num-1][0]  = 1
count1 = 0
count2 = 0
for i in range(n):
    if ans_list[i][0] == 1:
        count1 += 1
        count2 += ans_list[i][1]
print(count1,count2)


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    sum += p[i];
  }
  sort(p.begin(), p.end());
  sum -= (p[N-1]/2);
  cout << sum << endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int X=cin.ReadInt;
            bool flag = false;
            if (X == 2)
            {
                Console.WriteLine(X.ToString());
            }else if(X!=2){
                while (flag == false)
                {
                    for (int i = 2; i < X; i++)
                    {
                        if (X % i == 0)
                        {
                            X += 1;
                            break;
                        }
                        else if (i == X - 1)
                        {
                            flag = true;
                            break;
                        }
                    }
                }
                Console.WriteLine(X.ToString());

            }



        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

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

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main()
{
	int n;
	cin>>n;
	vector<ll> a(n+1),b(n);
	rep(i,n+1)cin>>a[i];
	rep(i,n)cin>>b[i];

	ll ans = 0;
	rep(i,n){
		ans += min(a[i]+a[i+1],b[i]);
		a[i+1] -= max(b[i]-a[i],0LL);
		a[i+1] = max(0LL,a[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define for1(a,b,i) for(int i=a;i<=b;++i)
#define FOR2(a,b,i) for(int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
inline int read() {
	int f=1,sum=0;
	char x=getchar();
	for(;(x<'0'||x>'9');x=getchar()) if(x=='-') f=-1;
	for(;x>='0'&&x<='9';x=getchar()) sum=sum*10+x-'0';
	return f*sum;
}

#define N 10000
#define M 1000005
int n;
char s[M];
int be[M],f[M],buc[M];
int id[M],Max[M],pos[M],nxt[M],sum[M],L[M],R[M];

inline bool check(int x,int xr,int y,int yr) {
	int len=min(xr-x,yr-y);
	for1(0,len,i)
		if(s[x+i]!=s[y+i]) return s[x+i]<s[y+i];
	return xr-x<=yr-y;
}

inline bool check_Max(int x,int y) {
	if(f[x]<N&&f[y]>N) return 0;
	if(f[x]>N&&f[y]<N) return 1;
	if(f[x]<N) return f[x]>=f[y];
	if(f[x]/N>f[y]/N||(f[x]/N==f[y]/N&&check(f[y]%N,R[y],f[x]%N,R[x]))) return 1;
	return 0;
}

int main() {
	//freopen("a.in","r",stdin);
	//freopen("mine.out","w",stdout);
	n=read()*2;
	scanf("%s",s+1);
	int shu=0;
	for1(1,n,i) {
		if(!shu) be[i]=++be[0];
		else     be[i]=be[i-1];
		shu+=('a'==s[i])-('b'==s[i]);
	}
	for1(1,n,i) R[be[i]]=i;
	FOR2(n,1,i) L[be[i]]=i;
	
	for(int l=1,r;l<=n;l=r+1) {
		r=l;
		while (be[r+1]==be[l]) ++r;
		if(s[l]=='a') {
			//怎么都没想到这里错啊，太马虎了
			int h=1,t=0;
			for1(l,r,i) 
				if(s[i]=='a') buc[++t]=i;
				else pos[buc[h++]]=i;
			int now=l;
			while (1) {
				++f[be[l]];
				now=pos[now]+1;
				while (now<=r&&s[now]!='a') ++now;
				if(now>r) break;
			}
		}
		else {
			sum[l-1]=0;
			for1(l,r,i) sum[i]=sum[i-1]+(s[i]=='b');
			int h=1,t=0;
			for1(l,r,i) 
				if(s[i]=='b') buc[++t]=i;
				else pos[buc[h++]]=i;
			FOR2(r,l,i)
				if(s[i]=='b') nxt[i]=nxt[i+1];
				else nxt[i]=i;
			int pre=sum[pos[l]],id=pos[l];
			for1(l,r-1,i) if(s[i]=='b') {
				int x[2]={sum[pos[i]]-sum[i],pos[i]+1};
				x[0]+=nxt[x[1]]-x[1];
				x[1]=nxt[x[1]];
				if(x[0]>pre||(x[0]==pre&&check(id,r,x[1],r))) pre=x[0],id=x[1];
			}
			f[be[l]]=pre*N+id;
		}
	}
	
	//abab是累加，不能比较字典序。。
	FOR2(be[0],1,i) {
		Max[i]=Max[i+1];
		if(f[i]>N&&check_Max(i,Max[i])) Max[i]=i;
	}
	//for1(1,be[0],i) cout<<f[be[i]]<<" "; cout<<endl;
	for1(1,be[0],i) if(!Max[i]) Max[i]=i;
	int pos=0;
	while (1) {
		pos=Max[pos+1];
		if(f[pos]>N) {
			FOR2(f[pos]/N,1,i) putchar('b');
			for1(f[pos]%N,R[pos],i) putchar(s[i]);
		}
		else {
			for1(1,f[pos],i) putchar('a'),putchar('b');
		}
		if(pos==be[0]) break;
	}
	puts("");
}

Measured memory_bytes: 16640
N = int(input())
#N =1000000000000000000
if N % 2: 
    #print("N % 2:", N % 2)
    print(0)
else:
    #print("N  :",N)
    N //= 10 #//で少数切り捨て
    #print("N  :",N, ": N //= 10")
    ans = N
    #print("ans:",ans)
    while N: #1以上なら
        N //= 5
        #print("N  :",N, ": N //= 5")

        ans += N
        #print("ans:",ans)
    print(ans)


Measured memory_bytes: 2940
N = int(input())
A = list(map(int, input().split()))
answer = 1
if 0 in A:
    print(0)
    exit()

for i in range(len(A)):
    if len(str(answer)) + len(str(A[i])) <= 20:
        answer *= A[i]
    else:
        print(-1)
        exit()

if answer <= 1000000000000000000:
    print(answer)
else:
    print(-1)


Measured memory_bytes: 84652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin >> N>>M;
  vector<int> first(M);
  vector<int> second(M);
  for(int i=0;i<M;i++)
    cin>>first.at(i)>>second.at(i);
  for(int i=0;i<N;i++){
    int count =0;
    for(int j=0;j<M;j++){
      if(first.at(j)==i+1)
        count++;
      if(second.at(j)==i+1)
        count++;
    }
    cout<<count<<endl;
  }
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let N: usize = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };
    let A: Vec<i64> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let B = {
        let mut B = A.iter().zip(1..(N + 1)).collect::<Vec<_>>();
        B.sort();
        B
    };
    let ans = B.iter().map(|&(_, b)| b.to_string()).collect::<Vec<_>>().join(" ");

    println!("{}", ans);
}


Measured memory_bytes: 12540
#include<bits/stdc++.h>
using namespace std;
#define R register int
#define AC 400100
#define ac 1601000//error!!!数据范围是2 00000, 不是1开头！！！

int n, m, ans = -INT_MAX, w;
int Head[AC], Next[ac], date[ac], tot;
int tree[ac], lazy[ac], l[ac], r[ac], l_[AC], r_[AC];

inline int read()
{
    int x = 0;char c = getchar();
    while(c > '9' || c < '0') c = getchar();
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x;
}

inline void add(int f, int w)
{
    date[++tot] = w, Next[tot] = Head[f], Head[f] = tot;
}

inline void upmax(int &a, int b)
{
    if(b > a) a = b;
}

void pre()
{
    n = read(), m = read();
    for(R i = 1; i <= n; i ++) 
        l_[i] = read(), r_[i] = read(), add(r_[i], i);
}

inline void pushdown(int x)
{
    if(lazy[x])
    {
        int ll = x * 2, rr = ll + 1;
        lazy[ll] += lazy[x], lazy[rr] += lazy[x];
        tree[ll] += lazy[x], tree[rr] += lazy[x];//这里因为是+=，所以必须用lazy[x]，不然会将lazy[ll]中的一些东西重复统计
        lazy[x] = 0;//最后才清空！！！！！！！！！！
    }//error!!!是区间加，不是赋值，不能直接覆盖，要+=
}

inline void update(int x)
{
    tree[x] = max(tree[x * 2], tree[x * 2 + 1]); 
}

void build(int x, int ll, int rr)
{
    l[x] = ll, r[x] = rr;
    if(ll == rr) 
    {
        tree[x] = -ll + 1;
        return ;
    }
    int mid = (ll + rr) >> 1;
    build(x * 2, ll, mid);
    build(x * 2 + 1, mid + 1, rr);
    update(x);
}

void change(int x, int ll, int rr)
{
    pushdown(x);
    if(l[x] == ll && r[x] == rr)
    {
        lazy[x] += w, tree[x] += w;
        return ;
    }
    int mid = (l[x] + r[x]) >> 1;
    if(rr <= mid) change(x * 2, ll, rr);
    else if(ll > mid) change(x * 2 + 1, ll, rr);
    else
    {
        change(x * 2, ll, mid);
        change(x * 2 + 1, mid + 1, rr);
    }
    update(x);
}
    
void find(int x, int ll, int rr)
{
    pushdown(x);
    if(l[x] == ll && r[x] == rr) 
    {
        upmax(ans, tree[x]);
        return ;    
    }
    int mid = (l[x] + r[x]) >> 1;
    if(rr <= mid) find(x * 2, ll, rr);
    else if(ll > mid) find(x * 2 + 1, ll, rr);
    else find(x * 2, ll, mid), find(x * 2 + 1, mid + 1, rr);//这是取max啊，，，，
}

void work()
{
    int now;
    ans = n - m;//r = 0的情况
    for(R i = Head[m + 1]; i; i = Next[i])
    {
        now = date[i], w = 1;
        change(1, l_[now] + 1, m + 1);
        //find(1, 4, 4);
    }
    //find(1, 4, 4);
    upmax(ans, tree[1]);
    for(R i = m; i; -- i)
    {
        w = -1;
        change(1, 1, i + 1);
        for(R j = Head[i]; j; j = Next[j])
        {
            now = date[j], w = 1;
            change(1, l_[now] + 1, i + 1);
        }
        find(1, 1, i + 1);//左端点在后面就不合法了
    }
    printf("%d\n", ans);
}

int main()
{
    pre();
    build(1, 1, m + 1);//要多出一位来代表左端点取0的情况
    work();//ri最大居然可以到m+1...
    fclose(stdin);
    return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  if(a==b+c || b==a+c || c==a+b){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int r = Integer.parseInt(S[0]);
    int D = Integer.parseInt(S[1]);
    int x = Integer.parseInt(S[2]);
    
    int ans = x;
    for(int i = 0; i < 10; i++){
      ans = ans * r -D;
      System.out.println(ans);
    }
  }
}

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

int main() {
  string A, B;
  cin >> A >> B;

  reverse(A.begin(), A.end());

  if(A==B){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }

return 0;  
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int
	var s string
	_, _ = fmt.Scan(&n)
	_, _ = fmt.Scan(&s)
	fmt.Println(calc(s))
}

func calc(s string) int {
	sum := 0
	ss := strings.Split(s,"")
	bf := 0
	for _, v := range ss{
		if bf == 0 {
			bf = cnv(v)
		} else if bf != cnv(v) {
			sum++
			bf = 0
		}
	}
	return sum
}

func cnv(s string) int {
	switch s {
	case "O":
		return 1
	case "X":
		return 2
	}
	return 0
}


Measured memory_bytes: 3480
import sys
import math

a,b,x=map(int,input().split())
V=a*a*b

if x*2==V:
    ans=45
    
elif x*2<V:
    y=2*x/(b*a)
    ans=math.degrees(math.atan(b/y))
else:
    y=(2*(V-x))/(a*a)
    ans=math.degrees(math.atan(y/a))


print(ans)

Measured memory_bytes: 3064
from sys import stdin

def main():

    input = stdin.readline

    X = int(input())

    min_num =  6000

    for i in range(-min_num,min_num+2):
        A_5 = i ** 5

        for j in range(-min_num,min_num+2):
            B_5 = j ** 5

            if(A_5 - B_5 == X):
                print(i,j)
                return

if __name__ == "__main__":
    main()

Measured memory_bytes: 68032
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 3004

using namespace std;

ll n,m;
string s,t;
ll dp[N][N];

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

    cin >> s >> t;
    n = s.size();
    m = t.size();
    s = "#" + s;
    t = "%" + t;

    rep(i,1,n+1)
    {
        rep(j,1,m+1)
        {
            dp[i][j] = (s[i] == t[j]) ? max({dp[i-1][j-1]+1,dp[i-1][j],dp[i][j-1]}) : max(dp[i-1][j],dp[i][j-1]);
        }
    }

    ll i = n;
    ll j = m;
    string res = "";

    while(dp[i][j] > 0)
    {
        //cout << i << " " << j << " " << dp[i][j] << endl;
        if(s[i]==t[j]&&dp[i-1][j-1]+1==dp[i][j])
        {
            char c=s[i];
            i--;
            j--;
            res=c+res;
        }
        else if(dp[i-1][j] == dp[i][j])
            i--;
        else
            j--;
    }

    cout << res;

    return 0;
}

/*
aba
b
*/


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 100000;
const long long MOD = 1000000007;
int n;
ll a,b,c;
ll comb[2*MAX_N];
ll apow[2*MAX_N];
ll bpow[2*MAX_N];

long long mod_pow(long long a, long long b)
{
  if (b == 0) return 1;
  long long ret = mod_pow(a, b/2);
  ret = ret * ret % MOD;
  if (b % 2 == 1) ret = a * ret % MOD;
  return ret;
}

vl pow(ll num, ll denom, int n) {
  vl res(n+1,1);
  for (int i = 1; i <= n; i++) {
    res[i] = res[i-1] * num % MOD * mod_pow(denom,MOD-2) % MOD;
  }
  return res;
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n >> a >> b >> c;

  ll n_1 = 1;
  forn1(i,n-1) n_1 = n_1 * i % MOD;
  ll m_1 = n_1;
  ll inv_n_1 = mod_pow(n_1,MOD-2);

  comb[n-1] = 1;
  for (int i = n; i < 2*n; i++) {
    m_1 = m_1 * mod_pow(i+1-n, MOD-2) % MOD;
    m_1 = i * m_1 % MOD;
    comb[i] = m_1 * inv_n_1 % MOD;
  }

  vl apow = pow(a,100-c,2*n);
  vl bpow = pow(b,100-c,2*n);

  ll res = 0;
  for (int m = n; m < 2*n; m++) {
    ll temp = comb[m-1] * ((apow[n]*bpow[m-n]%MOD + apow[m-n]*bpow[n]%MOD) % MOD) % MOD;
    temp = temp * m % MOD * 100 % MOD * mod_pow(100-c, MOD-2) % MOD;
    res = (res + temp) % MOD;
  }

  cout << res << endl;

  return 0;
}


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

int main() {
    // 整数の入力
    string s;
    cin >> s;

    if (s.compare("AAA") == 0 || s.compare("BBB") == 0) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

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

#define LL long long
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<LL>
#define VVL vector<vector<LL>>
#define VVVL vector<vector<vector<LL>>>
#define VB vector<bool>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

const int MOD = 10000;

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

    int N, K;
    cin >> N >> K;
    map<int, int> m;
    FOR(i, 0, K) {
        int a, b;
        cin >> a >> b;
        m[a] = b;
    }

    // dp[i][j][k] = i日目に2日前がパスタjで1日前がパスタkのときの場合の数
    VVVL dp(N + 1, VVL(4, VL(4, 0)));
    if (m[1]) {
        dp[1][0][m[1]] = 1;
    }
    else {
        dp[1][0][1] = 1;
        dp[1][0][2] = 1;
        dp[1][0][3] = 1;
    }

    FOR(i, 1, N) {
        FOR(j, 0, 4) {
            FOR(k, 0, 4) {

                // i + 1日目のパスタが指定されてる
                if (m[i + 1]) {
                    if (j == k and k == m[i + 1]) {

                    }
                    else {
                        (dp[i + 1][k][m[i + 1]] += dp[i][j][k]) %= MOD;
                    }
                    continue;
                }

                // 2日連続で同じパスタ
                if (j == k) {
                    if (j == 1) {
                        (dp[i + 1][k][2] += dp[i][j][k]) %= MOD;
                        (dp[i + 1][k][3] += dp[i][j][k]) %= MOD;
                    }
                    else if (j == 2) {
                        (dp[i + 1][k][1] += dp[i][j][k]) %= MOD;
                        (dp[i + 1][k][3] += dp[i][j][k]) %= MOD;
                    }
                    else if (j == 3) {
                        (dp[i + 1][k][1] += dp[i][j][k]) %= MOD;
                        (dp[i + 1][k][2] += dp[i][j][k]) %= MOD;
                    }

                }
                else {
                    (dp[i + 1][k][1] += dp[i][j][k]) %= MOD;
                    (dp[i + 1][k][2] += dp[i][j][k]) %= MOD;
                    (dp[i + 1][k][3] += dp[i][j][k]) %= MOD;
                }
            }
        }
    }

    LL ans = 0;
    FOR(j, 0, 4) {
        FOR(k, 0, 4) {
            (ans += dp[N][j][k]) %= MOD;
        }
    }
    print(ans % MOD);
}




Measured memory_bytes: 3280
from collections import deque

d = deque()
N=int(input())
A=[]
for i in range(N):
    a=int(input())
    A.append(a)
A=sorted(A)
A2=A.copy()
#61823
#351914
#419153
B=deque()
#最初に大きい方
B.append(A.pop(-1))
while len(A)>0:
    if len(A)>0:
        B.appendleft(A.pop(0))
    if len(A)>0:
        B.append(A.pop(0))
    if len(A)>0:
        B.appendleft(A.pop(-1))
    if len(A)>0:
        B.append(A.pop(-1))
B=list(B)
C=deque()
#最初に小さい方
C.append(A2.pop(0))
while len(A2)>0:
    if len(A2)>0:
        C.appendleft(A2.pop(-1))
    if len(A2)>0:
        C.append(A2.pop(-1))
    if len(A2)>0:
        C.appendleft(A2.pop(0))
    if len(A2)>0:
        C.append(A2.pop(0))
C=list(C)
countb=0
countc=0
for i in range(1,N):
    countb+=abs(B[i]-B[i-1])
    countc+=abs(C[i]-C[i-1])
print(max(countb, countc))


Measured memory_bytes: 9708
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

long long dp[105][100005];
long long w[105],v[105];
long long n,wt,ans,mv;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>wt;
	for(long long i=0;i<n;i++){
		cin>>w[i]>>v[i];
		mv=max(mv,v[i]);
	}
	fill(dp[0],dp[0]+100000+1,1e18);
	dp[0][0]=0;
	for(long long i=0;i<n;i++){
		for(long long j=0;j<=100000;j++){
			if(j<v[i]){
				dp[i+1][j]=dp[i][j];
			}else{
				dp[i+1][j]=min(dp[i][j],dp[i][j-v[i]]+w[i]);
			}
		}
	}
	for(long long i=0;i<=100000;i++){
		if(dp[n][i]<=wt){
			ans=i;//cout<<dp[n][i]<<' '<<i<<endl;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 80128