akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc173/tasks/abc173_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int H, W, K, ans = 0;
    cin >> H >> W >> K;
    vector<string> v(H);
    REP(i, H) { cin >> v[i]; }
    REP(bit, 1LL << (H + W)) {
        auto t = v;
        REP(j, (H + W)) {
            if (bit & (1LL << j)) {
                // 高さに対して変更
                if (j < H) {
                    REP(a, W) { t[j][a] = 'R'; }
                } else {
                    // 幅に対して変更
                    REP(a, H) { t[a][j - H] = 'R'; }
                }
            }
        }
        // '#'をカウント
        int cnt = 0;
        REP(a, H) REP(b, W) {
            if (t[a][b] == '#') {
                cnt++;
            }
        }
        if (cnt == K) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3568
#include<iostream>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)

int main(){
    int a, b;
    cin >> a >> b;
    if (a == 1){
        a += 13;
    }
    if (b == 1){
        b += 13;
    }
    if (a > b){
        cout << "Alice" << endl;
    }else if (a < b){
        cout << "Bob" << endl;
    }else{
        cout << "Draw" << endl;
    }
    
    
}

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


int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0 ; i< n ; i++)
        cin >> a[i];
    
    n--;k--;
    int ans = n/k;
    if(n%k != 0)
        ans++;
    cout<<ans<<endl;
    
	return 0;
}






