akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n==1 & m==1) ans = 1;
    else if (n==1 & m!=1) ans = m-2;
    else if (n!=1 & m==1) ans = n-2;
    else ans = (n-2)*(m-2);
    cout << ans << endl;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>p;
struct edge { int to, cost; };
std::vector<int>G[100000];
std::vector<int>I[100000];

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	int n, a[50][26] = { 0 };
	std::cin >> n;
	for (int i = 0;i < n;i++) {
		std::string s;
		std::cin >> s;
		for (int j = 0;j < s.size();j++) {
			a[i][s[j] - 'a']++;
		}
	}
	int b[26];
	for (int i = 0;i < 26;i++)b[i] = 100000;
	for (int i = 0;i < 26;i++) {
		for (int j = 0;j < n;j++) {
			b[i] = min(a[j][i], b[i]);
		}
	}
	for (int c = 0;c < 26;c++) {
		while (b[c] > 0) {
			std::cout << abc[c];
			b[c]--;
		}
	}
	std::cout << std::endl;
	}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main() {
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false), cout.tie(0), cin.tie(0);
  string s;
  cin >> s;
  if (s.back() == 's')
    s += "es";
  else
    s += "s";
  cout << s;

  return 0;
}
//2020.09.19 20:00:37


Measured memory_bytes: 3652
N=int(input())
list=[]
for i in range(N):
  list.append(int(input()))
M=max(list)
L=[i for i, v in enumerate(list) if v == M]
n=len(L)
if n>1:
  for i in range(N):
    print(M)
else:
  del list[L[0]]
  M2=max(list)
  for i in range(N):
    if i == L[0]:
      print(M2)
    else:
      print(M)


Measured memory_bytes: 20456
<?php
$n = (int)trim(fgets(STDIN));

$ss = [];
$al = range('a', 'z');
$len = count($al);
for ($i=0; $i < $n; $i++) { 
	$s = trim(fgets(STDIN));
	$sorted = [];
	for ($j=0; $j < $len; $j++) { 
		$cnt = substr_count($s, $al[$j]);
		for ($k=0; $k < $cnt; $k++) { 
			$sorted[] = $al[$j];
		}
	}
	$sorted = implode('', $sorted);
	if (isset($ss[$sorted])) {
		$ss[$sorted] += 1;
	}else{
		$ss[$sorted] = 1;
	}
}

$sum = 0;
foreach ($ss as $c) {
	$sum += c2($c);
}
echo $sum;

function c2($n){
	return (int)($n * ($n-1) / 2);
}

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



void solve(){
    int d,n;
    cin >> d >> n;
    int tmp = pow(100,d);
    if(n!=100) cout << n * tmp << endl;
    else cout << 101*(tmp) << endl;
}

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


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

struct state {
  int id,score,last;
  bool operator < ( const state &p ) const {
    if(score==p.score)return id > p.id;
    else return score < p.score;
  }
};

struct event {
  int d,t,x;
};

int N,R,L;
int score[100010];
int last[100010];
int sum[100010];
event events[1000010];


int main(){
  priority_queue < state > Q;
  for(int i=0;i<100010;i++)score[i]=last[i]=sum[i]=0;
  cin>>N>>R>>L;
  for(int i=1;i<=N;i++)Q.push( (state){i,0,0} );
  for(int i=0;i<R;i++){
    cin>>events[i].d>>events[i].t>>events[i].x;
  }
  events[R].t=L;
  events[R].d=events[R].x=0;
  state f = (state){1,0,0};
  state g;
  int a=0;
  for(int i=0;i<=R;i++){
    event e = events[i];
    score[e.d]+=e.x;
    last[e.d]=e.t;
    Q.push( (state){e.d,score[e.d],last[e.d]} );
    if(i+1<=R&&e.t==events[i+1].t)continue;
    g=f;
    while(1){
      f=Q.top();
      if(f.last==last[f.id])break;
      Q.pop();
    }
    sum[g.id]+=(e.t-a);
    //cout<<g.id << ' '<<e.t-a<<endl;
    a=e.t;
  }
  int ans=-1,ans2=0;
  for(int i=1;i<=N;i++){
    if(ans<sum[i]){
      ans=sum[i];
      ans2=i;
    }
  }
  cout<<ans2<<endl;
  return 0;
}

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

#define T 1
#define F 0
#define N 3

