akhauriyash/Code-Regression huggingface dataset:
import sys
def f(a,b,c):
  if b==1:x=1 if 0<=a<=9 else 0
  else:x=sum([f(a-e,b-1,c-9)for e in range(10) if 0<=a-e<=c])
  return x
for n in map(int,sys.stdin):print f(n,4,3*9)

Measured memory_bytes: 4204
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
using namespace std;

int main() {
	int n, l;
	char s[101][101], tmp[101] = {};
	cin >> n >> l;
	for (int i = 0; i < n; i++) cin >> s[i];
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n - 1; j++)
			for (int k = 0; k < l; k++) {
				if (s[j][k] < s[j + 1][k])
					break;
				else if (s[j][k] > s[j + 1][k]) {
					strcpy(tmp, s[j]);
					strcpy(s[j], s[j + 1]);
					strcpy(s[j + 1], tmp);
					break;
				}
			}
	for (int i = 0; i < n; i++)
		cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    long long a;
    cin>>a;
    long long k=a/500;
    long long b=a-500*k;
    long long c=b/5;
    long long d=k*1000+c*5;
    cout <<d;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_variables)]

use itertools::Itertools;
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: u64,
    }
    // annotate for rust-analyzer
    let mut n: u64 = n;

    let mut ans = "".to_string();
    while n != 0 {
        let i = n % 26;
        if i == 0 {
            ans = format!("{}{}", (((26 + 0x60) as u8) as char).to_string(), ans);
            n = n / 26 - 1;
        } else {
            ans = format!("{}{}", (((i + 0x60) as u8) as char).to_string(), ans);
            n /= 26;
        };
    }

    println!("{}", ans);
}


Measured memory_bytes: 2176
def iskaibun(N):
    S=str(N)
    for i in range(len(S)):
        if S[i]!=S[len(S)-1-i]:
            return False
    return True
A, B = map(int, input().split())
P = 0
for i in range(A, B+1):
    if iskaibun(i):
        P+=1
print(P)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N;
    cin >> N;
    vector<int> a(3 * N);
    REP (i, 0, a.size()) cin >> a[i];
    lli ans = -(1LL << 60);
    vector<lli> bl(N + 1, 0);
    vector<lli> br(N + 1, 0);

    priority_queue<lli, vector<lli>, greater<lli>> pql;
    REP (i, 0, N) pql.push(a[i]);
    lli lsum = 0;
    REP (i, 0, N) lsum += a[i];
    lli rsum = 0;
    REP (i, 2 * N, 3 * N) rsum += a[i];
    bl[0] = lsum;
    br[N] = rsum;

    REP (border, N, 2 * N) {
        int t = pql.top();
        if (t < a[border]) {
            pql.pop();
            pql.push(a[border]);
            lsum -= t;
            lsum += a[border];
        }
        bl[border - N + 1] = lsum;
    }

    priority_queue<lli, vector<lli>> pqr;
    REP (i, 2 * N, 3 * N) pqr.push(a[i]);
    for (int border = 2 * N - 1; border >= N; border--) {
        int t = pqr.top();
        if (t > a[border]) {
            pqr.pop();
            pqr.push(a[border]);
            rsum -= t;
            rsum += a[border];
        }
        br[border - N] = rsum;
    }

    REP (i, 0, N + 1) {
        ans = max(ans, bl[i] -br[i]);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5364
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int N; cin >> N;
	set<string> st;
	rep(i, N) {
		string str; cin >> str;
		st.insert(str);
	}
	cout << st.size() << endl;
	return 0;
}


Measured memory_bytes: 19052
#include <iostream>
#include <vector>
using namespace std;
int main(void){
     int N,M;
     cin >> N >> M;
     vector<int> num(100002);
     int ans = 0;
     for(int i = 0;i < M;i++){
         int a,b;
         cin >> a >> b;
         num[a]++;
         num[b + 1]--;
     }
     
     for(int i = 1; i <= 100002;i++){
         num[i] = num[i - 1] + num[i];
         if(num[i] == M){
             ans++;
         }
     }
     cout << ans << endl;
     
     
}


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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"

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

