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

#define EB emplace_back
#define int long long
#define F first
#define S second
#define N 100005
#define ALL(x) x.begin(),x.end()
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)


using namespace std;


int32_t main()
{
    IOS;

    int tt=1;
    //cin>>tt;
    while(tt--)
    {
        int n;
        n = 3;
        map<int,int> mp;
        int arr[3][3];
        int brr[3][3] ;
        memset(arr,0,sizeof arr);
        memset(brr,0,sizeof brr);
        for (int i = 0; i < n; i++)
        {
            for(int j= 0; j < n ; j++) cin>>arr[i][j];
        }
//exit(0)
        int q;
        cin>>q;
        while (q--)
        {
            int a;
            cin>>a;
            for (int i = 0; i < n; i++)
            {
                for(int j = 0 ; j < n; j++) if(arr[i][j] == a) brr[i][j] = 1;
            }
            
        }
        for (int i = 0; i < n; i++)
		{
			int cnt = 0;
			for(int j = 0 ; j < n; j++) cnt += brr[i][j];
			if(cnt == 3) return cout<<"Yes",0;
		}
		for (int i = 0; i < n; i++)
		{
			int cnt = 0;
			for(int j = 0 ; j < n; j++) cnt +=brr[j][i];
			if(cnt == 3) return cout<<"Yes",0;
		}
		if(brr[0][0] + brr[1][1] + brr[2][2] == 3) return cout<<"Yes",0;
		if(brr[2][0] + brr[1][1] + brr[0][2] == 3) return cout<<"Yes",0;
		
		cout<<"No";
		
       
    }
    return 0;

}


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

ll N,K,h[100000],m=100000000000;;