int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
int lim;
int p[N][N];

int huristic()
{
	int i,j,n,sum=0;
	for (i=0;i<N;i++)
  {
		for(j=0;j<N;j++)
    {
			if(p[i][j]==0)continue;
			n=p[i][j]-1;
			sum+=abs(n/N-i)+abs(n%N-j);
		}
	}
	return sum;
}

int dfs(int d,int pre,int y,int x)
{
	int h = huristic();
	int i;
	if(h==0)return T;
	if(lim<d+h) return F;

	for(i=0;i<4;i++)
  {
		if(abs(i-pre)==2)continue;
		int tx=x+dx[i],ty=y+dy[i];
		if (tx<0||ty<0||tx>=N||ty>= N)continue;
		int tmp=p[ty][tx];
		p[ty][tx]=p[y][x];
		p[y][x]=tmp;

		if(dfs(d+1,i,ty,tx))return T;
		tmp=p[ty][tx];
		p[ty][tx]=p[y][x];
		p[y][x]=tmp;
	}
	return F;
}

void azl(int x,int y)
{
	for(lim=0;;lim++)
  {
		if(dfs(0,99,y,x))
     {
			printf("%d\n",lim);
			return;
		}
	}
}

int main()
{
	int i,j;
	int a,b;

	for(i=0;i<3;i++)
  {
		for(j=0;j<3;j++)
    {
			scanf("%d",&p[i][j]);
			if(p[i][j]==0)
      {
				b=i;a=j;
			}
		}
	}
	azl(a,b);
	return 0;
}



Measured memory_bytes: 2140
from collections import defaultdict
from collections import deque
from collections import Counter
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def depth(self):
    	ans = 0
    	for r in self.roots():
    		ans = max(ans,self.size(r))
    	return ans

n,m = readInts()
ab = []
for i in range(m):
	ab.append(readInts())

uf = UnionFind(n+1)
for a,b in ab:
	uf.union(a,b)

print(uf.depth())


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c < 22) {
		cout << "win" << endl;
	}
	else {
		cout << "bust" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
void factorization(long long n,map<long long ,long long>& mp){
    for(long long i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n /= i;
        }
     }
     if(!(n == 1)) mp[n]++;
}
int main() {
ll n;
cin >> n;
ll ans = 0;
for (ll i = 1; i <= n; i += 2) {
    map<ll, ll> mp;
    factorization(i, mp);
    ll tmp = 1;
    for (auto i : mp) {
        tmp *= (i.second + 1);
    }
    if (tmp == 8) ans++;
}
cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))
#define sz(v) ((LLI)(v).size())

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T, typename U> istream& operator>>(istream &is, pair<T,U> &p){is >> p.first >> p.second; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int n;
  while(cin >> n){
    vector<int> p(n); cin >> p;

    int ans = 0;

    FOR(i,1,n-1){
      if(min(p[i-1],p[i+1]) < p[i] and max(p[i-1],p[i+1]) > p[i]) ++ans;
    }


    cout << ans << endl;
  }

  
  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
    int a = x2 - x1, b = y2 - y1;
    cout << x2 - b << " " << y2 + a << " " << x2 - b - a << " " << y2 + a - b << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <math.h>

int main(void){
  int nen, getu, hi, han;
  
  scanf("%d/%d/%d", &nen, &getu, &hi);
  if(nen>2019){
    han = 1;
  }else if(nen<2019){
    han = 2;
  }else{
    if(getu>4){
      han = 1;
    }else if(getu<4){
      han = 2;
    }else{
      if(hi>30){
        han = 1;
      }else if(hi<=30){
        han =2;
      }
    }
  }

  if(han==1){
    printf("TBD");
  }else{
    printf("Heisei");
  }

  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt(),b=stdIn.nextInt();
		if(10>a+b) System.out.print(a+b);
		else System.out.print("error");
	}
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(M), B(M);

  for(int i = 0; i < M; i++) {
    cin >> A[i] >> B[i];
    A[i]--;
    B[i]--;
  } 

  vector<vector<int>> s(2000001);
  bool hantei[2000001];
  int prev[2000001] = {0};
  int ans[2000001] = {0};
  for(int i = 0; i < M; i++) {
    s[A[i]].push_back(B[i]);
    s[B[i]].push_back(A[i]);
  }
  if(s[0].size() == 0) { cout << "No" << endl; return 0; } 
  queue<int> q;
  q.push(0);
  hantei[0] = true;
  while(!q.empty()) {
    int num = q.front(); q.pop();
    for(auto i : s[num]) {
      if(!hantei[i]) {
        hantei[i] = true;
        ans[i] = num;
        q.push(i);
      }
    }
  }
  printf("Yes\n");
  for(int i = 1; i < N; i++) {
    cout << ans[i] + 1 << endl; 
  }





  
  return 0;
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int counter = 0;
	while(true){
		if (a == b && b == c && a % 2 == 0) {
			cout << -1 << endl;
			break;
		}
		else {
			if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
				int d, e, f;
				d = a, e = b, f = c;
				a = (e + f) / 2;
				b = (f + d) / 2;
				c = (d + e) / 2;
				counter++;
			}
			else {
				cout << counter << endl;
				break;
			}
		}
	}
	
}

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

