akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(_itr, array) { cin >> *(_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int h,w;
	cin >>h>>w;
	Pi at, ter;
	int ans = 0;
	cin >> at.F >> at.S >> ter.F >> ter.S;
	at.F--;
	at.S--;
	ter.F--;
	ter.S--;
	vector<string> data(h);
	input(data);
	VVi dis(h, Vi(w, INF));
	deque<Pi> q;
	q.push_back(at);
	dis[at.F][at.S] = 0;
	while(!q.empty()){
		at = q.front();
		q.pop_front();
		for (int ni = max(0, at.F - 2); ni < min(h, at.F + 3);ni++){
			for (int nj = max(0, at.S - 2); nj < min(w, at.S + 3);nj++){
				if (data[ni][nj] == '#') continue;
				if(abs(at.F-ni)+abs(at.S-nj)==1){
					if(chmin(dis[ni][nj],dis[at.F][at.S])){
						q.push_front(mp(ni, nj));
					}
				}else{
					if (chmin(dis[ni][nj], dis[at.F][at.S]+1)) {
						q.push_back(mp(ni, nj));
					}
				}
		}
			 }
	}

	ans = dis[ter.F][ter.S];
	if(ans==INF){
		cout << -1 << endl;
	}else{
		cout << ans << endl;
	}
	//	cout<<ans<<endl;
}

Measured memory_bytes: 9500
program range_set
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: n, a, b, i, j
  integer(8) :: x = 1, f(0:5000, 2) = 0, g(0:5000, 2) = 0
  read(*,*) n, a, b
  if (a > b) then
    i = a
    a = b
    b = i
  end if
  g(1, 2) = 1
  do i = 2, b - 1
    g(i, 2) = mod(g(i - 1, 1) + g(i - 1, 2), modu)
    g(i, 1) = mod(sum(g(1:i - a, 2)), modu)
  end do
  f(0, :) = 1
  do i = 1, n - 1
    x = x + x
    if (x > modu) x = x - modu
    f(i, 1) = mod(sum(f(max(i - a + 1, 0):i - 1, 2)), modu)
    if (i < b) then
      do j = 1, i - 1
        f(i, 2) = f(i, 2) + mod(f(i - j, 1) * g(j, 2), modu)
      end do
      f(i, 2) = mod(f(i, 2) + g(j, 1) + g(j, 2), modu)
    else
      do j = 1, b - 1
        if (i == n) f(i, 1) = mod(f(i, 1) + f(i - j, 1) * g(j, 1), modu)
        f(i, 2) = f(i, 2) + mod(f(i - j, 1) * g(j, 2), modu)
      end do
      f(i, 2) = mod(f(i, 2), modu)
    end if
  end do
  x = x + x
  f(n, 1) = mod(sum(f(n - a + 1:n - 1, 2)), modu)
  do j = 1, b - 1
    f(n, 1) = f(n, 1) + mod(f(n - j, 1) * g(j, 1), modu)
    f(n, 2) = f(n, 2) + mod(f(n - j, 1) * g(j, 2), modu)
  end do
  write(*,'(i0)') modulo(x - f(n, 1) - f(n, 2), modu)
end program range_set

Measured memory_bytes: 3060
#ALDS1_7_B
N = int(input())
answer1= []

def get_parent(node):
    parent = -1
    if "parent" in node:
        return node["parent"]
    return parent

def get_depth(node):
    depth = 0
    while "parent" in node:
        depth += 1
        parent = node["parent"]
        node = rooted_tree[parent]
    return depth

def get_node_type(node):
    if "parent" not in node:
        return "root"
    if node["left"] == -1 and node["right"] == -1:
        return "leaf"
    return "internal node"

def get_sibling(id, node):
    sibling = -1
    if "parent" not in node:
        return sibling
    parent_rchild= rooted_tree[node["parent"]]["right"]
    parent_lchild= rooted_tree[node["parent"]]["left"]
    if id == parent_rchild:
        sibling = parent_lchild
    else:
        sibling = parent_rchild
    return sibling

def get_degree(node):
    degree = 0
    if node["left"] > -1:
        degree += 1
    if node["right"] > -1:
        degree += 1        
    return degree

def get_height(node):
    h1 = h2 = 0
    if node["right"] > -1:
        h1 = get_height(rooted_tree[node["right"]]) + 1
    if node["left"] > -1:
        h2 = get_height(rooted_tree[node["left"]]) + 1
    h =  max(h1, h2)
    return h

rooted_tree = [{} for i in range(N)]
for _ in range(N):
    row = input()
    id, left, right = list(map(int, row.split()))
    rooted_tree[id]["right"] = right
    rooted_tree[id]["left"] = left
    #子供のparentを左右で設定する。
    if left > -1:
        left_child_id = left
        rooted_tree[left_child_id]["parent"] = id
    if right > -1:
        right_child_id = right
        rooted_tree[right_child_id]["parent"] = id

for id in range(N):
    node = rooted_tree[id]
    parent = get_parent(node)
    sibling = get_sibling(id, node)
    degree = get_degree(node)
    depth = get_depth(node)
    height = get_height(node)
    node_type = get_node_type(node)
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(id, parent, sibling, degree, depth, height, node_type))


