akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
    int result = 1;
    int N, K = 0;
    cin >> N >> K;

    while(N > 0){
        if(result * 2 < result + K){
            result *= 2;
        }else{
            result += K;
        }

        N--;
    }

    cout << result;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,s,a[105],dp[100005];
int main(){
cin>>n>>s;
for(int k=1;k<=n;k++)
    cin>>a[k];
dp[0]=2;
for(int k=1;k<=s;k++){
   int h=2;
   for(int i=1;i<=n;i++){
        if(a[i]>k)
        continue;
    if(dp[k-a[i]]==2){
        h=1;
        break;
    }
   }
   dp[k]=h;
}
if(dp[s]==1)
    cout<<"First";
else cout<<"Second";
return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);

  int n, C;
  cin >> n >> C;
  vector<vector<P>> a(C);

  REP(i, n){
    int s,t,c;
    cin >> s >> t >> c;
    c--;
    a[c].push_back({s,t});
  }
  REP(i, C) sort(a[i].begin(), a[i].end(), [](P b, P d){
    return b.first < d.first;
  });

  //連続となっている区間の結合
  vector<vector<P>> aa(C);
  REP(i, a.size()) {
    if(a[i].empty()) continue;
    P tmp = a[i][0];
    REP(j, a[i].size() - 1){
      if(tmp.second == a[i][j + 1].first){
        tmp.second = a[i][j + 1].second;//繋がっている番組を結合
      }
      else{
        if(j + 1 < a[i].size() ) {
          aa[i].push_back(tmp);
          tmp = a[i][j + 1];
        }
      }
    }
    aa[i].push_back(tmp);
  }

  //imos法
  vec table(2 * 1e5 + 1, 0);
  REP(i, aa.size()) REP(j, aa[i].size()) {
    table[2 * aa[i][j].first - 1]++;
    table[2 * aa[i][j].second]--;
  }
  FOR(i, 1, table.size()){
    table[i] += table[i - 1];
  }

  cout << *max_element(table.begin(), table.end()) << endl;


  return 0;
}

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

int a[100005];
int b[100005];

int main()
{
	int n;
	cin >> n;
	for(int i = 0; i < n + 1; i++){
		scanf("%d",&b[i]);
	}
	for(int i = 0; i < n; i++){
		scanf("%d",&a[i]);
	}	
	long long sum = 0;
	for(int i = 0; i < n; i++){
		if(a[i] > b[i]){
			sum = sum + b[i];
			
//			cout << "1  "<<sum << endl;
            a[i] = a[i] - b[i];
			b[i] = 0;
            if(a[i] > b[i + 1]){
            	sum = sum + b[i + 1];
            	b[i + 1] = 0;
//            	cout <<"2  "<< sum << endl;
			}else{
			    b[i + 1] = b[i + 1] - a[i];
//			    cout <<"    " <<a[i]  <<" "<< b[i+1]<<endl;
				sum = sum +	a[i];
//				cout << "3  "<<sum << endl;

			}	    
		}else{
			sum = sum + a[i];
			b[i] = b[i] - a[i];
			a[i] = 0;
//			cout <<"4  "<< sum << endl;
		}
	}
	n--;
//	if(a[n] > b[n + 1]) sum = sum + b[n + 1];
//	else sum = sum + a[n];
	cout << sum;
    
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

bool Cmp(pii a,pii b){
  if(a.first>b.first){
    return true;
  }else{
    return false;
  }
}

int main(){
  int n;
  cin>>n;
  vector<pii>team;
  for(int j=0;j<n;j++) team.push_back(pii(0,j));
  for(int i=0;i<(n*(n-1))/2;i++){
    int ta,tb,sa,sb;
    cin>>ta>>tb>>sa>>sb;
    if(sa>sb){
      team[--ta].first+=3;
    }else if(sa<sb){
      team[--tb].first+=3;
    }else{
      team[--ta].first++;
      team[--tb].first++;
    }
  }
  sort(team.begin(),team.end(),Cmp);
  //for(pii a : team)cout <<"score :" << a.first << " team num: " <<a.second << endl;
  //cout << endl;
  int ans[n];
  for(int i=0;i<team.size();i++){
    int cnt=0;
      while(team[i].first==team[i-1-cnt].first)cnt++;
    ans[team[i].second]=i+1-cnt;
  }
  for(int i=0;i<n;i++){
    cout << ans[i] << endl; 
  }
 return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int i, n, m, f = 1, c = 0;
	string s;

	cin >> s;
	n = m = s.length();

	for (i = 0; i < (n + 1) / 2; i++) {
		if (s[i] != s[n - i - 1]){
			if (s[n - i - 1] == 'x') {
				s.insert(i, "x");
				i--;
				n++;
				c++;
			}
			else if (s[i] == 'x') {
				s.insert(n - i, "x");
				n++;
				c++;
			}
			else {
				s.insert(i, "x");
				i--;
				n++;
				c++;
			}
		}
		if (c >= m * 2) {
			break;
		}
	}

	for (i = 0; i < (n + 1) / 2; i++) {
		if (s[i] != s[n - i - 1]) {
			f = 0;
		}
	}

	if (f) {
		cout << c << endl;
	}
	else {
		cout << -1 << endl;
	}

	return 0;
}

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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  string s;
  cin >> s;
  if(s == "Sunny"){
  	cout << "Cloudy" << endl;
  }
  else if(s == "Cloudy"){
  	cout << "Rainy" << endl;
  }
  else{
  	cout << "Sunny" << endl;
  }
}

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