int main(void){
    cin >> N >> K;
    rep(i,N)cin >> h[i];
    
    sort(h,h+N);
    rep(i,N-K+1){
        m = min(m,h[i+K-1]-h[i]);
    }
    cout << m << endl;
    
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

type Edge struct {
	to, id int
}

func main() {
	sc := NewScanner()
	N := sc.nextInt()
	tree := make([][]Edge, N)
	for i := 0; i < N-1; i++ {
		a, b := sc.nextInt()-1, sc.nextInt()-1
		tree[a] = append(tree[a], Edge{b, i})
		tree[b] = append(tree[b], Edge{a, i})
	}
	ans := make([]int, N-1)
	var dfs func(current, parent, parentColor int)
	dfs = func(current, parent, parentColor int) {
		color := 1
		for _, e := range tree[current] {
			next, id := e.to, e.id
			if next == parent {
				continue
			}
			if color == parentColor {
				color++
			}
			ans[id] = color
			dfs(next, current, color)
			color++
		}
	}
	dfs(0, -1, -1)

	maxNum := 0
	for _, e := range tree {
		if maxNum < len(e) {
			maxNum = len(e)
		}
	}
	fmt.Println(maxNum)
	for _, v := range ans {
		fmt.Println(v)
	}
}


Measured memory_bytes: 33664
A, *BCD = map(int, input())
for bit in range(1 << 3):
    f = [A]
    s = A
    for i, n in enumerate(BCD):
        if bit >> i & 1:
            f += ['+', n]
            s += n
        else:
            f += ['-', n]
            s -= n
    if s == 7:
        f += ['=7']
        print(''.join(map(str, f)))
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define X           first
#define Y           second
#define pb          push_back
#define mp          make_pair
#define SZ(X)       (X.size())
#define mst(a,b)    memset((a),(b),sizeof(a))
#define lowbit(a)   ((a)&(-a))
using namespace std;
typedef unsigned long long ull;
typedef long long LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int mod=1e9+7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn=5500;
inline int add(int x,int y){
    if((x+=y)>=mod)x-=mod;
    return x;
}
inline int mul(int x,int y){
    return (ll)x*y%mod;
}
inline int sub(int x,int y){
    if((x-=y)<0)x+=mod;
    return x;
}
int ci[maxn];
vector<int>to[maxn];
int dp[maxn][maxn];
int sz[maxn],uu[maxn];
void dfs(int pos,int fa){
    sz[pos]=1;
    dp[pos][1]=1;
    for(int d:to[pos])if(d!=fa){
        dfs(d,pos);
        for(int i=0;i<=sz[pos]+sz[d];++i)
            uu[i]=0;
        for(int i=0;i<=sz[pos];++i)
            for(int j=0;j<=sz[d];++j)
            uu[i+j]=add(uu[i+j],mul(dp[pos][i],dp[d][j]));
        sz[pos]+=sz[d];
        for(int i=0;i<=sz[pos];++i)
            dp[pos][i]=uu[i];
    }
    for(int i=2;i<=sz[pos];i+=2)
        dp[pos][0]=sub(dp[pos][0],mul(dp[pos][i],ci[i]));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ci[0]=1;
    for(int i=2;i<maxn;i+=2)
        ci[i]=mul(ci[i-2],i-1);
    int n;cin>>n;
    for(int i=1;i<n;++i){
        int a,b;cin>>a>>b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    dfs(1,0);
    cout<<(mod-dp[1][0]);
    return 0;
}

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

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

using namespace std;
using ll = long long;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }

  ll ans = numeric_limits<ll>::max();

  for (int i = 0; i + k - 1 < n; i++) {
    const ll l = x[i], r = x[i + k - 1];
    ans = min(ans, min(abs(l), abs(r)) + r - l);
  }
  cout << ans << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 640
#include <cstdio>
int main() {
    char s1[15], s2[15], s3[15];
    scanf("%s %s %s", &s1[0], &s2[0], &s3[0]);

    printf("%c%c%c", 'A'+s1[0]-'a', 'A'+s2[0]-'a', 'A'+s3[0]-'a');

    return 0;
}


Measured memory_bytes: 128
<?php

fscanf(STDIN, "%d %d", $a, $b);


$ax = [];
for ($i = 1; $i <= sqrt($a); ++$i) {
    if ($a % $i === 0) {
        $ax[] = $i;
        $ax[] = $a / $i;
    }
}

$bx = [];
for ($i = 1; $i <= sqrt($b); ++$i) {
    if ($b % $i === 0) {
        $bx[] = $i;
        $bx[] = $b / $i;
    }
}

$res = array_unique(array_intersect($ax, $bx));
sort($res);

$cnt = 0;
foreach ($res as $val) {
    $flg = true;
    for ($i = 2; $i <= sqrt($val); ++$i) {
        if ($val % $i === 0) {
            $flg = false;
            break;
        }
    }

    $cnt += $flg ? 1 : 0;
}

echo $cnt;


Measured memory_bytes: 5112
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#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 FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef int64_t ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);


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

  deque<char> d;

  string s;
  cin >> s;
  rep(i, s.size()) {
    d.push_back(s[i]);
  }

  bool flag = true;

  int q;
  cin >> q;
  rep(i, q) {
    int t;
    cin >> t;
    if (t == 1) {
      flag = !flag;
      continue;
    }
    int f;
    cin >> f;
    char c;
    cin >> c;
    if (flag && f == 1 || !flag && f == 2) {
      d.push_front(c);
    } else {
      d.push_back(c);
    }
  }

  if (flag) {
    for (auto it = d.begin(); it != d.end(); it++) {
      printf("%c", *it);
    }
  } else {
    for (auto it = d.rbegin(); it != d.rend(); it++) {
      printf("%c", *it);
    }
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 976
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+5;

int n,a[maxn],b[maxn],c[maxn];
LL res,ans[maxn];
char ch;

inline void read(int& x)
{
	x=0,ch=getchar();
	while(!isdigit(ch))ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
}

int main()
{
	read(n);
	for(int i=1;i<=n;i++)read(a[i]);sort(a+1,a+n+1,greater<int>());
	for(int i=1;i<=n;i++)read(b[i]);sort(b+1,b+n+1,greater<int>());
	for(int i=1;i<=n;i++)read(c[i]);sort(c+1,c+n+1,greater<int>());
	c[0]=b[0]=1e9+5;
	for(int i=1,it=0;i<=n;i++)
	{
		while(c[it]>b[i]&&it<=n)it++;
		ans[i]=it-1;
	}
	for(int i=1;i<=n;i++)ans[i]+=ans[i-1];
	for(int i=1,it=0;i<=n;i++)
	{
		while(b[it]>a[i]&&it<=n)++it;
		res+=ans[it-1];
	}
	printf("%lld",res);
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

const int INF = 1 << 30, Array = 1400;
int dp[Array][Array];

int main(){
	int h, w, maxedge = 0;
	bool tail[Array][Array];
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++){
		for (int j = 0; j <w; j++){
			scanf("%d", &tail[i][j]);
			if (!tail[i][j]){
				dp[i][j] = 1;
				maxedge = 1;
			}
		}
	}
	for (int i = 1; i < h; i++){
		for (int j = 1; j < w; j++){
			if (!tail[i][j])
				dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
			maxedge = max(maxedge, dp[i][j]);
		}
	}
	printf("%d\n", maxedge * maxedge);
	return 0;
}

Measured memory_bytes: 9420
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;
#define int long long
void test_case(){
	int n , d; cin >> n >> d;
	int count = 0;
	while(n--){
		int x , y;
		cin >> x >> y;
		double k = sqrt(x*x+y*y);
		//~ cout<<k<<" ";
		if(k <= d)
			count++;
	}
	cout<<count;
	
}
 
int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3692
#include <stdio.h>

void saitan(int,int);

int n,v[100][100],d[100],u,k[100],c[100][100];

int main(){
  int i,j,u;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k[u]);
    for(j=0;j<k[u];j++){
      scanf("%d %d",&v[u][j],&c[u][j]);
    }
  }
  
  for(i=0;i<n;i++){
    d[i] = 1000000;
  }
  saitan(0,0);
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}