using ll = int64_t;
using ld = double;
const ld EPS = 1e-7;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 300001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif

    fast_io();

    cout.precision(6);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int h, w;
    cin >> h >> w;
    vector<string> maze(h);
    for (int i = 0; i < h; ++i) {
        cin >> maze[i];
    }
    vector<vector<int>> used(h, vector<int>(w));
    int i = 0, j = 0;
    used[0][0] = 1;
    while (!(i == h - 1 && j == w - 1)) {

        int deg = 0;
        int ni, nj;
        for (int dx:{-1, 1}) {
            if (i + dx >= 0 && i + dx < h && maze[i + dx][j] == '#') {
                ++deg;
                if (!used[i + dx][j]) {
                    ni = i + dx;
                    nj = j;
                    used[i + dx][j] = 1;
                }
            }
            if (j + dx >= 0 && j + dx < w && maze[i][j + dx] == '#') {
                ++deg;
                if (!used[i][j + dx]) {
                    ni = i;
                    nj = j + dx;
                    used[i][j + dx] = 1;
                }
            }
        }
        if (deg == 1 && i == 0 && j == 0 || !(i == 0 && j == 0) && deg == 2) {
            if (ni < i || nj < j) {
                cout << "Impossible";
                return 0;
            }
            i = ni;
            j = nj;
        } else {
            cout << "Impossible";
            return 0;
        }
    }
    int deg = 0;
    int ni, nj;
    for (int dx:{-1, 1}) {
        if (i + dx >= 0 && i + dx < h && maze[i + dx][j] == '#') {
            ++deg;
            if (!used[i + dx][j]) {
                ni = i + dx;
                nj = j;
                used[i + dx][j] = 1;
            }
        }
        if (j + dx >= 0 && j + dx < w && maze[i][j + dx] == '#') {
            ++deg;
            if (!used[i][j + dx]) {
                ni = i;
                nj = j + dx;
                used[i][j + dx] = 1;
            }
        }
    }
    if (deg > 1) {
        cout << "Impossible";
        return 0;
    }
    cout << "Possible";
    auto end = chrono::steady_clock::now();

    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



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

bool isSame(vector<int> a, vector<int> b) {
	for (int i = 0; i < 6; ++i) {
		if (a[i] != b[i]) return false;
	}
	return true;
}

bool areSame(vector<int> s, vector<int> b) {
	string com = "NNNNEEEE";
	int tmp;
	for (int n = 0; n < 8; ++n) {
		do {
			for (int i = 0; i < n; ++i) {
				if(isSame(s, b)) {
					return true;
				}
				if (com[i] == 'N') {
					tmp = s[5];
					s[5] = s[4];
					s[4] = s[0];
					s[0] = s[1];
					s[1] = tmp;
				}
				else if (com[i] == 'E') {
					tmp = s[5];
					s[5] = s[2];
					s[2] = s[0];
					s[0] = s[3];
					s[3] = tmp;
				}
			}
		} while (next_permutation(com.begin(), com.end()));
	}
	return false;
}