int main(){
     int m,f,b;

     cin >>m>>f>>b;

     if (m+f>=b && m<b){
    	 cout << b-m << endl;
     }
     if (m>=b){
    	 cout << "0"<< endl;
     }
     if (m+f<b){
    	 cout <<"NA"<< endl;
     }

     return 0;
}









Measured memory_bytes: 3108
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int dp[100000];
int h[100000];
const int inf = 2000000000;

int main(){
  int N;
  cin >> N;
  rep(i, N){
    cin >> h[i];
    dp[i] = inf;
  }
  dp[0] = 0;
  rep(i, N - 1){
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    if(i + 2 > N - 1) continue;
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
  }

  int ans = dp[N - 1];
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define lli long long int
#define rep(i,s,n) for(int i=s;i<=n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())

signed main(){

	lli n,m;
	cin>>n>>m;

	if(abs(n-m)>1){
		cout<<0<<endl;
		return 0;
	}

	lli sum=1;

	rep(i,1,n){
		sum *= i;
		sum %= MOD;
	}
	rep(j,1,m){
		sum *= j;
		sum %= MOD;
	}
	if(n==m){
		sum*=2;
		sum %= MOD;
	}

	cout<<sum<<endl;

	return 0;
}

Measured memory_bytes: 256
using System;

namespace B
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var result = 0.0;
			for (var i = 0; i < n; i++)
			{
				var line = Console.ReadLine().Split();
				var x = double.Parse(line[0]);
				if (line[1] == "JPY") { result += x; }
				else { result += 380000 * x; }
			}

			Console.WriteLine(result);
		}
	}
}

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

const int maxn = 100 + 5;
int mem[maxn];
int rem[maxn];
int n;

int solve()
{
	for(int i = 0; i < n; i++)
	{
		if(i!=0) 
			rem[i] = mem[i] + rem[i-1];
		else 
			rem[i] = mem[0];
	}
	int m = rem[n-1];
	for(int i = 0; i< n; i++)
	{
		int sum1 = rem[i];
		int sum2 = rem[n-1] - rem[i];
		if(abs(sum2-sum1) < m) m = abs(sum2-sum1);
	}
	return m;
}