void saitan(int p,int x){
  
  int i;
  
  d[p] = x;
  
  for(i=0;i<k[p];i++){
    if(d[v[p][i]] > x+c[p][i]){
      saitan(v[p][i],x+c[p][i]);
    }
  }
  return;
}

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

int main() {

    int N;
    cin >> N;
    int sum = 0;
    int sq_sum = 0;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }

    for (int i = 0; i < N; i++) {
        sum += vec.at(i);
    }
  
    int ave = ((double)sum/(double)N)+0.5;
    
  

    for (int i = 0; i < N; i++) {
        sq_sum += (vec.at(i) - ave) * (vec.at(i) - ave) ;

    }

    cout << sq_sum << endl;

return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  cout << fixed << setprecision(25);

  int n;
  cin >> n;

  string res;
  cout << 0 << endl;
  cin >> res;
  if (res == "Vacant") return 0;
  int left = 0, right = n;
  while (1) {
    int mid = (left + right) / 2;
    string nxt;
    cout << mid << endl;
    cin >> nxt;
    if (nxt == "Vacant") return 0;
    if (((mid - left) % 2 == 0 && res != nxt) || ((mid - left) % 2 == 1 && res == nxt)) right = mid;
    else {
      left = mid;
      res = nxt;
    }
  }



  
  return 0;
}

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

long long mod = 1000000007;
long long N, K, SQRT;
long long dp[109][50009], r[50009];

int main() {
	cin >> N >> K;
	for (int i = 1; i*i <= N; i++) SQRT = i;

	for (int i = 1; i <= SQRT; i++) { dp[1][i] = 1; }
	for (int i = 2; i <= K; i++) {
		long long sum = 0;
		for (int j = 1; j <= SQRT; j++) sum += dp[i - 1][j];
		sum %= mod;
		for (int j = 1; j <= SQRT; j++) dp[i][j] = sum;

		if (i == 2) {
			for (int j = 1; j <= SQRT; j++) {
				dp[i][j] += ((N / j) - SQRT);
				dp[i][j] %= mod;
			}
		}
		if (i >= 3) {
			long long rem = 0;
			for (int j = 0; j <= SQRT; j++) r[j] = 0;
			for (int j = 1; j <= SQRT; j++) {
				rem += dp[i - 2][j]; rem %= mod;
				r[j] += rem * ((N / j) - max(SQRT, N / (j + 1)));
				r[j] %= mod;
			}
			long long ret = 0;
			for (int j = SQRT; j >= 1; j--) {
				ret += r[j]; ret %= mod;
				dp[i][j] += ret;
				dp[i][j] %= mod;
			}
		}
	}

	long long ans = 0;
	for (int i = 1; i <= SQRT; i++) { ans += dp[K][i]; ans %= mod; }
	for (int i = 1; i <= SQRT; i++) { ans += dp[K - 1][i] * ((N / i) - SQRT); ans %= mod; }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 40192
#include <stdio.h>
#pragma warning(disable:4996)

int main()
{
	char str[101];
	scanf("%s", &str);
	int counter = 0;
	int makeCounter = 0;
	while (str[counter] != '\0')
	{
		if (makeCounter == 0)
		{
			if (str[counter] == 'C')
			{
				makeCounter++;
			}
		}
		if (makeCounter == 1)
		{
			if (str[counter] == 'F')
			{
				makeCounter++;
			}
		}
		counter++;
	}

	if (makeCounter == 2)
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}
    
void run(){
    int a,b;
    cin>>a>>b;
    Rep(i,1,1100){
        if(floor(i*0.08)==a&&floor(i*0.1)==b){
            cout<<i<<endl;
            return;
        }
    }
    cout<<-1<<endl;
}

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

#define loop(i, n) for(int i = 0;i < int(n);i++)
#define rloop(i, n) for(int i = int(n);i >= 0;i--)
#define range(i, a, b) for(int i = int(a);i <= int(b);i++)
#define sz(c) int(c.size())
#define clr(v, d)   memset(v, d, sizeof(v))
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define INF             INT64_MAX
#define NINF            INT64_MIN
#define ROW 1001
#define COL 1001

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<pll> vll;
typedef vector<ll> vl;

int arr[50];
int n,m;

int main(void){

    vector<string> A(51),B(51);
    cin>>n;

    cin>>m;
    loop(i,n)
            cin>>A[i];
    loop(i,m)
            cin>>B[i];
    bool exist=true;
    range(i,0,n-m+1)
    {

        range(j,0,n-m+1)
        {
            exist=true;
            loop(k,m)
            {

                loop(t,m)
                {
                    if(B[k][t]!=A[i+k][j+t])
                    {
                        exist = false;
                    }
                }
            }
            if(exist)
                break;

        }
        if(exist)
            break;
    }
    if(exist)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


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

typedef struct {
    int pref;       //prefecture number
    int year;       //constructed year
    int init_idx;   //input order
    int pref_idx;   //pref order
} city;

/* sort by year */
int cmp_year(const void *a, const void *b) {
    return ((city*)a)->year - ((city*)b)->year;
}
/* sort by init_idx */
int cmp_idx(const void *a, const void *b) {
    return ((city*)a)->init_idx - ((city*)b)->init_idx;
}


int main()
{
    int n, m;
    int i;

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

    city c[m];
    int *count = (int*)calloc(n+1,sizeof(int));      //count of each pref order

    for(i=0; i<m; i++) {
        scanf("%d %d", &c[i].pref, &c[i].year);
        c[i].init_idx = i;      //c[i]'s init_idx equals to "i";
    }

    /* sort by year */
    qsort(c,m,sizeof(city),cmp_year);

    /* count c[i]'s order in a pref
       (already arranged in year order) */
    for(i=0; i<m; i++) {
        c[i].pref_idx = (++count[c[i].pref]);
    }

    /* sort by init_idx to inital order */
    qsort(c,m,sizeof(city),cmp_idx);

    for(i=0; i<m; i++) {
        printf("%06d%06d\n", c[i].pref, c[i].pref_idx);
    }

    free(count);

    return 0;
}

Measured memory_bytes: 4964
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
  
N = input()
L = list(map(int, input().split()))
UL = set(L)
LC = lcm_list(UL) - 1
ANS = 0
for i in L:
  ANS += LC % i
print(ANS)

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

typedef long long ll;
typedef unsigned long long ull;

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

  ll x = 0;
  for (ll i = 1; i <= n; ++i) {
    if (i%2 != 0) ++x;
  }
  cout << fixed << setprecision(10);
  cout << double(x) / double(n) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
	int n, x;
	cin >> n;
	vector<int> v(n), u(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
		if (i == 0) {
			u[i] = 0;
		} else if (i == 1) {
			u[i] = abs(v[i] - v[i - 1]);
		} else {
			u[i] = min(u[i - 1] + abs(v[i] - v[i - 1]), u[i - 2] + abs(v[i] - v[i - 2]));
		}
	}
	cout << u[n - 1];
	return 0;
}

Measured memory_bytes: 1024
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

int main()
{
    cout.precision(18);

    long long A, B;
    cin >> A >> B;

    cout << A * B << endl;
}


Measured memory_bytes: 3636
// Vicfred
// https://atcoder.jp/contests/dp/tasks/dp_d
// dynamic programming
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.stdio;
import std.string;

void main() {
    long N, W;
    readf("%s %s\n", &N, &W);

    long[] ws = new long[N];
    long[] vs = new long[N];

    long[][] dp = new long[][](N+1, W+1);

    foreach(i; 0..N)
        readf("%s %s\n", &ws[i], &vs[i]);

    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= W; j++) {
            if(ws[i-1] <= j)
                dp[i][j] = max(dp[i-1][j],
                        dp[i-1][j-ws[i-1]] + vs[i-1]);
            else
                dp[i][j] = dp[i-1][j];
        }
    }

    dp[N][W].writeln;
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

