akhauriyash/Code-Regression huggingface dataset:
package main

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

// I/O
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) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

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 (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
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
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	ans := 0
	for i := 1; i <= 9; i++ {
		num := 0
		for j := 0; j < 3; j++ {
			num *= 10
			num += i
		}
		if N <= num {
			ans = num
			break
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}


//for(int i = ; i < ; i++){}

int main(){
  int n;
  cin>>n;
  cout<<"ABC"<<n<<endl;
  return 0;
}




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

long double A, B, H, M;
const long double PI = 3.14159265358979323846264338327950288;
int main(){
    cin >> A >> B >> H >> M;

    long double hrad = (2 * PI) / (12 * 60) * (60 * H + M); 
    long double mrad = (2 * PI) / 60 * M;

    long double minrad;
    long double hmrad;
    if(hrad - mrad >= 0){
        hmrad = hrad - mrad;
        minrad = min(hmrad, 2*PI - hmrad);
    }else{
        hmrad = 2 * PI - (mrad - hrad);
        minrad = min(hmrad , mrad - hrad);
    }
    
    long double innerP = A * B * cosl(minrad);
    long double res = powl(A, 2) + powl(B, 2) - 2 * innerP;
    res = sqrtl(res);
    cout << fixed << setprecision(20) << res << endl;
}

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

string str;

void input(){
    cin >> str;
}

void solve(){
    long sum = 0;
    for (int i=0;i<str.size();i++){
        sum += int(str[i])-48;
    }
    if (sum%9==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){
    input();
    solve();
    return 0;
}


Measured memory_bytes: 3260
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 (b<a) { a=b; return 1; } return 0; }

int A,B;

int main(){
    cin>>A>>B;
    if(B%A==0){
        out(A+B);
    }
    else{
        out(B-A);
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,x;
    cin >>N>>x;
    vector<ll>a(N);
    vector<ll>b(N);
    rep(i,N){
        cin>>a[i];
    }
    b=a;
    ll ans=0;
    rep(i,N-1){
        if(a[i]+a[i+1]-x>0){
            if(a[i]<=x){
                a[i+1]-=a[i]+a[i+1]-x;
            }else{
                a[i]=x;
                a[i+1]=0;

            }
        }
        
    }
    rep(i,N){
        ans+=b[i]-a[i];
    }
    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
#define inf (int)(1e9)

int main(){
	int W, H, N, x, y, a, i;
	scanf("%d%d%d", &W, &H, &N);
	int minx = 0, maxx = W, miny = 0, maxy = H;
	for(i = 0; i < N; i++){
		scanf("%d%d%d", &x, &y, &a);
		if(a == 1){
			minx = max(minx, x);
		}
		if(a == 2){
			maxx = min(maxx, x);
		}
		if(a == 3){
			miny = max(miny, y);
		}
		if(a == 4){
			maxy = min(maxy, y);
		}
	}
	printf("%d\n", max(0, maxx - minx) * max(0, maxy - miny));
	return 0;
}

Measured memory_bytes: 256
n, k = map(int,input().split())

if k >= 2 * n:
    print(n)
    quit()

if k >= n and k < 2*n:
    print(abs(n-k))
    quit()

if n > k:
    x_b = n%k
    x = abs(x_b - k)
    print(min(x_b,x))


Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define max(X) *max_element(all(X))
#define min(X) *min_element(all(X))
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  ll N,M,X,Y;
  cin >> N >> M >> X >> Y;
  vll x(N);
  vll y(M);
  rep(i,0,N) cin >> x[i];
  rep(i,0,M) cin >> y[i];

  bool ans = false;
  erep(i,X+1,Y){
    if(i>max(x) && i<=min(y)) ans = true;
  }

  if(ans) print("No War");
  else print("War");

  return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector<int> d(8);
  int v=0;
  REP(i,n) {
    if (a[i]>=3200) {
      v++;
    } else {
      d[a[i]/400]++;
    }
  }
  int cnt = 0;
  REP(i,8) {
    if (d[i]>0) cnt++;
  }

  if (cnt > 0) {
    cout << cnt << " " << cnt+v << endl;
  } else {
    cout << 1 << " " << v << endl;
  }
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
public class Program
{
  public static void Main()
  {
    string? s = System.Console.ReadLine();
    if(s[0] == '7')
    {
      System.Console.WriteLine("Yes");
      return;
    }
    if(s[1] == '7')
    {
      System.Console.WriteLine("Yes");
      return;
    }
    if(s[2] == '7')
    {
      System.Console.WriteLine("Yes");
      return;
    }
    System.Console.WriteLine("No");
  }
}

Measured memory_bytes: 17344
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
	long double x1,y1,x2,y2,ans;
	cin >> x1 >> y1 >> x2 >> y2;
	ans = (x2 - x1)*(x2 - x1)+(y2 - y1)*(y2 - y1);
	ans = sqrtl(ans);
	cout << setprecision(18) << ans << "\n";
	return 0;
}

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

void swap(int& a, int& b){
    int t;
    t=a;    a=b;    b=t;
}

void bubblesort(int N,int A[]){
    int co[1000]={0},cnt=0;
    for(int j=0;;j++){
        for(int i=N-1;i>j;i--){
            if(A[i]<A[i-1]){
                swap(A[i],A[i-1]);
                co[j]++;
            }
        }
        cnt+= co[j];
        if(co[j]==0)    break;
    }
    for(int i=0;i<N;i++){
        cout<<A[i];
        if(i!=N-1)  cout<<' ';
    }
    cout<<'\n';
    cout<<cnt<<endl;
}

int main(){

    int N=0,A[100]={0};
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    bubblesort(N,A);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
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 (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int R[23][100100];
int main(){
    int N;
    cin >> N;
    vector<ll> X(N);
    REP(i,N){
        ll x;
        cin >> x;
        X[i] = x;
    }

    ll L;
    cin >> L;

    int Q;
    cin >> Q;

    REP(k,N){
        R[0][k] = upper_bound(X.begin(), X.end(), X[k]+L) - X.begin() - 1;
    }

    REP(i,20){
        REP(k,N){
            R[i+1][k] = R[i][R[i][k]];
        }
    }

    REP(i,Q){
        int a, b;
        int ans = 0;
        cin >> a >> b;
        a--, b--;
        if(a > b) swap(a,b);

        for(int i = 20; i >= 0; i--){
            int r = R[i][a];
            if(r < b){
                a = r;
                ans += 1 << i;
            }
        }

        cout << ans+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 9856
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split(' ');
        var a = new int[N];
        for (int i = 0; i < N; i++)
        {
            a[i] = int.Parse(A[i]);
        }

        var l = new List<int>(a);
        l.Sort();
        l.Reverse();
        var al = 0;
        var bo = 0;
        for (int i = 0; i < N; i++)
        {
            if (i % 2 == 0) al += l[i];
            else bo += l[i];
        }
        WriteLine(al - bo);
    }
}

Measured memory_bytes: 13268
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
    string pat = "CODEFESTIVAL2016";
    string txt;

    cin >> txt;

    int cnt = 0;
    for(int i = 0; i < txt.size(); i++){
        if(txt[i] != pat[i]){
            cnt++;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    x--, y--;
    vector<int> ans(n+1);
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            int val = min({j-i, abs(x-i)+abs(y-j)+1, abs(x-j)+abs(y-i)+1});
            ans[val]++;
        }
    }
    for (int i = 1; i < n; ++i) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define mod 1000000007
#define size_f 100002
int main()
{
   int n;
   cin>>n;
   int i=0;
   pair<pair<string,int>,int >p[103];
   for(int i=0;i<n;i++)
   {
       string s; int q;
       cin>>s>>q;
       p[i]=make_pair(make_pair(s,-q),i+1);
   }
   sort(p,p+n);

   for(int i=0;i<n;i++)
      cout<<p[i].second<<"\n";
    return 0;
}


Measured memory_bytes: 256
// luogu-judger-enable-o2
#include <bits/stdc++.h>
#define Maxn 200005
#define rint register int
using namespace std;

char buf[1 << 20], *p1, *p2;
#define gc() ((p1 == p2) && (p2 = (p1 = buf) + fread(buf, 1, 1 << 20, stdin), p1 == p2) ? EOF : *p1++)
int read() {
	rint s = 0, f = 1; register char ch = getchar();
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { s = s * 10 + ch - '0'; ch = getchar(); }
	return s * f;
}

int n, k;

struct Edge { int ver, nxt; } edge[Maxn << 1];
int tot = 0, head[Maxn];
inline void add(int x, int y) { edge[++tot].ver = y, edge[tot].nxt = head[x], head[x] = tot; }

priority_queue<pair<int, int> > q;
int val[Maxn], fa[Maxn];
bool vis[Maxn], valid[Maxn];

void input() {
  n = read();
  for (rint i = 1; i <= n; ++i) valid[i] = true;
  for (rint i = 1; i < n; ++i) {
    int u = read(), v = read();
    add(u, v), add(v, u);
  }
  k = read();
  for (rint i = 1; i <= k; ++i) {
    int u = read(), p = read();
    val[u] = p; vis[u] = true;
  }
}

namespace Solution {
  bool BFS() {
    for (rint i = 1; i <= n; ++i) if (vis[i]) q.push(make_pair(val[i], i));
    while (q.size()) {
      int u = q.top().second; int x = q.top().first; q.pop();
      valid[u] = false;
			for (rint i = head[u]; i; i = edge[i].nxt) {
        int v = edge[i].ver;
        if (!valid[v]) continue;
        if (vis[v]) {
        	if (abs(x - val[v]) != 1) return false;
				} else vis[v] = true, q.push(make_pair(val[v] = val[u] - 1, v));
      }
    }
    return true;
  }
  void solve() {
    if (!BFS()) return void(puts("No"));
    puts("Yes");
    for (rint i = 1; i <= n; ++i) printf("%d\n", val[i]); 
  }
}

signed main() {
	input();
  Solution :: solve();
  return 0;
}

Measured memory_bytes: 6644
#include<iostream>
using namespace std;
int main(){
  int d[101];
  bool v[101];
  int map[101][101];
  int mx=99999999,mn,z,a,b,c,dd,e,hozon,k,n;
  while(1){
    for(int i=0;i<101;i++){
      for(int j=0;j<101;j++){
	map[i][j]=mx;
      }
      d[i]=mx;
    }
    cin>>n>>k;
    if(n==0&&k==0)break;
    for(int i=0;i<k;i++){
      cin>>z;
      if(z==1){
	cin>>c>>dd>>e;
	if(map[c][dd]>e){
	  map[c][dd]=e;
	  map[dd][c]=e;
	}
      }else{
	cin>>a>>b;
	for(int j=0;j<101;j++){
	  d[j]=mx;
	  v[j]=false;
	}
	d[a]=0;
	while(1){
	  mn=mx;
	  for(int j=0;j<=n;j++){
	    if(mn>d[j]&&v[j]==false){
	      mn=d[j];
	      hozon=j;
	    }
	  }
	  //cout<<hozon<<endl;
	  if(mn==mx)break;
	  v[hozon]=true;
	  for(int j=0;j<=n;j++){
	    if(d[j]>map[hozon][j]+d[hozon])d[j]=map[hozon][j]+d[hozon];
	  }
	}
	if(d[b]==mx){
	  cout<<-1<<endl;
	}else{
	  cout<<d[b]<<endl;
	}
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[6001];
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	ll n, x; cin >> n >> x;
	for(int i = 0; i < n; i++)
	{
		cin >> a[i];
		a[n+i] = a[i];
		a[2*n+i] = a[i];
	}
	ll ans = ll(1e18);
	for(int i = 0; i <= n; i++) //number of shifts
	{
		ll cur = 0;
		set<pair<ll,int> > s;
		for(int j = n; j >= n - i; j--)
		{
			s.insert(mp(a[j], j));
		}
		for(int j = 0; j < n; j++)
		{
			cur += (*s.begin()).fi;
			s.erase(mp(a[n + j - i], n + j - i));
			s.insert(mp(a[n + j + 1], n + j + 1));
		}
		ans = min(ans, cur+ll(x)*ll(i));
	}
	cout << ans;
}	


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        Solve();
        //WriteLine(Solve());
    }
    static void Solve()
    {
        var num = Input.num;
        var str = ReadLine();
        var k = Input.num;
        var res = "";
        for (var i = 0; i < num; i++)
            if (str[k - 1] == str[i])
                res += str[i];
            else res += '*';
        WriteLine(res);
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] ar2D(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] arL2D(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 11220
# coding: utf8

if __name__ == "__main__":
    n = int(input())
    w = []
    flag = True
    for _ in range(n):
        a = input()
        if len(w) == 0:
            w.append(a)
            continue
        last = w[len(w)-1]
        if a[0] != last[len(last)-1] or a in w:
            flag = False
            break
        w.append(a)
    if flag == True:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 3064
using System;

namespace ABC170
{
    class B_Crane_and_Turtle
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int x = int.Parse(input[0]);
            int y = int.Parse(input[1]);

            for(int i = 0; i <= x; i++)
            {
                int crane = i;
                int turtle = x - i;
                if(crane * 2 + turtle * 4 == y)
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 27524
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
const double PI = acos(-1);

#include <iomanip>
int main() {
    cout << fixed << setprecision(12);
    double a, b, x; cin >> a >> b >> x;
    x /= a;
    if (x > a * b / 2) {
        double s = a * b - x;
        cout << atan2(s * 2 / a, a) / PI * 180 << endl;
    } else {
        double s = x;
        cout << atan2(b, s * 2 / b) / PI * 180 << endl;
    }
    return 0;
}

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

typedef struct {
    int num[2][4];
    int time;
    int x, y;
} PUZZLE;

PUZZLE queue[50000];
int head, tail;

void enq(PUZZLE t)
{
    queue[(tail++) % 50000] = t;
}

void deq(PUZZLE *t)
{
    *t = queue[(head++) % 50000];
}

int main(void)
{
    PUZZLE first, temp;
    char str[30];
    int i, j;
    int dx[4] = {1, 0, -1, 0};
    int dy[4] = {0, 1, 0, -1};
    static signed char v[8][8][8][8][8][8][8][8];
    
    memset(v, -1, sizeof(v));
    v[0][1][2][3][4][5][6][7] = 0;
    
    first.time = 0;
    head = tail = 0;
    first.x = first.y = 0;
    for (i = 0; i < 8; i++){
        first.num[i / 4][i % 4] = i;
    }
    enq(first);
    
    while (head != tail){
        deq(&temp);
        for (i = 0; i < 4; i++){
            first = temp;
            first.time = temp.time + 1;
            first.x += dx[i];
            first.y += dy[i];
            if (0 <= first.x && first.x < 4 && 0 <= first.y && first.y < 2){
                first.num[temp.y][temp.x] ^= first.num[first.y][first.x];
                first.num[first.y][first.x] ^= first.num[temp.y][temp.x];
                first.num[temp.y][temp.x] ^= first.num[first.y][first.x];
                if (v[first.num[0][0]][first.num[0][1]][first.num[0][2]][first.num[0][3]][first.num[1][0]][first.num[1][1]][first.num[1][2]][first.num[1][3]] == -1){
                    v[first.num[0][0]][first.num[0][1]][first.num[0][2]][first.num[0][3]][first.num[1][0]][first.num[1][1]][first.num[1][2]][first.num[1][3]] = first.time;
                    enq(first);
                }
            }
        }
    }
    
    while (scanf("%[^\n]", str) != EOF){
        getchar();
        for (i = 0; i < 2; i++){
            for (j = 0; j < 4; j++){
                first.num[i][j] = str[j * 2 + i * 8] - '0';
                if (first.num[i][j] == 0){
                    first.x = j;
                    first.y = i;
                }
            }
        }
        printf("%d\n", v[first.num[0][0]][first.num[0][1]][first.num[0][2]][first.num[0][3]][first.num[1][0]][first.num[1][1]][first.num[1][2]][first.num[1][3]]);
    }
    
    return (0);
}

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

int main(){
    string s;
    cin >> s;
    int sum = 0;
    for(int i=0; i<s.size(); i++) sum += s[i] - '0';
    if(stoi(s)%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <list>
using namespace std;

int main(){
    string s;
    long long q;
    cin >> s >> q;
    long long n = s.length();
    std::list<char> char_list;
    for(int i=0;i<n;i++){
        char_list.push_back(s[i]);
    }
    int T;
    int F;
    char C;
    bool reverse = false;
    for(int i=0; i<q; i++){
        cin >> T;
        if(T == 1){
            reverse = !reverse; 
        }
        if(T == 2){
            cin >> F >> C;
            if((F == 1 && !reverse) || (F == 2 && reverse)){
                char_list.push_front(C);
            }else{
                char_list.push_back(C);
            }
        }
    }
    if(reverse){
        for(auto itr = char_list.rbegin(); itr != char_list.rend(); ++itr) {
            std::cout << *itr;
        }    
    }else{
        for(auto itr = char_list.begin(); itr != char_list.end(); ++itr) {
            std::cout << *itr;
        }   
    }
    return 0;
}

Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
int n;
int main()
{
	cin>>n;
	vector<int> L(n);
	for(int i=0;i<n;i++)cin>>L[i];
	sort(L.begin(),L.end());
	int sum=0;
	for(int i=0;i<n-1;i++)sum+=L[i];
	puts(sum>L.back()?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder.Beginner141
{
    public static class B
    {
        public static void Main()
        {
            string steps = Console.ReadLine();
            bool isEasy = true;
            for (int i = 0; i < steps.Length; ++i)
            {
                if ((i & 1) > 0)    // 'i' is odd, index is even
                {
                    if (steps[i] == 'R') isEasy = false;
                }
                else
                {
                    if (steps[i] == 'L') isEasy = false;
                }
            }
            Console.WriteLine(isEasy ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
s=input()
for i in range(1 << 3):
    ans=""
    for j in range(3):
        ans+=s[j]
        if (i>>j)& 1:
            ans+="+"
        else:
            ans+="-"
    ans+=s[-1]
    if eval(ans+"==7"):
        print(ans+"=7")
        break

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

int main(){
  int A,B;
  cin >> A >> B;
  int ans = 0;
  for(int c = 0;c<2;c++){
  if(A >= B){
    ans += A;
    A = A-1;
  }else{
    ans += B;
    B = B-1;
  }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int A, B, C, D;
  int cntMatch = 0;
  cin >> A >> B >> C >> D;
  for(int i = A; i < B; ++i)
  {
    for(int j = C; j < D; ++j)
    {
      if(i == j)
      {
        ++cntMatch;
        break;
      }
    }
  }
  cout << cntMatch;
  cout << endl;
  return 0;
}

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

int main() {
	vector<int> is_prime(100001, 1);
	is_prime[0] = 0;
	is_prime[1] = 0;
	for (int i = 2; i <= 100000; i++) {
		if (!is_prime[i]) continue;
		for (int j = i * 2; j <= 100000; j += i) is_prime[j] = 0;
	}
	vector<int> a(100001);
	for (int i = 0; i <= 100000; i++) {
		if (i % 2 == 0) continue;
		if (is_prime[i] && is_prime[(i + 1) / 2]) a[i] = 1;
	}
	vector<int> s(100001);
	for (int i = 0; i <= 100000; i++) s[i + 1] = s[i] + a[i];
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		r++;
		cout << s[r] - s[l] << endl;
	}
	return 0;
}

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

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

  string S;
  cin >> S;

  ll r = 0, g = 0, b = 0;
  for (char c : S) {
    if (c == 'R') {
      r++;
    } else if (c == 'G') {
      g++;
    } else {
      b++;
    }
  }

  ll ans = r * g * b;
  if (N >= 3) {
    for (int i = 1; i <= N - 2; i++) {
      char s1 = S[i - 1];
      for (int j = i + 1; j <= N - 1; j++) {
        char s2 = S[j - 1];
        if (s1 != s2) {
          // cout << i << j << s1 << s2 << endl;
          int k = 2 * j - i;
          if (k <= N) {
            char s3 = S[k - 1];
            if (s3 != s1 && s3 != s2) {
              ans--;
            }
          }
        }
      }
    }
  }
  

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
bool num[1000000005] , b=true;
signed main(){
	int n , a;
  	cin>>n;
  	for(int i=0;i<n;i++){
      cin>>a;
      if(num[a] == true){
        b=false;
      }
	  num[a]=true;
    }
  	if(b){
      cout<<"YES\n";
    } else {
	  cout<<"NO\n";
    }
  	return(0);
}

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

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


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)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var N = cin.ReadInt();
            var a = cin.ReadIntArray(N).Select(x => x - 1).ToArray();
            var b = Enumerable.Repeat(false, N).ToArray();
            var idx = 0;
            b[0] = true;
            
            for (int i = 0; i < N; ++i)
            {
                if (b[1]) { WriteLine(i); return; }
                b[a[idx]] = b[idx];
                b[idx] = false;
                idx = a[idx];
            }
            WriteLine(-1);
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            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() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { 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: 17744
#include <bits/stdc++.h>
#define rep(i,a) for(i=0;i<a;i++)
using namespace std;
static const int W = 0;
static const int G = 1;
static const int B = 2;

void prim(int n, int &total,vector<vector<int> > &M) {
    int i,u,min;
    vector<int> d(n);
    vector<int> p(n);
    vector<int> color(n);

    rep(i,n){
        d[i] = INT_MAX;
        p[i] = -1;
        color[i] = W;
    }
    d[0] = 0;
    while(true){
        min = INT_MAX;
        u = -1;
        rep(i,n){
            if(min > d[i] && color[i] != B) {
                u = i;
                min = d[i];
            }
        }
        if(u==-1) break;
        color[u] = B;
        rep(i,n){
            if(color[i] != B && M[u][i] != INT_MAX){
                if(d[i] > M[u][i]) {
                    d[i] = M[u][i];
                    p[i] = u;
                    color[i] = G;
                }
            }
        }
    }
    rep(i,n){
        if(p[i] != -1) total += M[i][p[i]];
    }
}

int main(void) {
    int i,j,n,total = 0;
    vector<vector<int> > M;
    cin >> n;
    M.resize(n);

    rep(i,n){
        M[i].resize(n);
    }
    rep(i,n){
        rep(j,n){
            cin >> M[i][j];
            if(M[i][j] == -1) M[i][j] = INT_MAX;
        }
    }
    prim(n,total,M);
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define f(i,a,b) for(i=a;i<=b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ll long long
#define mod (1000*1000*1000+7)
#define scan1(x) scanf("%lld",&x)
#define scan2(x,y) scanf("%lld %lld",&x,&y)
#define scan3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define print(x) printf("%lld\n",x)
#define ff first
#define ss second
using namespace std;


int main(){
    ll m,n,i,j;
    string x,y;
    cin>>x>>y;
    n=x.length();
    m=y.length();
    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(m+1,vector<ll>(4)));
    
    f(i,1,n)
    f(j,1,m){
        if(x[i-1]==y[j-1]){
            dp[i][j][0]=1+dp[i-1][j-1][0];
            dp[i][j][1]=i-1;
            dp[i][j][2]=i-1;
            dp[i][j][3]=j-1;
        }
        if(x[i-1]!=y[j-1]){
            if(dp[i-1][j][0]>=dp[i][j-1][0]){
                dp[i][j][0]=dp[i-1][j][0];
                dp[i][j][1]=dp[i-1][j][1];
                dp[i][j][2]=dp[i-1][j][2];
                dp[i][j][3]=dp[i-1][j][3];
            }
            else{
                dp[i][j][0]=dp[i][j-1][0];
                dp[i][j][1]=dp[i][j-1][1];
                dp[i][j][2]=dp[i][j-1][2];
                dp[i][j][3]=dp[i][j-1][3];
            }
        }
    }
    
    string res;
    ll val=dp[n][m][0];
    ll cx=n,cy=m;
    while(val!=0){
        res+=x[dp[cx][cy][1]];
        ll nx=dp[cx][cy][2];
        ll ny=dp[cx][cy][3];
        cx=nx;
        cy=ny;
        val=dp[cx][cy][0];
        
    }
    reverse(res.begin(),res.end());
    cout<<res<<"\n";
    
}

Measured memory_bytes: 633856
#include<bits/stdc++.h>
using namespace std;
long long s[100005];
int main(){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		scanf("%lld",&s[i]);
	}
	int Max=0;
	int ans=0;
	for(int i=0;i<n-1;i++){
		if(s[i]>=s[i+1]){
			ans++;
			if(ans>=Max)Max=ans;
		}
		else ans=0;
	}
	cout << Max << endl;
	return 0;
}

Measured memory_bytes: 1024
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	a := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	set := make(map[int]int, 0)
	for i := 0; i < n; i++ {
		set[nextInt(sc)]++
	}
	for i := 0; i < m; i++ {
		var b, c int
		b = nextInt(sc)
		c = nextInt(sc)
		set[c] += b
	}
	ks := make([]int, 0)
	for k := range set {
		ks = append(ks, k)
	}
	sort.Ints(a)
	sort.Sort(sort.Reverse(sort.IntSlice(ks)))
	// fmt.Println("n", n, "m", m, "set", set, "ks", ks)
	ans, rest := 0, n
	for i := 0; i < n && rest > 0; i++ {
		if rest >= set[ks[i]] {
			ans += ks[i] * set[ks[i]]
			rest -= set[ks[i]]
		} else {
			ans += ks[i] * rest
			rest = 0
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 18816
s=input()
s=s[::-1]
a=1
b=0
t=[0]*2019
t[0]=1
ans=0
for i in range(len(s)):
    b+=int(s[i])*a
    b%=2019
    a*=10
    ans+=t[b]
    t[b]+=1
    a%=2019

print(ans)

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

int main() {
    int K;
    string S;
    cin >> K >> S;
    if(S.size()<=K) cout << S << endl;
    else{
        for(int i=0;i<K;i++){
            cout << S.at(i);
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>

namespace Mylib{
    using namespace std;
    
}
int main(void){
    using namespace std;
    int N,A;
    
    cin >> N >> A;
    
    if(N==A){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	int N, A, B;
	scanf("%d", &N);
	scanf("%d", &A);
	scanf("%d", &B);
	if (N * A >= B)
		printf("%d", B);
	else
		printf("%d", N*A);
}

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

int main()
{
   int a,b,c,d;
   cin >>a;
   cin >>b;
   c=(a*b);
   d=(c%2);
   if (d==0)
   {
     cout << "Even"<< endl;
   }
   else 
   {
     cout << "Odd"<< endl;
   }
   return 0;
}

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

const int mod = 1000000007;
struct mint {
    long long x;
    mint(long long x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

unordered_map<int, int> factorization(int x){
    unordered_map<int, int> pn;
    for (int i=2; i*i<=x; i++)
    {
        while (x % i == 0) { x/=i; pn[i]++; }
    }
    if (x != 1) pn[x]++;
    return pn;
}

void Main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<unordered_map<int, int>> af(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        af[i] = factorization(a[i]);
    }
    unordered_map<int, int> g;
    for (int i = 0; i < n; i++)
    {
        for (auto j: af[i]){
            if(g[j.first] < j.second){
                g[j.first] = j.second;
            }
        }
    }
    mint l = 1;
    for (auto i: g) {
        l *= mint(i.first).pow(i.second);
    }

    mint sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += l/a[i];
    }
    
    cout << sum << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N;
  cin >> N;

  int n = N;
  int digit_sum = 0;
  while (n > 0) {
    digit_sum += n % 10;
    n /= 10;
  }

  // 解答
  cout << (N % digit_sum == 0 ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 200005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
     ll n,k;
     cin >> n >> k;
     ll fre[n+1] = {0};
     for(ll i=1;i<=k;i++)
     {
          ll sz;
          cin >> sz;
          for(ll j=0;j<sz;j++)
          {
               ll x;
               cin >> x;
               fre[x]++;
          }
     }
     ll ans = 0;
     for(ll i=1;i<=n;i++)   
     {
          if(fre[i]==0)  ans++;
     }
     cout<<ans;
}

int main()
{
     FAST;
     ll t = 1;
  //   cin >> t;
     while(t--)
     {    
          solve();
     }
}

Measured memory_bytes: 3644
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;
typedef long long ll;
int getint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9') { if(ch=='-')f=-1; ch=getchar();	}
	while('0'<=ch&&ch<='9') { x=x*10+ch-'0'; ch=getchar();	}
	return f*x;
}
#define N 212345
int ans=0,ed=0;
int main(){
	int n=getint(),t=getint();
	for(int i=1;i<=n;i++) {
		int x=getint();
		ans+=min(t,x+t-ed); 
		ed=x+t;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
def show(array):
    for i in range(len(array)):
        if i != len(array) - 1:
            print(array[i], end=' ')
        else:
            print(array[i])

length = int(input())
array = [int(x) for x in input().split()]

for i in range(length):
    v = array[i]
    j = i-1
    while j >= 0 and array[j] > v:
        array[j+1] = array[j]
        j -= 1
    array[j+1] = v
    show(array)



Measured memory_bytes: 5980
n = int(input())
s = list(input())

lft = [0]
rgt = [0]

cnt = 0
for i in range(1,n):
    if s[i-1] == "W":
        cnt += 1
    lft.append(cnt)

cnt = 0
for i in range(1,n):
    if s[(i)*(-1)] == "E":
        cnt += 1
    rgt.append(cnt)

ans = 10**9
for i in range(n):
    ans = min(ans,lft[i]+rgt[(i+1)*(-1)])
print(ans)

Measured memory_bytes: 20172
#include "bits/stdc++.h"

// Begin Header {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) x.begin(), x.end()
#define rep(i, n) for (intmax_t i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

constexpr size_t    operator""_zu(unsigned long long value) { return value; };
constexpr intmax_t  operator""_jd(unsigned long long value) { return value; };
constexpr uintmax_t operator""_ju(unsigned long long value) { return value; };

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class T>
inline istream& operator>>(istream &is, vector<T> &vec) {
    for (auto &e: vec) {
        is >> e;
    }
    return is;
}

inline void output() { cout << "\n"; }
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) {
        cout << " ";
    }
    output(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e: vec) {
        os << e << delim[&e == &vec.back()];
    }
    return os;
}

template <class T>
inline vector<T> makeVector(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeVector(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(initValue, args...))>(sz, makeVector<T>(initValue, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func>{forward<Func>(f)};
}

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

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

template <class T>
inline T diff(const T &a, const T &b) noexcept {
    return a < b ? b - a : a - b;
}
// End Header }}}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(intmax_t, r);

    if (r >= 2800) {
        output("AGC");
    } else if (r >= 1200) {
        output("ARC");
    } else {
        output("ABC");
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
 
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  sort(a.rbegin(), a.rend());
  ll hen[2];
  int hendex = 0;
  bool flag = false;
  rep(i, n-1){
    if(a[i] == a[i+1] && !flag){
      hen[hendex++] = a[i];
      if(hendex == 2) break;
      flag = true;
    }else{
      flag = false;
    }
  }
  cout << hen[0]*hen[1] << endl;
	return 0;
}


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

constexpr double pi = 3.14159265358979;

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

    double shrt = 5.0*h + m/12.0;
    double lng = (double)m;

    double x = abs(lng - shrt)*pi/30;
    double cos_x = sqrt(1 - sin(x)*sin(x));
    if(pi/2 <= x && x <= 3*pi/2) cos_x *= -1;
    
    double ans = sqrt(a*a + b*b - 2*a*b*cos_x);
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 4252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  for (int i=0;i<n;i++) {
    cin >> a.at(i); 
  }
  if(n==1){
    cout << "Yes" << endl;
    return 0;
  }
  int max=0;
  for (int i=0;i<n;i++) {
    if(max-1>a[i]){
      cout << "No" << endl;
      return 0;
    }
    if(max<a[i]){
      max=a[i];
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3744
package main

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

func main() {
	var a, b, k int
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	fmt.Sscanf(sc.Text(), "%d %d %d", &k, &a, &b)
	inc := b - a
	ans := 1

	for i:=0; i<k; i++{
		if inc > 1 && ans >= a && i < k-1{
			ans += inc
			i++
		} else {
			ans += 1
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,tmp,cnt[100010],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&tmp);
		for(int j=max(tmp-1,0);j<=tmp+1;++j)++cnt[j];
	}
	for(int i=1;i<=100000;++i)if(cnt[i]>ans)ans=cnt[i];
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 512
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#define N (ll)(1e6+3)
#define INF (ll)(1e18+3)

#define ll long long
#define rep(i,a,n) for(ll i = a; i < n; i++)
#define per(i,a,n) for(ll i = n-1; i >= a; i--)

//using namespace __gnu_pbds;
using namespace std;
 
// typedef
// tree<
//     pair<ll,ll>,
//     null_type,
//     less<pair<ll,ll>>,
//     rb_tree_tag,
//     tree_order_statistics_node_update>
// ordered_set;

ll n;
ll a[N], b[N];
ll c[N], d[N];

map<int, int> par;

void fail() {
    cout << -1 << endl;
    exit(0);
}

ll get_par(ll u) {
    if (!par.count(u)) par[u] = u;
    return par[u];
}

ll find(ll u) {
    if (get_par(u) == u) return u;
    return par[u] = find(par[u]);
}


void solve() {
    cin >> n;
    ll x = 0;
    rep(i,0,n) {
        cin >> a[i];
        a[n] ^= a[i];
    }
    rep(i,0,n) {
        cin >> b[i];
        b[n] ^= b[i];
    }
    n++;

    rep(i,0,n) c[i] = a[i];
    rep(i,0,n) d[i] = b[i];
    sort(&c[0],&c[n]);
    sort(&d[0],&d[n]);
    rep(i,0,n) if (c[i] != d[i]) fail();

    ll ans = -1;
    rep(i,0,n) {
        ll x = a[i], y = b[i];
        if (x == y && i+1<n) continue;
        ans++;
        x = find(x), y = find(y);
        par[x] = y;
    }

    int cc = 0;
    for (auto w: par) if (w.first == w.second) cc++;
    ans += max(0,cc-1);
    cout << ans << endl;

}


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

Measured memory_bytes: 23808