Measured memory_bytes: 5624
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN           PIC X(5).
01 A            PIC 9(1).
01 B            PIC 9(1).
01 C            PIC 9(1).
01 flg          PIC 9(1) VALUE ZERO.
01 ans          PIC X(3).

PROCEDURE DIVISION.
MAIN.
    ACCEPT LN.
    UNSTRING LN DELIMITED BY SPACE INTO A B C.
    IF A = B AND B NOT = C
        MOVE 1 TO flg
    END-IF.
    IF B = C AND C NOT = A
        MOVE 1 TO flg
    END-IF.
    IF C = A AND A NOT = B
        MOVE 1 TO flg
    END-IF.
    IF flg = 1
        DISPLAY "Yes"
    ELSE
        DISPLAY "No"
    END-IF.

MAIN-EXIT.
  STOP RUN.


Measured memory_bytes: 384
#include <stdio.h>

int h, w, d, i, j, x[90001], y[90001], sum[90001], q, l, r, a;

int myabs(int p)
{
	return p<0?-p:p;
}

int main()
{
	scanf("%d %d %d", &h, &w, &d);
	for(i=1; i<=h; i++)
		for(j=1; j<=w; j++)
		{
			scanf("%d", &a);
			x[a]=i;
			y[a]=j;
		}
	for(i=d+1; i<=h*w; i++)
		sum[i]=sum[i-d]+myabs(x[i]-x[i-d])+myabs(y[i]-y[i-d]);
	scanf("%d", &q);
	for(i=0; i<q; i++)
	{
		scanf("%d %d", &l, &r);
		printf("%d\n", sum[r]-sum[l]);
	}
}

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


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

	vector<vector<int>> G(N);
	for(int i=0;i<M;i++) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}

	int l, r;
	for(l = 0; l < N; l++) {
		if(G[l].size() > 0) {
			break;
		}
	}
	r = G[l][0];

	vector<bool> used(N, false);
	used[l] = true;
	used[r] = true;

	vector<int> ans;
	ans.push_back(l);

	bool ok = false;
	int i = l;
	while (!ok) {
		ok = true;
		for (int to : G[i]) {
			if (!used[to]) {
				ans.push_back(to);
				used[to] = true;
				i = to;
				ok = false;
				break;
			}
		}
	}
	reverse(ans.begin(), ans.end());
	ans.push_back(r);

	ok = false;
	i = r;
	while (!ok) {
		ok = true;
		for (int to : G[r]) {
			if (!used[to]) {
				ans.push_back(to);
				used[to] = true;
				r = to;
				ok = false;
				break;
			}
		}
	}
	cout << ans.size() << endl;
	for(int i=0;i<ans.size();i++) {
		if (i != 0) cout << " ";
		cout << ans[i] + 1;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 6776
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>

//#define PI 3.141592653589

using namespace std;



int main()
{
	string search_str, ring_str[100];
	int n;
	int cnt = 0;
	
	cin >> search_str;
	cin >> n;
	for (int i=0; i<n; i++)
	{
		cin >> ring_str[i];
	}
	for (int i=0; i<n; i++)
	{
		ring_str[i] += ring_str[i];
	}
	
	
	for (int i=0; i<n; i++)
	{
		if (ring_str[i].find(search_str) != string::npos) cnt++;
	}
	
	cout << cnt << endl;
	
	/*
	//テスト出力
	for (int i=0; i<n; i++)
	{
		cout << ring_str[i] << endl;
	}
	*/
	
	return 0;
}

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

int n;

int main(){
	cin>>n;
	bool B=1;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(x%2==0&&x%3!=0&&x%5!=0) B=0;
	}
	cout<<(B?"APPROVED":"DENIED")<<endl;
}

Measured memory_bytes: 256
//D - Bouquet

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <functional>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;
const int MOD = 1000000007;


ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

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

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

mint combination(int n, int a)
{
    mint x = 1;
    mint y = 1;
    REP(i, a){
        x *= n - i;
        y *= i + 1;
    }
    return x / y;
}

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

    mint ans = mint(2).pow(n);
    ans -= 1;
    ans -= combination(n, a);
    ans -= combination(n, b);

    cout << ans.x << endl;

    return 0;
}



Measured memory_bytes: 256
//使える文字が1以上N以下の数字のみである
//3桁のパスワードのみ使用可能
#include <iostream>
using namespace std;