signed main() {
	vector<int> s(6), b(6);
	int n;
	cin >> n;

	for (int i = 0; i < 6; ++i) {
		cin >> s[i];
	}

	for (int loop = 1; loop < n; ++loop) {
		for (int i = 0; i < 6; ++i) {
			cin >> b[i];
		}
		if (areSame(s, b)) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}



Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, k;
    cin >> a >> b >> k;
    for (int i = a; i <= min(a+k-1, b); ++i) {
        cout << i << endl;
    }
    for (int i = max(b-k+1, a+k); i <= b; ++i) {
        cout << i << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

ll distance2(int x, int y)
{
	return (ll)x * (ll)x + (ll)y * (ll)y;
}

int main()
{
	int n;
	ll d;
	int ans = 0;
	cin >> n >> d;
	int a, b;
	d *= d;

	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		if (d >= distance2(a, b)) {
			ans++;
		}
	}

	printf("%d", ans);
	return 0;
}


Measured memory_bytes: 3736
input()
s = input()
stk = list()
for c in s:
    if c == '(':
        stk.append('(')
    elif len(stk) != 0 and stk[-1] == '(':
        stk.pop()
    else:
        stk.append(')')
print(stk.count(')') * '(' + s + stk.count('(') * ')')


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

int main(void){
  int N,K;
  int l[60];
  cin >> N >>K;
  for(int i=0;i<N;i++) cin >> l[i];
  sort(l,l+N,greater<int>());
  int sum=0;
  
  for(int i=0;i<K;i++){
    sum+=l[i];
  }
  cout << sum <<endl;
  return 0;
}

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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;

const double PI = 3.14159;

using namespace std;

//vector<ll> memo(1000007, INF);

int main() {

    int x, y;
    cin >> x >> y;

    int ans = abs(abs(y) - abs(x));

    int a = 0;

    if (x == 0 || y == 0) {
        if (x == 0)
            if (y < 0)
                a++;
        if (y == 0)
            if (x > 0)
                a++;

    } else {

        if ((x > 0 && y < 0) || (x < 0 && y > 0))
            a++;
        else if (x > y)
            a += 2;

    }

    AA(ans + a);
}

Measured memory_bytes: 3572
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████  
//
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF (1LL<<60)
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
#define MSB(x) (63-__builtin_clzll(x))
#define pcnt(x) (__builtin_popcountll(x))
#define parity(i,j) (i&(1LL<<j))
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int a,b;
  cin >> a >> b;

  cout << 6-a-b << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

	int i,j,weight,by[10]={1,2,4,8,16,32,64,128,256,512},n[10]={0},last;

	while(scanf("%d",&weight)!=EOF){
		last=-1;
		for(i=10;i!=0;i--){
			if(weight>=by[i-1]){
				if(last==-1) last=i;
				weight-=by[i-1];
				n[i-1]++;
				if(weight==0) break;
			}
		}
		for(i=0;i<10;i++){
			if(n[i]==1){
				printf("%d",by[i]);
				n[i]--;
				if(i!=last-1) printf(" ");
			}
		}
		printf("\n");
	}





	return 0;

}

Measured memory_bytes: 600
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);
		StringBuilder sb = new StringBuilder();

		while (true) {
			int h = sc.nextInt();
			int w = sc.nextInt();

			if (h == 0 && w == 0)
				break;

			for (int i = 1; i <= h; i++) {

				for (int j = 1; j <= w; j++) {

					if (i == 1 || i == h) {
						sb.append("#");
					} else {

						if (j == 1 || j == w) {
							sb.append("#");
						} else {
							sb.append(".");
						}

					}

				}
				sb.append("\n");

			}
			sb.append("\n");
		}

		System.out.print(sb);
	}
}

Measured memory_bytes: 27456
xmas = input().split()
W = int(xmas[0])
H = int(xmas[1])
x = int(xmas[2])
y = int(xmas[3])
r = int(xmas[4])

if W >= (x + r) and H >= (y + r) and (x - r) >= 0 and (y - r) >= 0:
   print("Yes")
else:
   print("No")

Measured memory_bytes: 7688
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N, K; cin >> N >> K;
  ll MOD = 1000000007;
  ll ans = 0;
  for (ll k=K;k<=N+1;k++){
    (ans += k*N-k*(k-1)+1) %= MOD;
  }
  cout << ans << endl;

  


  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 
ll gcd(ll a,ll b){
	if(a>b)swap(a,b);
	// b>a
	if(b%a==0)return a;
	return gcd(b%a,a);
}