vector<string> S;
vector<string> T;

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

    S.resize(N);
    T.resize(N);

    REP(i, N)
    {
        cin >> S[i];
    }

    T = S;

    int cnt = 0;
    REP(i, N)
    {
        bool flg = true;
        if (i == 0)
        {
            REP(j, N)
            {
                REP(k, N)
                {
                    if (T[j][k] != T[k][j])
                    {
                        flg = false;
                        break;
                    }
                }
                if (!flg) break;
            }
            if (flg) cnt++;
            continue;
        }

        REP(j, N)
        {
            string s{T[j][N - 1]};
            T[j].pop_back();
            T[j].insert(0, s);
        }

        REP(j, N)
        {
            REP(k, N)
            {
                if (T[j][k] != T[k][j])
                {
                    flg = false;
                    break;
                }
            }
            if (!flg) break;
        }
        if (flg) cnt++;
    }

    cout << N * cnt << endl;
    return 0;
}


Measured memory_bytes: 512
import java.util.*;
import java.io.PrintWriter;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Q = sc.nextInt();
		int[] S = new int[N];
		int[] T = new int[N];
		int[] X = new int[N];
		int[] D = new int[Q];
		PrintWriter out = new PrintWriter(System.out);
		Comparator<Event> comparator = new Comparator<Event>() {
            @Override
            public int compare(Event o1, Event o2) {
                return Integer.valueOf(o1.t).compareTo(Integer.valueOf(o2.t));
            }
        };
		List<Event> event = new LinkedList<Event>();
		for (int i=0;i<N;i++) {
			S[i]=Integer.parseInt(sc.next());
			T[i]=Integer.parseInt(sc.next());
			X[i]=Integer.parseInt(sc.next());
			event.add(new Event(S[i]-X[i],1,X[i]));
			event.add(new Event(T[i]-X[i],-1,X[i]));
		}
		for (int i=0;i<Q;i++) {
			D[i]=Integer.parseInt(sc.next());
		}
		Collections.sort(event,comparator);
		TreeSet<Integer> set = new TreeSet<Integer>();
		int time=0;
		int w=0;
		loop:while (!event.isEmpty()) {
			Event tmp = event.remove(0);
			time=tmp.t;
			while (D[w]<time) {
				if (set.isEmpty()) {
					out.println(-1);
				} else {
					out.println(set.first());
				}
				w++;
				if (w==Q) {
					break loop;
				}
			}
			if (tmp.flag==1) {
				set.add(tmp.x);
			} else {
				set.remove(tmp.x);
			}
		}
		for (int i=w;i<Q;i++) {
			out.println(-1);
		}
		out.flush();
	}
}