int ab(int i,int j){
  int a=i-j;
return (a>0)?a:-a;
}


int main(){
	int n;
  	cin>>n;
  int h[n];
  
  for(int i=0;i<n;i++)
    cin>>h[i];
  
  int dp[n];
  dp[0]=0;
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++){
      dp[i]=min(dp[i-1]+ab(h[i],h[i-1]),dp[i-2]+ab(h[i],h[i-2]));
  }

cout<<dp[n-1];
  
  return 0;
} 


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

int main(){
    int N,K; cin >> N >> K;
    long long ans=0;
    for(int i=1;i<=N;i++){
        ans+=max(0,i-K)*(N/i);
        ans+=max(N-(N/i)*i-K+1,0);
    }
    if(K==0) ans-=N;
    cout << ans << endl;
}

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

int main(){
  
  int N, M, i, cnt = 1;
  cin >> N >> M;
  vector<pair<int, int>> ILND(M);
  
  for(i = 0; i < M; i++) cin >> ILND[i].second >> ILND[i].first;
  sort(ILND.begin(), ILND.end());
  
  for(i = 0;;){
    
    int G = ILND[i].first, j = 0;
    while(G > ILND[j].second){
      if(j == M - 1){
        cout << cnt << endl;
        return 0;
      }
      j++;
    }
    cout << endl;
    i = j, cnt++;
  }
  return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;

    cout << (1 + (b - a)) * (b - a) / 2 - b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


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

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

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

string to_string(char ch) {
	return string("'")+ch+string("'");
}

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

template <class InputIterator>
string to_string (InputIterator first, InputIterator last) {
	bool start = true;
	string res = "{";
	while (first!=last) {
		if (!start) {
			res += ", ";
		}
		start = false;
		res += to_string(*first);
		++first;
	}
	res += "}";
	return res;
}

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

void debug_out() { cerr << endl; }

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

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

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



const int mod=1e9+7;

int mul(int a,int b)
{
	return (a*1ll*b)%mod;
	}
	
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
		}
	return res;
	}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N=300005;
vi adj[N];
int dist[N];
int bfs(int v)
{
	queue<int>q;
	q.push(v);
	dist[v]=0;
	int m=-1;
	while(!q.empty())
	{
		int t=q.front();
		q.pop();
		m=t;
		for(int i=0;i<adj[t].size();i++)
		{
			if(dist[adj[t][i]]>dist[t]+1)
			
			{dist[adj[t][i]]=dist[t]+1;
			q.push(adj[t][i]);m=adj[t][i];}
			}
		
		}
	return m;
	}

void solve()
{  
int n;
cin>>n;
for(int i=0;i<n-1;i++)
{
	int a,b;
	cin>>a>>b;
	a--;b--;
	adj[a].pb(b);
	adj[b].pb(a);
	}
	for(int i=0;i<n;i++)dist[i]=1e9;
	int end1=bfs(0);
	for(int i=0;i<n;i++)dist[i]=1e9;
	int end2=bfs(end1);
	//cout<<dist[end2]<<'\n';
	if(dist[end2]%3==1)cout<<"Second";
	else cout<<"First";

} 
	
	
   
	
	

signed main()
{   
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tc=1;
	//cin>>tc;
    for(int i=0;i<tc;i++)
	{
		//cout<<"Case #"<<i+1<<": "; 
        solve();
		}
	
	}


Measured memory_bytes: 15988
//
//  respect the past, embrace the future
//

#include  <algorithm>
#include  <iostream>
#include  <climits>
#include  <cstdlib>
#include  <cstring>
#include  <cmath>
#include  <cstdio>
#include  <unordered_map>
#include  <map>
#include  <set>
#include  <stack>
#include  <string>
#include  <vector>
#include  <queue>

using namespace :: std;

using vpll = vector <pair <long long, long long> >;
using pll = pair <long long, long long>;
using vll = vector <long long>;
using ll = long long;