signed main(){
	ll n; cin>>n;
	ll ans; cin>>ans;
	rep(i,0,n-1){
		ll a; cin>>a;
		ans=gcd(ans,a);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3488
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int p[N];
    for(int i=0; i<N; i++){
        cin >> p[i];
    }
    
    int count = 0;
    for(int i=0; i<N; i++){
        if(p[i] != i+1) count++;
    }
    if(count==2||count==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main(){
int x,n;
cin>>x>>n;
set<int> s;
int p,m=1111;
for(int i=0;i<n;i++)
cin>>p,s.insert(p);
int a=x,b=x;
while(s.find(a)!=s.end()) a--;
while(s.find(b)!=s.end()) b++;
if(x-a>b-x) a=b;
cout<<a<<endl;
return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<deque>

int main(){
    std::deque <int> deq{};
    int q;
    int inst1,inst2,inst3;

    std::cin>>q;
    for (int i=0;i<q;i++){
        std::cin>>inst1;
        switch(inst1){
            case 0:{
                std::cin>>inst2;
                std::cin>>inst3;
                if(inst2==0){
                    deq.push_front(inst3);
                }else{
                    //std::cin>>inst3;
                    deq.push_back(inst3);
                }
                break;
            }
            case 1:{
                std::cin>>inst2;
                std::cout<<deq[inst2]<<std::endl;
                break;
            }
            case 2:{
                std::cin>>inst2;
                if(inst2==0){
                    deq.pop_front();
                }
                else{
                    deq.pop_back();
                }
                break;
            }

        }
    }

    return 0;
}


Measured memory_bytes: 4608
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))

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


ans = h // a
if (h % a != 0):
    ans += 1
print(ans)


Measured memory_bytes: 9148
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;

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

    for(int i = 0; i < s.size(); i++){
        if(s[i] != 'B'){
            t += s[i];
        }else if(t.size() > 0){
            t.erase(t.size()-1,1);
        }
    }
    put(t);
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

int main() {
  string K;
  cin >> K;
  while(K.size() < 15) K += "o";
  if(count(begin(K), end(K), 'o') >= 8) cout << "YES\n";
  else cout << "NO\n";
}



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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int testcase=1;
    //cin>>testcase;
    for(int p=0;p<testcase;p++){
        ll n=0,k=0;
        cin>>n>>k;
        ll array[n]={0};
        for(int i=0;i<n;i++)
            cin>>array[i];
        ll counter=0;
        ll x=0;
        for(int i=0;i<n;i++){
            x=min(array[i],k-array[i]);
           counter+=x;
        }
        cout<<counter*2;


    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			while (true) {
				String s = reader.readLine();
				String[] a = s.split(" ");
				
				int H = Integer.parseInt(a[0]);
				int W = Integer.parseInt(a[1]);
				
				if (H == 0 && W == 0) {
					break;
				}
				
				for (int i = 0; i < H; i++) {
					for (int j = 0; j < W; j++) {
						if ((i != 0 && i != (H - 1)) && (j != 0 && j != (W - 1))) {
							System.out.print(".");
						} else {
							System.out.print("#");
						}
					}
					System.out.println();
				}
				System.out.println();
			}
			
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 31064
import sys

def main():
    input = sys.stdin.readline
    n = float(input())
    tr = [float(input().replace('\n', '')) for i in range(5)] #なんで改行入るの 
    
    q, mod = divmod(n, min(tr))
    
    if(mod == 0):
        q = q - 1
    
    print(int(5 + q))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
using namespace std; 
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long int ll;

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

    ll a[n];

    for(ll i=0;i<n;i++)
        cin >> a[i];


    if(n==2)
    {
        cout << min(abs(a[0]-a[1]) , k - abs(a[0]-a[1]));
        return 0;
    }

    ll mn = INT_MAX;
    for(ll i=0;i<n-1;i++)
        mn = min(mn , k -  abs(a[i]-a[i+1]));
    
    //cout << mn << endl;
    mn = min(mn,abs(a[0]-a[n-1]));

    cout << mn << endl;
    return 0; 
} 


Measured memory_bytes: 1792
import sys
import numpy as np

n = int(sys.stdin.readline().rstrip())
xy = [[] for _ in range(n)]
for i in range(n):
    a = int(sys.stdin.readline().rstrip())
    for _ in range(a):
        x, y = map(int, sys.stdin.readline().split())
        xy[i].append((x - 1, y))

def main():
    comb = (np.arange(2 ** n).reshape(-1, 1) >> np.arange(n) & 1).astype(np.bool)
    for i in range(n):
        for x, y in xy[i]:
            bl = ~comb[:, i] | (comb[:, x] == np.bool(y))
            comb = comb[bl]
    
    ans = np.amax(np.sum(comb, axis=1))
    return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 20288
k = int(input())

dp = [0] * k

cur = 0
for i in range(k + 1):
    cur = (cur * 10 + 7) % k
    mod = cur % k
    if mod == 0:
        print(i + 1)
        break
    if dp[mod]:
        print(-1)
        break
    dp[mod] = 1


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int a, b;
    cin >> a >> b;
    int ans = a * b;

    cout << (ans & 1 ? "Odd" : "Even") << endl;

    return 0;
}


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

int main() {
    int N, M; cin >> N >> M;
    set<int> to[N];
    rep(i, M){
        int a, b; cin >> a >> b;
        a--; b--;
        to[a].insert(b);
        to[b].insert(a);
    }
    vector<int> V;
    for (int i = 1; i < N; i++){
        V.push_back(i);
    }

    int ans = 0;
    do {
        bool ch = true;
        int a = V[0];
        if(!to[0].count(a)){
            continue;
        }
        for (int i = 0; i < V.size()-1; i++){
            if(!to[V[i+1]].count(V[i])){
                ch = false;
                break;
            }
        }
        if(ch)ans++;
    } while(next_permutation(V.begin(), V.end()));

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c; cin >> a >> b >> c;
    cout << ((a<=c && c<=b) ? "Yes" : "No");
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
import sys
input=sys.stdin.readline
def main():
    n=int(input())
    al=tuple(map(int,input().split()))
    arr=[0,0,0]
    for i in al:
        arr[i-1]+=1
    dp=[[[0 for k in range(n+1)] for j in range(n+1)] for i in range(n+1)]
    for c in range(n+1):
        for b in range(n+1-c):
            for a in range(n-b-c+1):
                if a==b==c==0:
                    continue
                if 0<=c-1<=n and 0<=b+1<=n:
                    dp[a][b][c]+=dp[a][b+1][c-1]*c/n
                if 0<=b-1<=n and 0<=a+1<=n:
                    dp[a][b][c]+=dp[a+1][b-1][c]*b/n
                if 0<=a-1<=n:
                    dp[a][b][c]+=dp[a-1][b][c]*a/n
                dp[a][b][c]=(dp[a][b][c]+1)*n/(a+b+c)
    print(dp[arr[0]][arr[1]][arr[2]])
if __name__=='__main__':
    main()


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	string s;
	cin >> s;
	LL ans = 0;
	LL count = 0;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == 'W') {
			count++;
		}
		else {
			ans += count;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
M = int(input())
#リストAにappend()を使って格納していく
a = [input() for i in range(M)]

AC = 0
WA = 0
TLE = 0
RE = 0
for i in range(M):
    if(a[i] == 'AC'):
        AC+=1
    elif(a[i] == 'WA'):
        WA+=1
    elif(a[i] == 'TLE'):
        TLE+=1
    elif(a[i] == 'RE'):
        RE+=1

print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))


