akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
const int N=500005,M=1000000007;
int n,a,b,f[5005][2],i,j,g[5005][2],dp[5005][2];
int main()
{
	scanf("%d %d %d",&n,&a,&b);
	if(a<b)
		swap(a,b);
	int s=1;
	for(i=1;i<=n;++i)
		s=s*2%M;
	if(a==1||b==1)
	{
		cout<<s;
		return 0;
	}
	f[0][0]=1;
	g[1][1]=1;
	g[0][0]=1;
	for(i=2;i<=n;++i)
	{
		for(j=i-1;j>=0;--j)
			g[i][1]=(g[i][1]+g[j][0])%M;
		for(j=i-b;j>=0;--j)
			g[i][0]=(g[i][0]+g[j][1])%M;
	}
	dp[0][1]=1;
	for(i=1;i<=n;++i)
	{
		for(j=i-1;j>=0;--j)
			dp[i][1]=(dp[i][1]+dp[j][0])%M;
		for(j=i-b;j>=0;--j)
			dp[i][0]=(dp[i][0]+dp[j][1])%M;
	}
	for(i=1;i<=n;++i)
	{
		for(j=i-1;j>=0&&j>i-b;--j)
		{
			f[i][0]=(f[i][0]+f[j][1])%M;
			if(j==0)
				++f[i][0];
		}
		for(j=i-1;j>=0&&j>i-a;--j)
		{
			f[i][1]=(f[i][1]+1ll*f[j][0]*g[i-j][1])%M;
			if(j==0)
				f[i][1]=(f[i][1]+dp[i-j][1])%M;
		}
		if(i==n)
			for(j=i-1;j>=0&&j>i-a;--j)
				f[i][1]=(f[i][1]+1ll*f[j][0]*g[i-j][0])%M;
	}
	cout<<((s-f[n][0]-f[n][1])%M+M)%M;	
}


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

int main(){
    ll h1, s1, h2, s2;
    cin >> h1 >> s1 >> h2 >> s2;
    int turn = 1;
    while(h1 > 0 and h2 > 0){
        if(turn){
            h2 -= s1;
            turn = 0;
        }
        else{
            h1 -= s2;
            turn = 1;
        }
    }
    if(h1 <= 0)
        cout << "No\n";
    else
        cout << "Yes\n";

}


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

using namespace std;

int judge_triangle(int a, int b, int c)
{
  return b * b + c * c - a * a;
}