#define W (ll) (5e3 + 7)
#define N (ll) (2e6 + 7)
#define M (ll) (1e9 + 7)
#define INF (ll) (2e18)
#define F first
#define S second

inline void fastInputOutput () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
}

inline void ReadWriteFromFile () {
  freopen("../in.txt", "r", stdin);
  freopen("../out.txt", "w", stdout);
}

int a, b, c;
char str[M];

int32_t main (int argc, char *argv[]) {
  fastInputOutput();
  // ReadWriteFromFile();
  
  cin >> str + 1;
  a = strlen(str + 1);
  for (int i = 1; i <= a / 2; i++)
    c += str[i] != str[a - i + 1];
  cout << c;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const int MOD=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

int n,m,a;
int p[10]={};//p:その本数でできる最大数
void use(int x){
	if(a==1)p[2]=max(p[2],a);
	else if(a==7)p[3]=max(p[3],a);
	else if(a==4)p[4]=max(p[4],a);
	else if(a==2||a==3||a==5)p[5]=max(p[5],a);
	else if(a==6||a==9)p[6]=max(p[6],a);
	else if(a==8)p[7]=max(p[7],a);
}

int main(){
	cin>>n>>m;
	rep(i,0,m){
		cin>>a;
		use(a);
	}
	string s[10010]={};
	rep(i,2,8)if(p[i])s[i]+=char(p[i]+'0');
	rep(i,0,n+1){
		if(s[i].size()){
			rep(j,2,8){
				if(p[j]){
					if((int)s[i].size()+1>(int)s[i+j].size())s[i+j]=s[i]+(char)(p[j]+'0');
					else if((int)s[i].size()+1==(int)s[i+j].size()){
						string t=s[i]+(char)(p[j]+'0');
						sort(ALL(t),greater<>());
						sort(ALL(s[i+j]),greater<>());
						if(t.compare(s[i+j])>=0)s[i+j]=t;
					}
				}
			}
		}
	}
	sort(ALL(s[n]),greater<>());
	print(s[n]);
}



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

int main() {
	// your code goes here
	int n,flag;
	string s;
	cin>>n;
	char ch[n];
	cin>>ch;
	int t=n;
	if(t%2!=0){
	    cout<<"No"<<endl;
	}
	else{
	    flag=1;
	    for(int i=0;i<t/2;i++){
	        if(ch[i]==ch[(t/2)+i]){
	            continue;
	        }
	        else{
	            flag=0;
	            break;
	        }
	    }
	    if(flag==1){
	        cout<<"Yes"<<endl;
	        
	    }
	    else
	    cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
main(){for(char t[10];std::cin>>t;){int i,s=0,p[10]={1,9,6,4,6,6,4,6,9,1};for(i=0;i<10;i++)s+=(t[i]-('0'))*p[i];std::cout<<s%10<<"\n";}}

Measured memory_bytes: 0
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

int n;

int read() {
  if (scanf("%d", &n) < 1) {
    return 0;
  }
  return 1;
}

void solve() {
  int left = 0, right = inf;
  while (left + 1 < right) {
    int mid = (left + right) / 2;
    if ((long long) mid * (mid + 1) / 2 >= n) {
      right = mid;
    } else {
      left = mid;
    }
  }

  int x = right;
  for (; x > 0; --x) {
    if (n >= x) {
      n -= x;
      printf("%d\n", x);
    }
  }
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


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

 
int main(){
    int n, q, ans = 0;
    cin >> n;
    vector<int> s(n);
    for(int i = 0; i < n; i++){
        cin >> s.at(i);
    }
    cin >> q;
    vector<int> t(q);
    for(int i = 0; i < q; i++){
        cin >> t.at(i);
        for(int j = 0; j < n; j++){
            if(t.at(i) == s.at(j)) {ans++; break;}
        }
    }
    cout << ans << endl;
    
  return 0;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
#define LL long long
// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

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


Measured memory_bytes: 256
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<stack>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 105
#define inf (int)1e9
#define ll long long
#define mm 1000000007
#define eps 1e-9
#define low(x) x&(-x)
#define pb push_back
#define mp make_pair
#define PII pair<int,int>
using namespace std;

ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
int n;
int main(){
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	n=read();
	int cnt=n,cnt2=0.,flag=0;
	rep(i,1,n) {
		int x=read();
		if ((x%2==0)&&(x%4!=0)) flag=1,cnt--;
		else {
			if (x%4==0) cnt2++; 
		}
	}
	cnt+=flag;
//	printf("%d %d %d\n",flag,cnt,cnt2);
	if (cnt2>=cnt/2) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


a, b = map(int, input().split())

for i in range(1, 10000):
    aa = i*0.08
    aaa = math.floor(aa)
    bb = i*0.1
    bbb = math.floor(bb)
    if a == aaa and b == bbb:
        print(i)
        exit()
print(-1)


Measured memory_bytes: 3832
import sys
import math
input = sys.stdin.readline
##

num_score = int(input().rstrip())
while num_score != 0:
    scores = []
    for _ in range(num_score):
        scores.append(int(input().rstrip()))
    total = sum(scores) - max(scores) - min(scores)
    average = math.floor(total / (len(scores) - 2))
    print(average)
    num_score = int(input().rstrip())



Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  string t = "AKIHABARA";
  cin >> s;
  
  if (s.size() > t.size()) { 
    cout << "NO\n";
  }else if (s == t) {
    cout << "YES\n";
  }else {
    if (s.size() == 5) {
      if (s == "KIHBR") {
        cout << "YES\n";
      }else{
        cout << "NO\n";
      }
    }else if (s.size() == 6) {
      if (s == "AKIHBR" || s == "KIHABR" || s == "KIHBAR" || s == "KIHBRA") {
        cout << "YES\n";
      }else{
        cout << "NO\n";
      }
    }else if(s.size() == 7) {
      if (s == "AKIHABR" || s == "AKIHBAR" || s == "AKIHBRA" || s == "KIHABAR" || s == "KIHABRA" || s == "KIHBARA") {
        cout << "YES\n";
      }else {
        cout << "NO\n";
      }
    }else {
      if(s == "AKIHABAR" || s == "AKIHBARA" || s == "KIHABARA") {
        cout << "YES\n";
      }else {
        cout << "NO\n";
      }
    }
  }
}

Measured memory_bytes: 256
/// Bismillah Hir Rahmanir Rahim

#include <bits/stdc++.h>

using namespace std;

#define PI                    acos(-1.0)
#define Pi                    3.141592653589793
#define ff                    first
#define ss                    second
#define pb                    push_back
#define space                 " "
#define all(x)                (x).begin(), (x).end()
#define clr(ar)               memset(ar, 0, sizeof(ar))
#define eprintf(...)          fprintf(stderr, __VA_ARGS__)

/*
template <class T> T gcd(T a,T b){ if(b == 0) return a; return gcd( b,a % b ); }
template <class T> T lcm(T a, T b ){ return ( a * b ) / gcd( a,b ); }
template<class T> string ToString(const T &x){ stringstream s; s << x; return s.str(); }
template<class T> int ToInteger(const T &x){ stringstream s; s << x; int r; s >> r; return r; }
*/

const int dr[] = { -1, 1, 0, 0 }; /// 4 side moves.
const int dc[] = { 0, 0, -1, 1 };
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }; /// 8 side moves.
const int dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
const int kr[] = { 1, 1, -1, -1, 2, 2, -2, -2 }; /// Knight Moves.
const int kc[] = { 2, -2, 2, -2, 1, -1, 1, -1 };

typedef  long long int            ll;
typedef  map<string,int>          msi;
typedef  map<string, string>      mss;
typedef  map<int,int>	          mii;
typedef  map<ll, ll>              mll;
typedef  map<char,int>            mci;
typedef  map<int,string>	      mis;
typedef  pair<int,int> 	          ii;
typedef  pair<string, int>        psi;
typedef  pair<string, string>     pss;
typedef  vector<int> 	          vi;
typedef  vector<string> 	      vs;
typedef  vector<char>	          vc;
typedef  vector< ii >             vii;

template<class T1> void deb(T1 e1)
{
    cout << e1 << endl;
}
template<class T1,class T2> void deb(T1 e1, T2 e2)
{
    cout << e1 << space << e2 << endl;
}
template<class T1,class T2,class T3> void deb(T1 e1, T2 e2, T3 e3)
{
    cout << e1 << space << e2 << space << e3 << endl;
}

#define sf                    scanf
#define pf                    printf

#define sf1(a)                scanf("%d", &a)
#define sf2(a,b)              scanf("%d %d",&a, &b)
#define sf3(a,b,c)            scanf("%d %d %d", &a, &b, &c)
#define sf4(a,b,c,d)          scanf("%d %d %d %d", &a, &b, &c, &d)

#define sf1ll(a)              scanf("%I64d", &a)
#define sf2ll(a,b)            scanf("%I64d %I64d", &a, &b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d", &a, &b, &c)
#define sf4ll(a,b,c,d)        scanf("%I64d %I64d %I64d %I64d", &a, &b, &c, &d)

#define READ                  freopen("in.txt", "r", stdin);
#define WRITE                 freopen("out.txt", "w", stdout);
/// The End.

void check_time()
{
#ifdef the_badcoder
    eprintf("%.5lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif
}

const int res = 1e5 + 10;
const ll mod = 1e9 + 7;

int main()
{
    int n;
    ll a, b, sum = 0, mini = LONG_MAX;

    sf1( n );

    for( int i = 0; i < n; i++ )
    {
        cin >> a >> b;
        sum = a + b;
        mini = min( mini, sum );
    }

    deb( mini );

    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

ll lcm(ll a, ll b){
  ll gcd = 1;
  for(ll i = 1; i <= min(a,b); i++){
    if(a%i==0&&b%i==0){
      gcd = i;
    }
  }
  return a * b / gcd;
}

int main(){
  ll n,m;
  cin >> n >> m;
  str s,t;
  cin >> s >> t;
  ll l = lcm(n,m);
  ll l_step = lcm(l/n,l/m);
  REP(i,l/l_step){
      if(s[i*l_step/(l/n)]!=t[i*l_step/(l/m)]){
        cout << -1 << endl;
        return 0;
      }
  }
  cout << l << endl;
  return 0;
}


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

using namespace std;
const int INF = 1e9;

int minCost(int N, vector<int>& h) {
	vector<int> dp(N, INF);
	dp[0] = 0;
	
	for(int i = 0; i < N; ++i) {
		for(int j = i+1; j <= i+2; ++j) {
			if(j < N) {
				dp[j] = min( dp[j], dp[i] + abs(h[i] - h[j]) );
			}
		}
	}
	return dp[N - 1];
}
int main() {
	// your code goes here
	int N;
	cin >> N;

	vector<int> h(N, 0);
	for(int i = 0; i < N; ++i) {
		cin >> h[i];
	}
	
	cout << minCost(N, h) << endl;
	return 0;
}
	

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:usize = read();
    let mut b:usize = read();
    let mut c:usize = read();
    let k:usize = read();
    for _ in 0..k {
        if b <= a {
            b *= 2;
        } else if c <= b {
            c *= 2;
        }
    }
    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2148
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <fstream>
#include <cassert>
using namespace std;

//common
typedef long long i64,ll;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,r) for(int i=(l);i<(int)(r);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T pmod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

namespace Fenwicks{
	template<typename T> class Fenwick{
	public:
		int size;vector<T> bit;
		Fenwick():Fenwick(0){}
		Fenwick(int n):size(n){bit = vector<T>(n+1);}
		T sum(int n){// [0,n)
			T s=0;
			while(n>0){
				s+=bit[n];
				n-=n&-n;//low
			}
			return s;
		}
		void add(int i,T x){//[0,...i...,n)
			i++;
			while(i<=size){
				bit[i]+=x;
				i+=i & -i;//next
			}
		}
		
		//lib
		T sum(int a,int b){// [a,b)
			return sum(b)-sum(a);
		}
	};
}
using namespace Fenwicks;

ll MOD=1000000007;

class Main{
public:
	
	void run(){

		vector<ll> fact(100050);fact[0]=1;
		for(int i=1;i<100050;i++){
			fact[i]=pmod(fact[i-1]*i,MOD);
		}

		while(true){
			int N;scanf("%d",&N);if(N==0)break;
			int R;scanf("%d",&R);
			vector<int> as(N);
			REP(i,N)as[i]=i;
			REP(r,R){
				int s,t;scanf("%d%d",&s,&t);s--;t--;
				swap(as[s],as[t]);
			}

			ll res=0;
			Fenwick<int> fen(N);
			REP(i,N){
				res+=(as[i]-fen.sum(as[i]))*fact[N-1-i];
				res%=MOD;
				fen.add(as[i],1);
			}
			cout << res<<endl;
		}

	}
};

 int main(){
	//ios::sync_with_stdio(false);
 	Main().run();
 	return 0;
 }

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep (i, s.size() - 1) {
        string t = "";
        t += s[i];
        t += s[i + 1];
        if (t == "AC") {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b;std::cin >> a >> b;
  for(ld i=0;i<100000;i++){
    ld A = 0.08, B = 0.1;
    ll x = (ll)(i*A), y = (ll)(i*B);
    if(x==a&&y==b){
      std::cout << i << '\n';
      return 0;
    }
  }
  std::cout << -1 << '\n';
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  string ans = "";
  for (auto c :s) {
    if (c == '0' || c == '1')
      ans.push_back(c);
    else if (!ans.empty())
      ans.pop_back();
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A % 3 == 0)
    cout << "Possible" << endl;
  else if (B % 3 == 0)
    cout << "Possible" << endl;
  else if ((A + B) % 3 == 0)
    cout << "Possible" << endl;
  else
    cout << "Impossible" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 10
#define NUM_MAX 1000000
#define DIVISOR 1000000007

int main(void) {
    int i, j;
    static char is_prime[NUM_MAX];
    memset(is_prime, 0x01, NUM_MAX);
    is_prime[0] = is_prime[1] = 0;
    for(i = 2; i <= NUM_MAX; i++) {
        int limit = NUM_MAX/i;
        if(!is_prime[i]) continue;
        for(j = 2; j <= limit; j++) {
            is_prime[i*j] = 0;
        }
    }
    static int cum[NUM_MAX+1];
    for(i = 1; i <= NUM_MAX; i++) {
        cum[i] = cum[i-1] + is_prime[i];
    }
    while(1) {
        int num = 0;
        if(!scanf("%d", &num)) break;
        if(!num) break;
        printf("%d\n", cum[num]);
    }
    return 0;
}


Measured memory_bytes: 6612
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll n,k,s=0,m=0,ans=0;
    cin>>n>>k;
    FOR(i,1,k){
        s+=i-1;
        m+=n-i+1;
    }
    FOR(i,k,n+2){
        s+=i-1;
        m+=n-i+1;
        ans=(ans+(m-s)+1)%MOD;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> mvec(size_t a){return vector<T>(a);}template<class T, class... Ts>auto mvec(size_t a, Ts... ts){return vector<decltype(mvec<T>(ts...))>(a, mvec<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}/* 重み付きUnionFind */struct WUnionFind {vector<int> par;vector<int> rank;WUnionFind(int n = 1) {init(n);}void init(int n = 1) {par.resize(n); rank.resize(n);for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;}int root(int x) {if (par[x] == x) {return x;}else {int r = root(par[x]);return par[x] = r;}}bool issame(int x, int y) {return root(x) == root(y);}bool merge(int x, int y) {x = root(x); y = root(y);if (x == y) return false;if (rank[x] < rank[y]) swap(x, y);if (rank[x] == rank[y]) ++rank[x];par[y] = x;return true;}};/* IO高速化 */void fastio(){ios::sync_with_stdio(false);cin.tie(NULL);}
/* ここからコード開始 */

int main(){
  fastio;
  ll A, B, C;
  cin >> A >> B >> C;
  cout << max({A,B,C})*9+A+B+C << rt;
}

Measured memory_bytes: 256
N = int(input())
As = list(map(int, input().split()))
sAs = sum(As)
s2As = sum(map(lambda a: a*a, As))
#print(sAs, s2As)
cs = []
for x in range(min(As), max(As)+1):
  c = N*x*x-2*x*sAs+s2As
  cs.append(c)
r = min(cs)
print(r)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x,y);
    swap(x,z);
    cout << x << " " << y << " " << z;    
    return 0;
}

Measured memory_bytes: 3560
aaa = input()
bbb = input()
d = {}
d_rev = {}
ans = 'Yes'
for a, b in zip(aaa, bbb):
  if (a in d and d.get(a) != b) or (b in d_rev and d_rev.get(b) != a):
    ans = 'No'
  d[a] = b
  d_rev[b] = a
print(ans)

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

int main(){
  int r, g, b;
  cin >> r >> g >> b;
  if (((g * 10) + b) % 4 == 0) {
    cout << "YES" << endl;
}
  else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let a: Vec<usize> = (0..m).map(|_| input()).collect();
    const MOD: i64 = 1000000007;

    let mut k = 0;
    let mut v = vec![0; n + 1];
    v[0] = 1;
    for i in 1..n + 1 {
        if k < m && a[k] == i {
            k += 1;
            continue;
        }

        v[i] = v[i - 1];
        if i > 1 {
            v[i] += v[i - 2];
        }
        v[i] %= MOD;
    }

    println!("{}", v[n]);
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
int solve(vector<int>& vec, int n, int k)
{
	int dp[n + 2][k + 2];
	for(int j = 0; j <= k; j++)dp[1][j] = (j > vec[1])?0:1;
	for(int i = 2; i <= n ;i++){
		for(int j = 0; j <= k; j++){
			if(j == 0)dp[i][j] = dp[i-1][j];
			else{
				dp[i][j] = (mod+dp[i][j-1]+dp[i-1][j] - ((j-vec[i]-1 >= 0)?dp[i-1][j-vec[i]-1]:0))%mod;
			}
		}
	}
	return dp[n][k];
}

signed main()
{
	int n, k;
	cin >> n >> k;
	vector<int> vec(n + 1);
	for(int i = 1; i <= n; i++)cin >> vec[i];
	cout << solve(vec, n, k);
}

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

using namespace std;

int main(){
  string s;
  cin >> s;
  int count = 0;
  
  if(s[0] == '1'){count++;}
  if(s[1] == '1'){count++;}
  if(s[2] == '1'){count++;}
  
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007
var inf int = 1000000000000

type lazysegtree struct {
	n    int
	node []int
	lazy []int
}

func newlazySegtree(v []int) *lazysegtree {
	sz := len(v)
	_n := 1
	for _n < sz {
		_n *= 2
	}
	_node := make([]int, 2*_n-1)
	_lazy := make([]int, 2*_n-1)
	for i := 0; i < sz; i++ {
		_node[i+_n-1] = v[i]
	}
	for i := _n - 2; i >= 0; i-- {
		_node[i] = _node[2*i+1] + _node[2*i+2]
	}
	return &lazysegtree{
		n:    _n,
		node: _node,
		lazy: _lazy,
	}
}

// k番目のノードについて遅延評価を行う
func (u lazysegtree) eval(k int, l int, r int) {
	if u.lazy[k] != 0 {
		u.node[k] += u.lazy[k]
		if r-l > 1 {
			u.lazy[2*k+1] += u.lazy[k] / 2
			u.lazy[2*k+2] += u.lazy[k] / 2
		}
		u.lazy[k] = 0
	}
	return
}

func (u lazysegtree) add(a int, b int, x int, k int, l int, r int) {
	if r < 0 {
		r = u.n
	}
	u.eval(k, l, r)
	if b <= l || r <= a {
		return
	}
	if a <= l && r <= b {
		u.lazy[k] += (r - l) * x
		u.eval(k, l, r)
	} else {
		u.add(a, b, x, 2*k+1, l, (l+r)/2)
		u.add(a, b, x, 2*k+2, (l+r)/2, r)
		u.node[k] = u.node[2*k+1] + u.node[2*k+2]
	}
}

//[a,b)内の合計の取得
func (u lazysegtree) getsum(a int, b int, k int, l int, r int) int {
	if r < 0 {
		r = u.n
	}
	if r <= a || b <= l {
		return 0
	}
	u.eval(k, l, r)
	if a <= l && r <= b {
		return u.node[k]
	}
	vl := u.getsum(a, b, 2*k+1, l, (l+r)/2)
	vr := u.getsum(a, b, 2*k+2, (l+r)/2, r)
	return vl + vr
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	//予備
	a := iScan()
	b := iScan()
	c := iScan()
	d := iScan()
	a1 := a * c
	a2 := a * d
	a3 := b * c
	a4 := b * d
	tmp := []int{a1, a2, a3, a4}
	fmt.Println(max(tmp))
}

Measured memory_bytes: 1772
#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>;
const long double EPS = 1e-10;

int main() { 
  ll a, b, c;
  cin >> a >> b >> c;
  if ((c-a-b)>0 && (c-a-b)*(c-a-b) > 4*a*b) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#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--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}




int32_t main() {
	aryan_pandeya();
	FIO;

	string s ;
	cin>>s;

	if(s[s.length()-1]=='s'){
		cout<<s<<"es";
	}
	else{
		cout<<s<<"s";
	}



	return 0;
}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,x;
	cin>>a>>b>>x;
	if(x<a)
		cout<<"NO\n";
	else
	{
	int res = (x-a);
	if(res<=b)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	}
}

Measured memory_bytes: 256
n, k = map(int,input().split())
p = list(map(lambda x:int(x)+1,input().split()))

s = [0]*(n+1)

for i in range(n):
    s[i+1] = s[i] + p[i]
    
res = 0
for i in range(n-k+1):
    res = max(res,s[i+k]-s[i])
print(res/2)

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


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

    if(a+b<10) cout<<a+b<<endl;
    else cout<<"error"<<endl;

    return 0;
}

Measured memory_bytes: 256
import math
N=int(input())
A = list(map(int,input().split()))
s = [0]*N
ans=0

for i in reversed(range(N)):
    floor = math.floor(N/(i+1))
    sum=0
    for k in range(1,floor+1):

        sum+=s[((i+1)*k)-1]
    if (sum - A[i])%2 == 1:
        s[i] = 1
        ans+=1

print(ans)
for i in range(N):
    if s[i] == 1:
        print(i+1)

Measured memory_bytes: 7276
using System;
class Program
{
        static void Main(string[] args)
        {        
                // スペース区切りの整数の入力
                string[] input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]);
                int b = int.Parse(input[1]);
          		int c = int.Parse(input[2]);
               	int sa = int.Parse(input[3]);
          		bool flg=false;
          
          		//直接
          		int ac=Math.Abs(a-c);
          		if (ac<=sa){
            		//AとCの差がsa以内ならYes
            		flg=true;
          		}
          		//間接
          		int ab=Math.Abs(a-b);
          		int bc=Math.Abs(b-c);
          		if(ab<=sa && bc<=sa){
                     flg=true;
          		}
          		if (flg){
            		Console.WriteLine("Yes");
          		}else{
            		Console.WriteLine("No");
          		}
        }
}


Measured memory_bytes: 11092
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t a,b;
    cin >> a >> b;
    cout << a*b - (a+b-1) << endl;
}


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;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int A,B;cin>>A>>B;
  int ans = 0;
  FOR(x,A,B+1){
    string s=to_string(x);
    int l=0,r=s.length()-1;
    bool ok=true;
    while(l<r){
      if(s[l]!=s[r])ok=false;
      l++;
      r--;
    }
    ans += ok;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
const ll INF = 1e18;
#define print(x) cout << (x) << endl;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, ans = 0;
    cin >> n;
    vector<int> p(n);
    rep(i,0,n) {
        cin >> p.at(i);
    }
    rep(i,1,n-1) {
        vector<int> pp(3);
        pp.at(0) = p.at(i-1);
        pp.at(1) = p.at(i);
        pp.at(2) = p.at(i+1);
        sort(pp.begin(), pp.end());
        if (pp.at(1) == p.at(i)) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

def main():
    N,*S = map(int, open(0).read().split())
    S = sorted(S)

    g = [S.pop(-1)]

    for _ in range(N):
        tmp = []
        lg = len(g)
        for p in g[:lg]:
            while S:
                s = S.pop(-1)
                if p > s:
                    g.append(s)
                    break
                else:
                    tmp.append(s)
            else:
                print('No')
                sys.exit()
        S.extend(tmp[::-1])
        g.sort(reverse=True)
    print('Yes')

if __name__=='__main__':
    main()

Measured memory_bytes: 32044
# B

inp = input().split(' ')
N, K = int(inp[0]), int(inp[1])

sunuke = [1 for i in range(N)]

for i in range(K):
    di = int(input())
    tmp = [int(t)-1 for t in input().split(' ')]
    for t in tmp:
        sunuke[t] = 0
print(sum(sunuke))

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

inline unsigned long long xor128() {
	static unsigned long long x = 123456789;
	static unsigned long long y = 362436069;
	static unsigned long long z = 521288629;
	static unsigned long long w = 88675123;
	unsigned long long t = x ^ (x << 11);
	x = y;
	y = z;
	z = w;
	return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
}

int main() {
	ll N;
	cin >> N;
	vector<ll> a(N), b(N);
	for(ll i=0; i<N; i++) cin >> a[i];
	for(ll i=0; i<N; i++) cin >> b[i];

	map<ll,ll> am,bm;
	for(ll i=0; i<N; i++){
		am[a[i]]++;
		bm[b[i]]++;
	}
	for(auto&& pr:am){
		if(pr.second + bm[pr.first]> N){
			cout << "No\n";
			return 0;
		}
	}

	std::random_device seed_gen;
	std::mt19937 engine(seed_gen());
	shuffle(b.begin(), b.end(), engine);
	
	//shuffleの代わりにreverseもよさそう
	//reverse(b.begin(), b.end());
	
	ll i=0,j=N-1;
	while(i<j){
		while(i<N && a[i]!=b[i])i++;
		while(j>=0 && a[i]==b[i])j--;
		if(i<j){
			swap(a[i],a[j]);
			swap(b[i],b[j]);
		}
	}

	while(i<N){
		ll r=xor128()%(N-1);
		if(r>=i)r++;
		swap(b[i],b[r]);
		if(r<i){
			if(a[i]==b[i] && a[r]==b[r]){
				i--;
				swap(a[i],a[r]);
				swap(b[i],b[r]);
			}else if(a[i]!=b[i] && a[r]!=b[r]){
				i++;
			}else if(a[r]!=b[r]){
				;
			}else if(a[i]!=b[i]){
				swap(a[i],a[r]);
				swap(b[i],b[r]);
			}
		}else{
			if(a[i]==b[i] && a[r]==b[r]){
				;
			}else if(a[i]!=b[i] && a[r]!=b[r]){
				i++;
				swap(a[i],a[r]);
				swap(b[i],b[r]);
			}else if(a[r]!=b[r]){
				swap(a[i],a[r]);
				swap(b[i],b[r]);
			}else if(a[i]!=b[i]){
				;
			}
		}
	}

	vector<pair<ll,ll>> ans(N);
	for(ll i=0; i<N; i++){
		ans[i]={a[i],b[i]};
	}

	sort(ans.begin(), ans.end());
	cout << "Yes\n";
	for(ll i=0; i<N; i++) cout << ans[i].second << " \n"[i==N-1];

	return 0;
}


Measured memory_bytes: 34284