Measured memory_bytes: 16108
x,n = map(int,input().split())
if n > 0 :
  p = list( map(int,input().split()) )
  p = set(p)
else:
  p = set()

if x not in p:
  ans = x
else:
  i = x - 1
  j = x + 1
  while 1:
    if i not in p and j not in p:
      ans = min(i,j)
      break

    if i not in p:
      ans = i
      break
    elif j not in p:
      ans = j
      break

    i -= 1
    j += 1

print(ans)

Measured memory_bytes: 9212
# coding: utf-8

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)

need = [0,2,5,5,4,5,6,3,7,6]

dp = [-1] * (N + 1)
dp[0] = 0

for num in A:
        required = need[num]

        for i in range(N - required + 1):
                if dp[i] == -1:
                        continue
                
                dp[i + required] = max(dp[i + required], dp[i] * 10 + num)

print(dp[-1])



Measured memory_bytes: 16492
#!/usr/bin/env python3

n = int(input())
s = input()
x = 0 
xs = [x] 

for i in range(n):
    if s[i] == 'I':
        x += 1
        xs.append(x)
    else:
        x -= 1
        xs.append(x)

print(max(xs))


Measured memory_bytes: 2940
// Problem : B - Multiple of 9
// Contest : AtCoder - AtCoder Beginner Contest 176
// URL : https://atcoder.jp/contests/abc176/tasks/abc176_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

/* DEBUGGING */
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif

/* MACROS */ 
typedef long long int ll;
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

typedef map<int,int> mii;

#define  ff          first
#define  ss          second
#define  pb          push_back
#define  IOS         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define  lb          lower_bound
#define  ub          upper_bound
#define  all(x)      (x).begin(), (x).end()
#define  ps(x,y)     fixed<<setprecision(y)<<x
#define  setbit(x)   __builtin_popcountll(x)
#define  rep(i,a,b)  for(int i=a ; i<b ; ++i)
#define  repr(i,a,b) for(int i=a ; i>=b ; --i)