int main()
{
  int a, b, c;
  int num_of_triangle = 0;
  int num_of_acute = 0;
  int num_of_right = 0;
  int num_of_obtuse = 0;

  while (1) {
    cin >> a >> b >> c;
    int max_side = max({a, b, c});
    if (a + b + c - max_side <= max_side) break;
    num_of_triangle++;
    
    int judge;
    if (max_side == a) {
      judge = judge_triangle(a, b, c);
    } else if (max_side == b) {
      judge = judge_triangle(b, c, a);
    } else {
      judge = judge_triangle(c, a, b);
    }

    if (judge > 0) num_of_acute++;
    else if (judge < 0) num_of_obtuse++;
    else num_of_right++;
  }
  cout << num_of_triangle << " " << num_of_right << " " <<
      num_of_acute << " " << num_of_obtuse << endl;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define ll            long long

#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int main()
{
	//sb();
    ll n;
    cin>>n;
    vector<ll> dp(3,0);
    ll a,b,c;
    cin>>a>>b>>c;
    dp[0] = a;
    dp[1] = b;
    dp[2] = c;
    ll ans = max(dp[0],max(dp[1],dp[2]));
    for(int i=1;i<n;i++){
       vector<ll> curr(3,0);
       ll d,e,f;
       cin>>d>>e>>f;
       curr[0] = max(dp[1],dp[2])+d;
       curr[1] = max(dp[0],dp[2]) +e;
       curr[2] = max(dp[0],dp[1])+f;
       dp = curr;
       //cout<<dp[0]<<" "<<dp[1]<<" "<<dp[2]<<endl;
         ans = max(dp[0],max(dp[1],dp[2]));

    }
    cout<<ans;
    



return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
using ll = long long;
const int MAX = 2e5;
const ll mod = 1e9+7;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * (ll)i % mod;
        inv[i] = mod - inv[mod%i] * (mod/(ll)i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

ll Pow(ll x, ll n){
  if(n == 0) return 1;
  if(n % 2 == 0) return Pow(x*x % mod, n/2);
  else return x * Pow(x,n-1) % mod;
}

void extgcd(ll a, ll b, ll &x, ll &y) {
  if(b == 0) {
    x = 1;
    y = 0;
    return;
  }
  extgcd(b, a%b, y, x);
  y -= a/b*x;
  return; 
}

ll mod_inverse(ll a, ll m) {
  ll x, y;
  extgcd(a,m,x,y);
  return (m + x % m) % m;
}

int main(){
  COMinit();
  ll n, a, b, c;
  cin >> n >> a >> b >> c;
  ll child = 0;
  ll parent = Pow(a+b,2*n-1)*(100-c) % mod;
  for(ll i = 0; i < n; i++) {
    ll x = (n+i)*Pow(a,n) % mod;
    ll y = (n+i)*Pow(b,n) % mod;
    ll t = Pow(a+b,n-i-1)*Pow(b,i) % mod;
    ll s = Pow(a+b,n-i-1)*Pow(a,i) % mod;
    ll w = (x*t + y*s) % mod;
    (child += w*COM(n-1+i,i) % mod) %= mod;
  }
  (child *= 100) %= mod;
  ll ans = child * mod_inverse(parent,mod) % mod;
  cout << ans << endl;
  return 0;
}

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


int dp[100];

//最大公約数
int gcd(int x, int y){
  if(x % y == 0) return 1;
  return gcd(y, x % y);
}
//最小公倍数
int lcm(int x, int y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp[n] = 1;
  if(dp[n] != -1) return dp[n];
  return dp[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int a, p;
  cin >> a >> p;

  int ans = a * 3 + p;
  ans = ceil(ans / 2);
  cout << ans << endl;
}


/*





















*/


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <stdio.h>
#include <numeric>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	//freopen("input.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	int n;
	cin >>n;
	vector<int> mas(n);
	vector<int> perm(n);
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		cin >> mas[i];
		perm[i] = i + 1;
		cnt += (mas[i] != perm[i]);
	}
	if (cnt <= 2) cout << "YES\n";
	else cout << "NO\n";
	/*int n, m, k;
	cin >> n >> m >> k;
	vector <tuple<int, int, int>> edges(m);
	for (int i = 0; i < m; ++i) {
		int x, y, w;
		cin >> x >> y >> w;
		if (x > y) swap(x, y);
		edges[i] = make_tuple(w, x, y);
	}
	sort(edges.begin(), edges.end());
	vector <tuple<int, int, int>> paths;
	int curmin = get<0>(edges[0]);
	int ind = 0;
	int cnt = 0;
	while (get<0>(edges[ind]) == curmin && cnt < k) {
		paths.push_back(edges[ind]);
		++ind;
		++cnt;
	}
	while (cnt < k) {
		curmin = get<0>(edges[ind]);
		bool added = false;
		for (int i = 0; i < paths.size(); ++i)
			for (int j = i + 1; j < paths.size(); ++j) {
				int xi = get<1>(paths[i]);
			}

	}*/
	/*int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	vector<int> powers(n);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		++powers[a];
		++powers[b];
	}
	vector<pair<int, int>> sorted(n);
	for (int i = 0; i < n; ++i) {
		sorted[i].first = powers[i];
		sorted[i].second = i;
	}
	sort(sorted.begin(), sorted.end());
	if (m % 2) {
		cout << -1 << endl;
		return 0;
	}*/
	//cout << get<0>(paths[k - 1]);
	return 0;
}


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

struct Card
{
	char mark;
	int value;
};

int merge(struct Card A[], int left, int mid, int right)
{
	int n1=mid-left;
	int n2=right-mid;
	int i,j,k;
	struct Card L[50001];
	struct Card R[50001];
	
	for(i=0;i<=n1-1;i++) L[i]=A[left+i];
	for(i=0;i<=n2-1;i++) R[i]=A[mid+i];
	L[n1].value=2000000001;
	R[n2].value=2000000001;
	i=0;
	j=0;
	for(k=left;k<=right-1;k++)
	{
		if(L[i].value<=R[j].value)
		{
			A[k]=L[i];
			i++;
		}
		else
		{
			A[k]=R[j];
			j++;
		}
	}
}

int mergeSort(struct Card A[], int left, int right)
{
	int mid;
	if(left+1<right)
	{
		mid=(left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
}

int partition(struct Card A[], int p, int r)
{
	int i,j;
	struct Card x,temp;
	
	x=A[r];
	i=p-1;
	for(j=p;j<=r-1;j++)
	{
		if(A[j].value<=x.value)
		{
			i++;
			temp=A[j];
			A[j]=A[i];
			A[i]=temp;
		}
	}
	temp=A[r];
	A[r]=A[i+1];
	A[i+1]=temp;
	return i+1;
}

int quickSort(struct Card A[], int p, int r)
{
	int q;
	
	if(p<r)
	{
		q=partition(A,p,r);
		quickSort(A,p,q-1);
		quickSort(A,q+1,r);
	}
}

int main()
{
	int i,n,v;
	struct Card A[100000],B[100000];
	char m[2];
	int s=0;
	
	scanf("%d",&n);
	
	for(i=0;i<=n-1;i++)
	{
		scanf("%s %d",m,&v);
		A[i].mark=B[i].mark=m[0];
		A[i].value=B[i].value=v;
	}
	
	quickSort(A,0,n-1);
	mergeSort(B,0,n);
	
	for(i=0;i<=n-1;i++)
	{
		if(A[i].mark!=B[i].mark) s=1;
	}
	
	if(s==0) printf("Stable\n");
	else printf("Not stable\n");
	
	for(i=0;i<=n-1;i++)
	{
		printf("%c %d\n",A[i].mark,A[i].value);
	}
	
	return 0;
}

Measured memory_bytes: 5552
N, K = gets.split(" ").map(&:to_i)

answer = 0

N.times.each do |n|
  if n + 1 < K
    m = n + 1
    i = 0
    while m < K
      m = m * 2
      i += 1
    end
    answer += (Rational(1, N) * (Rational(1, 2) ** i)).to_f
  else
    answer += Rational(1, N).to_f
  end
end

puts answer


Measured memory_bytes: 1788
#include <bits/stdc++.h>
                
        typedef long long ll;
        using namespace std;
                
        #define F first
        #define S second
        #define sqr(x) x*x
        #define pb push_back
        #define mp make_pair
        #define sz(x) ((int) (x).size())
        #define all(x) (x).begin(), (x).end()
        #define allr(x) (x).rbegin(), (x).rend()
        #define repit(i, n) for(auto it = n.begin(); it != n.end(); ++it)
            
        const ll mod=1000000007;
        ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
        ll gcd(ll a,ll b){if(b==0)return a;else return gcd(b,a%b);}
        int lcm(int a,int b){return abs(a*b)/gcd(a,b);}

        bool isP(string s){
            for(int i = 0 ; i < sz(s) / 2; ++i){
                if(s[i] != s[sz(s) - 1 - i]){
                    return false;
                }
            }
            return true;
        }

        int main(){ios_base::sync_with_stdio(0);cin.tie(0);
            double a , b;
            cin >> a >> b;
            cout << ceil((b - 1) / (a - 1));
        }


Measured memory_bytes: 256
#include<algorithm>
#include <cstring>
#include <iostream>
#include<cmath>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<utility>
#include<stack>
#include <complex>
#include <cassert>
using namespace std;

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

const double EPS = 1e-8;
const int INF = 1<<29;
const double PI = acos(-1);

typedef complex<double> P;

namespace std {
bool operator<(const P &a, const P&b) {
  return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
}
}
double cross(const P &a, const P&b) {
  return imag(conj(a)*b);
}
double dot(const P &a, const P&b) {
  return real(conj(a)*b);
}
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
  L() {}
};
typedef  vector<P> G;

int ccw(P a, P b, P c) {
  b-=a; c-=a;
  if (cross(b,c) > 0) return 1;
  if (cross(b,c) < 0) return -1;
  if (dot(b,c) < 0) return 2;
  if (norm(b) < norm(c)) return -2;
  return 0;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0];
  if (abs(A) < EPS) assert(false);
  return m[0] + B/A*(m[1]-m[0]);
}
double area( const G &g) {
  double A = 0;
  for (int i=0; i<g.size(); ++i)
    A += cross(g[i],g[(i+1)%g.size()]);
  return abs(A/2);
}
G convex_cut(const G &g, const L &l) {
  G Q;
  for (int i=0; i<g.size(); ++i) {
    P A = g[i];
    P B = g[(i+1)%g.size()];
    if (ccw(l[0], l[1],A) != -1) Q.push_back(A);
    if (ccw(l[0],l[1],A)  * ccw(l[0],l[1],B) < 0)
      Q.push_back(crosspoint(L(A,B),l));
  }
  return Q;
}
L bisector(const P &a, const P &b) {
  P A = (a+b)*P(0.5,0);
  return L(A,A+(b-a)*P(0,PI/2));
}
G voronoi_cell(G g, const vector<P> &v, int s) {
  for (int i=0; i<v.size(); ++i) {
    if (i!=s) {
      g = convex_cut(g,bisector(v[s],v[i]));
    }
  }
  return g;
}

double ans[100];

int main() {
  int n,m;
  while(cin>>n>>m,n||m) {
    vector<P> p(n);
    for (int i=0; i< n; ++i) cin >> p[i].real() >> p[i].imag();
    memset(ans,0,sizeof(ans));
    for (int i=0; i<m; ++i) {
      int bx,by,dx,dy;
      cin>>bx>>by>>dx>>dy;
      int score;
      cin >> score;
      G g;
      g.push_back(P(bx-dx,by-dy));
      g.push_back(P(bx+dx,by-dy));
      g.push_back(P(bx+dx,by+dy));
      g.push_back(P(bx-dx,by+dy));
      for (int i=0; i<n; ++i) {
        G v = voronoi_cell(g, p, i);
        ans[i] += area(v) / area(g) * score;
      }
    }
    double res = *max_element(ans,ans+n);
    printf("%.10f\n", res);
  }
  
}

Measured memory_bytes: 1272
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

using namespace std;
int c = 0;
void selectionsort(vector<int>& a, int n) {
	for (size_t i = 0; i < n; i++)
	{
		int ind = i;
		for (size_t j = i; j < n; j++)
		{
			if(a[ind] > a[j]) {
				ind = j;
			}
		}
		if(a[i] != a[ind]) {
			c++;
			swap(a[i], a[ind]);
		}
	}
}

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	selectionsort(a, n);
	for (size_t i = 0; i < n; i++)
	{
		if(i == 0) {
			cout << a[i];
			continue;
		}
		cout << " " << a[i];
	}
	cout << endl;
	cout << c << endl;
}



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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	v.push_back(0);
	REP(i, n)cin >> v[i + 1];
	v.push_back(0);
	int sum = 0;
	REP(i, n+1) {
		sum += abs(v[i + 1] - v[i]);
	}
	REP(i, n) {
		cout << sum - abs(v[i + 1] - v[i]) - abs(v[i + 2] - v[i + 1]) + abs(v[i + 2] - v[i]) << endl;
	}

}


