akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll pow_mod(ll x, ll y, ll mod)
{
	if (y == 0)
		return 1;

	if (y == 1)
		return x % mod;

	return (pow_mod(x, y - 1, mod) * x) % mod;
}

int N;
int V[20],C[20];
int ans;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin>>N;
	rep(i,0,N)cin>>V[i];
	rep(i,0,N)cin>>C[i];
	rep(i,0,N){
		if((V[i]-C[i])>0)ans+=V[i]-C[i];
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  A
//
//  Created by Hashizo on 2020/02/16.
//  Copyright © 2020 Hashizo. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <regex>
#include <cmath>

using namespace std;
 
#undef LONG_MAX
#undef LONG_MIN
 
#define LONG_MAX    9223372036854775807
#define LONG_MIN    (-LONG_MAX  -1)
 
#define ll long long
 
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
 
#define SORT(c) sort((c).begin(), (c).end())
#define REVERSE(v) reverse((v).begin(), (v).end())


int main(int argc, const char * argv[]) {

	vector<ll> point(3);
	REP(i, 3) {
		cin >> point[i];
	}

	SORT(point);
	
	if(point[0] == point[1]) {
		if(point[1] == point[2]) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	else {
		if(point[1] == point[2]) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>

int main(){
  //std::ifstream in("input.txt");
  //std::cin.rdbuf(in.rdbuf());

  int A1, A2, A3;
  std::cin >> A1 >> A2 >> A3;

  if(A1 + A2 + A3 >= 22){
    std::cout << "bust" << std::endl;
  }else{
    std::cout << "win" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
S = list(map(int, list(input())))
l = len(S)
list = []
for i in range(l-2):
    a = 100 * S[i]
    b = 10 * S[i+1]
    c = S[i+2]
    n = a + b + c
    list.append(abs(n-753))

print(min(list))

Measured memory_bytes: 3060
S = str(input())

case1 =""
case2 =""

for i in range(len(S)):
    if i%2==0:
        case1 += "0"
        case2 += "1"
    else:
        case1 += "1"
        case2 += "0"
    
    
c1 = 0
c2 = 0
    
for i in range(len(S)):
    
    if S[i] != case1[i]:
        c1 +=1
    
    if S[i] != case2[i]:
        c2+=1
    
print(min(c1,c2))

Measured memory_bytes: 3316
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#define rg register
using namespace std;
template < typename T > inline void read(T& s) {
 	s = 0; int f = 0; char c = getchar();
 	while (!isdigit(c)) f |= (c == '-'), c = getchar();
 	while (isdigit(c)) s = s * 10 + (c ^ 48), c = getchar();
 	s = f ? -s : s;
}

typedef long long LL;
const int _ = 100010;
const LL p = 1e9 + 7;

int n; LL dp[_], sum[_], A, B, a[_];

int main() {
	read(n), read(A), read(B); if (A < B) swap(A, B);
	for (rg int i = 1; i <= n; ++i) read(a[i]);
	for (rg int i = 1; i + 2 <= n; ++i)
		if (a[i + 2] - a[i] < B) return puts("0"), 0;
	dp[0] = sum[0] = 1;
	for (rg int l = 0, r = 0, i = 1; i <= n; ++i) {
		while (r < i && a[i] - a[r + 1] >= A) ++r;
		if (l <= r) dp[i] = (sum[r] - (l > 0 ? sum[l - 1] : 0ll) + p) % p;
		sum[i] = (sum[i - 1] + dp[i]) % p;
		if (i > 1 && a[i] - a[i - 1] < B) l = i - 1;
	}
	LL ans = 0;
	for (rg int i = n; ~i; --i) {
		ans = (ans + dp[i]) % p;
		if (i < n && a[i + 1] - a[i] < B) break;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <stdio.h>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <queue>
using namespace std;

typedef long long LL;
const int MAX_N = 3e5+6;

struct Treap {
	Treap *lc,*rc;
	LL sum,key,pri;
	int sz=0;
	Treap(LL _key) {
		lc=rc=NULL;
		key=_key;
		pri = rand();
		sum = _key;
		sz=1;
	}
};

LL Sum(Treap* t) {
	return t?t->sum:0;
}

int Sz(Treap* t) {
	return t?t->sz:0;
}

LL Key(Treap* t) {
	return t?t->key:0;
}

void pull(Treap* t) {
	if (!t) return;
	t->sum = Sum(t->lc) + Sum(t->rc) + t->key;
	t->sz = Sz(t->lc) + Sz(t->rc) +1;
}

Treap* merge(Treap* a,Treap* b) {
	if (!a || !b) return a?a:b;
	else if (a->pri > b->pri) {
		a->rc=merge(a->rc,b);
		pull(a);
		return a;
	}
	else {
		b->lc=merge(a,b->lc);
		pull(b);
		return b;
	}
}

void split_by_key(Treap* t,LL k,Treap* &a,Treap* &b) {
	if (!t) a=b=NULL;
	else if (t->key <= k) {
		a=t;
		split_by_key(t->rc,k,a->rc,b);
		pull(a);
	}
	else {
		b=t;
		split_by_key(t->lc,k,a,b->lc);
		pull(b);
	}
}

void split_by_sz(Treap* t,LL k,Treap* &a,Treap* &b) {
	if (!t) a=b=NULL;
	else if (Sz(t->lc) + 1 <= k) {
		a=t;
		split_by_sz(t->rc,k - Sz(t->lc) - 1,a->rc,b);
		pull(a);
	}
	else {
		b=t;
		split_by_sz(t->lc,k,a,b->lc);
		pull(b);
	}
}

LL a[MAX_N];

Treap *root;

void add(LL val) {
	Treap* tl;
	split_by_key(root,val,tl,root);
	root = merge(merge(tl,new Treap(val)),root);
}

void meruru(LL val) {
	Treap* tl,*tr;
	split_by_key(root,val-1,tl,root);
	split_by_key(root,val,root,tr);
	root = merge(merge(tl,root->lc),merge(root->rc,tr));
}

int n;

LL kirino() {
	Treap* tl;
	int szz=Sz(root);
	split_by_sz(root,szz-n,tl,root);
	LL ret=Sum(root);
	root = merge(tl,root);
	return -ret;
}

int main () {
	while (scanf("%d",&n) != EOF) {
		LL nn=3*n;
		root=NULL;
		for (int i=1;nn>=i;i++) {
			scanf("%lld",&a[i]);
			if (i>n) {
				add(-a[i]);
			}
		}
		priority_queue<LL,vector<LL>,greater<LL> > pq;
		LL sum=0;
		for (int i=1;n>=i;i++) {
			sum += a[i];
			pq.push(a[i]);
		}
		LL ans = sum-kirino();
		for (int i=n+1;2*n>=i;i++) {
			sum += a[i];
			pq.push(a[i]);
			meruru(-a[i]);
			sum -= pq.top();
			pq.pop();
			ans = max(ans,sum-kirino());
		}
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 16248
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#include <assert.h>
#define FOR(i,a,n) for(i=(a);i<(n);i++)
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0)
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define LOCAL
#ifdef LOCAL
    #define DEBUG(...) printf(" "__VA_ARGS__)
#else
    #define DEBUG(...)
#endif /* LOCAL */
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}

int a[100];
int main(void)
{
	int n,x,i;
	scanf("%d%d",&n,&x);
	FOR(i,0,n) scanf("%d",&a[i]);
	qsort(a,n,sizeof(int),comp);
	i=0;
	while(i<n&&x>0){
		x-=a[i];
		i++;
	}
	printf("%d\n",x==0?i:i-1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define ll long long

int main(int argc, char** argv) {
	int n,r;
	cin>>n>>r;
	if(n<=10)
	{
		cout<<r+100*(10-n);
	}
	else cout<<r;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
#include <sstream>
#include <iomanip>
using namespace std;


#define int int64_t
#define vi vector<int>
#define vb vector<bool>
#define vbb vector< vector<bool> >
#define all(x) (x).begin(), (x).end()
#define vii vector< vector<int> >
#define rip(dp, n, m) vector< vector<int> > dp(n, vector<int>(m,0))
#define ff first
#define ss second
#define pii pair<int64_t, int64_t>
#define miv map<int, vector<int> >
#define mp make_pair
#define pb push_back
#define prr(x) cout << (#x) <<'	' << (x) << endl
#define pr(x) cout  << (x) << endl
#define f(i,n) for(i=0;i<n;i++)
#define pqb priority_queue<int>
#define pqs priority_queue<int,vi,greater<int> >
#define setbits(x)  __builtin_popcountll(x)
#define zrobits(x)  __builtin_ctzll(x)
#define mod 1000000007
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x) int x; cin>>x; while(x--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int dr8[] = {1,1,0,-1,-1,-1, 0, 1};
int dc8[] = {0,1,1, 1, 0,-1,-1,-1};
int dr4[] = {1,0,0,-1};
int dc4[] = {0,1,-1,0};
int gcd(int a, int b)
{
    if(a%b==0) return b;
    return gcd(b, a%b);
}
void solve();

int32_t main()
{
    FIO;
//    int i, n, j, m, k, l, t;
    int a , b, c, d, k, l;
    cin >> a>> b >> c >> d;
    k = a*c;
    k = max(k, a*d);
    l = b*c;
    l = max(l, b*d);

    cout << max(k,l);
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <utility>
#include <queue>
#include <ios>
#include <iomanip>
#include <ctime>
#include <tuple>

#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; i++)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFF
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")

#define PInt pair<int, int>
#define PLL pair<long long, long long>
#define VInt vector<int>
#define VLL vector<long long>
#define MatrixInt vector<vector<int>>
#define MatrixLL vector<vector<long long>>

typedef long long ll;
using namespace std;

int main() {
    
    long double ans = 0;
    int n;
    cin >> n;
    REP(i, n) {
        long double okane;
        string tanni;
        cin >> okane >> tanni;
        if (tanni[0] == 'B') okane *= 3.8e5;
        ans += okane;
    }

    cout << setprecision(13) << ans << endl;
    
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)

	var ans int
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for k := 0; k <= c; k++ {

				if i*500+j*100+k*50 == x {
					ans++
				}
			}
		}
	}
	fmt.Print(ans)
}

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

typedef pair<int, int> P;
int d, g;
P data[11];
int ans;
set<int> yet;

void set_yet() { rep(i, d) yet.insert(i+1); }
void set_max() { rep(i, d) ans += data[i+1].first; }

void dfs(int cnt, int res) {
  if (cnt >= ans) return ;
  if (res <= 0) {
    ans = min(ans, cnt);
    return ;
  }
  for (int i : yet) {
    if (res - i*data[i].first <= 0) {
      cnt += (res+(i-1)) / i;
      ans = min(ans, cnt);
      continue;
    }
    yet.erase(yet.find(i));
    dfs(cnt + data[i].first, res - i*data[i].first - data[i].second);
    yet.insert(i);
  }
}

int main() {
  cin >> d >> g;
  g /= 100;
  rep(i, d) {
    cin >> data[i+1].first >> data[i+1].second;
    data[i+1].second /= 100;
  }
  set_yet();
  set_max();
  dfs(0, g);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define OUT(x)                cout << #x << " = " << x << endl; 
#define rep(i, n)             for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r)          for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r)          for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define each(i, v)            for (auto i : v)
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define pb(x)                 push_back(x)
#define bp(x)                 __builtin_popcount(x)
#define mp(x, y)              make_pair((x), (y))
#define fi                    first
#define se                    second
#define setp(x)               setprecision(x)
#define mset(m, v)            memset(m, v, sizeof(m))
static const int INF        = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD        = 1000000007;
static const double PI      = 3.14159265358979;

#define int                   long long

typedef vector<double>        vd;
typedef vector<string>        vs;
typedef vector<bool>          vb;
typedef vector<int>           vi;
typedef pair<int, int>        pii;
typedef vector<pii>           vpii;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; i ++) cout << *i << " "; cout << endl; }
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }
int in() { int _x; cin >> _x; return _x; }
      
signed main() { 
        int n, k;
        cin >> n >> k;
        vpii a(n);
        rep(i, n) cin >> a[i].fi >> a[i].se;
        sort(all(a));
        int sum = 0;
        int ans;
        rep(i, n) {
                sum += a[i].se;
                if (sum >= k) {
                       ans = i;
                       break;
                }
        }
        cout << a[ans].fi << endl;
        return 0;
}               



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;


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

    long long ans=MOD*MOD;
    for(long long i=1; i*i<=N; i++){
        if(N%i==0){
            ans=min(ans, i+N/i-2);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 1000000007
using namespace std;
using namespace __gnu_pbds;

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

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

    map<int, int> c;
    bool flag = false;
    for(int i = 0; i<n; ++i)
    {
        int temp;
        cin>>temp;
        if(c[temp]) flag = true;
        c[temp] = 1;
    }

    if(!flag)
    {
        cout<<"YES\n";
    }
    else
    {
        cout<<"NO\n";
    }
}


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

using ll = long long;

const int mod = 1000000007;
const int INF = 1000000000;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)

	ans := 0
	n := len(s)
	var k int
	l := 1
	m := make(map[int]int)
	var tmp int
	for i := 0; i < n; i++ {
		k, _ = strconv.Atoi(s[n-i-1 : n-i])
		tmp += k * l
		tmp %= 2019
		m[tmp]++

		if m[tmp] > 1 {
			ans += m[tmp] - 1
		}

		l *= 10
		l %= 2019
	}
	ans += m[0]
	fmt.Println(ans)
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int main(){
    string s,t; cin >> s >> t;
    reverse(t.begin(), t.end());
    if(s == t) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
S = input()
T = input()

ans = 0
ans2 = 10000

for i in range(len(S)-len(T)+1):
    tmp = S[i:i+len(T)]
    ans = 0
    for j in range(len(T)):
        if tmp[j] != T[j]:
            ans += 1
    ans2 = min(ans,ans2)
            
print(ans2)

Measured memory_bytes: 9120
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int h = cin.Int();
			int a = cin.Int();
			int ans = h / a;
			if (h % a != 0) {
				++ans;
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 13140
import Control.Applicative
import Control.Monad
import Data.Char
import Data.List

oper :: String -> [String] -> String -> ( String, String )
oper "print"   (p1:p2:_)    str = ( str, (take (b-a+1).drop a)str ++ "\n" ) where (a,b) = (read p1, read p2)
oper "reverse" (p1:p2:_)    str = ( take a str ++ reverse((take (b-a+1).drop a) str) ++ drop (b+1) str, "") where (a,b) = (read p1, read p2)
oper "replace" (p1:p2:p3:_) str = ( take a str ++ p3 ++ drop (b+1) str, "") where (a,b) = (read p1, read p2)

run :: [[String]] -> String -> (String, String)
run [] str = (str,"")
run (x:xs) str = ( tstr, prt' ++ tprt)
                 where (str', prt') = run xs str
                       (tstr, tprt) = oper (x!!0) (drop 1 x) str'

main = do
    str <- getLine
    q <- readLn ::IO Int
    s <- replicateM q (words <$> getLine) :: IO [[String]]
    --let tstr = "0123456789"
    --let tscr = [["print"],["reverse" , "1", "3"],["print"],["replace","3","7","AAAAA"],["print"]]
    
    putStr $ snd (run (reverse s) str)
    

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



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

    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }

    int ans = 0;
    for(int i = 1;i < N - 1;i++) {
      int sum = vec.at(i) + vec.at(i + 1) + vec.at(i - 1);
      int maxi = max(vec.at(i),max(vec.at(i + 1),vec.at(i - 1)));
      int mini = min(vec.at(i),min(vec.at(i + 1),vec.at(i - 1)));

      if(sum - maxi - mini == vec.at(i)) ans++;
    }

    cout << ans << endl;
}



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

using namespace std;

int gcd(int a, int b) {
  while (b) swap(a %= b, b);
  return a;
}

long long lcm(int a, int b) {
  return (long long)(a) * (long long)(b) / gcd(a, b);
}

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

  int a, b;
  cin >> a >> b;
  cout << lcm(a, b) << endl;

  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# TODO はじめの二匹について組み合わせの仮説を作り、検証する
# 計算時間はO(N)になるはず (4通り×N匹)

from itertools import product

N = int(input())
s = list(input())
assert N == len(s)

def solve(type_b, type_n, ox_n, s=s):
    pass
# input: type_before + type_now + ox_now
# output: type_next

solve = {"WSo": "W",
         "SSx": "W",
         "WSx": "S",
         "SSo": "S",
         "WWx": "W",
         "SWo": "W",
         "WWo": "S",
         "SWx": "S"}

answer = -1

for n0, n1 in product("SW", "SW"):
    animals = [0 for n in range(N)]
    animals[0] = n0
    animals[1] = n1
    for i in range(2, N):
        animals[i] = solve["{}{}{}".format(animals[i-2], animals[i-1], s[i-1])]
    if solve["{}{}{}".format(animals[-2], animals[-1], s[-1])] == n0 and solve["{}{}{}".format(animals[-1], animals[0], s[0])] == n1:
        answer = ""
        for animal in animals:
            answer += animal

print(answer)

Measured memory_bytes: 5640
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
    string T, P;
    cin >> T >> P;
    Rep(i, T.size() - P.size() + 1) {
        if (T[i] == P[0]) {
            bool flag = true;
            Rep(j, P.size()) {
                if (P[j] != T[i + j]) {
                    flag = false;
                    break;
                }
            }
            if (flag) cout << i << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3212
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt;
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};


fn solve(r: i32, g: i32) -> i32 {
    2 * g - r
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next(), sc.next()));
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }
}


trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: fmt::Display, I: IntoIterator<Item = T>>(xs: I) {
    let stdout = io::stdout();
    let mut stdout = BufWriter::new(stdout.lock());
    for x in xs.into_iter() {
        writeln!(stdout, "{}", x).unwrap();
    }
    stdout.flush().unwrap();
}


#[allow(dead_code)]
fn print_or<T: fmt::Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
vector <double> input;
vector <vector <double> > dp;
int n;
double func(int total , int heads)
{
    if(total == n)
    {
        if(heads > n/2)
            return 1;
        return 0;
    }
    if(dp[total][heads] != -1.00)
        return dp[total][heads];
    double result  = 0.00;
    result = input[total]*func(total+1,heads+1)+(1-input[total])*func(total+1,heads);
    return dp[total][heads] = result;
}
int main()
{
    cin>>n;
    input.clear();
    input.resize(n);
    for(int i=0;i<n;i++)
    {
        cin>>input[i];
    }
    dp.clear();
    dp.resize(n+1,vector <double> (n+1,-1.00));
    cout<<setprecision(9)<<func(0,0);
    return 0;
}

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

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

    long long ans = 0;
    ans += (n / (a + b)) * a;
    if (n % (a + b) > a) {
        ans += a;
        cout << ans << endl;
    }
    else {
        ans += n % (a + b);
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}
void judgement(int a){
  if(a){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  if(a){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

int main(){
  ll i,j,N,H,W,ans;
  cin>>N;
  string s,t;cin>>s>>t;
  rep(i,N){
    cout<<s[i]<<t[i];
  }
  //vec v(N);
  cout<<endl;
  return 0;
}

Measured memory_bytes: 256
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

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

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    cpp();
    ll n;
    cin>>n;
    vector<ll> v(n+1);
    for(ll i=1; i<=n; i++){
        for(ll j=i; j<=n; j+=i){
            v[j]++;
        }
    }
    ll ans = 0;
    for(ll i=1; i<=n; i++){
        ans+=(i*v[i]);
    }
    cout<<ans<<endl;
    return 0;
}




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

struct PrimeFactorization {
    vector<pair<int, int>> factors;
    void factor(ll n) {
        int sqrt_n = (int)(sqrtl(n) + 1e-6);
        primes.clear();
        isPrime.assign(sqrt_n + 1, true);
        for (int k = 2; k <= sqrt_n; ++k) {
            if (!isPrime[k]) continue;
            primes.push_back(k);
            for (int m = k * 2; m <= sqrt_n; m += k) isPrime[m] = false;
        }
        factors.clear();
        for (int i = 0; i < (int)primes.size() && n > 1;) {
            if (n % primes[i] == 0) {
                factors.emplace_back(primes[i], 0);
                while (n % primes[i] == 0) {
                    n /= primes[i];
                    factors.back().second++;
                }
            }
            i++;
        }
        if (n > 1) factors.emplace_back(n, 1);
        sort(factors.begin(), factors.end());
    }
    pair<int, int> operator [](int i) const { return factors[i]; }
    int size() const { return factors.size(); }
private:
    vector<int> primes;
    vector<bool> isPrime;
};

int main() {
    int n;
    cin >> n;
    PrimeFactorization pf;
    pf.factor(n);
    cout << n << ":";
    for (const auto& f : pf.factors) {
        for (int i = 0; i < f.second; ++i) {
            cout << " " << f.first;
        }
    }
    cout << endl;
}


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

int main() {
  int k,n,m;
 cin>>k>>n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
  cin >>vec.at(i);
}
  sort(vec.begin(), vec.end()); 
  for(int i=0;i<n-1;i++){
  m=max(m,vec.at(i+1)-vec.at(i));
  }
  m=max(m,(vec.at(0)-vec.at(n-1)+k));
        cout<<k-m<<endl;
  

            
            
            
}


Measured memory_bytes: 1024
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	double w,h,x,y;
	scanf("%lf %lf %lf %lf",&w,&h,&x,&y);
	printf("%.12f ", (w * h / 2.00));
	if(w / 2.00 == x && h / 2.00 == y)	printf("1\n");
	else	printf("0\n");
}


Measured memory_bytes: 128
import numpy as np
N=int(input())
s=np.array(list(map(int,input().split())))

d_even=np.zeros(np.max(s)+1)
d_odd=np.zeros(np.max(s)+1)

for i in range(N//2):
    d_even[s[2*i]]+=1
    d_odd[s[2*i+1]]+=1
    
se=np.argsort(d_even)[::-1]
so=np.argsort(d_odd)[::-1]

e1=se[0]
e2=se[1]
o1=so[0]
o2=so[1]

if e1!=o1:
    ans=N-d_even[e1]-d_odd[o1]
else:
    ans=min(N-d_even[e1]-d_odd[o2],N-d_even[e2]-d_odd[o1])     
        
print(int(ans))

Measured memory_bytes: 24164
import Text.Printf

parseInts :: String -> [Int]
parseInts = map (\x -> read x :: Int) . words

divD :: Int -> Int -> Double
divD a b = fromIntegral a / fromIntegral b

main :: IO ()
main = do
    line <- getLine
    let
        [a, b] = parseInts line
        d = a `div` b
        r = a `mod` b
        f = a `divD` b
    printf "%d %d %f\n" d r f

Measured memory_bytes: 3984
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7, N = 1e7 + 5;

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	ll ans = 0;
	for(int i = 1; i <= n; i++) {
		int cnt = n / i;
		ans += (ll) i * cnt * (cnt + 1) / 2;
	}	
	cout << ans << endl;

}





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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++)
    cin >> a.at(i);
  
  vector<int> b(n);
  
  for(int i=0;i<n;i++)
    b.at(a.at(i)-1)=i+1;
  
  for(int i=0;i<n;i++)
    cout << b.at(i) << " ";
  
}

Measured memory_bytes: 1536
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b, c = 1;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    a--;
    int cnt = 0;
    while (c < b) {
        c += a;
        cnt++;
    }
    cout << cnt << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
ll fpow(ll a,ll b){
	ll c=1;
	while(b){
		if(b&1) c=c*a%mod;
		a*=a;
		a%=mod;
		b>>=1;
	}
	return c;
}
ll C(ll a,ll b){
	ll x=1,y=1;
	for(int i=1;i<=b;i++){
		x=x*(a-i+1)%mod;
		y=y*i%mod;
  }
  return x*fpow(y,mod-2)%mod;
}
int main(){
  ll  n,a,b;
  cin>>n>>a>>b;
	ll ans=fpow(2,n);
	ll x1=C(n,a);
	ll x2=C(n,b);
	ans=(ans-x1+mod)%mod;
	cout<<(ans-x2-1+mod)%mod<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    ll n, m, k; cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    rep(i, n-1) a[i+1] += a[i];
    rep(i, m-1) b[i+1] += b[i];

    int ak=0, bk;
    // aが0冊の時、bから何冊取れるか
    bk = lower_bound(ALL(b), k) - b.begin();
    if(b[bk]!=k) bk--;

    int ans = bk+1;
    FOR(i, 0, n){
        if(a[i] > k) break;
        ak = i;
        for(int j=bk; j>=0; j--){
            if(a[i] + b[j] <= k){
                bk = j;
                break;
            }
            if(j==0) bk=-1;
        }
        // printf("%d, %d\n", ak+1, bk+1);
        chmax(ans, ak+bk+2);
    }
    pr(ans);
    return 0;}

Measured memory_bytes: 6364
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define hell 1000000007
        using namespace std;

        void solve()
        {
         int i,j,k,n,m;
         int a[5];
         rep(i,0,5)
         {
             cin>>a[i];
             if(a[i]==0)
             {
                 m=i;
             }
         }
         cout<<m+1;
    }

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


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, a[300010], q, l, r;


int32_t main(){
INIT
cin>>n>>k;
for(int i=1; i<=n; i++){
    cin>>a[i];
}


int l=0, r=1e9;
while((l+1)<r ){
    int mid=(l+r)/2;
    int cnt=0;
    for(int i=1; i<=n; i++){
        if(a[i]%mid==0 ){
            cnt+=(a[i]/mid)-1;
        }
        else{
        cnt+=a[i]/mid;}
    }
    if(cnt<=k){r=mid;}
    else{l=mid;}
}
cout<<r;


return 0;
}





Measured memory_bytes: 5176
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
#define ll long long

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int n;
    cin >> n;
    set<string> cnt;
    while (n--)
    {
        string s;
        cin >> s;
        cnt.insert(s);
    }
    cout << cnt.size()<<endl;
}

Measured memory_bytes: 19240
S = input()
N = len(S)
ans = [0] * N

T = []
c = 1
p = "R"
for n in range(1, N):
    if S[n] == p:
        c += 1
    else:
        T.append(c)
        c = 1
        p = S[n]
    if n == N-1:
        T.append(c)

M = len(T)
for n in range(0, M, 2):
    for _ in range(T[n] - 1):
        print(0, end=" ")
    
    print((T[n] - 1) // 2 + T[n+1] // 2 + 1 , end=" ")
    print(T[n] // 2 + (T[n+1] - 1) // 2 + 1, end=" ")

    for _ in range(T[n+1]-1):
        print(0, end=" ")

Measured memory_bytes: 55640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#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(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int n, w, h;
int fx[100100], fy[100100];
int fix[100100], fiy[100100];

int main() {
	cin >> n >> w >> h;
	REP(i, n) {
		int x, y, W;
		cin >> x >> y >> W;
		fx[max(x - W, 0)]++;
		fx[min(x + W, w) + 1]--;
		fy[max(y - W, 0)]++;
		fy[min(y + W, h) + 1]--;
		fix[max(x - W, 0)]++;
		fix[min(x + W, w)]--;
		fiy[max(y - W, 0)]++;
		fiy[min(y + W, h)]--;
	}
	bool f = 0;
	REP(i, w + 1) {
		if (i != 0) {
			fx[i] += fx[i - 1];
			fix[i] += fix[i - 1];
		}
		if (i != w)if (fix[i] <= 0)break;
		if (fx[i] <= 0)break;
		if (i == w)f = 1;
	}
	REP(i, h + 1) {
		if (i != 0) {
			fy[i] += fy[i - 1];
			fiy[i] += fiy[i - 1];
		}
		if (i != h)if (fiy[i] <= 0)break;
		if (fy[i] <= 0)break;
		if (i == h)f = 1;
	}
	//REP(i, w+1) {
	//	cout << i << " " << fix[i] << endl;
	//
	//cout << endl;
	//REP(i, h) {
	//	cout << i << " " << fiy[i] << endl;
	//}
	if (!f)cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 4656
import sys
input = sys.stdin.readline
N, Y = map(int, input().strip("\n").split())
for x in range(N + 1):
    for y in range(N - x + 1):
        remainder = Y - 10000 * x - 5000 * y
        if (N - x - y) * 1000 == remainder:
            print(" ".join([str(x), str(y), str(N - x - y)]))
            exit(0)
print("-1 -1 -1")

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,ans=1;
    cin >> n;
    
    while(ans*2<=n){
        ans*=2;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

ll pow(int x, int n)
{
  ll pow = 1;
  for (int i = 0; i < n; i++){
    pow *= x;
  }
  return pow;
}

int main()
{
  int n, k;
  cin >> n >> k;

  cout << k * pow(k - 1, n - 1) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main()
{
    ll i,j,k,n;
    string s;
    cin>>k>>s;
    n=s.length();
    if(n<=k)
    {
       cout<<s<<endl; 
    }
    else
    {
        for(i=0;i<k;i++)
        {
            cout<<s[i];
        }
        cout<<"..."<<endl;
    }
    return 0;
}


Measured memory_bytes: 3592
while True :
    N, K = map(int, input().split())
    if N == 0 and K == 0 :
        break
    
    S = list(map(int, input().split()))
    total_B = [0] * K
    for i in range(N) :
        B = list(map(int, input().split()))
        for j in range(K) :
            total_B[j] += B[j]
            
    ans = 'Yes'
    for i in range(K) :
        if S[i] < total_B[i] :
            ans = 'No'
            break
    print(ans)


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

using namespace std;

#define FOE(i, s, t) for (int i = s; i <= t; i++)
#define FOR(i, s, t) for (int i = s; i < t; i++)
#define FOD(i, s, t) for (int i = s; i >= t; i--)

#define LL long long
#define mp make_pair
#define pb push_back

#define M 1000000007
#define K 6001
int n;
int a[K];
vector<int> nxt[K];
LL ret;

int groups[K], m, head[K], tot;
int cnt = 0;
int v[K];

int DFS(int u) {
	cnt++;
	v[u] = 1;
	int isGood = (a[u] == -1 ? 1 : 0);
	FOR(i, 0, nxt[u].size()) {
		int nt = nxt[u][i];
		
		if (!v[nt]) {
			int ntGood = DFS(nt);
			if (ntGood) isGood = 1;
		}
	}
	
	return isGood;
}	

#define pow jpoidjnvw
LL pow[K];

LL xx[K], gg[K], k; 
LL tots;

LL bigmod(LL a, LL p) {
	if (!p) return 1;
	
	LL t = bigmod(a, p >> 1);
	t = t * t % M;
	
	if (p & 1) t = t * a % M;
	return t;	
}

int main() {
	scanf("%d", &n);
	FOE(i, 1, n) scanf("%d", &a[i]);
	FOE(i, 1, n) tot += (a[i] == -1 ? 1 : 0);
	
	pow[0] = 1;
	FOE(i, 1, n) {
		pow[i] = pow[i - 1] * (n - 1) % M;	
	}
	
	LL r2 = bigmod(2, M - 2);
	 
	FOE(i, 1, n) if (a[i] != -1) {
		nxt[a[i]].pb(i);
		nxt[i].pb(a[i]);	
	}
	
	FOE(i, 1, n) if (!v[i]) {
		cnt = 0;
		int good = DFS(i);
	
	//	printf("DEBUG %d %d\n", cnt, good);
		
		m++; groups[m] = cnt; head[m] = good;
		
		ret = (ret + pow[tot] * (cnt - 1) % M) % M;
	}
	
//	printf("tot = %d\n", tot);
	
	FOE(i, 1, m) if (head[i]) {
		ret = (ret + pow[tot - 1] * (n - groups[i]) % M) % M;
		k++; xx[k] = gg[k] = groups[i];
	}
	
//	printf("ret = %lld\n", ret);
	
	FOE(i, 1, k) tots += xx[i];
	FOE(i, 2, k) {
		FOE(j, 1, k) {
			xx[j] = gg[j] * ((tots - (i - 1) * xx[j] % M + M) % M) % M;
		}
		tots = 0;
		FOE(j, 1, k) tots = (tots + xx[j]) % M; 
	
	//	printf("flag = %d: %lld\n", i, tots * pow[tot - i] % M * bigmod(i, M - 2) % M); 
	
		ret = (ret - pow[tot - i] * tots % M * bigmod(i, M - 2) % M + M) % M;
	}
	
	printf("%lld\n", ret);
	// cout << ret << endl;
}

Measured memory_bytes: 4228
#include <iostream>

int main(int argc, const char * argv[]) {
    std::string line;
    int chars[26] = {};
    for ( ; getline(std::cin, line); ) {
        for (size_t i = 0; i < line.length(); i++) {
            if ('a' <= line[i] && line[i] <= 'z') {
                chars[line[i] - 'a']++;
            } else if ('A' <= line[i] && line[i] <= 'Z') {
                chars[line[i] - 'A']++;
            }
        }
    }
    for (size_t i = 0; i < 26; i++) {
        std::cout << (char)(i + 'a') << " : " << chars[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3120
import java.util.*;
import java.io.*;

public class Main {
	 static int[] w;
	 static long []v;
	static int n;
	static int s;
	static long [][]mydpArr ;
	public static long dp(int indx, int remw) {
		if (remw<0)
			return (long) - 1e9;
	
	if (indx == n)
		return 0;
	if(mydpArr[indx][remw]!=-1)
		return mydpArr[indx][remw];
	long take = v[indx] + dp(indx+1,remw-w[indx]);
	long leave = dp(indx+1,remw);
	return mydpArr[indx][remw] = Math.max(take, leave);	
	}
	public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = sc.nextInt();
        s = sc.nextInt();
        w =new int[n];
        v =new long[n];
        mydpArr =new long[n+1][ (s+1)];
        for(int i=0;i<n;i++) {
        	w[i]=sc.nextInt();
        	v[i]=sc.nextLong();
        }
        for(long[] x :mydpArr) {
        	Arrays.fill(x,-1);
        }
        pw.print(dp(0,s));
        pw.close();
        }
	  static class Scanner {
	         BufferedReader br;
	         StringTokenizer st;
	 
	         public Scanner(InputStream s) {
	             br = new BufferedReader(new InputStreamReader(s));
	         }
	 
	         public String next() throws IOException {
	             while (st == null || !st.hasMoreTokens())
	                 st = new StringTokenizer(br.readLine());
	             return st.nextToken();
	         }
	 
	         public int nextInt() throws IOException {
	             return Integer.parseInt(next());
	         }
	 
	         public long nextLong() throws IOException {
	             return Long.parseLong(next());
	         }
	 
	         public double nextDouble() throws IOException {
	             return Double.parseDouble(next());
	         }
	 
	         public int[] nextIntArr(int n) throws IOException {
	             int[] arr = new int[n];
	             for (int i = 0; i < n; i++) {
	                 arr[i] = Integer.parseInt(next());
	             }
	             return arr;
	         }
	 
	     }
}

Measured memory_bytes: 131012
import sys
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    S = 0
    for b in range(K + 1, N + 1):
        i_max = (N - K)/b
        t = max((i_max * b + (b - 1)) - N, 0)
        S += (((N - K)/b) + 1) * (b-K) - t
    if K == 0:
        S -= N
    print S

if __name__ == '__main__':
    main()

Measured memory_bytes: 5764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int p[] = new int[N + 1];
		int miss = 0;

		for (int i = 1; i <= N; i++) {
			p[i] = sc.nextInt();

			if (p[i] != i) miss++;
		}

		if (miss == 2 || miss == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23892