/* CONSTANTS */ 
#define PI 3.141592653589793
const ll MOD = 1e9 + 7;
const ll INF = 1000000000;
const ll MAX_N = 2e5 + 2;

// #define cerr if(false)cerr
/* CODE STARTS HERE */

void solve(){
    string s; cin >> s;
    ll sum = 0;
    rep(i,0,(int)s.size()){
        sum += (s[i]-'0');
        sum %= 9;
    }
    if(sum == 0) cout << "Yes";
    else cout << "No";
}

int main(){
    IOS;
    solve();
}

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

int main(){
  int N, M;
  int d[50]={};
  cin >> N >> M;
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    d[a-1]++;
    d[b-1]++;
  }
  for(int i=0; i<N; i++){
    cout << d[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int main() {
    char ai, bi, ci ,di;
    int x=0, y=0, z=0;
    cin >> ai >> bi >> ci >> di;
    int a=(ai-'0'),b=(bi-'0'),c=(ci-'0'),d=(di-'0');
    int bs[2]={b,-b},cs[2]={c,-c},ds[2]={d,-d};
    rep(i,0,2){
        rep(j,0,2) {
            rep(k,0,2){
                if (a+bs[i]+cs[j]+ds[k]==7) {
                    x=i,y=j,z=k;
                }
            }
        }
    }
    cout << a;
    if (bs[x]<0) cout << "-";
    else cout << "+";
    cout << b;
    if (cs[y]<0) cout << "-";
    else cout << "+";
    cout << c;
    if (ds[z]<0) cout << "-";
    else cout << "+";
    cout << d << "=7";
    return 0;
}


Measured memory_bytes: 760
#pragma comment(linker, "/STACK: 1024000000,1024000000")
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pii pair<int,int>
#define de(x) cout << #x << " = " << x << endl
#define dd(x) cout << #x << " = " << x << " " << endl
#define clr(a,b) memset(a,b,sizeof(a))
#define INF (0x3f3f3f3f)
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))
#define F first
#define S second
using namespace std;

const int N = 1e5 + 15;
typedef long long ll;
const ll MOD = 1e9 + 7;
ll f[N][13];
char s[N];

int main() {
	f[0][0] = 1;
	scanf("%s", s+1);
	int n = strlen(s+1);
	for ( int i = 1; i <= n; i ++ ) {
		if ( s[i] != '?' ) {
			int nw = s[i] - '0';
			for ( int j = 0; j < 13; j ++ ) {
				f[i][(j*10+nw)%13] += f[i-1][j];
				f[i][(j*10+nw)%13] %= MOD;
			}
		}
		else {
			for ( int j = 0; j < 13; j ++ ) {
				for ( int k = 0; k < 10; k ++ ) {
					f[i][(j*10+k)%13] += f[i-1][j];
					f[i][(j*10+k)%13] %= MOD;
				}
			}
		}
	}
	printf("%lld\n", f[n][5]%MOD);
	return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

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

  string S;
  cin >> S;

  string tmp(S);


  while(true){
    auto pos = S.find("()");
    if(pos == -1) break;
    S.replace(pos, 2, "");
  }

  REP(i, S.size()){
    if(S[i] == '('){
      tmp = tmp + ")";
    }else{
      tmp = "(" + tmp;
    }
  }

  cout << tmp << endl;
}


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