class Event {
	int t;
	int flag;
	int x;
	Event(int t,int flag,int x) {
		this.t=t;
		this.flag=flag;
		this.x=x;
	}
}

Measured memory_bytes: 191892
import sys
from collections import deque

def solve():
    input = sys.stdin.readline
    S = list(input().strip("\n"))
    q = deque()
    for i, s in enumerate(S): q.append(s)
    state = 0 #0の時初期の順番
    Q = int(input())
    for _ in range(Q):
        query = list(input().strip("\n").split())
        if query[0] == "1": state ^= 1
        else:
            f = int(query[1]) % 2
            c = query[2]
            if state ^ f == 1: q.appendleft(c)
            else: q.append(c)
    Ans = ""
    if state == 0:
        while q: Ans += q.popleft()
    else:
        while q: Ans += q.pop()
    print(Ans)
    
    

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 7052
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n;
	while (cin >> n,n) {
		vector<string> group_name;
		vector<set<string>> member(n);
		REP(i,n) {
			string s;
			cin >> s;
			int idx = 0;
			REP(j, s.length()) {
				if (s[j] == ':') {
					group_name.push_back(s.substr(0, j));
					idx = j + 1;
				}
				if (s[j] == ','|| s[j] == '.') {
					member[i].insert(s.substr(idx, j - idx));
					idx = j + 1;
				}
			}
		}
		REP(j,group_name.size()) {
			REP(i,member.size()) {
				if (member[i].find(group_name[j]) != member[i].end()) {
					member[i].erase(group_name[j]);
					member[i].insert(member[j].begin(), member[j].end());
				}
			}
		}
		cout << member[0].size() << endl;
	}
}

