akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define f(a,j,k) for(int i = a ; i < j ; i += k)
#define f1(a,j,k) for(int i = a ; i > j ; i -= k)
using namespace std;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<int> vi;
typedef pair<int,int> pri;
typedef pair<long long,long long> prl;
ll cnt[200001];
int a[200001];
int main() {
	std::ios::sync_with_stdio(false);
	int n , k;
	cin >> k >> n;
	int a[n+1];
	f(0,n,1) cin >> a[i];
	sort(a,a+n);
	int maxn = -1;
	f(0,n-1,1) maxn = max(maxn,a[i+1] - a[i]);
	maxn = max(maxn,k-a[n-1]+a[0]);
	cout << k - maxn << endl;
	return 0;
}


Measured memory_bytes: 1024
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "b.cpp"

int main() {
  ll n;
  cin >> n;
  vector<string> s(n), t = {"AC", "WA", "TLE", "RE"};
  cin >> s;

  map<string, ll> c;
  for (auto&& i : s) {
    c[i]++;
  }

  for (auto&& i : t) {
    cout << i << " x " << c[i] << el;
  }
}


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

#define ARC(i, a, b) for(int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)

template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a > b ? a - b : b - a; }
template<class T> T &anth(T &a, const T &b){ return a = ant(a, b); }
template<class T> T &onth(T &a, const T &b){ return a = ont(a, b); }

int main(){
	int H, W, h, w;
	scanf("%d%d%d%d", &H, &W, &h, &w);
	printf("%d\n", (H - h) * (W - w));
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long k = sc.nextLong();

		int n = sc.nextInt();

		List<Long> list = new ArrayList<Long>();

		for (long i = 0; i < n; i++) {
			list.add(sc.nextLong());
		}

		list.add(k);

		long totalA = 0;
		long maxLength = 0;
		int point = 0;

		for (int num = 0; num < list.size() - 1; num++) {
			Long a = list.get(num);
			Long b = list.get(num + 1);

			if (maxLength <= (b - a)) {
				maxLength = b - a;
				point = num + 1;
			}
		}

		if (maxLength <= k - list.get(list.size() - 2) + list.get(0)) {
			maxLength = k - list.get(list.size() - 2) + list.get(0);
			point = 0;
		}

		for (int num = point; num < list.size() - 1; num++) {
			Long a = list.get(num);
			Long b = list.get(num + 1);

			if (point == 0 && num + 1 == n) {
				break;
			}

			totalA += b - a;
		}

		if (0 < totalA && list.get(0) != 0 && 1 < point) {
			totalA += list.get(0);
		}

		for (int num = 0; num < point - 1; num++) {

			if (num + 1 == n) {
				break;
			}

			Long a = list.get(num);
			Long b = list.get(num + 1);

			totalA += b - a;
		}

		System.out.println(totalA);

	}
}


Measured memory_bytes: 86744
import sys
import statistics

N = int(input())
AAA = list(map(int, sys.stdin.readline().split()))

AAA_minus_i = [A - (i+1) for i, A in enumerate(AAA)]
median_AAA_minus_i = round(statistics.median(AAA_minus_i))

ans = sum(list(map(lambda x: abs(x-median_AAA_minus_i), AAA_minus_i)))

print(ans)


Measured memory_bytes: 29592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main(void)
{	
	int t=0,n=0,s[100]={0},f[100]={0},time=0;
	while(1)
	{
		scanf("%d",&t);
		if(t==0){break;}
		scanf("%d",&n);
		for(int i=0;i<n;i++)
		{
			scanf("%d %d",&s[i],&f[i]);
			time=time+f[i]-s[i];
		}
		if(time>=t)
		{
			printf("OK\n");
		}
		else
		{
			printf("%d\n",t-time);
		}
		time=0;
	}
	return 0;
}


Measured memory_bytes: 3168
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

const int N = 1000;
ll dist[N];
ll inf = 1e16;
vector<pair<int, ll> > edges[N];
vector<int> rev[N];