Measured memory_bytes: 1656
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    ll c;
    cin>>n>>c;
    vector<pair<ll, ll> > v(n+2);
    v[0] = make_pair(0, 0);
    rep(i, n) {
        ll a, b;
        cin>>a>>b;//aが距離, bがカロリー
        v[i+1] = make_pair(a, b);
    }
    v[n+1] = make_pair(c, 0);
    vector<ll> s1(n+1);
    vector<ll> s2(n+1);
    vector<ll> s1max(n+1);
    vector<ll> s2max(n+1);
    ll now = 0;
    for(int i = 0;i<n;i++){
        now += v[i+1].second;
        s1[i+1] = now - v[i+1].first;
        s1max[i+1] = max(s1max[i], s1[i+1]);
    }
    reverse(v.begin(), v.end());
    now = 0;
    for(int i = 0;i<n;i++){
        now += v[i+1].second;
        s2[i+1] = now - (c-v[i+1].first);
        s2max[i+1] = max(s2max[i], s2[i+1]);
    }
    ll ans = 0;
    reverse(v.begin(), v.end());
    rep(i, n+1){
        ans = max(ans, s2[i]-(c-v[n+1-i].first)+s1max[n-i]);
    }
    rep(i, n+1){
        ans = max(ans, s1[i]-v[i].first+s2max[n-i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7,INF=1e18;
#define ll long long
#define pll pair<ll,ll>
#define x first
#define y second
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    // cin>>t;
    while(t--)
    {
        ll d,t,s;
        cin>>d>>t>>s;
        if(d<=t*s)
        cout<<"Yes\n";
        else
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>

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

	std::string S;
	std::cin >> S;

	bool result = false;
	if(S.size() % 2 == 0) {
		const int half = S.size() / 2;
		if(S.substr(0, half) == S.substr(half, half)) {
			result = true;
		}
	}

	std::cout << (result ? "Yes" : "No") << std::endl;

	return 0;
}


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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  
  int ans = min(a,k);
  k -= a;
  if (k>0) {k -= b;}
  if (k>0) {ans -= k;}
  cout << ans << endl;
  
  return 0;
}

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

using namespace std;

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

    int n;
    cin>>n;

    vector<int> arr(n);

    for(int i=0;i<n;i++) cin>>arr[i];

    int q;
    cin>>q;

    while(q--)
    {
        int l,r;
        cin>>l>>r;

        reverse(arr.begin()+l,arr.begin()+r);
    }

    for(int i=0;i<arr.size();i++)
    {
        cout<<arr[i]<<((i==arr.size()-1)?'\n':' ');
    }


    return 0;
}



Measured memory_bytes: 3236
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef pair<int, int> P;

vector<P> rect;

bool solve(){
  int h, w;
  cin >> h >> w;
  if(h == 0 && w == 0)return false;
  for(int i = 0;i < rect.size();i++){
    if(rect[i] == P(h, w)){
      cout << rect[i+1].first << " " << rect[i+1].second<< endl;
      return true;
    }
  }
}

bool diag(P a, P b){
  int x = a.first;
  int y = a.second;
  int z = b.first;
  int zz = b.second;
  if(x*x+y*y == z*z+zz*zz)return x < z;
  return x*x+y*y < z*z+zz*zz;
}

int main(){
  for(int i = 1;i <= 210;i++){
    for(int j = i + 1;j <= 210;j++){
      rect.push_back(P(i, j));
    }
  }
  sort(rect.begin(), rect.end(), diag);
  while(solve());
  return 0;
} 

Measured memory_bytes: 1328
def max_for_str(a, b):
    if len(a) > len(b):
        return a
    elif len(a) < len(b):
        return b
    else:#This case is unlikely to happen.
        for c1, c2 in zip(a, b):
            if c1 > c2:
                return a
            elif c1 < c2:
                return b
        return a
            
match = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]