ll solve() {
    ll N, X;
    cin >> N >> X;
    ll ans = 0, a, b;
    ans += X;
    a = N, b = N - X;
    while ( b > 0 ) {
        ans += ( 1 + (a - b) / b * 2) * b + a % b;
        if ( a % b == 0 ) ans -= b;
        ll t = a % b;
        a = b;
        b = t;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

ll area(ll x1, ll y1, ll x2, ll y2) {
  return (abs(x1 * y2 - x2 * y1));
}

int main() {
  ll S;
  cin >> S;
  ll v = pow(10, 9);
  ll t = sqrt(S);
  if (t * t == S) {
    cout << "0 0 " << t << " " << "0 0 " << t << "\n";
    return 0;
  }
  t += 1;
  ll e = t * t - S;
  ll k = t * (t - 1) - S;
  ll s = area(t, e, 1, t);
  
 // cout << k << "\n";
  //cout << s << "\n";
  //cout << e << "\n";
  cout << "0 0 " << t << " " << e << " " << "1 " << t << "\n";
  return 0;
}

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

int main() {
  ll w, h, x, y; cin >> w >> h >> x >> y;
  double s = w * h / 2.0;
  int cnt, ans=0;
  if (w == x*2) cnt++;
  if (h == y*2) cnt++;
  if (cnt > 1) ans = 1;
  cout << fixed << setprecision(10);
  cout << s << " " << ans << endl;
  return 0;
}

Measured memory_bytes: 3804
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int A, B; cin >> A >> B;
    if (A + B == 3) cout << 3 << endl;
    else if (A + B == 5) cout << 1 << endl;
    else cout << 2 << endl;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int k = scanner.nextInt();
			if (k == 0)
				break;
			int size = k * (k - 1) / 2;
			int ans = 0;
			for (int i = 0; i < size; i++)
				ans += scanner.nextInt();
			System.out.println(ans / (k - 1));
		}
	}
}

Measured memory_bytes: 62056
def main():
    n = int(input())
    vals = list(map(int, input().split()))
    flg = 0

    vals.sort()
    for i in range(n-1):
        if vals[i] == vals[i + 1]:
            flg += 1
            break
    if flg == 0:
        print('YES')
    else:
        print('NO')


if __name__ == "__main__":
    main()


Measured memory_bytes: 25936
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    map<int,int> mp;
    for(int i = 0;i < N;i++){
        int a;
        cin >> a;
        mp[a]++;
    }
    int sum = 0;
    for(auto p:mp){
        sum += p.first <= p.second ? p.second-p.first : p.second;
    }
    cout << sum << endl;
}

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

using namespace std;

#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(0)
typedef long long ll;
//#define int ll
#define swap(x, y)((x)^=(y)^=(x)^=(y))
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> matrix;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(c) c.begin(),c.end()
#define mp make_pair
#define pb push_back
#define f first
#define tcase int _; cin>> _; for( ; _; --_)
#define s second
#define endl '\n'
const int MAX = 1e6+1;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double DEG = 180/PI;
const int MOD = 1e9+7;
int mod(int x, int m){ if(x >= 0) return x % m; if(-x < m) return m-(-x); return mod(x%m, m);}
int gcd (int a, int b) {while(b){a = mod(a, b); swap(a, b);} return a;}
int lcm (int a, int b) {return a / gcd(a, b) * b;}
int fexp(int base, int exp, int m){
	int total = 1;
	while(exp > 0){
		if(exp % 2 == 1){
			total = mod(((mod(total, m)) * (mod(base, m))), m);
			exp--;
		}
		base= mod((mod(base, m) * mod(base, m)), m);
		exp /= 2;
	}
	return mod(total, m);
}

int n;

void solve(){
	string s;
	cin>> s;

	int n = s.size();

	bool flag = 1;
	for(int i = 0; i<=(n-3)/2 and flag; i++)
		if(s[i] != s[((n-3)/2)-i] or s[(n-1)-i] != s[((n+1)/2)+i] or s[i]!=s[(n-1)-i]) flag = 0;

	cout<< (flag? "Yes\n" : "No\n");

}

int32_t main(){
	fastio;
	solve();
	return 0;
}


Measured memory_bytes: 3660
#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 n, k, h, ans;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> h;
        if (h >= k) ans++;
    }
    cout << ans << E;
    //system("pause");
    return 0;
}

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