int main(void){
  int n, m;
  cin >> n >> m;
  REP(i, 0, n) {
    dist[i] = inf;
  }
  dist[0] = 0;
  REP(i, 0, m) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    edges[a].push_back(make_pair(b, -c));
    rev[b].push_back(a);
  }
  vector<bool> tone(n);
  queue<int> que;
  que.push(n - 1);
  while (not que.empty()) {
    int t = que.front(); que.pop();
    if (tone[t]) { continue; }
    tone[t] = true;
    REP(i, 0, rev[t].size()) {
      int u = rev[t][i];
      que.push(u);
    }
  }
  bool neg_cycle = false;
  REP(iter, 0, n) {
    REP(i, 0, n) {
      REP(j, 0, edges[i].size()) {
	pair<int, ll> e = edges[i][j];
	int w = e.first;
	if (dist[i] == inf) { continue; }
        ll tmp = dist[i] + e.second;
	if (dist[w] > tmp) {
	  dist[w] = tmp;
	  if (iter == n - 1 && tone[w]) {
	    neg_cycle = true;
	  }
	}
      }
    }
  }
  if (neg_cycle) {
    cout << "inf" << endl;
  } else {
    cout << -dist[n - 1] << endl;
  }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define ll long long
#define mod 1000000007

const int sz=1e5+5;
ll inf=1e15;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        string ans="No";
        int cnt=0;
        for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            if(x==y){
                cnt++;
            }
            else{
                cnt=0;
            }
            if(cnt>=3){
                ans="Yes";
            }
        }

        cout<<ans;
    }

    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MOD = 1e9 + 7;

void solve()
{
    ll N,W;
    cin>>N>>W;
    ll w[N];
    ll v[N];
    for(ll i=0;i<N;i++)
    {
        cin>>w[i]>>v[i];
    }
    ll dp[N+1][W+1];
    for(ll i=0;i<=N;i++)
    {
        for(ll j=0;j<=W;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j] = 0;
            }
            else
            {
                if(w[i-1] <= j)
                    dp[i][j] = max(v[i-1]+dp[i-1][j-w[i-1]] , dp[i-1][j]);
                else
                    dp[i][j] = dp[i-1][j];
            }
        }
    }
    cout << dp[N][W] <<"\n";
}

//MAIN 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 82504
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
    int n, c, tu; cin >> n >> c >> tu; //capacity, timeup
    int t[n];
    for (int i = 0; i < n; ++i) {
        cin >> t[i];
    }
    sort(t, t + n);
    int total = 1;
    int st = t[0];
    int cnt = 1;
    for (int i = 1; i < n; ++i) {
        ++cnt;
        if ((st + tu < t[i]) || (cnt > c)) {
            st = t[i];
            cnt = 1;
            ++total;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lstd
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}



void debug_out() { cerr << endl; }

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

int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

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

using namespace std;

class CAlchemist {
public:
	void solve(std::istream& in, std::ostream& out) {
		double x;
		int n;
		priority_queue<double, vector<double>, greater<double>> pq;

		in >> n;
		for (int i = 0; i < n; i++)
			in >> x, pq.push(x);

		while(pq.size() > 1){
			double a,b;
			a = pq.top(); pq.pop();
			b = pq.top(); pq.pop();
			//out << ((a+b)/2.0)<< endl;
			pq.push((a+b)/2.0);
		}

		out.precision(16);
		out << pq.top();

	}
};

int main() {
	CAlchemist solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		sc.close();
		System.out.println(Math.max(a + b, Math.max(a - b, a * b)));
	}

	public static boolean isPrime(long jud) {
		double root = Math.sqrt(jud);
		for (int i = 2; i <= root; i++) {
			if (jud % i == 0) {
				return false;
			}
		}
		return true;
	}

	// 配列要素数が1だと前触れなくバグるので注意！！！REりたくなければ要素数を保証するか例外処理を入れろ！！！
	public static long gcd(final long[] param) {
		final int len = param.length;
		long g = gcd(param[0], param[1]);
		for (int i = 1; i < len - 1; i++) {
			g = gcd(g, param[i + 1]);
		}
		return g;
	}

	public static long gcd(long a, long b) {
		// a > b にする(swap)
		if (a < b) {
			a = a ^ b;
			b = a ^ b;
			a = a ^ b;
		}
		// ユークリッドの互除法
		long r = -1;
		while (r != 0) {
			r = a % b;
			a = b;
			b = r;
		}

		return a; // b には r=0 の値が入るため、a を返す
	}

	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	public static long lcm(final long[] param) {
		final int len = param.length;
		long l = lcm(param[0], param[1]);
		for (int i = 1; i < len - 1; i++) {
			l = lcm(l, param[i + 1]);
		}
		return l;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};

int main()
{
    int n,m;
    while(cin>>n>>m,n>0)
{
    vector<int>a(n);vector<int>b(m);
    int suma=0,sumb=0;
    REP(i,n){cin>>a[i];suma+=a[i];}REP(i,m){cin>>b[i];sumb+=b[i];}
    if(abs((suma-sumb))%2==1){cout<<-1<<endl;continue;}
    sort(ALL(a));sort(ALL(b));
    int sum=(suma-sumb)/2;
    bool flag=1;
    REP(i,n)
    {
        auto re=find(ALL(b),a[i]-sum);
        if(re!=b.end())
        {
            cout<<a[i]<<" "<<*re<<endl;
            flag=0;
            break;
        }
    }
    if(flag)cout<<-1<<endl;
}    
}


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

#define step(i, s, n, d) for(int i=s; i<n; i+=d)
#define FOR(i,s,n) step(i,s,n,1)
#define rep(i,n) FOR(i,0,n)
#define gets(x) x; cin >> x;
#define puts(x) x; cout << x << endl;
#define list_input(x, n) x[n]; rep(i,n){ gets(x[i]);}
#define ll long long

int main(){
  string s;
  cin >> s;
  bool check[27] = {};
  rep(i, s.size()){
    if (!check[(int)s[i]-96]) {
      check[(int)s[i]-96] = !check[(int)s[i]-96];
    }else{
      puts("no")
      exit(0);
    }
  }
  puts("yes")
}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

int n;
ll a[100005] = {},b[100005] = {},c[100005] = {};

int main(){
    cin >> n;
    rep(i,0,n)cin >> a[i];
    rep(i,0,n)cin >> b[i];
    rep(i,0,n)cin >> c[i];

    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);

    ll ans = 0;
    rep(i,0,n){
        ans += lb(a,n,b[i]) * (n-ub(c,n,b[i]));
    }
    P(ans);
	return  0;
}