int main()
{
	scanf("%d", &n);
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &mem[i]);
	}
	printf("%d\n", solve());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(long long int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
int N;
long long int X,dp[51],d[51],ans=0;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> X;
	dp [0] = d[0] = 1;

	REP(i,N){
		dp[i + 1] = dp[i] * 2 + 3;
		d[i + 1] = d[i] * 2 + 1;
	}
	while (X) {
		if(X >= dp[N]){
			ans += d[N];
			X = 0;
			break;
		}
		else if(X - 1 < dp[N-1]){
			N--;
			X--;
			continue;
		}
		else if(X == dp[N-1] + 1){
			ans += d[N-1];
			X = 0;
			break;
		}
		else{
			ans += d[N - 1] + 1;
			X -= dp[N - 1] + 2;
			N--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef pair< pair<string, int>, int> P;
int beki(int N){
  if(N==0) return 1;
  else return 2*beki(N-1);
}
int main(){
  int N, M;
  cin >> N >> M;

  int swi[N][M];
  //cout << swi[1][1] <<endl;
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++) swi[i][j] = 0;
  }


  for(int j=0;j<M;j++){
    int k;
    cin >> k;
    for(int i=0;i<k;i++){
      int s;
      cin >> s;
      swi[s-1][j] = 1;
    }
  }

  int p[M];
  for(int j=0;j<M;j++){
    cin >> p[j];
  }

  int range = beki(N);
  int cnt = 0;

  for(int x=0;x<range;x++){
    int onoff[M];
    for(int j=0;j<M;j++) onoff[j] = 0;

    for(int i=0;i<N;i++){
      if(x&(1<<i)){
        for(int j=0;j<M;j++){
          onoff[j] += swi[i][j];
        }
        //cout << 'a' <<endl;
      }
    }
    bool ans = true;
    for(int j=0;j<M;j++){
      if(onoff[j]%2!=p[j]){
        ans = false;
        break;
      }
    }
    if(ans){
      cnt++;
    }
  }

  cout << cnt <<endl;


  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = []
for _ in range(N):
  u, v = map(int, input().split())
  a.append((u, v))
b = bin(K)[2: ]
t = [K]
for i in range(len(b)):
  if b[i] == "1":
    tt = 0
    for j in range(i):
      if b[j] == "1": tt += 1 << (len(b) - j - 1)
    for j in range(i + 1, len(b)):
      tt += 1 << (len(b) - j - 1)
    t.append(tt)
res = 0
for tt in t:
  ttt = 0
  for i in range(N):
    u, v = a[i]
    if tt & u == u:
      ttt += v
  res = max(res, ttt)
print(res)

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

int main() {
	int N;
	cin >> N;
	vector<int> p(N);
	rep(i, N) cin >> p[i];
	int cnt = 0;
	for (int i = 1; i < N - 1; i++){
		if ((p[i - 1] < p[i] && p[i] <= p[i + 1]) || (p[i + 1] < p[i] && p[i] <= p[i - 1])){
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}


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


long k,a,b;
long bis=1;
int main(){
    scanf("%ld%ld%ld",&k,&a,&b);
    int plus=b-a;
    if(plus<2)plus=2;
    while(k>=1){
        if(bis<a){
            k-=1;
            bis++;
        }else{
            if(k>=2){
                k-=2;
                bis+=plus;
            }else{
                k-=1;
                bis++;
            }
        }
    }
    printf("%ld",bis);
}

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

int main() {
  bool chk = false;
  int a,b;
  cin >> a >> b;
  
  if(a % 3 == 0){
   chk = true; 
  }else if(b % 3 == 0){
    chk = true; 
  }else if((a + b) % 3 == 0){
    chk = true;
  }
  
  if(chk == true) cout << "Possible";
  else cout << "Impossible";
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int a,b;
  scanf("%d%d", &a,&b);
  if	 ( a >= 13 ){ printf("%d\n", b); }
  else if( a <=  5 ){ printf("0\n"); }
  else				{ printf("%d\n", b/2); }
  return 0;
}

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

int main() {
    int a[6];
    for (int i = 0; i < 6; i++) {
        cin >> a[i];
    }
    if (a[4] - a[0] <= a[5]) {
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }

	return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int n;
  cin >> n;
  int count = 0;
  rep(i, n)
  {
    if (i % 2 == 0)
      count++;
  }
  cout << (float)count / n;
  return 0;
}


Measured memory_bytes: 3772
#include <stdio.h>
 
int main(void){
  int a,b,c,ans;
  scanf("%d %d %d", &a,&b,&c);
  ans = c-(a-b);
  if(c-(a-b)<0){
      ans = 0;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;

int main()
{
  IOS
  ll n,k;
  cin>>n>>k;
  ll i,a[n+5];
  for(i=1;i<=n;i++)
  	cin>>a[i];
  set<ll> s;
  ll ans=1;
  for(i=1;i<=k;i++)
  	s.insert(a[i]);
  ll j=1;
  for(;i<=n;i++)
  {
  	 ll mini=*(s.begin());
  	 ll flag=0;
  	 if(mini==a[j])
  	 	flag++;
  	 s.erase(s.find(a[j]));
  	 j++;
  	 s.insert(a[i]);
  	 ll maxi=*(s.rbegin());
  	 if(maxi==a[i])
  	 	flag++;
  	 if(flag==2)
  	 	continue;
  	 ans++;
  }
  ll cnt=0;
  i=2;
  for(;i<=n;i++)
  {
  	 ll t=1;
  	 while(i<=n && a[i]>a[i-1])
  	 	{
  	 		i++;
  	 		t++;
  	 	}
  	 	if(t>=k)
  	 		cnt++;
  }
  cnt--;
  if(cnt<0)cnt=0;
  cout<<ans-cnt;
  return 0;
}                   

Measured memory_bytes: 11264
n = int(input())
s = input()
tmp = []
for i in range(1, n):
    tmp.append([s[0:i], s[i:n]])

m = 0
for i in range(len(tmp)):
    cnt = 0
    tmp2 = []
    for j in range(len(tmp[i][0])):
        if tmp[i][0][j] in tmp[i][1] and tmp[i][0][j] not in tmp2:
            cnt += 1
            tmp2.append(tmp[i][0][j])
    if cnt > m:
        m = cnt
print(m)


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

int sumsum(int a, int b){ 
    int suma = 0,sumb = 0,sum = 0;
    while(a > 0 or b > 0){
        suma = suma + a % 10;
        sumb = sumb + b % 10;
        a = a / 10;
        b = b / 10;
    }
    sum = suma + sumb;
    return sum;
}


int main(){
    int n;
    cin >> n;
    int a,b,ans = 100000;
    for(int i = 1; i < n; i++){
        a = i;
        b = n - i;
        ans = min(ans,sumsum(a,b));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<stdio.h>
#include<queue>
#include<stack>
#include<map>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int>P;

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

Measured memory_bytes: 256
/*Code by Codercjh*/
#include<bits/stdc++.h>
#define fr(i,a,b) for(int i=(a);i<=(b);++i)
#define rf(i,a,b) for(int i=(a);i>=(b);--i)
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
using namespace std;
typedef long long ll;
template<typename T>
inline void read(T &x){
	char c=getchar();T fh=0;bool f=false;
	while(!isdigit(c))f|=(c=='-'),c=getchar();
	while(isdigit(c))fh=(fh<<1)+(fh<<3)+(c^48),c=getchar();
	x=f?-fh:fh;
	return;
}
const int mod=1e9+7;
int n,k;
ll qp(ll a,ll b){
	ll s=1;
	while(b){
		if(b&1)s=(s*a)%mod;
		a=(a*a)%mod;b>>=1;
	}
	return s;
}
ll ans,a[200005];
int main(){
    read(n),read(k);
	rf(i,k,1){
		ll tmp=qp(k/i,n);
		fr(j,2,k/i)tmp-=a[i*j];
		while(tmp<0)tmp+=mod;
		a[i]=tmp;
		ans=(ans+a[i]*i)%mod;
	}
	cout<<ans;
	return 0;
}


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

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

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, n, a) for(int i = (a); i >= (n); i--)
#define mod 1e9+7
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i, 0, s.length()) {
    ans += (int)(s[i] - 48);
  }

  if(s.length() > 1 && ans == 1) {
    cout << ans * 10 << endl;
  }else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#if ONLINE_JUDGE
    #define DEBUG false
#else
    #define DEBUG true
#endif
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rep1(i, n) REP(i, 1, n)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)
#define rrep(i, n) rREP(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) std::sort(all(x))
#define REV(x) std::reverse(all(x))
#define UNIQUE(x) x.erase(std::unique(all(x)), x.end());
#define MAX(x) *std::max_element(all(x))
#define MIN(x) *std::min_element(all(x))
#define LOWitr(x, n) std::lower_bound(all(x), n)
#define UPRitr(x, n) std::upper_bound(all(x), n)
#define cii(x) int x; std::cin >> x
#define cill(x) signed long long int x; std::cin >> x
#define cis(x) std::string x; std::cin >> x
#define co(x) std::cout << x << "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define truecheck assert
#define dump(x) if(DEBUG) std::cout<<#x<<" : "<<(x)<<"\n"
template<class T>using V = std::vector<T>;
template<class T>using VV = std::vector<std::vector<T>>;
template<class T>using Q = std::queue<T>;
template<class T>using PQ = std::priority_queue<T>;
template<class T,class U>using P = std::pair<T, U>;
template<class T,class U>using M = std::map<T, U>;
template<class T,class U>using UM = std::unordered_map<T, U>;
template<class T,class U>inline bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>inline bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T>inline void vcin(T &v){for(auto&& i : v) std::cin >> i;}
template<class T>inline void dumpv(const T& v, std::ostream& os = std::cout){
    if(DEBUG){
        os<<"{";
        std::for_each(all(v),[&os](typename T::value_type p){os<<p<<',';});
        os<<"}\n";
    }
}
using std::cin;
using std::cout;
using std::string;
using std::next_permutation;
using LL = signed long long int;
const int INF = INT_MAX, MOD = 1e9 + 7;
const LL LLINF = LLONG_MAX;
const double PI = M_PI;

void Main(){
    cis(s);
    cis(t);
    string ans = "Yes";
    rep(i, s.length()){
        if (s[i] != t[i]){
            ans = "No";
            break;
        }
    }
    co(ans);
}

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

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

int month[13]={0, 31,29,31,30,31,30,31,31,30,31,30,31};
string week[7]={"Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", "Wednesday"};

int main(){
    while(1){
        int mm,dd;
        cin >> mm >> dd;
        if(mm==0) break;
        
        int m=1,d=1,w=0;
        while(m!=mm || d!=dd){
            if(month[m]==d){
                d=1;
                m++;
            }else{
                d++;
            }
            w = (w+1)%7;
        }
        cout << week[w] << endl;
    }
    return 0;
}

Measured memory_bytes: 3112
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace mondai0069
{
	class Program
	{
		static void Main(string[] args)
		{
			while( true ) {
				var	n	= int.Parse( Console.ReadLine() );
				if( n == 0 ) {
					break;
				}
				var	m		= int.Parse( Console.ReadLine() );
				var	atari	= int.Parse( Console.ReadLine() );
				var	d		= int.Parse( Console.ReadLine() );
				var	amida	= new bool[ d, n + 1 ];				
				for( int i = 0; i < d; i++ ) {
					var	s	= Console.ReadLine();
					for( int j = 1; j < n; j++ ) {
						if( s[ j - 1 ] == '1' ) {
							amida[ i, j ]	= true;
						}
					}
				}

				if( amida_chk( amida, m ) == atari ) {
					Console.WriteLine( "0" );
					continue;
				}
				
				bool	more_ok	= false;
				for( int i = 0; (i < d) && (more_ok == false); i++ ) {
					for( int j = 1; j < n; j++ ) {
						if( amida[ i, j ] == false ) {
							if( (amida[ i, j - 1 ] == false) && (amida[ i, j + 1 ] == false) ) {
								amida[ i, j ]	= true;
								if( amida_chk( amida, m ) == atari ) {
									Console.WriteLine( "{0} {1}", i + 1, j );
									more_ok	= true;
									break;
								} else {
									amida[ i, j ]	= false;
								}
							}
						}
					}
				}
				if( more_ok == false ) {
					Console.WriteLine( "1" );
				}
			}
		}
		
		static int amida_chk( bool[,] amida, int m )
		{
			for( int i = 0; i < amida.GetLength( 0 ); i++ ) {
				if( amida[ i, m - 1 ] ) {
					m--;
				} else if( amida[ i, m ] ) {
					m++;
				}
			}
			return( m );
		}
	}
}

Measured memory_bytes: 5612
#include <iostream>

using namespace std;

int main()
{
    int k;
    cin >> k;
    int ans = 0;
    if(k%2 == 0){
        int e = k/2;
        ans = e*e;
    }else{
        int e = k/2;
        int o = k/2+1;
        ans = e*o;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

//const int mod = 1000000007;
const int mod = 998244353;

struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};

istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    int n;
    int s;
    cin >> n >> s;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    vector<mint> dp(s+1);
    dp[0] = 1;
    rep(i, n) {
        rep(j, s+1) {
            j = s-j;
            dp[j] *= 2;
            if(j >= a[i]) {
                dp[j] += dp[j-a[i]];
            }
            j = s-j;
        } 
    }
    

    cout << dp[s] << endl;
}

Measured memory_bytes: 3660
#!/usr/bin/env python


def main():
    n = int(input())
    a = [int(ai) for ai in input().split()]
    b = [int(bi) for bi in input().split()]

    cnt, prev_cnt = 0, -1
    while cnt != prev_cnt:
        prev_cnt = cnt
        for i in range(n):
            adj_sum = b[i - 1] + b[(i + 1) % n]
            k = (b[i] - a[i]) // adj_sum
            if k > 0:
                b[i] -= k * adj_sum
                cnt += k

    print(cnt if a == b else -1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 33752
#!/usr/bin/env python3
import sys


def solve(K: int, X: int):
    print(' '.join(map(str, range(X - K + 1, X + K))))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define     LL      long long int
queue<LL>q;
vector<LL>v;
int main()
{
    LL k,a;
    cin>>k;
    for(int i=1;i<=9;i++){
        q.push(i);
    }
    while(!q.empty()){
        if(v.size()>k) break;
        LL ans=q.front();
        q.pop();
        v.push_back(ans);
        LL bs=ans%10;
        if(bs>0){
            q.push((ans*10)+(bs-1));
        }
        q.push((ans*10)+bs);
        if(bs<9){
            q.push((ans*10)+(bs+1));
        }

    }
    cout<<v[k-1]<<endl;


     return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    if (n==1){
        cout<<"Hello World\n";
        return 0;
    }
    int a,b; cin>>a>>b;
    cout<<a+b<<endl;
    return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/abc116/tasks/abc116_b
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class reverse_range {private:struct I {int x;int operator*() {return x-1;}bool operator!=(I& lhs) {return x>lhs.x;}void operator++() {--x;}};I i, n;public:reverse_range(int n) :i({ 0 }), n({ n }){}reverse_range(int i, int n) :i({ i }), n({ n }){}I& begin() {return n;}I& end() {return i;}};
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }reverse_range operator!(){return reverse_range(*i,*n);}};
int f(int n){
    if(n%2)return 3*n+1;
    else return n/2;
}
bool vis[1000001];
int main(){
    int s;
    cin>>s;
    vis[s]=true;
    for(int i=2;;i++){
        s=f(s);
        if(vis[s]){
            cout<<i<<endl;
            return 0;
        }
        vis[s]=true;
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let d: i64 = sc.cin();
    let ans = (0..n)
        .map(|_| {
            let x: i64 = sc.cin();
            let y: i64 = sc.cin();
            (x, y)
        })
        .filter(|&(x, y)| x * x + y * y <= d * d)
        .count();
    put!(ans);
}

use std::collections::VecDeque;
use std::io::{self, Write};
use std::str::FromStr;

struct Scanner {
    stdin: io::Stdin,
    buffer: VecDeque<String>,
}
impl Scanner {
    fn new() -> Self {
        Scanner {
            stdin: io::stdin(),
            buffer: VecDeque::new(),
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.is_empty() {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.cin::<String>().chars().collect()
    }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.cin()).collect()
    }
}


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

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

	long long num = 0;
	long long blocksize = 26;
	long long len = 1;
	while(1) {
		if(num + blocksize >= N) {
			break;
		}
		len++;
		num+= blocksize;
		blocksize *= 26;
	}
	N-=num;
	N--;


	blocksize/=26;
	string ans = "";

	while(1) {
		ans += 'a' + N/blocksize;
		N%=blocksize;
		blocksize/=26;
		if(blocksize == 0) {
			cout << ans << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 3632
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[2,5,5,4,5,6,3,7,6]


dp=[0]*(N+10)
for j in range(M):
    need=B[A[j]-1]
    dp[need]=max(dp[need],A[j])

for i in range(1,N+1):
    for j in range(M):
        need=B[A[j]-1]
        if i-need>=0:
            if dp[i-need]:
                dp[i]=max(dp[i], dp[i-need]*10+dp[need])
            
print(dp[N])



Measured memory_bytes: 51420
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char str[12];
    int a,b;
    cin>>a>>b;
    cin>>str;
    int flag=0,count=0;
    if(str[a]=='-') flag=1;
    for( int i=0;i<a+b+1;i++)
    {
        if(str[i]>=48 && str[i]<=57) count++;
    }
    if(flag==1 && count==a+b) cout<<"Yes"<<endl;
    else                      cout<<"No"<<endl;

    return 0;


}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    bool ok;
    int remi=n;
    REP(i,n){
        ok = true;
        REP(j,n-i){
            if(s[j+i]!=t[j]){
                ok = false;
                break;
            }
        }
        if(ok){
            remi = i;
            break;
        }
    }
    cout << remi+n << endl;
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	LL x = 1, y = 1;
	inc(i, n) { x *= 3; }
	inc(i, n) { if(a[i] % 2 == 0) { y *= 2; } }
	
	cout << (x - y) << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int X=0,t=0,a=0;

	scanf("%d %d", &X,&t);

	if (X>=t)
	{
		a = X - t;
	}
	else
	{
		a = 0;
	}
	printf("%d\n", a);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>
int main(void){

    char str[3000];
    char *tok;
    int m,n;
    int i1,i2,i3,i4,i44;
    int gn,gm,sn,sm;
    int fin=0;
    int nn,nm;
    int a[1000][1000];
    int b[8000][2]; //searching list
    int c[8000][2]; //next searching list
    
    fgets(str, sizeof(str), stdin);
    tok=strtok(str," ");
    m=strtol(tok,NULL,10);
    tok=strtok(NULL," ");
    n=strtol(tok,NULL,10);

    if(m>=n*2-1){
        printf("YES");
    }
    else{
        printf("NO");
    }
    
}

Measured memory_bytes: 128
import numpy as np
import sys
import math
read = sys.stdin.readline

N , M = map(int,input().split())
H = list(map(int,input().split()))
lo = []
[lo.append(list(map(int,input().split()))) for _ in range(M)]

t = [0] * N 
for m in range(M):
    if H[ lo[m][0] - 1 ] > H[ lo[m][1] - 1 ]:
        if t[lo[m][0] - 1 ] != -1 :
            t[lo[m][0] - 1] = 1
        t[lo[m][1] - 1] = -1
        continue 

    if H[ lo[m][0] - 1 ] < H[ lo[m][1] - 1 ]:
        if t[lo[m][1] - 1 ] != -1 :
            t[lo[m][1] - 1] = 1
        t[lo[m][0] - 1] = -1
        continue 

    if H[ lo[m][0] - 1 ] == H[ lo[m][1] - 1 ]:
        t[lo[m][0] - 1] = -1
        t[lo[m][1] - 1] = -1
        continue 

good = 0
for i in t:
    if i != -1:
        good += 1

print(good)

Measured memory_bytes: 51280
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N, A;
	cin >> N >> A;
	cout << N*N - A << endl;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import           Control.Applicative
import           Control.Monad
import qualified Data.ByteString.Char8 as B

import           Data.Array.IArray
import           Data.Array.IO
import           Data.Array.MArray
import           Data.Array.Unboxed
import           Data.Array.Unsafe

readi :: B.ByteString -> Int
readi b | Just (n, _) <- B.readInt b = n

prim :: Int -> UArray (Int, Int) Int -> [Int]
prim n g = go [1] []
  where
    go :: [Int] -> [Int] -> [Int]
    go !as !bs
        | null xs   = bs
        | otherwise = let (v, i) = minimum xs
                       in go (i:as) (v:bs)
      where
        xs =
            [ (g ! (a, i), i)
            | i <- filter (`notElem` as) [1 .. n]
            , a <- as
            , (g ! (a, i)) /= -1
            ]

main :: IO ()
main = do
    n <- readLn
    xss <- fmap (fmap readi . B.words) <$> replicateM n B.getLine
    a <- newArray ((1, 1), (n, n)) (-1) :: IO (IOUArray (Int, Int) Int)
    forM_ (zip [1 ..] xss) $ \(i, xs) -> do
        forM_ (zip [1 ..] xs) $ \(j, x) -> do
            writeArray a (i, j) x
    a <- unsafeFreeze a :: IO (UArray (Int, Int) Int)

    print . sum $ prim n a



Measured memory_bytes: 5576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < n;i++)
using namespace std;
 
int main(){
    int n, l; cin >> n >> l;
    vector<int> a(n);
    rep(i,n){
        a.at(i) = l + i;
    }
    int sum = 0;
    rep(i,n){
        sum += a.at(i);
    }
    int ans = l;
    rep(i,n){
        int b = sum - a.at(i);
        if(abs(b - sum) < abs(ans - sum)) ans = b;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int l, i=0, a[10];
    while(cin>>l){
        a[i] = l;
        i++;
    }
 if(a[0]<10)
 {
 cout<<100*(10-a[0])+a[1]<<"\n";
 }else{
 cout<<a[1]<<"\n";
 
 }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
	string o,e;
	cin>>o>>e;
	for(int i=0;i<e.size();i++){
		cout<<o[i]<<e[i];
	}
	if(o.size()-e.size()==1)cout<<o[o.size()-1]<<endl;
}

Measured memory_bytes: 256