N, M = map(int, input().split())
As = list(input().split())

dp = [None] * (N+1)
dp[0] = ""

for i in range(N+1):
    for A in As:
        if i - match[int(A)] >= 0 and not dp[i - match[int(A)]] is None:
            if dp[i] is None:
                dp[i] = A + dp[i - match[int(A)]]
            else:
                dp[i] = max_for_str(dp[i] , A + dp[i - match[int(A)]])

print(dp[N])

Measured memory_bytes: 28916
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}
ll gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}




int main() {
	ll N,K;
	cin >> N >> K;
	set<ll> s;
	rep(i, K) {
		ll b;
		cin >> b;
		s.insert(b);
	}
	ll an = N;
	while (1) {
		ll x = an;
		ll c = 1;
		while (x > 0) {
			if (s.count(x % 10)) {
				c = 0;
				break;
			}
			x /= 10;
		}
		if (c == 1) {
			break;
		}
		an++;
	}
	cout << an  << endl;


}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int n, d;
    cin >> n >> d;
    int cnt = 0;
    
    int a[n][d];
    
    for(int i = 0; i < n; i++){
       for(int j = 0; j < d; j++){
           cin >> a[i][j];
       }
    }
    
    for(int i = 0; i < n - 1; i++){
        
        for(int j = i+1; j < n; j++){
            int sum = 0;
            for(int k = 0; k < d; k++){
               sum += (a[i][k]  - a[j][k]) * (a[i][k]  - a[j][k]);
            }
            
            double ans = sqrt(sum);
            
            if (ceil(ans) != double(ans)){
                
            } else {
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
//Code by Anshuman Das Gupta

#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define int long long
#define MOD 1000000007
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define loop(I,N) for(int i=I;i<N;i++)
#define sortvec(V) sort(V.begin(),V.end())
#define vec vector<int>
#define endl "\n"
using namespace std;
int fast_power(int base, int power) {
    int result = 1;
    while (power > 0) {

        if (power & 1 == 1) {
            result = (result * base) % MOD;
        }
        base = (base * base) % MOD;
        power = power >> 1;
    }
    return result % MOD;
}

bool isPrime(int x) {
    for (int i = 2; i <= sqrt(x); i++) {
        if (x % i == 0)
            return false;
    }
    if (x == 1)
        return false;
    return true;
}

int binsearch(int a[], int f, int r, int x) {
    while (f <= r) {
        int mid = (f + r) / 2;
        if (a[mid] == x)
            return mid;
        else if (a[mid] > x) {
            r = mid - 1;
        }
        else {
            f = mid + 1;
        }
    }
    return -1;
}
void sieve(int a[], int n) {
    a[0] = 0;
    a[1] = 0;
    for (int i = 2; i <= n; i++) {
        if (a[i] == 1) {
            for (int j = i + i; j <= n; j += i) {
                a[j] = 0;
            }
        }
    }
}
int32_t main() {
#ifndef ONLINE_JUDGE
    //for getting input from input.txt
    freopen("input.txt", "r", stdin);
    //for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
    while (t--) {
        int a, b, h, m;
        cin >> a >> b >> h >> m;
        h = h * 60 + m;
        double hangle = h * 0.5;
        double mangle = m * 6;
        double angle = fabs(hangle - mangle);
        if (angle >= 180) {
            angle = 360 - angle;
        }
        double pi = 2 * acos(0.0);
        angle = (angle * pi) / 180;
        double ans = sqrt(pow(a, 2) + pow(b, 2) - (2 * a * b * cos(angle)));
        cout << fixed << setprecision(20) << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4164
#include<iostream>
using namespace std;
int main (){
	int W,V;
	for(;;){
		cin>>V>>W;
		if(W==0&&V==0){
			break;}
	for(int z = 0; z < V; z++ ){
	for(int y = 0; y < W; y++ ){
		cout<<"#";
	}
	cout<<endl;
	}cout<<endl;
	
	}
	return 0;
}


Measured memory_bytes: 3076
while 1:
  m = int(raw_input())
  if m==0: break

  card = []
  total = 0
  for i in range(m):
    a, b = map(int, raw_input().split())
    card.append([a, b])
    total += a*b
  card = sorted(card)[::-1]

  B = [0]*(total+1)
  for a, b in card:
    A = B[:]
    B = [0] * (total+1)
    B[a:a*b+1:a] = [1]*b
    for i in range(total+1)[::-1]:
      if A[i]:
        for e in range(i, i+a*b+1, a):
          B[e] += A[i]

  g = int(raw_input())
  for _ in [0] * g:
    n = int(raw_input())
    if 0<=n<=total:
      print B[n]
    else:
      print 0

Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

const int MAX = 4000004;

int main() {
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }

    bitset<MAX> dp;
    dp[0] = 1;

    rep(i,n){
        dp |= (dp << a[i]);
    }

    srep(i, (sum+1)/2, sum+1){
        if(dp[i] == 1){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}




Measured memory_bytes: 5116
n=int(input())
n_100=n//100
n_10=(n-n_100*100)//10
n_1=(n-n_100*100-n_10*10)
if n_100==1:
    ans_100=9
elif n_100==9:
    ans_100=1
else:
    ans_100=n_100
if n_10==1:
    ans_10=9
elif n_10==9:
    ans_10=1
else:
    ans_10=n_10
if n_1==1:
    ans_1=9
elif n_1==9:
    ans_1=1
else:
    ans_1=n_1
ans=ans_100*100+ans_10*10+ans_1
print(ans)

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

int main(void){
    int a, b;
    cin >> a >> b;
    if(a >= 13){
        cout << b << endl;
    }else if(a >= 6 && a <= 12){
        cout << b/2 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int m=1000000007;
#define ll long long int

ll binpow(ll a, ll b) {
    a %= m;
    ll result=1;
    while (b > 0) {
        if (b & 1)
            result = result * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return result;
}
int main()
{
	
   int n;cin>>n;
   if(n==1)
   {
   	cout<<0;
   	
   }
   else if(n==2)
   {
   	cout<<2;
   	
   }
   else
   {
   	ll ans=(binpow(10,n)-binpow(9,n)-binpow(9,n)+binpow(8,n))%m;
   	cout<<(ans+m)%m;


   }

}

   	
   	


	
	

	




Measured memory_bytes: 3632
import numpy as np

n, d = map(int,input().split())

listA=[] #appendのために宣言が必要
while True:
    try:
        listA.append(list(map(int,input().split())))

    except:
        break;
        #または、quit(),os.exit()をして止める。

count = 0
for i in range(n):
    for j in range(n):
        if(i < j):
            dis = 0
            for k in range(d):
                dis += (listA[i][k]-listA[j][k]) ** 2
            dis = np.sqrt(dis)
            #if(dis.is_integer()):
            if( dis/int(dis) == 1 ):
                count += 1


print(count)


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

int main(void) 
{
    int n;
    ll k;
    cin >> n >> k;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
    }

    vector<int> s;
    vector<int> ord(n+1,-1);

    int c =1, l = 0;

    int v = 1;
    while(ord[v] == -1){
        ord[v] = s.size();
        s.push_back(v);
        v = a[v -1];
    }
    c = s.size() -ord[v];
    l = ord[v];

    if(k < l) cout << s[k] << endl;
    else {
        k -= l;
        k %= c;
        cout << s[l+k] <<endl;
    }
}


Measured memory_bytes: 5856
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<vector<pair<int, int>>> A(N);
  REP(i, N){
    int a;
    cin >> a;
    A[i].resize(a);
    REP(j, a){
      cin >> A[i][j].first >> A[i][j].second;
      A[i][j].first--;
    }
  }

  int ans = 0;
  REP(bit, (1<<N)){
    [&]{
      int ret = 0;
      bool flag = true;
      REP(i, N){
        if((bit >> i)&1){
          REP(j, A[i].size()){
            if(((bit >> A[i][j].first)&1) != A[i][j].second) return;
          }
          ret++;
        }
      }

      if(flag) chmax(ans, ret);
    }();
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD1 1000000007

int ketasum(int x) {
  int sum  = 0;
  while (x > 0) {
    sum += x % 10;
    x = x / 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  rep(i, N) cin >> a.at(i);

  sort(all(a), greater<int>());
  int Alice = 0, Bob = 0;

  rep(i, N) {
    if (i % 2 == 0) Alice += a.at(i);
    else Bob += a.at(i);
  }

  cout << Alice - Bob << endl;


}


Measured memory_bytes: 256
import sys
from collections import Counter, deque, defaultdict
from math import factorial
from fractions import Fraction
import heapq, bisect
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
MOD = 10**9 + 7
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

s = input()
n = len(s) + 1
s = list(s)
a = []
temp = 0
for i in range(n-1):
    if i == n-2:
        a.append(n-1-temp)
    else:
        if s[i] != s[i+1]:
            a.append(i+1-temp)
            temp = i+1

if s[0] == '>':
    a.insert(0, 0)
if s[-1] == '<':
    a.append(0)
res = 0
for i in range(len(a)//2):
    h = max(a[2*i], a[2*i + 1])
    l = min(a[2*i], a[2*i + 1])
    ans = l*(l-1)//2 + h + h*(h-1)//2
    res += ans

print(res)


Measured memory_bytes: 115416
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 20;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main()
{
	ll N;
	scanf("%lld", &N);
	ll m = 1, n = 0;
	while(m*10 <= N ) m *= 10, n += 9;
	for(int i = 1; i <= 9; i++){
		if( (i+1)*m-1 <= N ) n++;
		else break;
	}
	printf("%lld\n", n);
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 a,b,c; cin >> a >> b >>c;
    i32 ans = max<i32>({a,b,c}) - min<i32>({a,b,c});
    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


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

int main(){
    ll n,ans=0;
    cin>>n;
    if(n==2)ans=1;
    if(n>=3)ans=((n-1)*n)/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 300005;

int n, w, h, ans, x[MAXN], y[MAXN], tmp[MAXN], st1[MAXN], st2[MAXN], val[MAXN << 2], tag[MAXN << 2];
pii a[MAXN];

inline void Build(int x, int l, int r)
{
	val[x] = -tmp[l], tag[x] = 0;
	if (l == r)
		return ;
	int mid = l + r >> 1;
	Build(x << 1, l, mid), Build(x << 1 | 1, mid + 1, r);
}

inline void Modify(int x, int l, int r, int ql, int qr, int v)
{
	if (ql > qr)
		return ;
	if (l == ql && r == qr)
		return (void)(val[x] += v, tag[x] += v);
	int mid = l + r >> 1;
	if (qr <= mid)
		Modify(x << 1, l, mid, ql, qr, v);
	else if (ql > mid)
		Modify(x << 1 | 1, mid + 1, r, ql, qr, v);
	else
		Modify(x << 1, l, mid, ql, mid, v), Modify(x << 1 | 1, mid + 1, r, mid + 1, qr, v);
	val[x] = max(val[x << 1], val[x << 1 | 1]) + tag[x];
}

inline void Solve()
{
	int n = ::n, m = 0, mid = h >> 1, tp1 = 0, tp2 = 0;
	for (int i = 1; i <= n; i ++)
		a[i] = mp(x[i], y[i]);
	sort(a + 1, a + n + 1);
	if (a[n].xx < w)
		a[++ n] = mp(w, 0);
	for (int i = 1; i <= n; i ++)
		tmp[++ m] = a[i].xx;
	tmp[++ m] = 0;
	sort(tmp + 1, tmp + m + 1);
	m = unique(tmp + 1, tmp + m + 1) - tmp - 1;
	for (int i = 1; i <= n; i ++)
		a[i].xx = lower_bound(tmp + 1, tmp + m + 1, a[i].xx) - tmp;
	a[0].xx = 1;
	Build(1, 1, m);
	if (a[1].xx > 1)
		Modify(1, 1, m, 1, 1, h);
	for (int i = 1; i <= n; i ++)
		if (a[i].yy <= mid)
		{
			Modify(1, 1, m, a[i].xx, a[i].xx, h);
			ans = max(ans, tmp[a[i].xx] + val[1]);
			Modify(1, 1, m, a[st1[tp1]].xx, a[i].xx - 1, -a[i].yy);
			while (tp1 && a[st1[tp1]].yy <= a[i].yy)
				Modify(1, 1, m, a[st1[tp1 - 1]].xx, a[st1[tp1]].xx - 1, a[st1[tp1]].yy - a[i].yy), tp1 --;
			st1[++ tp1] = i;
		}
		else
		{
			Modify(1, 1, m, a[i].xx, a[i].xx, h);
			ans = max(ans, tmp[a[i].xx] + val[1]);
			Modify(1, 1, m, a[st2[tp2]].xx, a[i].xx - 1, a[i].yy - h);
			while (tp2 && a[st2[tp2]].yy >= a[i].yy)
				Modify(1, 1, m, a[st2[tp2 - 1]].xx, a[st2[tp2]].xx - 1, a[i].yy - a[st2[tp2]].yy), tp2 --;
			st2[++ tp2] = i;
		}
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	w = Read(), h = Read(), n = Read();
	for (int i = 1; i <= n; i ++)
		x[i] = Read(), y[i] = Read();
	Solve();
	for (int i = 1; i <= n; i ++)
		swap(x[i], y[i]);
	swap(w, h);
	Solve();
	return printf("%d\n", ans << 1), 0;
}


Measured memory_bytes: 17920
#include <iostream>

using namespace std;


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

    if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
        cout << a * b << endl;
    } else {
        cout << "-1" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
    }
    println!("{}", (n - 2) * 180);
}


Measured memory_bytes: 4352
from sys import stdin

N = int(stdin.readline().rstrip())

if N == 0:
    print(0)
    exit

bits = ''
rest = N
while rest != 0:
    if rest % 2 == 0:
        bits = '0' + bits
        rest = rest // -2
    else:
        bits = '1' + bits
        rest = (rest - 1) // -2

print(bits)


Measured memory_bytes: 2940
#include<cstdio>

int main(){
	int a,b;
	scanf("%d %d", &a, &b);
	int c[9];
	while(a || b){
		int count = 0;
		if(b < 46){
			for(int i = 0; i < 10; i++){
				for(int j = i + 1; j < 10; j++){
					for(int k = j + 1; k < 10; k++){
						for(int l = k + 1; l < 10; l++){
							for(int m = l + 1; m < 10; m++){
								if(a == 5){
									if(i + j + k + l + m == b){
										count++;
									}
								}
							}
							if(a == 4){
								if(i + j + k + l == b){
									count++;
								}
							}else if(a == 6){
								if(i + j + k + l == 45 - b){
									count++;
								}
							}
						}
						if(a == 3){
							if(i + j + k == b){
								count++;
							}
						}else if(a == 7){
							if(i + j + k == 45 - b){
								count++;
							}
						}
					}
					if(a == 2){
						if(i + j == b){
							count++;
						}
					}else if(a == 8){
						if(i + j == 45 - b){
							count++;
						}
					}
				}
				if(a == 1){
					if(i == b){
						count++;
					}
				}else if(a == 9){
					if(i == 45 - b){
						count++;
					}
				}
			}
		}
		printf("%d\n", count);
		scanf("%d %d", &a, &b);
	}
	return 0;
}

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

int main() {
    vector<int> N(5);
    for (int i = 0; i < 5; i++) {
        cin >> N.at(i);
    }
    sort(N.begin(), N.end());
    int m = 0, cnt;
    for (int i = 0; i < 5; i++) {
        m += N.at(i);
        if (m % 10 != 0 && i != 4) {
            m += 10 - m % 10;
        }
    }
    while(next_permutation(N.begin(), N.end())) {
        cnt = 0;
        for (int i = 0; i < 5; i++) {
            cnt += N.at(i);
            if (cnt % 10 != 0 && i != 4) {
                cnt += 10 - cnt % 10;
            }
        }
        m = min(m, cnt);
    }
    cout << m << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int        long long
#define MOD        1000000007
#define MAX        100005
#define pb         push_back
#define mp         make_pair
#define pii        pair<int,int>
#define mii        map<int,int>
#define vi         vector<int>
#define ff         first
#define ss         second
#define T          int t;cin>>t;while(t--)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define umi        unordered_map<int,int>
#define maxheap    priority_queue<int>
#define minheap    priority_queue<int,vector<int>,greater<int> >
#define inp(n)     for(int i=0;i<n;i++)
#define N          200005
#define mxN           2000005
#define all(v)        v.begin(),v.end()
#define lb(v,val)  (int)(lower_bound(v.begin(),v.end(),val)-v.begin())
#define ub(v,val)  (int)(upper_bound(v.begin(),v.end(),val)-v.begin())
using namespace std;
using namespace std::chrono;

void solve(){
    int k,a,b;
    cin >> k >> a >> b;
    if(a%k==0 || (a+k-1)/k*k <= b){
        cout << "OK\n";
    }
    else{
        cout << "NG\n";
    }
}

signed main(){

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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




Measured memory_bytes: 3652
#include<iostream>
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);
int n;
int a,b,c,d,e,f,g,h,i,j;
cin>>n;

  if(n==3)
   {
    cin>>a>>b>>c;
    if(max(max(a,b),c)-a-b-c+max(max(a,b),c)<0)
    cout<<"Yes";
    else
    cout<<"No";
    return 0;
   }
    
  if(n==4)
  {
   cin>>a>>b>>c>>d;
   if(max(max(max(a,b),c),d)-a-b-c-d+max(max(max(a,b),c),d)<0)
   cout<<"Yes";
   else
   cout<<"No";
   return 0;
  }
  
  if(n==5)
  {
   cin>>a>>b>>c>>d>>e;
   if(max(max(max(max(a,b),c),d),e)-a-b-c-d-e+max(max(max(max(a,b),c),d),e)<0)
   cout<<"Yes";
   else
   cout<<"No";
   return 0;
  }
  
    if(n==6)
  {
   cin>>a>>b>>c>>d>>e>>f;
   if(max(max(max(max(max(a,b),c),d),e),f)-a-b-c-d-e-f+max(max(max(max(max(a,b),c),d),e),f)<0)
   cout<<"Yes";
   else
   cout<<"No";
   return 0;
  }
  
    if(n==7)
  {
   cin>>a>>b>>c>>d>>e>>f>>g;
   if(max(max(max(max(max(max(a,b),c),d),e),f),g)-a-b-c-d-e-f-g+max(max(max(max(max(max(a,b),c),d),e),f),g)<0)
   cout<<"Yes";
   else
   cout<<"No";
   return 0;
  }
  
    if(n==8)
  {
   cin>>a>>b>>c>>d>>e>>f>>g>>h;
   if(max(max(max(max(max(max(max(a,b),c),d),e),f),g),h)-a-b-c-d-e-f-g-h+max(max(max(max(max(max(max(a,b),c),d),e),f),g),h)<0)
   cout<<"Yes";
   else
   cout<<"No";
   return 0;
  }
  
    if(n==9)
  {
   cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
   if(max(max(max(max(max(max(max(max(a,b),c),d),e),f),g),h),i)-a-b-c-d-e-f-g-h-i+max(max(max(max(max(max(max(max(a,b),c),d),e),f),g),h),i)<0)
   cout<<"Yes";
   else
   cout<<"No";
   return 0;
  }
  
    if(n==10)
  {
   cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>j;
   if(max(max(max(max(max(max(max(max(max(a,b),c),d),e),f),g),h),i),j)-a-b-c-d-e-f-g-h-i-j+max(max(max(max(max(max(max(max(max(a,b),c),d),e),f),g),h),i),j)<0)
   cout<<"Yes";
   else
   cout<<"No";
   return 0;
  }
  
return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()

w = [0]
e = [0]
w_cnt = 0
e_cnt = 0
for i in range(n):
    if s[i] == "W":
        w_cnt += 1
    else:
        e_cnt += 1
    w.append(w_cnt)
    e.append(e_cnt)

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

Measured memory_bytes: 17644
//
//  main.cpp
//  D - Make Them Even
//
//  Created by Jędrzej Dudzicz on 16.09.2018.
//  Copyright © 2018 Jędrzej Dudzicz. All rights reserved.
//

#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <vector>
#define mp make_pair
#define pb push_back
#define f first
#define s second
using namespace std;
typedef pair<int,int> PI;
int h,w;
int n;
int tab[505][505];
vector<PI>kolejka;
int main(){
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            scanf("%d",&tab[i][j]);
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(tab[i][j]%2==1){
                tab[i][j]--;
                if(j+1<w){
                    tab[i][j+1]++;
                    kolejka.pb(mp(i,j));
                    kolejka.pb(mp(i,j+1));
                }
                else{
                    if(i+1<h){
                        tab[i+1][j]++;
                        kolejka.pb(mp(i,j));
                        kolejka.pb(mp(i+1,j));
                    }
                }
            }
        }
    }
    n=kolejka.size()/2;
    printf("%d\n",n);
    for(int i=0;i<kolejka.size();i+=2){
        printf("%d %d %d %d\n",kolejka[i].f+1,kolejka[i].s+1,kolejka[i+1].f+1,kolejka[i+1].s+1);
    }
    return 0;
}


Measured memory_bytes: 5232
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        String s = sc.next();
        char first = s.charAt(0);
        char sec = s.charAt(s.length()-1);
        int t = s.length()-2;

        String str = String.valueOf(first);
        String str2 = String.valueOf(sec);

        System.out.println(str+t+sec);



    }

}

Measured memory_bytes: 23764
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stack>

using namespace std;

int main()
{
    stack<int> A;
    int x,next,p=1;
    long long n,sum=0;
    cin>>n;
    cin>>x;
    if(x!=0)
        p=0;
    for(int i=1;i<n;i++)
    {
        cin>>next;
        if(next-x>1)
            p=0;
        else if(next-x==1)
            sum++;
        else
            sum+=next;
        x=next;
    }
    if(p)
        cout<<sum<<endl;
    else cout<<"-1"<<endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a[i];

    int cnt = 0;
    rep(i,N) if (a[a[i]-1] == i+1) cnt++;

    cout << cnt/2 << endl;
}

Measured memory_bytes: 640