Measured memory_bytes: 2688
fun main(args: Array<String>) {
    val (H, W) = listOfInt()
    val A = Array(H) { listOfInt() }.flatMap { it }.toIntArray()
    fun rc(v: Int) = "${(v / W) + 1} ${(v % W) + 1}" //row-col
    var cnt = 0
    val str = StringBuilder()
    for (src in 0 until (W * H) - 1) {
        if (A[src] % 2 != 0) {
            cnt += 1
            val dst =  if (src < W * (H - 1)) src + W else src + 1
            A[src] -= 1
            A[dst] += 1
            str.append("\n${rc(src)} ${rc(dst)}")
        }
    }
    val ans = "${cnt}${str.toString()}"
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 87488
#include <iostream>
#include <map>

using namespace std;

const long long int MOD=1e9+7;

int main() {
    int N;
    cin >> N;
    int A;
    map<int, int> mp;
    for(int n=0; n<N; n++) {
        cin >> A;
        mp[A]++;
    }
    
    long long int ans=0;
    bool flag=true;
    if(N%2==0) {
        int cur=1;
        for(auto i=mp.begin(); i!=mp.end(); i++) {
            if(i->first==cur) {
                if(i->second!=2) {
                    ans = 0;
                    flag = false;
                    break;
                }

                cur += 2;
            } else {
                ans = 0;
                flag = false;
                break;
            }
        }

        if(flag) {
            ans = 1;
            for(auto i=mp.begin(); i!=mp.end(); i++) {
                ans *= 2;
                ans %= MOD;
            }
        }
    } else {
        int cur=0;
        for(auto i=mp.begin(); i!=mp.end(); i++) {
            if(i->first==cur) {
                if(cur==0) {
                    if(i->second!=1) {
                        ans = 0;
                        flag = false;
                        break;
                    }
                } else {
                    if(i->second!=2) {
                        ans = 0;
                        flag = false;
                        break;
                    }
                }
                
                cur += 2;
            } else {
                ans = 0;
                flag = false;
                break;
            }
        }
        
        if(flag) {
            for(auto i=mp.begin(); i!=mp.end(); i++) {
                if(i==mp.begin()) {
                    ans = 1;
                    continue;
                }
                ans *= 2;
                ans %= MOD;
            }
        }
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE long long
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int a=in(),b=in(),c=in(),d=in();
	if(a<=c&&c<=b&&b<=d)print(b-c);
	else if(c<=a&&a<=d&&d<=b)print(d-a);
	else if(a<=c&&c<=d&&d<=b)print(d-c);
	else if(c<=a&&a<=b&&b<=d)print(b-a);
	else print(0);
	return 0;
}

Measured memory_bytes: 128
N = gets.chomp.to_i
a = Array.new(N)
str = gets.split
for i in 0...N do
    a[i] = str[i].to_i
end
answer = 1
min = a[0]
for i in 1...N do
    if a[i] < min
        min = a[i]
        answer += 1
    end
end

puts answer

Measured memory_bytes: 15236
import math
import numpy as np
from itertools import permutations

N = int(input())

def cal(x1, y1, x2, y2):
    return ((x1-x2)**2 + (y1-y2)**2)**0.5

a = []
for i in range(N):
    a.append(list(map(int, input().split())))
    
total = 0
for i in permutations(a):
    for j in range(N-1):
        total += cal(i[j][0], i[j][1], i[j+1][0], i[j+1][1])
print(total / math.factorial(N))
    


Measured memory_bytes: 14496
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    string s;
    cin >>s;
    int count = 0;
    int ma = 0;
    rep(i,0,s.size()) {
        if (s[i] == 'R') {
            count++;
        } else {
            count = 0;
        }
        ma = max(ma, count);
    }
    cout << ma << endl;
}

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n),b(n),c(n);
  rep(i,n)cin>>a[i];
  
  rep(i,n)
  cin>>b[i];
  
  rep(i,n-1)
  cin>>c[i];
  
  
  int sum=0;
  rep(i,n){
    sum+=b[a[i]-1];
  }
 
  
  rep(i,n-1){
    if(a[i]+1==a[i+1])sum+=c[a[i]-1];
  }
  
  cout<<sum<<endl;
    
  
  
  
  
  
}

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