int main()
{
	ll x,y,a,b,c;
	cin >> x >> y >> a >> b >> c;
	vector<pair<int,int>> V;
	for(int i = 0;i<a;i++)
	{
		int xx;cin >> xx;
		V.emplace_back(xx,0);
	}
	for(int i = 0;i<b;i++)
	{
		int xx;cin >> xx;
		V.emplace_back(xx,1);
	}
	for(int i = 0;i<c;i++)
	{
		int xx;cin >> xx;
		V.emplace_back(xx,2);
	}

	sort(V.begin(),V.end(),greater<pair<int,int>>());
	int n = V.size();
	int A=0,B=0,C=0;
	ll ans = 0;
	for(int i =0;i<n;i++)
	{
		if(V[i].second==0&&A==x)continue;
		if(V[i].second==1&&B==y)continue;
		ans += V[i].first;
		if(V[i].second==0)A++;
		if(V[i].second==1)B++;
		if(V[i].second==2)C++;
		if(A+B+C==x+y)break;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6256
from itertools import accumulate
n,k = map(int,input().split())
ans = 0
a = list(map(int,input().split()))
a = [0] + a
b = list(accumulate(a))
for i in range(n-k+1):
    ans = max(ans,b[i+k]-b[i])
print((ans+k)/2)

Measured memory_bytes: 25148
n = int(input())

ans = dict()
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            now = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            if now not in ans:
                ans[now] = 1
            else:
                ans[now] += 1

for i in range(1, n + 1):
    if i not in ans:
        print(0)
    else:
        print(ans[i])

Measured memory_bytes: 77908
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}


void solve() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return;
		int val[100][100] = {};
		int depth[100][100] = {};
		REP(i, n) {
			int dice[6] = {};
			cin >> dice[1] >> dice[4];
			queue<vector<int>> gogo;
			vector<int> tmp{ 2,1,5,6,3,4};
			gogo.push(tmp);
			
			while (gogo.empty() == false) {
				vector<int> now = gogo.front();
				if (now[1] == dice[1] && now[4] == dice[4]) {
					REP(j, 6) {
						dice[j] = now[j];
					}
					break;
				}

				{
					vector<int> now = gogo.front();
					REP(q, 3) {
						swap(now[q], now[q + 1]);
					}
					gogo.push(now);
				}

				{
					vector<int> now = gogo.front();
					REP(q, 3) {
						swap(now[3 - q], now[3 - (q + 1)]);
					}
					gogo.push(now);
				}

				{
					vector<int> now = gogo.front();
					swap(now[5], now[1]);
					swap(now[1], now[4]);
					swap(now[4], now[3]);
					gogo.push(now);
				}

				{
					vector<int> now = gogo.front();
					swap(now[4], now[3]);
					swap(now[1], now[4]);
					swap(now[5], now[1]);
					gogo.push(now);
				}

				gogo.pop();
			}
			pair<int, int> now = mp(50, 50);
			depth[now.first][now.second]++;
			int moved = 1;
			while (moved == 1) {
				moved = 0;
				depth[now.first][now.second]--;
				for (int q = 6; q >= 4; --q) {
					if (dice[5] == q&&depth[now.first+1][now.second] < depth[now.first][now.second]) {
						//x += 1
						now.first++;
						swap(dice[5], dice[1]);
						swap(dice[1], dice[4]);
						swap(dice[4], dice[3]);
						moved = 1;
						break;
					}

					if (dice[4] == q && depth[now.first - 1][now.second] < depth[now.first][now.second]) {
						now.first--;
						swap(dice[4], dice[1]);
						swap(dice[1], dice[5]);
						swap(dice[5], dice[3]);
						moved = 1;
						break;
					}

					if (dice[0] == q && depth[now.first][now.second + 1] < depth[now.first][now.second]) {
						now.second++;
						swap(dice[0], dice[1]);
						swap(dice[1], dice[2]);
						swap(dice[2], dice[3]);
						moved = 1;
						break;
					}

					if (dice[2] == q && depth[now.first][now.second - 1] < depth[now.first][now.second]) {
						now.second--;
						swap(dice[3], dice[2]);
						swap(dice[2], dice[1]);
						swap(dice[0], dice[1]);
						moved = 1;
						break;
					}
				}

				depth[now.first][now.second]++;
			}
			val[now.first][now.second] = dice[1];
		}
		int cnt[7] = {};
		REP(i, 100) {
			REP(q, 100) {
				cnt[val[i][q]]++;
			}
		}
		for (int i = 1; i < 7; ++i) {
			if (i != 1) cout << " ";
			cout << cnt[i];
		}
		cout << endl;
	}
}

int main() {
	init();
	solve();
}


Measured memory_bytes: 3184