int main(){

  int input = 0;
  int pass = 0;

  cin >> input;
  pass = input*input*input;

  cout << pass << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <cstring>
#include <cstdlib>
#include <cctype>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

llong pow(int x, int n) {
    llong ans = x;
    if (n == 0) return 1;

    for(int i = 0; i < n - 1; i++) {
        ans *= x;
    }

    return ans;
}

void swap(int *X, int *Y){
    int t = *X; *X = *Y; *Y = t;
}

int main() {
    int n, m;
    cin >> n;
    string tmp;
    map<string, int> A;
    rep(i, n) {
        cin >> tmp;
        A[tmp]++;
    }
    cin >> m;
    rep(i, m) {
        cin >> tmp;
        A[tmp]--;
    }

    int ans = -10000000;
    for (auto it = A.begin(); it != A.end(); ++it) {
        ans = max(ans, it->second);
    }

    if (ans < 0) {
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#define N 23
typedef long long ll;
template<typename T> inline void read(T &x) {
	x = 0; char c = getchar();
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
}
using namespace std;
const ll inf = 1e16;
inline void MIN(ll &a, ll b) {
	if (b < a)	a = b;
}
int n;
ll a[N];
ll dfs(int l, int r, int x, int y) {
	if (l == r - 1 || l == r)	return 0;
	ll res = inf;
	for (int i = l + 1; i < r; ++i)
		MIN(res, dfs(l, i, x, x + y) + dfs(i, r, x + y, y) + a[i] * (x + y));
	return res;
}
int main() {
	read(n);
	for (int i = 1; i <= n; ++i)	read(a[i]);
	printf("%lld\n", a[1] + a[n] + dfs(1, n, 1, 1));
	return 0;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll n, r;
  cin >> n >> r;

  ll ans = r;
  if (n < 10) {
    ans = r + 100*(10-n);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include <vector>
#include <list>
#include <string>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <climits>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <set>
using namespace std;


int main(){
	int n;
	cin >> n;
	vector<int> rabi;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		cin >> tmp;
		tmp--;
		rabi.push_back(tmp);
	}
	int counter=0;
	for (int i = 0; i < rabi.size(); i++)
	{
		if (rabi[i] != -1 && rabi[rabi[i]] == i){ rabi[rabi[i]] = -1; rabi[i] = -1; counter++; }
	}

	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <cmath>
using namespace std;
 
 
int main() {
    int A, B ,C;
    cin >> A >> B >> C;

    int ten = max(A,max(B,C));
    
    int other = (ten == A) ? B+C : (ten == B) ? A+C : A+B;
    
    cout << ten*10 + other << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static long bignum = 1000000000+7;

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);



		int k = sc.nextInt();

		int[] ans = {1,9,30,76,141,267,400,624,885,1249,1590,2208,2689,3411,4248,5248,6081,7485,8530,10248,11889,13687,15228,17988,20053,22569,25242,28588,31053,35463,38284,42540,46581,50893,55362,61824,65857,71247,76884,84388,89349,97881,103342,111528,120141,128047,134580,146316,154177,164817,174438,185836,194157,207927,218812,233268,245277,257857,268182,288216,299257,313635,330204,347836,362973,383709,397042,416448,434025,456967,471948,499740,515581,536073,559758,583960,604833,633651,652216,683712,709065,734233,754734,793188,818917,846603,874512,909496,933081,977145,1006126,1041504,1073385,1106467,1138536,1187112,1215145,1255101,1295142,1342852,1373253,1422195,1453816,1502376,1553361,1595437,1629570,1691292,1726717,1782111,1827492,1887772,1925853,1986837,2033674,2089776,2145333,2197483,2246640,2332104,2379085,2434833,2490534,2554600,2609625,2693919,2742052,2813988,2875245,2952085,3003306,3096024,3157249,3224511,3306240,3388576,3444609,3533637,3591322,3693924,3767085,3842623,3912324,4027884,4102093,4181949,4270422,4361548,4427853,4548003,4616104,4718640,4812789,4918561,5003286,5131848,5205481,5299011,5392008,5521384,5610705,5739009,5818390,5930196,6052893,6156139,6239472,6402720,6493681,6623853,6741078,6864016,6953457,7094451,7215016,7359936,7475145,7593865,7689630,7886244,7984165,8130747,8253888,8403448,8523897,8684853,8802826,8949612,9105537,9267595,9376656,9574704,9686065,9827097,9997134,10174780,10290813,10493367,10611772,10813692};

		System.out.println(ans[k-1]);
		/*
		for(int k =1;k<201;k++) {


		long ans =0;
		for(int i =1;i<=k;i++) {
			for(int j=1;j<=k;j++) {
				for(int h=1;h<=k;h++) {
					ans += gcd(i,j,h);
				}
			}
		}
		System.out.print(ans+",");
*/
		/*
		int n = sc.nextInt();
		String s = sc.next();
		String[] ss = s.split("");
		*/

	}

	static int gcd(int a,int b,int c) {
		int ans = 1;
		int max = Math.max(Math.max(a, b),c);
		for(int i =max;i>0;i--) {
			if(a%i==0) {
				if(b%i==0) {
					if(c%i==0) {
						ans = i;
						break;
					}
				}
			}
		}
		return ans;
	}





}
/*
class City{
	int order;
	int prefecture;
	int year;
	int number;
	City(int order,int prefecture, int year){
		this.order = order;
		this.prefecture = prefecture;
		this.year = year;
	}
}
*/


Measured memory_bytes: 35792
#include<bits/stdc++.h>
using namespace std;
int N, M, Q;
const int _ = 100096;
int a[_], r[_], id[_], s[_];
bool vis[_];

int main() {
	scanf("%d%d%d", &N, &M, &Q);
	int t = 1;	
	for(int i = 1; i <= Q; ++i) {
		scanf("%d", a + i);
		if(a[i] >= t-1) t = a[i];
	}
	if(t == 1) return puts("Yes"), 0;
	int c = 0;
	for(int i = Q; i >= 1; --i)
		if(!vis[a[i]]) {
			r[++c] = a[i];
			vis[a[i]]= true;
		}
	for(int i =1; i <= M; ++i)
		if(!vis[i]) r[++c] = i;
	for(int i = 1; i <= M; ++i)
		id[r[i]] = i;
	int init = M;
	for(;init > 1 && r[init] > r[init - 1]; -- init);
	int worst = init;
	s[init] = N;
	for(int i = 1; i <= Q; ++i) {
		int k = id[a[i]];
		if(s[k + 1]) {
			s[k + 1]--;
			++s[k];
			if(k + 1 == worst && !s[k + 1])
				--worst;
		} else {
			if(k > worst) {
				--s[worst];
				++s[worst = k];
			} 
		}
	}
	puts(worst > 1? "No": "Yes");
}


Measured memory_bytes: 1920
m = gets.chomp.to_i
commands = []
m.times do 
    cmd, v = gets.chomp.split(' ')
    v = v.to_i unless v.nil?
    commands.push([cmd, v])
end

def insert(tree, z)
    y = nil
    x = tree[:root]
    # p x, y, z
    until x.nil? do
        y = x
        # puts "x[:key] = #{x[:key]}"
        # puts "z[:key] = #{z[:key]}"
        if z[:key] < x[:key] then
            x = tree[x[:l]]
        else
            x = tree[x[:r]]
        end
    end
    z[:p] = y[:key] unless y.nil?
    if y.nil? then
        tree[:root] = z
        tree[z[:key]] = z
    elsif z[:key] < y[:key]
        y[:l] = z[:key]
        tree[z[:key]] = z
    else
        y[:r] = z[:key]
        tree[z[:key]] = z
    end
end

def getMinimium(tree, z)
    return z if tree[z][:l] == nil
    min = getMinimium(tree, tree[z][:l])
    return min
end

def getSuccessor(tree, z)
    s = getMinimium(tree, tree[z][:r])
    return s
end

def delete(tree, z)
    return unless tree.has_key?(z)
    if tree[z][:l] == nil && tree[z][:r] == nil then
        [:l, :r].each do |child|
            tree[tree[z][:p]][child] = nil if tree[tree[z][:p]][child] == z
        end
    elsif tree[z][:l] && tree[z][:r] then
        y = getSuccessor(tree, z)
        # 次節点yをzにコピーしてyは削除する。削除の際は以下略。
        zLOrR = tree[tree[z][:p]][:l] == z ? :l : :r
        tree[tree[z][:p]][zLOrR] = y
        tree[tree[z][:l]][:p] = y
        if tree[y][:p] == z then
            tree[y][:p] = tree[z][:p]
            tree[y][:l] = tree[z][:l]
        else
            tree[tree[z][:r]][:p] = y
            # yLOrR = tree[tree[y][:p]][:l] == y ? :l : :r
            # tree[tree[y][:p]][yLOrR] = nil
            tree[tree[y][:p]][:l] = nil
            tree[y] = tree[z]
            tree[y][:key] = y
        end
    else
        onlyChild = tree[z][:l].nil? ? :r : :l
        # zが親のlかrかを特定、そこをzの子（lかrか）にすげかえる
        [:l, :r].each do |child|
            tree[tree[z][:p]][child] = tree[z][onlyChild] if tree[tree[z][:p]][child] == z
        end
        # zの子（lかrか）の親をzの親にすげかえる
        tree[tree[z][onlyChild]][:p] = tree[z][:p]
    end
    tree.delete(z)
end

def preParse(tree, key)
    return if key == nil
    print " #{key}"
    preParse(tree, tree[key][:l])
    preParse(tree, tree[key][:r])    
end

def inParse(tree, key)
    return if key == nil
    inParse(tree, tree[key][:l])
    print " #{key}"
    inParse(tree, tree[key][:r])
end

tree = { root: nil }
commands.each do |cmd|
    if cmd[0] == "insert" then
        node = { key: cmd[1], p: nil, l: nil, r: nil }
        insert(tree, node)
    elsif cmd[0] == "delete" then
        delete(tree, cmd[1])
    elsif cmd[0] == "find" then
        puts tree.has_key?(cmd[1]) ? "yes" : "no" # ずるいけどｗ
    else
        # p tree
        inParse(tree, tree[:root][:key])
        puts "\n"
        preParse(tree, tree[:root][:key])
        puts "\n"
    end
end



Measured memory_bytes: 173636
#include <iostream>;
#include <algorithm>;
#include <vector>;

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector <int> a;
	long long sum = 0;
	for (int i = 0; i < n; i++)
	{
		long long temp;
		cin >> temp;
		a.push_back(temp);
		sum += temp;
	}
	long long x = a[0];
	sum -= a[0];
	long long ans = abs(x - sum);
	for (int i = 1; i < n - 1; i++)
	{
		x += a[i];
		sum -= a[i];
		long long curans = abs(x - sum);
		ans = min(ans, curans);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1400
# -*- coding: utf-8 -*-

def solve():
    N,M = map(int,input().split())
    D = dict()
    for _ in range(M):
        s,c = map(int,input().split())
        if s in D and D[s] != c:
            return '-1'
        else:
            D[s] = c

    if N==1 and (M==0 or (1 in D and D[1] == 0)):
        return '0'

    if N>1 and 1 in D and D[1] == 0:
        return '-1'

    if 1 not in D:
        D[1] = 1

    if 2 not in D:
        D[2] = 0

    if 3 not in D:
        D[3] = 0

    res = sum(D[i+1]*10**(N-i-1) for i in range(N))

    return str(res)

if __name__ == '__main__':
    print(solve())



Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr ll mod998=998244353;

int L,R,d,c;

int main(){
	cin>>L>>R>>d;
	for(int i=L;i<=R;i++){
		if(i%d==0)c++;
	}
	cout<<c<<endl;
}


Measured memory_bytes: 3628
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>

#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int res = 0, cnt = 0;
    rep(i, n){
      if(s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')cnt++;
      else {
        chmax(res, cnt);
        cnt = 0;
      }
    }
    chmax(res, cnt);
    cout << res << endl;
}





Measured memory_bytes: 3560
H, W = map(int,input().split())
s = [input() for i in range(H)]
for i in range(H):
    l = ""
    for j in range(W):
        if s[i][j] == "#":
            l += "#"
        else:
            l += str(sum([t[max(0,j-1):min(W,j+2)].count("#") for t in s[max(0,i-1):min(H,i+2)]]))
    print(l)

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

int main() {
    string s;
    int K;
    cin >> s >> K;

    int N = (int)s.size();
    for (int i = 0; i < N; i++) {
        if (s[i] == 'a') continue;

        int need = 26 - (s[i] - 'a');
        if (K >= need) {
            s[i] = 'a';
            K -= need;
        }
    }
    if (K > 0) {
        int ascii = s[N - 1] - 'a';
        ascii = (ascii + K) % 26;
        s[N - 1] = char('a' + ascii);
    }

    cout << s << endl;
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    if (a <= b) {
        rep(i, b) cout << a;
        cout << endl;
    } else {
        rep(i, a) cout << b;
        cout << endl;
    }
}

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

#define ll long long
#define pii pair<int, int>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    int ans = 1;
    while (n >= k) {
        n /= k;
        ans++;
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 3010, mod = 998244353;
int a, b, c, d, f[N][N];
signed main() {
    scanf ("%d %d %d %d", &a, &b, &c, &d);
    f[a][b] = 1;
    for (int i = a; i <= c; ++i)
        for (int j = b; j <= d; ++j) {
            if (i == a && j == b) continue;
            f[i][j] = f[i - 1][j] * j + f[i][j - 1] * i - f[i - 1][j - 1] * (i - 1) * (j - 1);
            f[i][j] = (f[i][j] % mod + mod) % mod;
        }
    return printf ("%lld\n", f[c][d]), 0;
}


Measured memory_bytes: 74272
/*Author SHUBH AGRAWAL  */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
//a power n mod p

#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 

long long int modp(lld a,lld p,lld n)
{
    int d[100];
    int i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
    
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    lld fac[n+1]; 
    fac[0] = 1; 
    for (lld i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


long long int gcd(lld b,lld a)
{
    if(a<b) return gcd(a,b);
    if(a%b==0) return b;
    return gcd(a%b , b);
}


lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,d;

void solve()
{
    cin>>n;
    vector<pair<lld,lld> > v;
    for(i=0;i<n;i++)
    {
        cin>>l;
        v.pb(mp(l,i+1));
    }
    sort(all(v));
    for(i=0;i<n;i++) cout<<v[i].se<<" ";

}

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

Measured memory_bytes: 2544
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

H_ = [abs(A-(T-0.006*h)) for h in H]

temp = 10**7
ans = 1

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

Measured memory_bytes: 3064
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main(){
  int n,q,A[3000],M[3000];
  int dp[3000];

  cin >> n;
  rep(i,n)cin >> A[i];
  cin >> q;
  rep(h,q){
    cin >> M[h];
    rep(i,M[h]+1)dp[i]=-1;
    dp[0] = 0;
    rep(i,n){
      for(int j=0;j<=M[h];j++){
	if(dp[j] >= 0){
	  dp[j] = 1;
	}
	else if(dp[j-A[i]] <= 0 || j<A[i]){
	  dp[j]=-1;
	}else{
	  dp[j] = dp[j-A[i]]-1;
	}
	//	cout << dp[j] << endl;
      }
    }
    if(dp[M[h]] >= 0)cout << "yes" << endl;
    else cout << "no" << endl;

  }

  return 0;
}

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

x = [0]*(N+1)
for i in range(1,N+1):
    for j in range(1,N+1,2):
        if j % i == 0:
            x[j]+=1
ans = 0
for i in x:
    if i == 8:
        ans +=1
print(ans)

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


ll solve() {
    ll N;
    vector<ll> A(4);
    vector<ll> ms{2,3,5};
    cin >> N;
    for ( int i = 0; i < 4; i++ ) {
        cin >> A[i];
    }
    ll INF = 1e18;
    map<ll, ll> coin;  // n, cost
    priority_queue<pii, vector<pii>, greater<>> q;    // cost, n
    coin[N] = 0;
    q.push(pii(0,N));
    while ( !q.empty() ) {
        ll c0 = q.top().first;
        ll n0 = q.top().second;
        q.pop();
        if ( n0 == 0 ) return c0;
        if ( coin.count(n0) > 0 && coin[n0] < c0 ) continue;
        for ( int i = 0; i < 3; i++ ) {
            ll m = ms[i];
            if ( n0 / m == 0 ) {
                ll c = c0 + A[3]*n0;
                ll n = 0;
                if ( coin.count(n) == 0 || coin[n] > c ) {
                    coin[n] = c;
                    q.push(pii(c,n));
                }
            }
            ll r = n0 % m;
            if ( r > 0 ) {
                ll c = c0 + A[3]*(m-r) + A[i];
                ll n = (n0 + m-r)/m;
                if ( coin.count(n) == 0 || coin[n] > c ) {
                    coin[n] = c;
                    q.push(pii(c,n));
                }
            }
            {
                ll c = c0 + A[3]*r + A[i];
                if ( n0 <= (m*A[i])/((m-1)*A[3]) ) {
                    c = min(c, c0 + A[3]*(n0 - (n0-r)/m));
                }
                ll n = (n0 - r)/m;
                if ( coin.count(n) == 0 || coin[n] > c ) {
                    coin[n] = c;
                    q.push(pii(c,n));
                }
            }
        }
    }
    return -1LL;
}

int main() {
    int T;
    cin >> T;
    vector<ll> ans(T);
    for ( int t = 0 ; t < T ; t++ ) {
        ans[t] = solve();
    }
    for ( int t = 0; t < T; t++ ) {
        cout << ans[t] << "\n";
    }
    return 0;
}

Measured memory_bytes: 4368
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const int INF=1e9;
const ll MX = 1e18;
const ll MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define YN {puts("YES");}else{puts("NO");}
const ll MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {fac[0] = fac[1] = 1;finv[0] = finv[1] = 1;inv[1] = 1;for (ll i = 2; i < MAX; i++){fac[i] = fac[i - 1] * i % MOD;inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;finv[i] = finv[i - 1] * inv[i] % MOD;}}
long long COM(ll n, ll k){if (n < k) return 0;if (n < 0 || k < 0) return 0;return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;}
ll llpow(ll n,ll i){ll cnt=n;  for(ll j=0;j<i-1;j++){n*=cnt;}return n;}

int main() {
  ll n,w;
  cin >> n >> w;
  v(ll) weight(n+1),value(n+1);
  vv(ll) dp(n+1,v(ll)(w+1));
  for (int i = 0; i < n; ++i) cin >> weight[i] >> value[i];
  rep(i,n){
    for (int sum_w = 0; sum_w <= w; ++sum_w) {
      if (sum_w - weight[i] >= 0) {
        maxs(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
      }
      maxs(dp[i+1][sum_w], dp[i][sum_w]);
    }
  }
  cout << dp[n][w] << endl;
}    


Measured memory_bytes: 83096
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

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

// Sort
type Line struct {
	l, r int
}

type Byl []Line

func (a Byl) Len() int           { return len(a) }
func (a Byl) Less(i, j int) bool { return a[i].l < a[j].l }
func (a Byl) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, M, Q := sc.nextInt(), sc.nextInt(), sc.nextInt()
	A := make([][500]int, 500)
	for i := 0; i < M; i++ {
		l, r := sc.nextInt()-1, sc.nextInt()-1
		A[l][r]++
	}
	S := make([][501]int, 500)
	for i := 0; i < N; i++ {
		for j := 1; j <= N; j++ {
			S[i][j] += S[i][j-1] + A[i][j-1]
		}
	}
	for i := 0; i < Q; i++ {
		ans := 0
		p, q := sc.nextInt()-1, sc.nextInt()-1
		for j := p; j <= q; j++ {
			ans += S[j][q+1]
		}
		fmt.Fprintln(wtr, ans)
	}
}


Measured memory_bytes: 7040
n, l = map(int, input().split())
s = sum(range(l, n+l))
ans = -1
ans_dif = 10**9
for i in range(l, n+l):
    if ans_dif > abs(s - (s - i)) :
        ans_dif = abs(s - (s - i))
        ans = s - i
print(ans)


Measured memory_bytes: 61776
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_N 200001

using namespace std;

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



int main() {
    int N;
    ll A[MAX_N], B[MAX_N];
    cin >> N;
    ll sum = 0;
    ll min_b = INF;
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
        sum += A[i];
        if (A[i] > B[i]) {
            min_b = min(min_b, B[i]);
        }
    }
    
    if (min_b == INF) {
        cout << 0 << endl;
    } else {
        cout << sum - min_b << endl;
    }
    
    return 0;
}


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

long long K;
int n;
long long a[55];

int main() {
	scanf("%lld", &K);
	n = 50;
	for (int i = 1; i <= n; ++i) a[i] = n - 1;
	for (int i = 1; i <= n; ++i) a[i] += K / n;

	K %= n;
	for (int i = 1; i <= n; ++i) {
		if (K == 0) break;
		a[i] += n;
		for (int j = 1; j <= n; ++j) if (j != i) a[j]--;
		--K;
	}

	printf("%d\n", n);
	for (int i = 1; i <= n; ++i) printf("%lld ", a[i]); printf("\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a);i<=(b);i++)
#define ROF(i,a,b) for(int i = (a);i>=(b);i--)
#define MST(a,x) memset(a,x,sizeof(a))
#define ll long long
#define PB push_back
#define PH push
#define MP make_pair
#define FT first
#define SD second
#define N 405
#define M 51
#define INF 500
#define MOD 924844033
#define MOD2 1000000009
#define eps 1e-7
using namespace std;
inline int Max(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^b;
}
inline int Min(int a,int b)
{
    return (((b-a)>>(32-1))&(a^b))^a;
}
 
ll a[N];
ll x[N][4];
ll c[N][10];
ll dp[N][10];
int mp[4][4] = {{1,0,3,2},{0,3,2,1},{3,2,1,0},{2,1,0,3}};
map<ll,int>m;
ll get(ll x,ll y,ll z,ll h)
{
    ll ret = x;
    ret = (ret<<10)+y;
    ret = (ret<<10)+z;
    ret = (ret<<10)+h;
    return ret;
}
ll pack(ll x,ll y,ll z,ll h)
{
    return min(min(get(x,y,z,h),get(y,z,h,x)),min(get(z,h,x,y),get(h,x,y,z)));
}
ll fac(ll x)
{
    ll ret = 1;
    FOR(i,1,x)ret*=i;
    return ret;
}
ll rot(ll key)
{
    int k[4];
    FOR(i,0,3)
    {
        k[i] = key&((1<<10)-1);
        key>>=10;
    }
    if(k[0] == k[1]&&k[1] == k[2]&&k[2] == k[3])return 4;
    if(k[0] == k[2]&&k[1] == k[3])return 2;
    return 1;
}
int main()
{
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        c[1][0] = c[1][1] = 1;
        FOR(i,2,n)
        {
            c[i][0] = 1;
            FOR(j,1,min(4,i-1))c[i][j] = c[i-1][j]+c[i-1][j-1];
            c[i][i] = 1;
        }
        FOR(i,1,n)
        {
            FOR(j,0,3)scanf("%d",&x[i][j]);
            a[i] = pack(x[i][0],x[i][1],x[i][2],x[i][3]);
        }
        ll ans = 0;
        m.clear();
        FOR(i,1,n)
        {
            FOR(ii,1,i-1)
            {
                FOR(j,0,3)
                {
                    ll y[4];
                    y[0] = pack(x[i][1],x[i][0],x[ii][mp[j][0]],x[ii][mp[j][1]]);
                    y[1] = pack(x[i][0],x[i][3],x[ii][mp[j][3]],x[ii][mp[j][0]]);
                    y[2] = pack(x[i][3],x[i][2],x[ii][mp[j][2]],x[ii][mp[j][3]]);
                    y[3] = pack(x[i][2],x[i][1],x[ii][mp[j][1]],x[ii][mp[j][2]]);
                    sort(y,y+4);
                    ll ret = 1;
                    for(int p = 0;p<4;)
                    {
                        int cnt = 1;
                        for(int r = p+1;r<4&&y[r] == y[p];r++)cnt++;
                        int num = m[y[p]];
                        if(y[p] == a[ii])num--;
                        if(num<cnt)
                        {
                            ret = 0;
                            break;
                        }
                        ret*=c[num][cnt]*pow(rot(y[p]),cnt)*fac(cnt);
                        p+=cnt;
                    }
                    ans+=ret;
                }
            }
            m[a[i]]++;
        }
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 20224
z = input()
a = z.split()
if int(a[2]) >= int(a[4]) and int(a[3]) >= int(a[4]) and \
int(a[0]) >= int(a[2])+int(a[4]) and int(a[1]) >= int(a[3])+int(a[4]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 7648
n = int(input())
h = [int(i) for i in input().split()]
move = 0
mmax = 0

for i in range(n-1):
    if h[i]>=h[i+1]:
        move = move + 1
    else:
        if mmax<move:
            mmax = move
        move = 0

if mmax<move:
    mmax = move

print(mmax)


Measured memory_bytes: 14224
#include <iostream>
#include <map>
int main()
{
	char from, to, comma;
	std::map<char, bool> cups;
	cups['A'] = true;
	cups['B'] = false;
	cups['C'] = false;
	while (std::cin >> from >> comma >> to) {
		std::swap(cups[from], cups[to]);
	}
	std::cout << (cups['A'] ? 'A' : (cups['B'] ? 'B' : 'C')) << std::endl;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define all(a) (a).begin(), (a).end()

int main () {
  int a, b;
  cin >> a >> b;
  cout << (a - 1 + (a <= b)) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;
import java.util.function.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        System.out.println(new Main().solve());
    }
    
    // パラメタ渡しもちゃんとクラス作るのも面倒なので手抜き
    // 必要な値はここで全部取ってしまう
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    
    
    int solve() {
        char[] c = s.toCharArray();
        int countA = 0;
        
        // 左端0の場合
        char head = '0';
        for(int i = 0; i < c.length; i++) {
            if(i % 2 == 0) {
                if(c[i] == head) {
                    countA++;
                }
            } else {
                if(c[i] != head) {
                    countA++;
                }
            }
        }
        
        
        int countB = 0;
        
        // 左端0の場合
        head = '1';
        for(int i = 0; i < c.length; i++) {
            if(i % 2 == 0) {
                if(c[i] == head) {
                    countB++;
                }
            } else {
                if(c[i] != head) {
                    countB++;
                }
            }
        }
        
        
        return countA < countB ? countA : countB;
    }
    
    // int solve() {
    //     char[] c = s.toCharArray();
        
    //     char head = c[0];
        
    //     int evenOk = 0;
    //     int oddOk = 0;
        
    //     for(int i = 0; i < c.length; i++) {
            
    //         if(i % 2 == 0) {
    //             if(c[i] == head) {
    //                 evenOk++;
    //             }
    //         } else {
    //             if(c[i] != head) {
    //                 oddOk++;
    //             }
    //         }
            
    //     }
        
    //     // 最大手数
    //     int max = c.length - evenOk - oddOk;
        
    //     if(max == 0) {
    //         return 0;
    //     }
        
    //     // 左端を1と仮定してカウント
    //     // 0としてカウント
    //     // 少ない方
        
        
    //     return max;
    // }
}


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    map<long long, int> cnt;
    for(int i = 0; i < n; i++){
        long long a; cin >> a;
        cnt[a]++;
    }
    if(cnt[0] == n)
        cout << "Yes" << endl;
    else if(cnt[0] == n/3 && cnt.size() == 2)
        cout << "Yes" << endl;
    else if(cnt.size() == 4){
        bool yes = true;
        long long b[3];
        int q = 0;
        for(auto p : cnt){
            if(p.first == 0) continue;
            if(p.second != n/3) yes = false;
            b[q++] = p.first;
        }
        if((long long)(b[0] ^ b[1] ^ b[2]) != 0) yes = false;
        if(yes) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 5120
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

int main()
{
	int N;
	in >> N;
	std::vector<std::vector<std::vector<std::pair<LL, LL>>>>data(N, std::vector<std::vector<std::pair<LL, LL>>>(3, std::vector<std::pair<LL, LL>>(2)));
	rep(i, N) rep(j, 3) rep(k, 2) in >> data[i][j][k].first >> data[i][j][k].second;

	std::vector<std::vector<std::vector<int>>>res(3);
	rep(i, N)
	{
		rep(j, 3)
		{
			rep(k, 2)
			{
				int h = data[i][j][k].first, m = data[i][j][k].second;
				std::vector<int>temp;
				rep(l, N)
				{
					int lh = data[l][j][0].first, lm = data[l][j][0].second;
					int rh = data[l][j][1].first, rm = data[l][j][1].second;
					int ls = lh * 60 + lm;
					int rs = rh * 60 + rm;
					int ss = h * 60 + m;
					if (ls <= ss && ss <= rs) temp.push_back(l);
				}
				if (temp.size() > 0) res[j].push_back(temp);
			}
		}
	}

	int ans = 0;
	rep(i, res[0].size())
	{
		rep(j, res[1].size())
		{
			rep(k, res[2].size())
			{
				int cnt = 0;
				rep(l, N)
				{
					auto it1 = std::lower_bound(res[0][i].begin(), res[0][i].end(), l);
					auto it2 = std::lower_bound(res[1][j].begin(), res[1][j].end(), l);
					auto it3 = std::lower_bound(res[2][k].begin(), res[2][k].end(), l);
					if (it1 != res[0][i].end() && it2 != res[1][j].end() && it3 != res[2][k].end())
					{
						if (*it1 == l && *it2 == l && *it3 == l) ++cnt;
					}
				}
				ans = std::max(ans, cnt);
			}
		}
	}

	out << ans << std::endl;
	return 0;
}



Measured memory_bytes: 3232
import java.io.PrintWriter
import kotlin.math.pow

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun Int.pow(n: Int) = pow(n.toLong())
fun Int.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()
fun Long.pow(n: Int) = pow(n.toLong())
fun Long.pow(n: Long) = toDouble().pow(n.toDouble()).toLong()

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val S = next().groupBy { it }.mapValues { it.value.size }
    val A = S.count { it.value == 1 }
    var ans = MInt(2).pow(A)
    for ((_, v) in S) {
        if (v == 1) continue
        ans *= (v + 1)
    }
    println(ans - 1)
}

class MInt {
    private val MOD = 1000000007L
    var v: Long

    constructor(v: Long) {
        this.v = v % MOD
    }

    constructor(v: Int) {
        this.v = v.toLong() % MOD
    }

    operator fun plus(b: MInt): MInt {
        val a = MInt(v)
        a.v += b.v
        if (a.v >= MOD) a.v -= MOD
        return a
    }

    operator fun plus(b: Int) = plus(MInt(b))
    operator fun plus(b: Long) = plus(MInt(b))

    operator fun minus(b: MInt): MInt {
        val a = MInt(v)
        a.v -= b.v
        if (a.v < 0) a.v += MOD
        return a
    }

    operator fun minus(b: Int) = minus(MInt(b))
    operator fun minus(b: Long) = minus(MInt(b))

    operator fun times(b: Int) = times(MInt(b))
    operator fun times(b: Long) = times(MInt(b))
    operator fun times(b: MInt): MInt {
        val a = MInt(v)
        a.v *= b.v
        a.v %= MOD
        return a
    }

    operator fun div(b: MInt): MInt {
        return MInt(v) * b.inv()
    }

    fun inv(): MInt {
        var a = v
        var b = MOD
        var u = 1L
        var w = 0L
        while (b != 0L) {
            val t = a / b
            a -= t * b
            u -= t * w
            var tmp = a
            a = b
            b = tmp
            tmp = u
            u = w
            w = tmp
        }
        u %= MOD
        if (u < 0) u += MOD
        return MInt(u)
    }

    fun pow(N: Int) = pow(N.toLong())

    fun pow(N: Long): MInt {
        var ans = MInt(1)
        var a = this
        var n = N
        while (n > 0) {
            if (n.and(1) == 1L) {
                ans *= a
            }
            a *= a
            n = n.shr(1)
        }
        return ans
    }

    override fun toString(): String {
        return v.toString()
    }
}

Measured memory_bytes: 39436