using namespace std;

const int maxn = (1<<18) + 5;
int n;
int a[maxn];
int x[maxn][2];
int num[maxn][2];

int main() {
	cin >> n;
	for (int i = 0; i < (1<<n); ++i)
		cin >> a[i];
	memset(x, 0, sizeof(x));
	memset(num, 0, sizeof(num));
	for (int i = 1; i < (1<<n); i <<= 1)
		if (x[i][0] < a[0]) {
			x[i][0] = a[0];
			num[i][0] = 0;
		}
		else if (x[i][1] < a[0]){
			x[i][1] = a[0];
			num[i][1] = 0;
		}
	int last = 0;
	for (int i = 1; i < (1<<n); ++i) {
		if (a[i] > x[i][0]) {
			swap(x[i][0], x[i][1]);
			swap(num[i][0], num[i][1]);
			x[i][0] = a[i];
			num[i][0] = i;
		}
		else if (a[i] > x[i][1]) {
			x[i][1] = a[i];
			num[i][1] = i;
		}
		last = max(last, x[i][0]+x[i][1]);
		printf("%d\n", last);
		for (int j = 1; j < (1<<n); j <<= 1) {
			if (x[i|j][0] < x[i][0]) {
				swap(x[i|j][0], x[i|j][1]);
				swap(num[i|j][0], num[i|j][1]);
				x[i|j][0] = x[i][0];
				num[i|j][0] = num[i][0];
				if (x[i|j][1] < x[i][1] && num[i|j][1] != num[i][1]) {
					x[i|j][1] = x[i][1];
					num[i|j][1] = num[i][1];
				}
			}
			else if (x[i|j][1] < x[i][0] && num[i|j][0] != num[i][0]) {
				x[i|j][1] = x[i][0];
				num[i|j][1] = num[i][0];
			}
			else if (x[i|j][1] < x[i][1]) {
				x[i|j][1] = x[i][1];
				num[i|j][1] = num[i][1];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 8192
#include<iostream>
using namespace std;
int main()
{
	long long int n,i,t,p=100000;
	cin >> n;
	if(n==1)
	{
		cout << "Yes" << endl;
		p=1;
	}
	else
	{
		for(i=9;i>=1;i--)
		{
			if(n%i==0)
			{
				t=n/i;
				if(t>=1 && t <= 9)
				{
					cout << "Yes" << endl;
					p=1;
					break;
				}
			}
		}
	}
	if(p==100000)
		cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

mp::cpp_int GCD(mp::cpp_int a,mp::cpp_int b){
	mp::cpp_int tmp;
	if(a<b){
		tmp = a;
		a = b;
		b =tmp;
	}
	mp::cpp_int r = a % b;
	while(r != 0){
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

mp::cpp_int LCM(mp::cpp_int a,mp::cpp_int b){
	mp::cpp_int gcd;
	gcd = GCD(a,b);
	return (a * b)/gcd;
}


int main(){
	int N;
	int i;
	mp::cpp_int lcm; 
	cin >> N;
	mp::cpp_int T[N];

	for(i=0;i<N;i++){
		cin >> T[i];
	}
	if(N != 1){
		lcm = LCM(T[0],T[1]);
	}else{
		lcm = T[0];
	}
	for(i=2;i<N;i++){
		lcm = LCM(lcm,T[i]);
	}
	cout << lcm << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> PL;

int A[100010];
const int MOD = 1e9 + 7;

void solve(){
	int n; scanf("%d", &n);
	for(int i=1;i<=n;i++){
		int x; scanf("%d", &x);
		A[i+1] = max(0, i - (x+1)/2);
	}
	ll ans = 1;
	for(int i=0, j=1;i<n;i++){
		while(j<=n && A[j] <= i)++j;
		ans = ans * (j-i-1) % MOD;
	}
	printf("%lld\n", ans);
}

int main(){
	int Tc = 1; //scanf("%d", &Tc);
	for(int tc=1;tc<=Tc;tc++){
		//printf("Case #%d: ", tc);
		solve();
	}
	return 0;
}

Measured memory_bytes: 640
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2006

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

string table[10] = { "#", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};

int main() 
{
	int N;
	cin >> N;
	rep(nth,N)
	{
		int count=0;
		string msg;
		cin >> msg;
		rep(i,msg.length())
		{
			if(msg[i] == msg[i+1]){
			count++;
			}else{
				string tmp = table[(msg[i]-'0')];
				char word = tmp[ count % (tmp.length()) ];
				if(word != '#'){ cout << word; }
				count=0;
			}
		}
		cout << endl;
	}
	return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<string> a(n);
    rep(i, n){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());

    int count = 0, tmp = 0;
    int max_t = 0;
    vector<string> s(n);
    rep(i, n-1){
        if(a.at(i) == a.at(i+1)){
            count++;
            if(max_t < count){
                max_t = count;
                s.at(1) = a.at(i);
                tmp = 1;
            } else if(max_t == count){
                tmp++;
                s.at(tmp) = a.at(i);
            }
        } else {
            count = 0;
        }
    }

    if(tmp == 0){
        rep(i, n){
            cout << a.at(i) << endl;
        }
        return 0;
    }

    for(int i = 1; i < tmp+1; i++){
        cout << s.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 16000
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int[] N = new int[3];
        for (int i = 0; i < 3; i++) {
            N[i] = Integer.parseInt(scanner.next());
        }

        Arrays.sort(N);
        System.out.println(N[0] * N[1] / 2);
    }
}



Measured memory_bytes: 23252
N = int(input())

S = [input().strip() for _ in range(N)]

cnt = {}
for c in 'MARCH':
    cnt[c] = 0
for s in S:
    c = s[0]
    if c not in 'MARCH':
        continue
    cnt[c] += 1

# print(cnt)
s = 'MARCH'
ans = 0
for i in range(3**5):
    a = i % 5
    b = i // 5 % 5
    c = i // 25 % 5
    if a == b or b == c or c == a:
        continue

    ans += cnt[s[a]] * cnt[s[b]] * cnt[s[c]]

print(ans // 12)


Measured memory_bytes: 10136
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ull mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vd a,b;

bool f(double m){
	double l=-inf,r=inf;
	for(int i=0;i<n;i++){
		double t=sqrt(b[i]*b[i]-m*m);
		l=max(l,a[i]-t);
		r=min(r,a[i]+t);
	}
	return l<r;
}

int main(){
	cin>>n;
	double l=0,r=inf;
	a=b=vd(n);
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		r=min(r,b[i]);
	}
	for(int i=0;i<60;i++){
		double m=(l+r)/2;
		if(f(m)) l=m;
		else r=m;
	}
	cout<<syosu(9)<<r<<endl;
}


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

int main() {
    int n;
    long long t, ma = 0;
    cin >> n >> t;
    for (int i = 0; i < n; ++i) {
        long long h;
        cin >> h;
        ma = max(ma, h);
        t -= h;
        if (t < 0)
            cout << "1\n";
        else
            cout << t / ma + 2 << "\n";
    }
    return 0;
}



Measured memory_bytes: 3112
def abc142_a():    
    n = int(input())
    # 奇数の数 / N　で確率が計算できる、

    # 偶数の数はn//2(2で割って小数点以下を切り捨てる)
    even_cnt = n // 2
    print((n - even_cnt) / n)

if __name__ == '__main__':
    abc142_a()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 2e5+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int k, n;
	cin >> k >> n;
	int a[n], cur = 0, ans = 2e9;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		cur += a[i] - (i ? a[i-1] : a[i]);
	}
	ans = min(ans, cur);
	for (int i = 0; i < n - 1; i++)
	{
		if (i == 0)
			cur = cur + a[0] + (k - a[n-1]) - (a[1] - a[0]);
		else
			cur = cur + (a[i] - a[i-1]) - (a[i+1] - a[i]);
		ans = min(ans, cur);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
 
int main() {
  int N; cin >> N;
  double sum = 0.0;
  rep(i, N) {
    double A; cin >> A;
    sum += 1.0 / A;
  }
  cout << setprecision(16) << 1.0/sum << endl;
}

Measured memory_bytes: 256
s = input()
s += "a"
n = len(s)
k = 1
lis = []
for i in range(n-1):
  if s[i] != s[i+1]:
    lis.append(k)
    k = 1
  else:
    k += 1
def fac(i):
  return i*(i+1)//2
lislis = []
num = len(lis)
for i in range(num):
  lislis.append(fac(lis[i]))
ans = sum(lislis)
if s[0] == "<":
  for i in range(0, num-1, 2):
    l = min(lis[i], lis[i+1])
    ans -= l
else:
  for i in range(1, num-1, 2):
    l = min(lis[i], lis[i+1])
    ans -= l
print(ans)

Measured memory_bytes: 8220
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>
#include <vector>
using namespace std;

const long long LL_INF = (long long) 2e18 + 5;

int N;
vector<long long> A, prefix_sum;
vector<vector<long long>> dp;

int main() {
    scanf("%d", &N);
    A.resize(N);
    prefix_sum.assign(N + 1, 0);
    dp.assign(N + 1, vector<long long>(N + 1, LL_INF));

    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
        prefix_sum[i + 1] = prefix_sum[i] + A[i];
        dp[i][i] = 0;
        dp[i][i + 1] = A[i];
    }

    for (int i = N - 1; i >= 0; i--)
        for (int j = i + 2; j <= N; j++)
            for (int k = i + 1; k < j; k++)
                dp[i][j] = min(dp[i][j], prefix_sum[j] - prefix_sum[i] + dp[i][k] + dp[k][j]);

    printf("%lld\n", dp[0][N] - prefix_sum[N]);
}


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

int main() {
  int A, B;
  cin >> A >> B;
  int N = 0;
  for(int i = A; i <= B; i++){
    int a = i / 10000;
    int b = i / 1000 % 10;
    int d = i % 100 / 10;
    int e = i % 10;
    if((a == e) && (b == d)){
      N++;
    }
  }
  cout << N <<endl;
}

Measured memory_bytes: 256
N = int(input())

S = {}
for i in range(N):
    s = input()
    if s not in S.keys():
        S[s] = 0
    S[s] += 1

m = 0
ans = []
for s, c in S.items():
    if c > m:
        ans = []
        ans.append(s)
        m = c
    elif c == m:
        ans.append(s)


for i in sorted(ans):
    print(i)


Measured memory_bytes: 32988
#include<iostream>

using namespace std;

int main()
{
    char c;
    cin >> c;
    if(c == 'a' ||c == 'e'||c == 'i'||c == 'o'||c == 'u')
    {
        cout<<"vowel"<<endl;
    }
    else{
        cout<<"consonant"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String S=sc.next();
    String T=sc.next();  
    int A=sc.nextInt();
    int B=sc.nextInt(); 
    String U=sc.next();
    
    if(U.equals(S))A--;
    else B--;
    System.out.println(A+" "+B);
   }
}

  

Measured memory_bytes: 25044
#include <stdio.h>
#define area(x,y) ((x) * (y))
#define rotation(x,y) ((2) * ((x) + (y)))

int main(void) {
	int a,b;
	scanf("%d%d",&a,&b);
	printf("%d %d\n",area(a,b),rotation(a,b));
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int div_ct(int n) {
  int c = 0;
  for (int i = 1; i <= n; ++i) {
    if ( n % i == 0) c++;
  }
  return c;
}
int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i <= n; ++i) {
    if ( i % 2 == 0) continue;
    else {
      if (div_ct(i) == 8) cnt++;
    }
  }
  cout << cnt << endl;

}

Measured memory_bytes: 256
using System;

class Program {
    static void Main(string[] args) {
        string s = Console.ReadLine();
        int a = 0, b = 0, c = 0, d = 0;
        foreach(var i in s) {
            if (i == 'N') a = 1;
            else if (i == 'S') b = 1;
            else if (i == 'W') c = 1;
            else if (i == 'E') d = 1;
        }
        Console.WriteLine(a - b == 0 && c - d == 0 ? "Yes" : "No");
    }
}

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  ll res = 0;
  for (int k = 30; k >= 0; --k) {
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      a[i] %= (1ll << (k + 1));
      b[i] %= (1ll << (k + 1));
    }
    sort(b.begin(), b.end());
    ll t = (1ll << k);
    for (int i = 0; i < n; ++i) {
      cnt += lower_bound(b.begin(), b.end(), 2 * t - a[i]) -
             lower_bound(b.begin(), b.end(), t - a[i]);
      cnt += lower_bound(b.begin(), b.end(), 4 * t - a[i]) -
             lower_bound(b.begin(), b.end(), 3 * t - a[i]);
    }
    if (cnt & 1) {
      res += (1ll << k);
    }
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

int main()
{
    int n,l;
    scanf("%d%d",&n,&l);
    int all=0,j=l;
    for(int i=0;i<n;i++)
    {
        all+=l+i;
        if(l+i<=0)
            j=l+i;
    }
    printf("%d\n",all-j);
    return 0;
}


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

int main() {
    long n, k;
    std::cin >> n >> k;
    std::vector<int> a(n);
    std::vector<int> b(n);
    std::vector<std::pair<int, int> > c(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i] >> b[i];
    }
    for (int i = 0; i < n; i++) {
        c[i] = std::make_pair(a[i], b[i]);
    }
    std::sort(c.begin(), c.end());
    for (int i = 0; i < n; i++) {
        k -= c[i].second;
        if (k <= 0) {
            std::cout << c[i].first << std::endl;
            break;
        }
    }
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;
	int x, y;
	cin >> x >> y;

	for(int i=0; i<100; i++){
		for(int j=0; j<100; j++){
			if(i+j==x && 2*i+4*j==y){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}

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


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC43
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int m = (int)Math.Round(a.Average());
            long cost = 0;
            for (int i = 0; i < n; i++)
            {
                cost += (a[i] - m) * (a[i] - m);
            }

            Console.WriteLine(cost);
        }
    }
}



Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pdd = pair<double, double>;
const int MOD = 1e9 + 7;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

int N, K;
double x[60], y[60], c[60], r[60];

double dist(const pdd &a, const pdd &b) {
	double xx = a.X - b.X;
	double yy = a.Y - b.Y;
	return sqrt(xx * xx + yy * yy);
}
vector<pair<double, double>> inter(int a, int b) {
	vector<pair<double, double>> ret;
	double d = dist(pdd(x[a], y[a]), pdd(x[b], y[b]));

	if (r[a] + r[b] < d) return ret;
	if (x[a] == x[b] && y[a] == y[b] || d < abs(r[a] - r[b])) return { { x[a], y[a] } };

	double tmp = (r[a] * r[a] - r[b] * r[b] + d * d) / (2 * d);
	double h = sqrt(r[a] * r[a] - tmp * tmp);

	double xx = x[a] + tmp / d * (x[b] - x[a]);
	double yy = y[a] + tmp / d * (y[b] - y[a]);

	ret.emplace_back(xx + h * (y[b] - y[a]) / d, yy - h * (x[b] - x[a]) / d);
	ret.emplace_back(xx - h * (y[b] - y[a]) / d, yy + h * (x[b] - x[a]) / d);

	return ret;
}
int check(double t) {
	for (int i = 0; i < N; ++i) r[i] = t / c[i];

	int ret = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			auto pts = inter(i, j);
			for (auto &p : pts) {
				int cnt = 0;
				for (int k = 0; k < N; ++k)
					if (dist(p, pdd(x[k], y[k])) <= r[k] + 1e-9) ++cnt;
				ret = max(ret, cnt);
			}
		}
	}

	return ret;
}
int main() {
	fastio;
	cin >> N >> K;
	for (int i = 0; i < N; ++i) cin >> x[i] >> y[i] >> c[i];

	double s = 0, e = 1e10;
	for (int i = 0; i < 100; ++i) {
		double m = (s + e) / 2.0;
		
		if (check(m) < K) s = m;
		else e = m;
	}

	cout << fixed << setprecision(9) << (s + e) / 2.0;

	return 0;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

typedef pair<double,int> pi;

struct circle
{
    double x,y,r;
};

struct edge
{
    int to;
    double cost;
};

const int N=1002;
vector<edge> G[N];

const double INF=1e18;
double dist[N];

inline double dtd(double x1, double y1, double x2, double y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}

inline double dtc(double x, double y, circle c)
{
    double d=dtd(x,y,c.x,c.y);
    d-=c.r;

    if(d<0) return 0;
    return d;
}

inline double ctc(circle a, circle b)
{
    double d=dtd(a.x,a.y,b.x,b.y);
    d-=a.r+b.r;

    if(d<0) return 0;
    return d;
}

int main()
{
    double xs,ys,xt,yt;
    scanf(" %lf %lf %lf %lf", &xs,&ys,&xt,&yt);

    int n;
    scanf(" %d", &n);
    vector<circle> c(n);
    rep(i,n) scanf(" %lf %lf %lf", &c[i].x, &c[i].y, &c[i].r);

    G[0].pb(edge{n+1,dtd(xs,ys,xt,yt)});
    G[n+1].pb(edge{0,dtd(xs,ys,xt,yt)});

    rep(i,n)
    {
        double d=dtc(xs,ys,c[i]);
        G[0].pb(edge{i+1,d});
        G[i+1].pb(edge{0,d});
        // printf("%d,%d %f\n", 0,i+1,d);
    }
    rep(i,n)
    {
        double d=dtc(xt,yt,c[i]);
        G[n+1].pb(edge{i+1,d});
        G[i+1].pb(edge{n+1,d});
        // printf("%d,%d %f\n", n+1,i+1,d);
    }

    rep(i,n)rep(j,i)
    {
        double d=ctc(c[i],c[j]);
        G[i+1].pb(edge{j+1,d});
        G[j+1].pb(edge{i+1,d});
        // printf("%d,%d %f\n", i+1,j+1,d);
    }

    // dijkstra
    priority_queue< pi,vector<pi>,greater<pi> > que;

    fill(dist,dist+N,INF);
    dist[0]=0;
    que.push(pi(0,0));
    while(!que.empty())
    {
        pi p=que.top();
        que.pop();
        int v=p.se;
        if(dist[v]<p.fi) continue;

        rep(i,G[v].size())
        {
            edge e=G[v][i];
            if(dist[e.to]>dist[v]+e.cost)
            {
                dist[e.to]=dist[v]+e.cost;
                que.push(pi(dist[e.to],e.to));
            }
        }
    }

    printf("%.20f\n", dist[n+1]);
    return 0;
}


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

using namespace std;

int main(){
	int n, k; cin >> n >> k;
	int ans = 1;
	for(int i = 0; i < n; i++){
		ans = ans + k < ans *2 ? ans +k: ans * 2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

int main() {
    int k, s;
    cin >> k >> s;
    int res = 0;
    REP(i, 0, k+1) {
        int t = s - i;
        if (s - i < 0) continue;
        int y;
        if (k <= t) {
            y = k;
        } else {
            y = t;
        }

        int x = t - y;
        if(y - x + 1 < 0) continue;
        res += (y - x + 1);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char> > field(H, vector<char>(W));
    vector< vector<vector<int> > > cnt(2, vector<vector<int> >(H, vector<int>(W)));
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> field[i][j];

    for (int i = 0; i < H; i++) {
        int tmp = 0;
        for (int j = 0; j < W; j++) {
            if (field[i][j] == '.') {
                tmp++;
                cnt[0][i][j] = tmp;
            }
            else tmp = 0;
        }
    }
    for (int i = 0; i < W; i++) {
        int tmp = 0;
        for (int j = 0; j < H; j++) {
            if (field[j][i] == '.') {
                tmp++;
                cnt[1][j][i] = tmp;
            }
            else tmp = 0;
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = W - 1; j > 0; j--) {
            if (cnt[0][i][j - 1] == 0) continue;
            cnt[0][i][j - 1] = max(cnt[0][i][j], cnt[0][i][j - 1]);
        }
    }
    for (int i = 0; i < W; i++) {
        for (int j = H - 1; j > 0; j--) {
            if (cnt[1][j - 1][i] == 0) continue;
            cnt[1][j - 1][i] = max(cnt[1][j][i], cnt[1][j - 1][i]);
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, cnt[0][i][j] + cnt[1][i][j] - 1);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 51328