Measured memory_bytes: 3380
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) {
        cin >> v[i];
        v[i]--;
    }

    int ans = 0;
    REP(i,n-1) {
        if (v[i] == i) {
            swap(v[i],v[i+1]);
            ans++;
        }
    }
    if (v[n-1] == n-1) ans++;

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	string s;
	cin >> s;
	if (s.size() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < s.size() - 1; i += 2) {
		if (!(s[i] == 'h' && s[i + 1] == 'i')) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
A = [input().split() for i in range(3)]
B = [[False]*3 for i in range(3)]
n = int(input())
for i in range(n) :
    b = input()
    for j in range(3) :
        for k in range(3) :
            if A[j][k] == b :
                B[j][k] = True

res = "No"
for i in range(3) :
    if B[i][0] == B[i][1] == B[i][2] == True :
        res = "Yes"
    elif B[0][i] == B[1][i] == B[2][i] == True :
        res = "Yes"

if B[0][0] == B[1][1] == B[2][2] == True :
    res = "Yes"
elif B[2][0] == B[1][1] == B[0][2] == True :
    res = "Yes"

print(res)


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

int wa(int n){
    int ans = 0;
    while(n>0){
        ans += n%10;
        n /= 10;
    }
    return ans;
}

int main(){
  int n;
  cin >> n;
  int ans,j;
  int min1 = 50;
  for(int i=1;i<n;i++){
      j = n-i;
      ans = wa(i)+wa(j);
      min1 = min(min1,ans);
  }
  cout << min1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long
using namespace std;
int main()
{
    int y,m,d;
    char a, b;
    cin >> y >> a >> m >> b >> d;
    if(m<=4){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
    int a,b,s=0;
    cin>>a>>b;
	for(int d=b;d;d/=10)
	{
		s++;
	}
	int d=pow(10,s)*a+b;
	for(int f=0;f*f<=d;f++)
	{
		if(f*f==d)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r << '\n';
	} else {
		cout << 100 * (10 - n) + r << '\n';
	}
	
 	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define ll long long
using namespace std;
ll a[300000];
int main()
{
	ll n;
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%lld", &a[i]);
		if (a[i] > i) {
			printf("-1");
			return 0;
		}
		if (i)
		{
			if (a[i] > a[i - 1] + 1)
			{
				printf("-1");
				return 0;
			}
		}
	}
	ll dap = 0;
	for (int i = 1; i < n; i++)
	{
		if (a[i] != 0)
		{
			if (a[i] != a[i - 1] + 1)
				dap += a[i];
			else
				dap++;
		}
	}
	printf("%lld", dap);
}

Measured memory_bytes: 1664
import numpy as np
s = input()
s_list = list(s)
s_array = np.array(s_list)
s_without_x_ar = s_array[s_array != "x"]

if (s_without_x_ar != s_without_x_ar[::-1]).any():
    print(-1)
else:
    kw_count = len(s_without_x_ar)
    if kw_count == 0:
        print(0)
    elif kw_count % 2 == 0:
        half_s_wox_left = s_without_x_ar[:int(kw_count/2)]
        lastw_count = len(half_s_wox_left[half_s_wox_left==half_s_wox_left[-1]])
        check_last_idx = np.where(s_array == half_s_wox_left[-1])[0][lastw_count-1]
        half_array = s_array[:check_last_idx+1]
        
        
        a = np.where(half_array!="x")[0]
        a = np.insert(a,0,-1)
        left_count_ar = a[1:] - a[:-1] - 1


        # right
        half_s_wox_right = s_without_x_ar[int(kw_count/2):]
        half_s_wox_right_back = half_s_wox_right[::-1]
        s_array_back = s_array[::-1]

        lastw_count = len(half_s_wox_right_back[half_s_wox_right_back==half_s_wox_right_back[-1]])
        check_last_idx = np.where(s_array_back == half_s_wox_right_back[-1])[0][lastw_count-1]

        half_array = s_array_back[:check_last_idx+1]
        
        a = np.where(half_array!="x")[0]
        a = np.insert(a,0,-1)
        right_count_ar = a[1:] - a[:-1] - 1
        
        print(np.abs(right_count_ar - left_count_ar).sum())
        
    else:
        half_s_wox_left = s_without_x_ar[:int(kw_count//2+1)]
        lastw_count = len(half_s_wox_left[half_s_wox_left==half_s_wox_left[-1]])
        check_last_idx = np.where(s_array == half_s_wox_left[-1])[0][lastw_count-1]
        half_array = s_array[:check_last_idx+1]
        
        
        a = np.where(half_array!="x")[0]
        a = np.insert(a,0,-1)
        left_count_ar = a[1:] - a[:-1] - 1


        # right
        half_s_wox_right = s_without_x_ar[int(kw_count//2):]
        half_s_wox_right_back = half_s_wox_right[::-1]
        s_array_back = s_array[::-1]

        lastw_count = len(half_s_wox_right_back[half_s_wox_right_back==half_s_wox_right_back[-1]])
        check_last_idx = np.where(s_array_back == half_s_wox_right_back[-1])[0][lastw_count-1]

        half_array = s_array_back[:check_last_idx+1]
        
        a = np.where(half_array!="x")[0]
        a = np.insert(a,0,-1)
        right_count_ar = a[1:] - a[:-1] - 1
        
        print(np.abs(right_count_ar - left_count_ar).sum())

Measured memory_bytes: 21688
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const ll mod2 = 998244353;

int gcd(int a,int b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd(b, a%b);
}

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> l(n);
  vector<int> r(n);
  l[1] = a[0];
  FOR(i, 2, n) l[i] = gcd(l[i-1], a[i-1]);
  r[n-2] = a[n-1];
  repr(i, n-3) r[i] = gcd(r[i+1], a[i+1]);
  l[0] = r[0];
  r[n-1] = l[n-1];
  int ans = 0;
  rep(i, n) ans = max(ans, gcd(l[i], r[i]));
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
int a, b, h;
cin >> a >> b >> h;
cout << (a+b)*h/2 << endl;	

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;



int main() {
	int N; cin >> N;
	for (int i = 0; i < N; ++i) {
		int a, b; cin >> a >> b;
		bool ok = true;
		for (int j = -200; j <= 200; ++j) {
			for (int k = -200; k <= 200; ++k) {
				if ((!j&&!k)||(j == 0 && abs(k) == 1) || (k == 0 && abs(j) == 1) || (j == a&&k == b) || (j == -a&&k == -b) || (j == b&&k == -a) || (j == -b&&k == a)){
					continue;
				}
				else {
					if (!((a*j + b*k) % (j*j + k*k)) && !(((a*k - b*j) % (j*j + k*k)))) {
						ok = false;
						break;
					}
					
				}
			}
		}
		if (ok)cout << "P" << endl;
		else cout << "C" << endl;
	}
	return 0;
}

Measured memory_bytes: 3040
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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

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

const ll MAX = 1000000LL;

vector<ll> list_primes() {
    vector<bool> numbers(MAX, true);
    vector<ll> primes;
    primes.push_back(2);
    primes.push_back(3);

    numbers[0] = 0;
    numbers[1] = 0;
    for (int i = 4; i <  MAX; i += 2) {
        numbers[i] = false;
    }
    for (int i = 6; i < MAX; i += 3) {
        numbers[i] = false;
    }
    for (int i = 5; i < MAX; i++) {
        if (numbers[i]) {
            primes.push_back(i);
            for (int j = i + i; j < MAX; j += i) {
                numbers[j] = false;
            }
        }
    }

    return primes;
}

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

    vector<ll> primes = list_primes();
    // for (int i = 0; i < (int) primes.size(); i++) {
    //     cout << primes[i] << endl;
    // }

    auto ans = lower_bound(primes.begin(), primes.end(), X);
    cout << *ans << endl;

    return 0;
}


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

int main(void){
    int a,b,i,ans;
    ans = 0;
    cin >> a >> b;

    if(a < b){
        for(i=0; i<b; i++){
            ans += pow(10,i)*a;
        }
    }else{
        for(i=0; i<a; i++){
            ans += pow(10,i)*b;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int n = readint;
    auto dx = readints;
    int d = dx[0], x = dx[1];
    int[] a;
    for (int i = 0; i < n; i++) {
        a ~= readint;
    }

    int ans = x;
    for (int i = 0; i < n; i++) {
        int p = 1;
        while (p <= d) {
            ans++;
            p += a[i];            
        }
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>

using namespace std;

typedef long long ll;
typedef double db;
ll a, b, h, m;

int main() {
	cin >> a >> b >> h >> m;

	db xs = 0.5 * (h * 60 + m);
	db xf = 6 * m;
	db x = xs - xf;

	db pi = acos(-1);
	printf("%.12lf", sqrt(a * a + b * b - 2 * a * b * cos(pi / 180 * x)));

	return 0;
}

Measured memory_bytes: 4152
A, B = map(int, input().split())

# 桁を反転する関数
def reverseDigits(n):
  reversed = 0
  while n > 0:
    q, mod = divmod(n, 10)
    reversed = reversed * 10 + mod
    n = q
  return reversed

counter = 0
for i in range(A, B + 1):
  if i == reverseDigits(i):
    counter += 1

print(counter)

Measured memory_bytes: 3060
#include<iostream>

int main() {
    int n;
    std::cin >> n;
    
    int r = 0, b = 0;
    for (int i = 0; i < n; i++) {
        char c;
        std::cin >> c;
        if (c == 'R') {
            r++;
        } else {
            b++;
        } 
    }

    if (b < r) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

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

class Main{
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 1) {
		    System.out.println(sc.nextInt());
		}
		else {
		    int[] a = new int[n];
		    for(int i=0;i<n;i++) a[i] = sc.nextInt();
		    Arrays.sort(a);
		    double cur = (a[0]+a[1]) / 2.0;
		    for(int i=2;i<n;i++) {
		        cur = (cur + a[i]) / 2.0;
		    }
		    System.out.println(cur);
		}
	}
}

Measured memory_bytes: 21844
//author rhythmicankur
                                                                  //god_is_almighty
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include<bits/stdc++.h>
#define f 	first
#define s 	second
#define ll 	int
#define int 	long long
#define ld 	long double
#define pb 	push_back
#define eb 	emplace_back
#define mk 	make_pair
#define vi 	vector<int>
#define pii 	pair<int,int>
#define vpi 	vector<pii>
#define fori(a,b,c) for(register int i=a;i<b;i+=c)
#define ford(a,b,c) for(register int i=a;i>=b;i-=c)
#define 	PI acos(-1)
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define M1 	998244353
#define M2 	1000000007
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); } 
#define test4(x,y,z,a) 		cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"  |  "<<#a<<": "<<a<<endl;
#define test1(x)                cerr<<#x<<": "<<x<<endl
#define test2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define test3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
ll power(ll a,ll b,ll m=M2){ll answer=1;while(b){if(b&1)answer=(answer*a)%m;b/=2;a=(a*a)%m;}return answer;}
using namespace std;
void ctrl()
{
	cout<<"Control\n";
}
signed main()
{	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n,k;
    cin>>n>>k;

    int A[n];
    fori(0,n,1)cin>>A[i];

    sort(A,A+n);

    int s=0;
    for(int i=0;i<n-k;i++)
    s+=A[i];

    cout<<s;


return 0;
}

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

int main(){
	double d,y;
	int res;
	while(cin>>d){
		y=d*d/19.6;
		res=ceil(y);
		res=max((res-1)/5+2,1);
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# (a,b,c,d) -> (ab,bc,cd,da) と変換
# xor x で不変量になる

N = int(readline())

A = list(map(int,readline().split()))
B = list(map(int,readline().split()))

def convert(A):
    return [x ^ y for x,y in zip(A,A[1:])] + [A[-1] ^ A[0]]

C = convert(A); D = convert(B)

def Z_algorithm(S):
    # 共通接頭辞の長さを返す
    N=len(S)
    arr = [0]*N
    arr[0] = N
    i,j = 1,0
    while i<N:
        while i+j<N and S[j]==S[i+j]:
            j += 1
        arr[i]=j
        if not j:
            i += 1
            continue
        k = 1
        while i+k<N and k+arr[k]<j:
            arr[i+k] = arr[k]
            k += 1
        i += k; j -= k
    return arr

Z = Z_algorithm(D + [-1] + C + C)[N+1:N+N+1]

K = [i for i,x in enumerate(Z) if x == N]
X = [A[k] ^ B[0] for k in K]

print('\n'.join('{} {}'.format(k,x) for k,x in zip(K,X)))


Measured memory_bytes: 67028
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	vector<int> nums(n); fore(e, nums) cin >> e;
	int cnt = 0;
	forl(i, 1, 101) {
		int tmp = 0; bool fg = false;
		forl(j, 0, n) {
			if(fg) { if(nums[j] < i) fg = false; }
			else { if(nums[j] >= i) { fg = true; tmp++; } }
		}
		cnt += tmp;
	}
	println(cnt);
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int k,a,b,count=0;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++){
    if(i%k==0){
      count++;
      break;
    }
  }
  if(count!=0)  puts("OK");
  else          puts("NG");
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
const int maxn=222,maxm=22222;
#define MP make_pair
#define PB push_back
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline ll read(){
	char ch=getchar();ll x=0,f=0;
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,m,a[maxn][maxn],b[maxn][maxn],c[maxn][maxn],tmp[maxn];
int s,t,q[maxn],h,r,dis[maxn],el,head[maxn],cur[maxn],to[maxm],nxt[maxm],w[maxm];
bool use[maxm];
inline void add(int u,int v,int w_){
	to[++el]=v;nxt[el]=head[u];head[u]=el;w[el]=w_;
	to[++el]=u;nxt[el]=head[v];head[v]=el;w[el]=0;
}
bool bfs(){
	MEM(dis,-1);
	q[h=r=1]=s;
	dis[s]=0;
	while(h<=r){
		int u=q[h++];
		for(int i=head[u];i;i=nxt[i]) if(w[i]){
			int v=to[i];
			if(dis[v]==-1) dis[v]=dis[u]+1,q[++r]=v;
		}
	}
	return ~dis[t];
}
int dfs(int u,int minres){
	if(u==t || !minres) return minres;
	int f,rtf=0;
	for(int &i=cur[u];i;i=nxt[i]){
		int v=to[i];
		if(dis[v]==dis[u]+1 && (f=dfs(v,min(minres,w[i])))){
			minres-=f;rtf+=f;
			w[i]-=f;w[i^1]+=f;
			if(!minres) break;
		}
	}
	return rtf;
}
int main(){
	n=read();m=read();
	FOR(i,1,n) FOR(j,1,m) a[i][j]=read();
	s=2*n+1;t=2*n+2;
	FOR(i,1,m){
		FOR(i,1,2*n+2) head[i]=0;
		FOR(i,1,el) to[i]=nxt[i]=w[i]=0;
		el=1;
		FOR(i,1,n) add(s,i,1),add(i+n,t,1);
		FOR(i,1,n) FOR(j,1,m) if(!use[a[i][j]]) add(i,(a[i][j]+m-1)/m+n,1);
		int f=0;
		while(bfs()){
			FOR(i,1,2*n+2) cur[i]=head[i];
			f+=dfs(s,1e9);
		}
		assert(f==n);
		FOR(j,1,n) for(int e=head[j];e;e=nxt[e]) if(!w[e]){
			int tp=to[e]-n;
			FOR(k,1,m) if((a[j][k]+m-1)/m==tp && !use[a[j][k]]){
				use[b[j][i]=a[j][k]]=true;break;
			}
		}
	}
	FOR(i,1,n){
		FOR(j,1,m) printf("%d ",b[i][j]);
		puts("");
	}
	FOR(j,1,m){
		FOR(i,1,n) tmp[i]=b[i][j];
		sort(tmp+1,tmp+n+1);
		FOR(i,1,n) c[i][j]=tmp[i];
	}
	FOR(i,1,n){
		FOR(j,1,m) printf("%d ",c[i][j]);
		puts("");
	}
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <bitset>
using namespace std;

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)
#define iter(it,c) for(auto it=(c).begin(); it!=c.end(); ++it)

typedef vector<int> vi;
typedef map<int, int> mii;

int const score[] = { 0, 0, 60, 70, 80 };
int eval(int n){
    int s = 0;
    rep(i, 5){
        s += score[n & 7];
        n >>= 3;
    }
    return s;
}

int flip(int n, int f){
    f <<= 2;
    int r = 0;
    rep(i, 5){
        int t = n >> (i * 3) & 7;
        if (t){
            int c = (f >> (i * 2) & 3) + (f >> (i * 2 + 2) & 3);
            t = ((t - 1 + c) & 3) + 1;
        }
        r |= t << (i * 3);
    }
    return r;
}

int solve(vi const& v){
    mii prev;
    prev[v[0]] = eval(v[0]);
    rep(i, 4){
        mii next;
        iter(it, prev){
            int bef = eval(it->first);
            rep(f, 1 << 8){
                int n = flip(v[i + 1], f);
                int e = it->second - bef + eval(flip(it->first, f)) + eval(n);
                next[n] = max(next[n], e);
            }
        }
        swap(prev, next);
    }

    int ans = 0;
    iter(it, prev) ans = max(it->second, ans);
    return ans;
}

int main(){
    int n; cin >> n;
    while (n--){
        vi v(5);
        rep(i, 5){
            rep(j, 5){
                int t = 0; cin >> t;
                v[i] <<= 3;
                v[i] |= t;
            }
        }
        cout << solve(v) << endl;
    }
}

Measured memory_bytes: 1220