Measured memory_bytes: 640
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt, sum int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	A := make([]int, N)
	var minus, A_min int = 0, 1e9
	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(read())
		if A[i] < 0 {
			sum += A[i] * (-1)
			minus++
		} else {
			sum += A[i]
		}
		A_min = min(A_min, abs(A[i]))
	}
	if minus%2 == 0 {
		fmt.Println(sum)
	} else {
		fmt.Println(sum - A_min*2)
	}
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy []int

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

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> students;
  for (int i = 0; i < n; i++) {
	int s, t;
	cin >> s >> t;
	students.push_back(make_pair(s, t));
  }
  vector<pair<int, int>> points;
  for (int i = 0; i < m; i++) {
	int s, t;
	cin >> s >> t;
	points.push_back(make_pair(s, t));
  }
  for (int i = 0; i < n; i++) {
	int minim = abs(students[i].first - points[0].first) + abs(students[i].second - points[0].second);
	int ans = 1;
	for (int j = 1; j < m; j++) {
	  int temp = abs(students[i].first - points[j].first) + abs(students[i].second - points[j].second);
	  if (minim > temp) {
		minim = temp;
		ans = j + 1;
	  }
	}
	cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  string S;
  cin>>S;
  S+="X";
  int ans=0,X=0;
  rep(i,S.size()){
    if(S[i]=='A'||S[i]=='T'||S[i]=='C'||S[i]=='G') X++;
    else{
      ans=max(ans,X);
      X=0;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll =  long long;
int main()
{
    ll n;
    cin>>n;
    map <ll,ll> m;
    ll temp;
    for(ll i = 1 ;i<=n-1;i++){
        cin>>temp;
        if(m.count(temp)){
            m[temp]++;
        }
        else{
            m[temp]=1;
        }
    }
    for(int i=1;i<=n;i++){
        if(m.count(i)){
            cout<<m[i]<<endl;
        }
        else{
            cout<<0<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 16100
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if(s[2]==s[3] && s[4]==s[5])
        {
            cout<<"Yes"<<endl;
            return 0;
        }
        else
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    return 0;
}


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

int main()
{
int n,k,d,S ;
while(1){ 
cin >> n >> k ;
if(n==0&&k==0){
break;
}
vector<int> a(n) ;
for(int i=0;i<n;i++){
cin >> d ;
a.at(i)=d ;
}
S=0 ;
for(int j=0;j<k;j++){
S=S+a.at(j) ;
}
int A=0;
A=S ;
for(int l=0;l<n-k;l++){
S=S-a.at(l)+a.at(l+k);
A=max(A,S) ;
}
cout << A << endl;
}
}



Measured memory_bytes: 3104
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;

#define ran 111

int n, m;
vector<int> e[ran];
int lo[ran], d[ran];
int ans;

void dfs(int cur, int par, int dep) {
	lo[cur] = d[cur] = dep;
	for(int i=0;i<(int)e[cur].size();i++) {
		int nxt = e[cur][i];
		if (d[nxt] > d[cur]) continue;
		if (nxt == par) continue;
		
		if (lo[nxt] == -1) {
			dfs(nxt, cur, dep+1);
			//printf("%d %d %d %d\n", cur, nxt, lo[nxt], dep);
			if (lo[nxt] > dep) ans++;
			lo[cur] = min(lo[cur], lo[nxt]);
		} else lo[cur] = min(lo[cur], d[nxt]);
	}
	//printf("- %d %d %d\n", cur, lo[cur], dep);
	//if (lo[cur] == dep) ans++;
}

int main() {
	scanf("%d%d", &n, &m);
	for(int i=0;i<m;i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		e[x].push_back(y); e[y].push_back(x);
	}
	
	memset(lo, -1, sizeof lo);
	memset(d, -1, sizeof d);
	ans = 0;
	dfs(1, -1, 0);
	printf("%d\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
/**
 *      AGC 1 A
 *      author  : kyomukyomupurin
 *      created : 2018-10-11 06:15:56
**/

#include <algorithm>
#include <array>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#define int64 long long
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int L[N + N] = {};
    for (auto i = 0; i < N + N; ++i) {
        cin >> L[i];
    }
    
    sort(L, L + N + N);
    int ans = 0;

    for (auto i = N + N - 2; i >= 0; i -= 2) {
        ans += L[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIXED_FLOAT(x)  std::fixed <<std::setprecision(7)<<(x)
#define all(v) (v).begin(), (v).end()
using namespace  std;
#define loop(i,a,b) for (int i=a; i<b; ++i)
using ll = long long;
const int mod = 1e9+7;
typedef pair<int , int> pairs;
typedef complex<ll> G;

const int N = 205;

int power(int a,int b){
    if(!b)
        return 1;
    int c=power(a,b/2);
    c=(1LL*c*c)%mod;
    if(b%2)
        c=(1LL*c*a)%mod;
    return c;
}


void done() {


}

/*string solve_palindrome(const string& s)
{
    string a = s;
    reverse(a.begin(), a.end());
    //a = s + "#" + a;
    int c = 0;
    for (int i = 1; i < (int)a.size(); i++)
    {
        while (c != 0 && a[c] != a[i])
            c = pref[c - 1];
        if (a[c] == a[i])
            c++;
        pref[i] = c;
    }
    return s.substr(0, c);
}
*/

void solve()
{



}
void another() {
    string s;
    cin >> s;
    int ans = 0;
    int c = 0;
    for(int i =0;i < 3;++i) {
        if(s[i] == 'R')++c;
        else c = 0;
        ans = max(ans, c);
    }
    cout << ans << '\n';


}
void test_case() {
    int t;
    cin >> t;
    while(t--)another();
}
int main() {

   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    another();
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;

const int MAXN = 5000;
const int MAXM = 200;
int n, m;
int a[MAXN+1];
int b[MAXM+1][MAXN+1];
int ans;

class Seg{
  private:
    int arr[MAXN*4+5];
  public:
    int id;
    void build(int now=1, int l=1, int r=n) {
      if (l == r) {
        arr[now] = b[id][l];
        return;
      }
      int mid = l + r >> 1;
      build(now*2  , l, mid);
      build(now*2+1,mid+1,r);
      arr[now] = max(arr[now*2], arr[now*2+1]);
    }
    int qry(int ql, int qr, int now=1, int l=1, int r=n) {
      if (ql <= l && r <= qr) {
        return arr[now];
      } else if (l > qr || r < ql) return 0;
      int mid = l + r >> 1, tmp = 0;
      tmp = max(tmp, qry(ql, qr, now*2  , l, mid));
      tmp = max(tmp, qry(ql, qr, now*2+1,mid+1,r));
      return tmp;
    }
} seg[MAXM+1];

void cal(int l, int r, int sl, int sr) {
  int mid = l + r >> 1, tmp = 0;
  pii mmax = pii(-1, -1);
  for (int i = sl; i <= min(mid, sr); i++) {
    tmp = a[i] - a[mid];
    for (int j = 1; j <= m; j++)
      tmp += seg[j].qry(i, mid);
    mmax = max(mmax, pii(tmp, i));
  }
  ans = max(ans, mmax.ff);
  if (mid > l)
    cal(l, mid-1, sl, mmax.ss);
  if (mid < r)
    cal(mid+1, r, mmax.ss, sr);
}

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n >> m;
  for (int i = 2; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i-1];
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      cin >> b[j][i];
  for (int i = 1; i <= m; i++)
    seg[i].id = i, seg[i].build();
  cal(1, n, 1, n);
  cout << ans << "\n";
}


Measured memory_bytes: 37848
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec[i]; 
    }
    sort(vec.begin(), vec.end());
    int a;
    a = vec[N-1] - vec[0];
    cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int h,w;

while(1){
cin >> h>>w;
if(h==0&&w==0)break;

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

  if(hc%2==1 && i%2==1){
  cout<<"#";
  }else if(hc%2==0 && i%2==0){
  cout<<"#";
  }else if(hc%2==1 && i%2==0){
  cout<<".";
  }else if(hc%2==0 && i%2==1){
  cout<<".";
  }

  }
cout<<endl;
}
cout<<endl;

}

}


Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main(){
	int k,n;
	cin>>k>>n;
	int m=10000000;
	for(int i=0;i<k;i++){
		int x;
		cin>>x;
		m=min(x,m);
		n-=x;
	}
	cout<<k+(n/m)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

static size_t A[100000];

int compare_f(const void *a, const void *b) {
	return *((size_t *)a) > *((size_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

int main(void) {
	size_t N, Y;

	scanf("%zu %zu", &N, &Y);

	bool combExist = false;
	size_t oneCount = (Y % 5000) / 1000;
	const size_t oneMax = MIN(Y / 1000, 2000);
	size_t fiveCount = 0;
	size_t tenCount = 0;
	while (oneCount <= oneMax) {
		fiveCount = 0;
		const size_t fiveMax = MIN(Y / 5000, N - oneCount);
		while (fiveCount <= fiveMax) {
			tenCount = N - oneCount - fiveCount;
			if (oneCount + fiveCount * 5 + tenCount * 10 == Y / 1000) {
				combExist = true;
				goto result;
			}

			fiveCount++;
		}

		oneCount += 5;
	}

result:
	if (combExist) {
		printf("%zu %zu %zu\n", tenCount, fiveCount, oneCount);
	}
	else {
		printf("%d %d %d\n", -1, -1, -1);
	}

	return 0;
}


Measured memory_bytes: 128
// INCLUDES
#include <bits/stdc++.h>
#include <assert.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s), end(s)
#define MIN3POS(a, b, c) (a) = < (b) ? ((a) = < (c) ? 1 : 3) : ((b) = < (c) ? 2 : 3)
#define MAX3POS(a, b, c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2 : 3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define error(args...)                           \
    {                                            \
        string _s = #args;                       \
        replace(_s.begin(), _s.end(), ',', ' '); \
        stringstream _ss(_s);                    \
        istream_iterator<string> _it(_ss);       \
        err(_it, args);                          \
    }
//NAMESPACES
using namespace __gnu_pbds;
using namespace std;
vector<string> vec_splitter(string s)
{
    s += ',';
    vector<string> res;
    while (!s.empty())
    {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
    vector<string> __attribute__((unused)) args,
    __attribute__((unused)) int idx,
    __attribute__((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T)
{
    if (idx > 0)
        cerr << ", ";
    else
        cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss;
    ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32, 0);
void initialize()
{
    for (int i = 1; i < powers2.size(); i++)
        powers2[i] = powers2[i - 1] * 2;
}
int32_t main()
{
    IOS int n, k;
    cin >> n >> k;
    vector<int> v(n + 1);
    FOR(i, 1, n + 1)
        cin >> v[i];
    int pos = 1;
    int count = 0;
    vector<int> p(n + 1, 0), visited(n + 1, 0);
    int cycle = 0, rot = 0;
    while (visited[pos] != 1)
    {
        p[pos] = count;
        visited[pos] = 1;
        if (visited[v[pos]]){
            cycle = count-p[v[pos]]+1, rot = v[pos];
            break;
        }
        pos = v[pos];
        count++;
    };
    int dest = 1;
    if(k<=p[rot]) {
        FOR(i,0,k) dest = v[dest];
    } else {
        k-=p[rot];
        dest = rot;
        FOR(i,0,k%cycle) dest = v[dest];
    }
    cout<<dest;
    return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 7964
//#include <StdAfx.h>
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
	int N,M;
	cin>>N>>M;
	if(N>12)printf("%d\n",M);
	else if(N>5&&N<13)printf("%d\n",M/2);
	else printf("0\n");
 
	return 0;
}

Measured memory_bytes: 256
use proconio::input;

#[allow(non_snake_case)]
fn main() {
    input! {
        A: i32,
        B: i32,
        C: i32,
        D: i32,
    }

    let ans = if (A + D - 1) / D >= (C + B - 1) / B { "Yes" } else { "No" };
    println!("{}", ans);
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std; 
    
int main(){
  long long A,B,C,K;
  cin >> A >> B >> C >> K;
  if(K<=A){
    cout << K << endl;
  }
  else if(K<=A+B){
    cout << A << endl;
  }
  else{
    cout << 2*A+B-K << endl;
  }
}
  

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

using namespace std;

int main()
{
    int n,x;
    cin>>n>>x;
    int *candy=new int[n];
    for(int i=0;i<n;i++)
        cin>>candy[i];
    sort(candy,candy+n);
    int count=0;
    int rem=x;
    for(int i=0;i<n;i++)
    {
        if(candy[i]<=rem)
            {count++;

             if(i==n-1&&candy[i]<rem)
                count--;
              rem=rem-candy[i];

             }
        else
            break;
    }

    cout<<count<<endl;
}


Measured memory_bytes: 256
dy = [-1,0,1,0]
dx = [0,1,0,-1]

h,w = parse.(split(readline()))
s = []

for i in 1:h
  line = split(readline())
  for j in line
    push!(s,j)
  end
end

res = 1

for i in 1:h
  for j in 1:w
    if s[i][j] == '#'
      _res = 0
      for k in 1:4
        ny = i + dy[k]
        nx = j + dx[k]
        if ny < 1 || ny > h || nx < 1 || nx > w
          continue
        end
        if s[ny][nx] == '#'
          _res = 1
          break
        end
      end

      if _res == 0
        global res = 0
        break
      end
    end

    if res == 0
      break
    end
  end

  if res == 0
    break
  end
end

println( res == 1 ? "Yes" : "No")

Measured memory_bytes: 120004
#include <iostream>
#include <list>
using namespace std;
int main(void){
    // Your code here!
    list<int> int_list;
    
    int n;
    cin >> n;
    
    string str;
    for(int i = 0; i < n; i++)
    {
        cin >> str;
        
        if(str == "insert")
        {
            int x;
            cin >> x;
            
            int_list.push_front(x);
        }
        else if(str == "delete")
        {
            int x;
            cin >> x;
            
            for(auto itr = int_list.begin(); itr != int_list.end(); ++itr)
            {
                if(*itr == x)
                {
                    int_list.erase(itr);
                    break;
                }
            }
        }
        else if(str == "deleteFirst")
        {
            int_list.pop_front();
        }
        else if(str == "deleteLast")
        {
            int_list.pop_back();
        }
        else
        {
        }
    }
    
    int count = 0;
    for(auto x : int_list)
    {
        if(count != 0)
        {
            cout << " ";
        }
        cout << x;
        count++;
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 34336
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define print(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;




signed main()
{
	fastio(0);
	string s;
	cin>>s;
	int d;
	cin>>d;
	vec(int) v;
	v.pb(0);
	reverse(all(s));
	for(auto it:s) v.pb(it - '0');
	
	int dp[2][d][2]; // dp[idx, sum%d, tight], idx 0 - prev, idx 1 - current
	init(dp,0);
	loop(i,0,10) dp[0][i%d][0] += 1;
	loop(i,0,v[1]+1) dp[0][i%d][1] += 1;

	loop(n,2,size(v))
	{
		loop(sum,0,d)
		{
			int temp = 0;
			loop(i,0,10) temp = (temp + dp[0][(sum-i+ 10*d)%d][0])%mod;
			dp[1][sum][0] = temp;

			temp = 0;
			loop(i,0,v[n]+1) 
				if(i<v[n]) temp = (temp + dp[0][(sum-i+ 10*d)%d][0])%mod;
				else  temp = (temp + dp[0][(sum-i+ 10*d)%d][1])%mod;
			dp[1][sum][1] = temp;
		}
		loop(sum,0,d)
		{
			dp[0][sum][0] = dp[1][sum][0];
			dp[0][sum][1] = dp[1][sum][1];
		}
	}

	cout<<(dp[0][0][1] - 1 + mod)%mod<<endl; // -1 to remove no. 000000000

	return 0;		
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int W, H, N; cin >> W >> H >> N;
	int nx, ny; cin >>nx >> ny;
	int sum = 0;
	for (int i = 1; i < N; ++i) {
		int x, y; cin >> x >> y;
		int dx = x - nx;
		int dy = y - ny;
		if (dx < 0) {
			if (dy < 0) {
				sum += max(abs(dx), abs(dy));
			}
			else {
				sum += abs(dx) + abs(dy);
			}
		}
		else {
			if (dy < 0) {
				sum += abs(dx) + abs(dy);
			}
			else {
				sum += max(abs(dx), abs(dy));
			}
		}
		nx = x;
		ny = y;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3068
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
#include <array>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <numeric>
using ll = long long;
using namespace std;
using pii = pair<int, int>;

int N;
vector<int> A;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int tmpA;
		cin >> tmpA;
		A.push_back(tmpA);
	}
	sort(A.begin(), A.end());

	ll sum = 0;
	if (N % 2 == 0) {
		for (int i = 0; i < N / 2 - 1; i++)
		{
			sum -= A.at(i) * 2;
		}
		sum -= A.at(N / 2 - 1);
		sum += A.at(N / 2);
		for (int i = N / 2 + 1; i < N; i++)
		{
			sum += A.at(i) * 2;
		}
	}
	else {
		for (int i = 0; i < (N - 1) / 2 - 1; i++)
		{
			sum -= A.at(i) * 2;
		}
		sum -= A.at((N - 1) / 2 - 1);
		sum -= A.at((N - 1) / 2);
		for (int i = (N - 1) / 2 + 1; i < N; i++)
		{
			sum += A.at(i) * 2;
		}

		ll sum2 = 0;
		for (int i = 0; i < (N - 1) / 2; i++)
		{
			sum2 -= A.at(i) * 2;
		}
		sum2 += A.at((N - 1) / 2);
		sum2 += A.at((N - 1) / 2 + 1);
		for (int i = (N - 1) / 2 + 2; i < N; i++)
		{
			sum2 += A.at(i) * 2;
		}

		sum = max(sum, sum2);
	}


	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 892
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

long long combi(long long n, long long k) {
  if (n == k || k == 0)
    return 1;
  else {
    return combi(n - 1, k - 1) + combi(n - 1, k);
  }
}

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

int main(){    
  long long K;
  cin >> K;
  long long sum = 0;

  for(int i=1;i<=K;i++){
    for(int j=1;j<=K;j++){
      for(int k=1;k<=K;k++){
	sum += gcd(gcd(i,j),k);
      }
    }
  }
  
  cout << sum << endl;

}
 


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std ;
typedef long long LL;
const int MAXN = 1 + 1e5;
typedef pair <int,int> II;

LL n,a[MAXN],f[MAXN][2];



int main(){
                            #define NAME "ABC"
                     //   freopen(NAME".inp","r",stdin);
                   //     freopen(NAME".out","w",stdout);
                        ios_base::sync_with_stdio(0);
                        cin.tie();

                        cin >> n;
                        for (int i = 1; i <= n; i++)
                            cin >> a[i];
                        f[1][0] = a[1];
                        f[1][1] = a[1];
                        f[2][1] = -a[1] - a[2];
                        f[2][0] = a[1] + a[2];
                        for (int i = 3; i <= n; i++){
                            f[i][0] = a[i] + max ( a[i-1] + max(f[i-2][0] , f[i-2][1]) , f[i-1][1]);
                            f[i][1] = -a[i] + max (-a[i-1] + max (f[i-2][0] , f[i-2][1]) , f[i-1][1] + 2 * a[i-1]);
                        }
                        cout << max (f[n][0] , f[n][1]);










return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define ms(x, n) memset(x,n,sizeof(x));
typedef  long long LL;
const LL maxn = 30;
const int NIL = -1;

struct node{
    int p, l, r;
}T[maxn];
int N, D[maxn], H[maxn];
void setDepth(int u, int d){
    if(u == NIL) return;
    D[u] = d;
    setDepth(T[u].l, d+1);
    setDepth(T[u].r, d+1);
}
int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(T[u].l != NIL) h1 = setHeight(T[u].l)+1;
    if(T[u].r != NIL) h2 = setHeight(T[u].r)+1;
    return H[u] = max(h1, h2);
}
void print(int u){
    int sibling = -1, degree = 0;
    if(T[u].p!=NIL && u!=T[T[u].p].l) sibling = T[T[u].p].l;
    else if(T[u].p!=NIL && u!=T[T[u].p].r) sibling = T[T[u].p].r;
    if(T[u].l!=NIL) degree++;
    if(T[u].r!=NIL) degree++;

    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, ",u,T[u].p,sibling,degree,D[u],H[u]);
    if(T[u].p==NIL) printf("root\n");
    else if(T[u].l==NIL && T[u].r==NIL) printf("leaf\n");
    else printf("internal node\n");
}
int main()
{
    for(int i = 0; i < maxn; i++) T[i].l = T[i].r = T[i].p = NIL;

    cin >> N;
    int l, r, id, root;
    for(int i = 1; i <= N; i++){
        cin >> id >> l >> r;
        T[id].l = l, T[id].r = r;
        T[l].p = T[r].p = id;
    }
    for(int i = 0; i < N; i++)
    if(T[i].p == NIL) root = i; //确定根节点

    setDepth(root, 0);
    setHeight(root);
    for(int i = 0; i < N; i++)
        print(i);

	return 0;
}




Measured memory_bytes: 3192
#include <stdio.h>

int main() {
	struct Card
	{
		char Mark;
		int rank[13];
	};

	Card card[4];
	
	int num;
	char mark_;
	int buf;
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 13; j++)
		{
			card[i].rank[j] = 0;
		}
	}
	scanf("%d", &num);
	if (num <= 52) {
		for (int i = 0; i < num; i++)
		{
			scanf(" %c %d", &mark_, &buf);
			switch (mark_)
			{
			case 'S':
			case 's':
				card[0].Mark = mark_;
				card[0].rank[buf-1] = buf;
				break;
			case 'H':
			case 'h':
				card[1].Mark = mark_;
				card[1].rank[buf-1] = buf;
				break;
			case 'C':
			case 'c':
				card[2].Mark = mark_;
				card[2].rank[buf-1] = buf;
				break;
			case 'D':
			case 'd':
				card[3].Mark = mark_;
				card[3].rank[buf-1] = buf;
				break;
			default:
				printf("No corresponding mark\n");
				i--;
				break;
			}
		}
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++)
			{
				if (card[i].rank[j] == 0) {
					printf("%c %d\n", card[i].Mark, j+1);
				}
			}
		}
	}

	return 0;
}

Measured memory_bytes: 2684
n=int(input())
h=list(map(int,input().split()))

for i in range(n-1, 0, -1):
    if h[i-1] <= h[i]:
        continue
    elif h[i-1] == h[i] + 1:
        h[i-1] -= 1
    else:
        print("No")
        exit(0)
print("Yes")

Measured memory_bytes: 14396
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){

	int h,w;
	cin >> h >> w;

	char s[52][52];
	
	for(int i = 0; i < 52; i++)
	{
		
		for(int j = 0; j < 52; j++)
		{
			s[i][j] = '#';
		}
		
	}
	
	
	for(int i = 1; i <= h; i++)
	{
		
		for(int j = 1; j <= w; j++)
		{
			cin >> s[i][j];
		}
		
	}

	bool flag = false;
	for(int i = 1; i <= h; i++)
	{
		
		for(int j = 0; j <= w; j++)
		{
			if(s[i][j] == '#'){
				if(s[i+1][j] == '.'&&s[i-1][j] == '.'&&s[i][j-1] == '.'&&s[i][j+1] == '.'){
					flag = true;
				}
			}
		}
		
	}
	if(flag==true){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int a, b, c, d;
        
        a = sc.nextInt();
        b = sc.nextInt();
        
        c = a * b;
        d = (a + b)*2;
        
        System.out.println(c + " " + d);
        
    }
}


Measured memory_bytes: 26336
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    if N < 2:
        print(0)
        return
    if N % 2 == 1:
        print(0)
        return
    n = 2
    cnt = 0
    while n * 5 <= N:
        n *= 5
        cnt += 1
    ans = 0
    for _ in range(cnt):
        ans += N // n
        n //= 5
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import sys

N = int(input())
line_data = input()
data = list(map(lambda x: int(x), line_data.split(' ')))

if N == 0:
    if data[0] == 1:
        print(1)
    else:
        print(-1)
    sys.exit(0)

tmp_sum = sum(data)
tmp_data = []
for i in data:
    tmp_sum -= i
    tmp_data.append(tmp_sum)

num = 1
prev_leaf = 1
for i, d in enumerate(data[:-1]):
    tmp = (prev_leaf - d) * 2
    top = tmp_data[i]
    if tmp <= 0:
        num = -1
        break
    if tmp < top:
        prev_leaf = tmp
    else:
        prev_leaf = top
    num += prev_leaf
else:
    if prev_leaf != data[-1]:
        num = -1

print(num)


Measured memory_bytes: 20936
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
vector<int>adj[100001];
int visited[100001];

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust\n";
    else cout<<"win\n";
    
    
}

Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <numeric>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <deque>
#include <bitset>
#include <cstring>
#include <sstream>
 
#define f first
#define s second
#define ll long long
#define ld long double
#define pb push_back
#define all(x) x.begin(),x.end()
#define mp make_pair
#define y0 eto
#define y1 mezhdy
#define y2 nami
#define left extermination
#define right dismemberment
#define O random_shuffle(all(p));
 
using namespace std;
 
typedef pair<int,int> pii;
 
template <class T>void read(vector<T> &a,ll n){T x; a.clear();for(ll i=0;i<n;i++){cin>>x;a.pb(x);}}
template <class T>void write(vector<T> &a){for(T x : a) cout<<x<<" ";cout<<endl;}

const int N=405;


vector<pii> g[N];
vector<pair<int,pii> > orders;
int n,m,Tmax;
vector<pair<int,pii> > e;
vector<pii> gt[N];
vector<int> ans;
int par[N];
int p[N];

vector<int> path[N];
vector<int> rev[N];
vector<int> cur;
vector<int> cur_r;

int fnd(int u)
{
    if(u==p[u]) return u;
    return p[u]=fnd(p[u]);
}

void un(int a,int b)
{
    int u=fnd(a);
    int v=fnd(b);
    if(rand()&1) swap(u,v);
    if(u!=v)
        p[u]=v;
}

void dfs(int u,int p=-1)
{
    par[u]=p;
    path[u]=cur;
    rev[u]=cur_r;
    for(int i=0;i<gt[u].size();i++)
        if(gt[u][i].f!=p)
        {
            for(int j=0;j<gt[u][i].s;j++)
                cur.pb(gt[u][i].f);
            for(int j=0;j<gt[u][i].s;j++)
                cur_r.pb(u);
            
            dfs(gt[u][i].f,u);
            
            for(int j=0;j<gt[u][i].s;j++)
            {
                cur.pop_back();
                cur_r.pop_back();
            }
        }
}

void go(int u,int v)
{
    if(u==1)
    {
        for(int i=0;i<path[v].size();i++)
            ans.pb(path[v][i]);
    }
    else
    {
        for(int i=(int)rev[u].size()-1;i>=0;i--)
            ans.pb(rev[u][i]);
    }
    while(ans.size()>Tmax) ans.pop_back();
}

int main()
{
    ios_base::sync_with_stdio(0);
    //freopen("INPUT.txt", "r", stdin);
    for(int i=0;i<N;i++)
        p[i]=i;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        e.pb(mp(c,mp(a,b)));
        g[a].pb(mp(b,c));
        g[b].pb(mp(a,c));
    }
    cin>>Tmax;
    for(int i=0;i<Tmax;i++)
    {
        int Nnew;
        cin>>Nnew;
        while(Nnew--)
        {
            int id,x;
            cin>>id>>x;
            orders.pb(mp(i,mp(id,x)));
        }
    }
    sort(all(e));
    for(int i=0;i<e.size();i++)
    {
        int a=e[i].s.f;
        int b=e[i].s.s;
        int w=e[i].f;
        if(fnd(a)!=fnd(b))
        {
            un(a,b);
            gt[a].pb(mp(b,w));
            gt[b].pb(mp(a,w));
        }
    }
    dfs(1);
    for(int i=0;i<orders.size();i++)
    {
        if(ans.size()==Tmax) break;
        while(ans.size()<orders[i].f)
            ans.pb(-1);
        int to=orders[i].s.s;
        go(1,to);
        go(to,1);
    }
    while(ans.size()<Tmax)
        ans.pb(-1);
    for(int i=0;i<ans.size();i++)
        cout<<ans[i]<<endl;
    
}


Measured memory_bytes: 896
#include<stdio.h>
int gcd(int x,int y){
	int d;
	d=(x%y);
	while(d!=0){
			x=y;
			y=d;
			d=(x%y);
	}
	return y;
}
int main(){
    int x,y,d;
	scanf("%d%d",&x,&y);
	if(x>y)d=gcd(x,y);
	else if(x<=y)d=gcd(x,y);
	printf("%d\n",d);
    return 0;
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  if (A <= C && C <= B)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3592
n, k = map(int, input().split())
p = list(map(int, input().split()))
A = [0]
for i in range(1, 1001):
    A.append(A[i-1]+i)
S = [0]*n
for j in range(n):
    S[j] = A[p[j]]/p[j]
ANS = [sum(S[a] for a in range(k))]
for i in range(n-k):
    ANS.append(ANS[i]-S[i]+S[k+i])
print(max(ANS))

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

			//出力の都度更新をやめる
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);


			Ans();

			//更新する
			Console.Out.Flush();
			
		}

 public static void Ans() {

			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			long N = inputArray[0];
			var kabukas = retreiveLongArray();

			long money = 1000;
			long shojikabu = 0;

			for (int i = 0; i < N-1; i++) {

				if (kabukas[i + 1] - kabukas[i] > 0) {//値上がりするときはすべて株に帰る
					var kounyu = money / kabukas[i];
					shojikabu += kounyu;
					money -= kounyu * kabukas[i];

				}
				else {//それ以外のときはすべて現金にする
					money += shojikabu * kabukas[i];
					shojikabu = 0;
				}


			}

			//最終日はすべての株を現金に換える
			money += shojikabu * kabukas[N-1];
			shojikabu = 0;

			//答えの出力
			var ans =money;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}


		/// <summary>
		/// 2組みずつの入力データ(数値)からTuppleListを作成する
		/// </summary>
		/// <param name="N"></param>
		/// <returns></returns>
		private static List<Tuple<long, long>> createLongTuppleList(long N) {
			var inpList = new List<Tuple<long, long>>();

			for (int i = 0; i < N; i++) {
				var inp = retreiveLongArray();
				var item1 = inp[0];
				var item2 = inp[1];
				inpList.Add(new Tuple<long, long>(item1, item2));
			}
			return inpList;
		}
	}
}



Measured memory_bytes: 28076
import java.util.*;

class Main{

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = Integer.toString(n);
        StringBuilder sb = new StringBuilder();
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='1') sb.append("9");
            else if(s.charAt(i)=='9') sb.append("1");
            else sb.append(s.charAt(i));
        }


        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 23252
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    try (final var stdin = new InputStreamReader(System.in);
         final var br = new BufferedReader(stdin)) {
      final var s = br.readLine();
      System.out.println(s.endsWith("s") ? s + "es" : s + "s");
    }
  }
}


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

def main():
    n = int(input())
    s = input()

    r = []
    g = []
    b = []

    for i in range(n):
        if s[i] == 'R':
            r.append(i+1)
        elif s[i] == 'G':
            g.append(i+1)
        elif s[i] == 'B':
            b.append(i+1)

    count = len(r) * len(g) * len(b)
    for r_num in r:
        for g_num in g:
            dif = abs(r_num - g_num)
            i, j = tuple(sorted([r_num, g_num]))

            if i - dif > 0:
                if s[i - dif - 1] == 'B':
                    count -= 1
            if j + dif <= n:
                if s[j + dif - 1] == 'B':
                    count -= 1
            if dif % 2 == 0:
                if s [i + dif // 2 - 1] == 'B':
                    count -= 1

    print(count)

if __name__ == '__main__':
    main()


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

int main() 
{
    int x,n,k=0;
    cin>>x>>n;
    if(n==0)
    {
    cout<<x<<endl;
    return 0;
    }
    int a[n],i,c[200]={0};
    for(i=0;i<n;i++)
    {
      cin>>a[i];
      c[a[i]]++;
    }
    while(1)
    {
      if(c[x-k]==0)
      {
        cout<<x-k<<endl;
        return 0;
      }
      else if(c[x+k]==0)
      {
        cout<<x+k<<endl;
        return 0;
      }
      else
      k++;
    }
}

Measured memory_bytes: 3636
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout(a) cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#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 CtoI(c)         int((c)) - int('0')
#define ItoC(c)         char((c) + '0')

//functions=============
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); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int a, b; cin >> a >> b;
    if(a >= 9 || b >= 9){
        cout << ":(" << endl;
        return 0;
    }
    else cout << "Yay!" << endl;

return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

int main(){
    int a, b, c;
    int d = 0;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if (a > b) {
        d = a;
        a = b;
        b = d;
    }
    if (b > c) {
        d = b;
        b = c;
        c = d;
    }
    if (a > b) {
        d = a;
        a = b;
        b = d;
    }
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}



Measured memory_bytes: 2052
#include <iostream>
#include <set>
using namespace std;
int main() {
    int n;
    cin >> n;
    set<int> st;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        st.insert(a);
    }
    if (st.size() == n) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 9600
#include<stdio.h>
int main(){
	int angka, digitBelakang, digitTengah, digitAwal;
	scanf("%d", &angka);
	
	digitBelakang = angka % 10;
	
    digitTengah = (angka - digitBelakang) / 10 % 10;
   	
    digitAwal = (angka - digitBelakang) / 100 % 10 ;
	
	if (digitBelakang == 7){
		puts ("Yes");
	}
	else if (digitTengah == 7){
		puts ("Yes");
	}
	else if (digitAwal == 7){
		puts ("Yes");
	}
	else {
		puts ("No");
	}
	return 0;
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n, m; cin >> n >> m;

    multimap<int, int> ma;

    for (int i = 0; i < m; ++i) {
        int a, b; cin >> a >> b;

        ma.insert(make_pair(a, b));
    }

    vector<int> t;

    auto p = ma.equal_range(1);
    for (auto it = p.first; it != p.second; ++it) {
        t.push_back(it->second);
    }

    for (int i = 0; i < t.size(); ++i) {
        auto p = ma.equal_range(t[i]);
        for (auto it = p.first; it != p.second; ++it) {
            if (it->second == n) {
                puts("POSSIBLE");
                return 0;
            }
        }
    }

    puts("IMPOSSIBLE");
}

Measured memory_bytes: 11764
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
int main() {
	// your code goes here
	string s;
	cin>>s;
	int i;
	for( i=0;i<s.size();i++){
		cout<<s[i]<<s[i+1]<<s[i+2];
		break;
	}

	return 0;
}

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

# define    ll            long long 
# define    vi             std::vector<int>
# define    int            long long 
# define    setbits(x)     __builtin_popcountll(x)
# define    zrobits(x)     __builtin_ctzll(x)
# define    fast           ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
# define    pb             push_back
# define    fn             for(int i=0;i<n;i++)
# define    rep(i,a,b)      for(ll i=a;i<b;i++)
# define    all(x)         x.begin(), x.end()
# define    allr(a)        a.rbegin(), a.rend()
# define    PI             3.14159265358979323846
# define    mod            1000000007
# define    endl           "\n"
# define    pii            pair<ll,ll>
# define    deb1(x)        cout<<#x<<" "<<x<<endl;
# define    deb2(x,y)      cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
# define    deb3(x,y,z)    cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
 
void getio();

void solve()
{
	// code here : 
	int n;
	cin >> n;
	vi a(n);
	fn cin >> a[i];

	int cnt=0;
	rep(i,0,n)
	{
		rep(j, i+1, n)
		{
			rep(k, j+1, n)
			{
				if(a[i]!=a[j] and a[i]!=a[k] and a[j]!=a[k])
				{
					if(a[i]+a[j]>a[k] and a[j]+a[k]>a[i] and a[k]+a[i]>a[j])
						cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
}



int32_t main()
{
	ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	getio();
    // int t; cin>>t; while(t--) 
    solve();
}

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

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define inf 1000000000000000000

using namespace std;

void run();

signed main(){
    cout<<fixed;
    run();
    return 0;
}

void run(){
    int n,x;
    cin>>n>>x;
    int a;
    cin>>a;
    int ans=abs(x-a);
    rep(i,n-1){
        cin>>a;
        ans=__gcd(ans,abs(x-a));
    }
    cout<<ans<<endl;
}

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

int main(){
    string S;
    cin >> S;
    if(S=="Sunny") cout << "Cloudy" <<endl;
    if(S=="Cloudy") cout << "Rainy" <<endl;
    if(S=="Rainy") cout << "Sunny" << endl;
    return 0;
 }

Measured memory_bytes: 256
def count_dig(m)
  dig = 0
  while m > 0
    m /= 10
    dig += 1
  end
  dig
end

n = gets.chomp.to_i

min_dig = count_dig(n)
mid = Math.sqrt(n).floor
(2..mid).each do |a|
  next if n % a != 0

  # always b >= a
  b = n / a

  dig = count_dig(b)
  min_dig = dig if dig < min_dig
end

puts min_dig

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

int main() {
  ll k, i = 1;
  cin >> k;
  queue<ll> q;
  for (int j = 1; j < 10; j++) q.push(j);

  while (i < k) {
    ll x = q.front();
    q.pop();

    if (x % 10 != 0 && x % 10 != 9) {
      q.push(10 * x + (x % 10) - 1);
      q.push(10 * x + (x % 10));
      q.push(10 * x + (x % 10) + 1);
    } else if (x % 10 == 0) {
      q.push(10 * x + (x % 10));
      q.push(10 * x + (x % 10) + 1);
    } else if (x % 10 == 9) {
      q.push(10 * x + (x % 10) - 1);
      q.push(10 * x + (x % 10));
    }
    i++;
  }

  cout << q.front() << endl;
}


Measured memory_bytes: 1792
n = gets.to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

count = 0
for i in 0.upto(n - 1)
    if a[i] <= b[i] then
        count += a[i]
        b[i] = b[i] - a[i]
        if a[i + 1] <= b[i] then
            count += a[i + 1]
            a[i + 1] = 0
        else
            count += b[i]
            a[i + 1] = a[i + 1] - b[i]
        end
    else
        count += b[i]
    end
end

puts count


Measured memory_bytes: 17320