akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <cstring>
#include <stdio.h>
#include <complex>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i, 0, t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))

const LD PI = acos(-1.0);
const LD EPS = 1e-6;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL mod = 1000000007;
const LL MAX = 1e5 + 47;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	LL n, a, b;
	cin >> n >> a >> b;
	if (a > b)
	{
		cout << 0;
		return 0;
	}

	if (n == 1)
	{
		if (a == b)
			cout << 1;
		else
			cout << 0;
		return 0;
	}

	LL m1 = a + (n - 1)*b;
	LL m2 = b + (n - 1)*a;
	LL ans = abs(m1 - m2) + 1;
	cout << ans;

	cin >> n;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

typedef long long ll;

set< ll > divisor(ll n) {
  set< ll > ret;
  ll num = n;
  for(ll i = 2; i * i <= n; i++) {
    while (num % i == 0) {
      num /= i;
      ret.insert(i);
    }
  }
  ret.insert(num);
  ret.insert(1);
  return ret;
}

ll gcd(ll a,ll b)
{
  if (a%b==0) {
    return(b);
  }
  return(gcd(b,a%b));
}

int main() {
  ll a, b;
  cin >> a >> b;
  ll c = gcd(a, b);
  set<ll> lc = divisor(c);
  cout << lc.size() << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    int n, q;
    cin >> n >> q;
    dsu d(n);
    rep(q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0) d.merge(u, v);
        else {
            if (d.same(u, v)) print(1);
            else print(0);
        }
    }
}

Measured memory_bytes: 3980
'use strict'
 
function main(n) {
  let num = n.split("\n")[0]*1;
  let x = n.split("\n")[0].split('').reduce((m,n)=>{return n*1+m*1});
  if(num%x === 0){
    console.log("Yes");
  } else {
    console.log("No");
  }
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
package main

import "fmt"

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	as := make([][]int, n)
	for i := 0; i < n; i++ {
		as[i] = make([]int, 2)
		fmt.Scan(&as[i][0], &as[i][1])
	}
	ans := make([]int, n)
	ac := make([][]int, m)
	for i := 0; i < m; i++ {
		ac[i] = make([]int, 2)
		fmt.Scan(&ac[i][0], &ac[i][1])
	}
	for i := 0; i < n; i++ {
		l := 1000000007
		for j := 0; j < m; j++ {
			if abs(ac[j][0]-as[i][0])+abs(ac[j][1]-as[i][1]) < l {
				ans[i] = j + 1
				l = abs(ac[j][0]-as[i][0]) + abs(ac[j][1]-as[i][1])
			}
		}
	}
	for _, v := range ans {
		fmt.Println(v)
	}
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int MAX_N = 105, INF = 1001001000;
const int WHITE = 0, GRAY = 1, BLACK = 2;

int n;
int M[MAX_N][MAX_N], color[MAX_N], d[MAX_N], p[MAX_N];

void init(){
    rep(i,n){
        rep(j,n) M[i][j] = -1;
        color[i] = WHITE;
        d[i] = INF;
    }
}

void dijkstra(int u){
    d[u] = 0;
    p[u] = -1;
    while(true){
        // 第一段階：次に更新する辺を決定する
        int mincost = INF;
        rep(i,n){
            if(color[i] != BLACK && mincost > d[i]){
                mincost = d[i];
                u = i;
            }
        }
        if(mincost == INF) break;   // 全ての辺の最小コストが無限大であることはないので、全ての頂点のcolorがBLACKになったということ
        color[u] = BLACK;   // 現時点で最短経路木に含まれない中で最短のものを最短経路木に含める
        // 第二段階:ただいま最短経路木に含めた頂点に隣接する頂点への最短経路を更新する
        rep(v,n){
            if(color[v] != BLACK && M[u][v] != -1){
                if(d[v] > M[u][v] + d[u]){
                    d[v] = M[u][v] + d[u];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
}

int main()
{
    cin >> n;
    init();
    rep(i,n){
        int u; cin >> u;
        int k; cin >> k;
        rep(_,k){
            int v,c; cin >> v >> c;
            M[u][v] = c;
        }
    }
    dijkstra(0);
    rep(i,n){
        printf("%d %d\n", i, d[i]);
    }
}


Measured memory_bytes: 3128
#include <stdio.h>
#include <string.h>

#define BIT 380000.0

int main(void) {
    int N,i;
    scanf("%d", &N);
    double x, ans = 0.0; char s[4];
    for(i = 0; i < N; ++i){
        scanf("%lf %s", &x, s);
        if(strcmp(s, "JPY") == 0) {
            ans += x;
        } else if(strcmp(s, "BTC") == 0) {
            ans += BIT*x;
        }
    }
    printf("%lf\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <stdlib.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

char s[12];

int main() {
    scanf("%s", s);
    int len = strlen(s);
    ll ans = 0;
    for (int t = 0; t < (1 << (len - 1)); ++t) {
        ll num = s[0] - '0';
        rep(i, len - 1) {
            if (t & (1 << i)) {
                ans += num;
                num = 0;
            }
            num = num * 10 + s[i+1] - '0';
        }
        ans += num;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

A = set(A)
MAX_A = 10 ** 6
X = [0] * (MAX_A + 1)
for a in A:
    for i in range(a, MAX_A + 1, a):
        X[i] += 1

ans = len([a for a in A if (X[a] == 1) and (C[a] == 1)])
print(ans)

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

int main() {
    int n, a, b, sum = 0, b_rank = 0;
    string s;
    cin >> n >> a >> b >> s;
    for(int i = 0; i < n; ++i) {
        if(s[i] == 'a') {
            if(sum < a + b) {
                sum++;
                cout << "Yes" << '\n';
            } else cout << "No" << '\n';
        } else if(s[i] == 'b') {
            if(sum < a + b && b_rank < b) {
                sum++;
                b_rank++;
                cout << "Yes" << '\n';
            } else cout << "No" << '\n';
        } else {
            cout << "No" << '\n';
        }
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll 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 << A-(K-(A+B)) << endl;

    return 0;

}

Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll a,b;
    cin>>a>>b;
    ll x=abs(a-b);
    if(x<=1)
    cout<<"Yay!";
    else
    cout<<":(";}

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

int main(){
  int n;
  cin >> n;
  int t, a;
  cin >> t >> a;
  int ans_i = 0;
  int ans_T = 1<<30;
  for(int i = 1; i <= n; ++i){
    int temp_h; cin >> temp_h;
    int temp_T = t*1000 - 6 * temp_h;
   // cout << "temp_T "<<temp_T <<endl;
    if(abs(ans_T-a*1000) >= abs(temp_T-a*1000)){
      ans_T = temp_T;
      ans_i = i;
    }
  }
  cout << ans_i << endl;
}


Measured memory_bytes: 256
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-03-28 21:12:16
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod) {
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod) {
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod) {
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int n, x, y;
    cin >> n >> x >> y;

    map<pair<int, int>, int> dist;
    for (int i = 1; i <= n; i++) {
        for (int j = i+1; j <= n; j++) {
            pair<int, int> edge = make_pair(i, j);
            
            if (i <= x && j >= y) {
                dist[edge] = j - i + x - y + 1;
            } else if (i <= x) {
                int a, b;
                a = j - i;
                b = x + y - i - j + 1;

                dist[edge] = min(a, b);
            } else if (j >= y) {
                int a, b;
                a = j - i;
                b = i + j - x - y + 1;

                dist[edge] = min(a, b);
            } else {
                int a, b;
                a = j - i;
                b = i - j - x + y + 1;

                dist[edge] = min(a, b);
            }
        }
    }

    vector<int> ans(n, 0);
    for (const auto& x : dist) {
        int d = x.second;
        ans[d]++;
    }

    for (int k = 1; k <= n-1; k++)
        cout << ans[k] << endl;

    return 0;
}


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

int main() {
  int h,w;
  cin>>h>>w;
   vector<vector<string>> data(h, vector<string>(w));
 
  // 入力 (2重ループを用いる)
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> data.at(i).at(j);
    }
  }
  int gyo;
  char retu;
  string atoz="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(data.at(i).at(j)=="snuke"){
        gyo=i+1;
        retu=atoz.at(j);
      }
    }
  }
  cout<<retu<<gyo;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int h = sc.nextInt();
		int m = sc.nextInt();
		double kakudo = Math.abs((m * 360 / 60) - ((h + (double)m / 60) * 360 / 12));
		double x = Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(Math.toRadians(kakudo)); 
		System.out.println(Math.sqrt(x));
	}
}


Measured memory_bytes: 35976
import java.util.*;
public class Main
{
  public static void main(String[] args)
  {
    Scanner Sc=new Scanner(System.in);
    int n=Sc.nextInt();
    int l=Sc.nextInt();
    int min=1+l-1;
    int max=n+l-1;
    int sum=0;
    for(int i=1;i<=n;i++)
    {
        sum=sum+(i+l-1);
        //System.out.println(sum);
    }
    if(min<=0&&max>=0)
    System.out.println(sum);
    else if(min>0)
    System.out.println(sum-min);
    else if(max<0)
    System.out.println(sum-max);
    
  }
}


Measured memory_bytes: 21844
using System;
    using System.Collections.Generic;
    using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            //input
            string[] input = Console.ReadLine().Split(' ');
            int k = int.Parse(input[0]);
            int n = int.Parse(input[1]);
            string[] input2 = Console.ReadLine().Split(' ');
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(input2[i]);
            }

            int[] sa = new int[n];
            for (int i = 0; i < n -1 ; i++)
            {
                sa[i + 1] = a[i + 1] - a[i];
            }
            sa[0] = a[n - 1] - a[0];
            sa[0] = sa[0] > k / 2 ? k - sa[0] : sa[0];

            Array.Sort(sa);
            int ans = 0;
            for (int i = 0; i < n - 1; i++)
            {
                ans += sa[i];
            }

            Console.WriteLine(ans);
        }
    }

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

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

    int N;
    cin >> N;
    int L[N];

    for(int i = 0; i < N; ++i) cin >> L[i];

    sort(L, L + N, greater<int>());

    int res = 0;

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

        for(int j = i + 1; j < N - 1; ++j){
            int d = L[i] - L[j];

            for(int k = N - 1; k > j; --k){
                if(L[k] > d){
                    int idx = k;
                    res += k - j;
                    break;
                }

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

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var A = cin.ReadInt;
            var B = cin.ReadInt;
            var C = cin.ReadInt;
            var K = cin.ReadInt;

            var ans = 0;
            var rest = K;

            if (A <= rest)
            {
                ans = A;
                rest -= A;
            }
            else 
            {
                ans = rest;
                rest = 0;
            }
            if (rest != 0) 
            {
                if (B <= rest)
                {
                    rest -= B;
                }
                else 
                {
                    rest = 0;
                }
            }
            if (rest != 0)
            {
                ans -= rest;
            }
            WriteLine(ans);
 
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


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

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

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int f(int x) {
    if (x % 2 == 0)
        return x / 2;
    else
        return 3 * x + 1;
}

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

    if (s == 2 || s == 1 || s == 4) {
        cout << 4 << endl;
        return 0;
    }

    int flag = 0;
    int cur_num = s;
    int i = 1;
    while (flag != 2) {
        int new_num = f(cur_num);
        cur_num = new_num;
        i++;
        if (new_num == 4) {
            flag++;
        }
    }
    cout << i << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
As = [int(input()) for i in range(N)]
visited=[False]*N
c = 0
now = 0
while True:
    if visited[now]:
        c = -1
        break
    visited[now] = True
    c+=1
    now = As[now]-1
    if now == 1:
        break
print(c)

Measured memory_bytes: 85932
#include<stdio.h>
#include<string.h>
#include<ctype.h>
main(){
  char w[10],t[1000];
  int i,counter=0;
  scanf("%s",w);
  while(1){
    scanf("%s",t);
    if(strcmp(t,"END_OF_TEXT")==0)
      break;
    for(i=0;t[i]!='\0';i++)
      t[i]=tolower(t[i]);
    if(strcmp(w,t)==0)
      counter++;
  }
  printf("%d\n",counter);
  return 0;
}

Measured memory_bytes: 552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    string p[h];
    for(int i=0;i<h;i++){
        cin >> p[i];
    }
    bool jadge=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(p[i][j]=='#'){
                int num_of_sharp = 0; // 上下左右に '#' が何個あるか
                // 下
                if(i+1<h && p[i+1][j] == '#') num_of_sharp++;
                // 上
                if(i-1>=0 && p[i-1][j] == '#') num_of_sharp++;
                // 右
                if(j+1<w && p[i][j+1] == '#') num_of_sharp++;
                // 左
                if(j-1>=0 && p[i][j-1] == '#') num_of_sharp++;
                
                // '#' が 1 個もなかったらダメ
                if (num_of_sharp == 0) jadge = 1;
            }
            else continue;
            
            if(jadge==1){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.algorithm;

void main()
{
    int[string] memo;
    foreach(str; ["A", "B", "AB", "O"])
    {
        memo[str] = 0;
    }
    while(true)
    {
        auto line = readln;
        if(!line)break;
        auto f = line.chomp.split(",");
        ++memo[f[1]];
    }
    foreach(str; ["A", "B", "AB", "O"])
    {
        memo[str].writeln;
    }
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

int n, a[102];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    double Ans = 0;
    for (int i = 1; i <= n; i++) Ans += 1.0 / a[i];
    Ans = 1.0 / Ans;
    printf("%.9f\n", Ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M; cin >> N >> M; 
	string S; cin >> S; 
	int A[100010] = {}; 
	fill(A, A+100005, -1); 
	A[0] = N; int now = 0;   
	while(1){
		int m = max(A[now] - M, 0); 
		for(int i = m; i < A[now]; i++){
			if(S.at(i) == '0'){
				A[now+1] = i; break; 
			}
		}
		if(A[now+1] == -1){
			cout << -1 << endl; return 0; 
		}
		now ++; 
		if(A[now] == 0) break;  
	}
	for(int i = now; i >= 1; i--){
		cout << - A[i] + A[i-1] << " "; 
	}
	cout << endl; 
}

Measured memory_bytes: 1024
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
      (cons (subseq str 0 pos)
            (split x (subseq str (+ pos size))))
      (list str))))

(setq *n* (read))
(setq *array* (make-array *n*))

(defun ans (cnt)
  (if (<= *n* cnt)
    nil
    (let ((a (read)))
    (progn (setf (aref *array* (1- a)) (1+ cnt))
    (ans (1+ cnt))
     ))))

(ans 0)
;(print *array*)

(defun answer (cnt)
  (if (<= *n* cnt) nil
    (progn (format t "~a " (aref *array* cnt)) (answer (1+ cnt))
  )))

(answer 0)


Measured memory_bytes: 60988
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=3005,mod=998244353;
int f[N][N],a,b,c,d;

signed main(){
	read(a,b,c,d);
	f[a][b]=1;
	for(int i=a;i<=c;i++) for(int j=b;j<=d;j++) if(i>a||j>b)
		f[i][j]=(1ll*f[i-1][j]*j%mod+1ll*f[i][j-1]*i%mod+(mod-1ll*f[i-1][j-1]*(i-1)%mod*(j-1)%mod)%mod)%mod;
	write(f[c][d]);
}

Measured memory_bytes: 38628
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
map<int,int>f;
inline int read() 
{
    char ch=getchar();
    int x=0,q=1;
    while(ch>'9' || ch<'0')q=ch==45?-1:q,ch=getchar();
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=getchar();
    return x*q;
}
inline int solve(int k)
{
    if(f[k]!=0) return f[k];
    else
    return f[k]=((solve(k/2)+solve((k-1)/2)+solve((k-2)/2)))%mod;
}
signed main()
{
    f[0]=1;
    f[1]=2; 
    int n;
    n=read(); 
    int ans=solve(n);
    printf("%lld\n",ans);
    return 0;
}

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

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(0);

	string s;
	cin>>s;
	unsigned long long int sum=0;
	for(int i=0;i<s.length();++i)
	{
		sum+=(s[i]-48);
	}
	if(sum%9==0)
		cout<<"Yes\n";
	else
		cout<<"No\n";
}

Measured memory_bytes: 3736
#include <iostream>
#include <cmath> 
#include <string>
#include<bits/stdc++.h> 
#define ll long long 
//deepaz
using namespace std;
//int num = stoi(a); -> str to int
//a = to_string(num); -> int to str
//total += c-48; -> char to int

//comparison func
bool comp(int x,int y){
	return x<y;
}
//char to int
int to_int(char c){
	return c;
}
//minimum in array
int getMin(long long arr[], int n,long long idx){ 
	long long res;
    for (int i = idx; i <= n; i++) 
        res = min(res, arr[i]); 
    return res; 
}
//get divisors of number 
int divisors(int n){
	long long cnt = 0;
	for(int i=1;i<sqrt(n);i++){
		if(n%i==0){
			cnt++;
		}
	}
	return cnt;
}
//find if prime
bool isPrime(ll n){
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			return false;
		}
	}
	return true;
}
//display prime in faster way
void dispPrime(ll n){
	long long num = 1e6;
	bool prime[num+num];
	memset(prime,true,sizeof(prime));
	for(int i=2;i*i<num+num;i++){
		if(prime[i]){
			for(int j=i*2;j<num+num;j+=i){
				prime[j] = false;
			}
		}
	}
	ll k = 2;
	ll cnt = 0;
	while(true){
		if(prime[k]){cnt++;cout<<k<<" ";}
		if(cnt==n){break;}
		k++;
	}
}


int main(){
	ll yen;
	cin>>yen;
	if(yen%1000 == 0){
		cout<<0<<"\n";
		return 0;
	}
	else{
		cout<<1000- (yen%1000)<<"\n";
	}
	return 0;
}






Measured memory_bytes: 3680
#include<stdio.h>
#include<cmath>
using namespace std;

int main() {
    int N, L;
    int taste;
    int minv = 500;
    int sum = 0; 

    scanf("%d %d", &N, &L);

    for (int i=1; i<=N; i++) {
        taste = L+i-1;
        sum += taste;
        if (abs(taste)<abs(minv)) minv = taste;
    }

    sum -= minv;

    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		if (a == b && a != c) {
			System.out.println("Yes");
		} else if (b == c && b != a) {
			System.out.println("Yes");
		} else if (a == c && a != b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		sc.close();
	}
}

Measured memory_bytes: 27076
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

int main(){
    ll k;
    cin>>k;
        vll d(50,49+k/50);
        ll i=k%50;
        int l=0;
        for(ll j=i;j>0;j--){
            d[l]+=51;
            rep(q,50) d[q]--; 
            l+=1;
        }
        cout<<50<<endl;
        rep(p,49){
            cout<<d[p]<<" ";
        }
        cout<<d[49]<<endl;
}

Measured memory_bytes: 256
n = int(input())
r = range(1, min(9, n) + 1)
a = [None] + [[0] * 10 for _ in r]
for i in r:
  a[i][i] += 1
for i in r:
  for j in r:
    k = 1
    while 10 * k * i + j <= n:
      a[i][j] += min(k, (n - j) // 10 - k * i + 1)
      k *= 10
print(sum(a[i][j] * a[j][i] for i in r for j in r))


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

struct Dice {
	int top;
	int north;
	int east;
	int south;
	int west;
	int bottom;
};

void rotn(void);
void rote(void);
void rots(void);
void rotw(void);

Dice d;
int tmp;

int main() {
	int i, q, t, f, r;
	cin >> d.top >> d.south >> d.east >> d.west >> d.north >> d.bottom;
	cin >> q;
	for (i = 0; i < q; i++) {
		cin >> t >> f;
		if (t == d.north)rots();
		else if (t == d.east)rotw();
		else if (t == d.south)rotn();
		else if (t == d.west)rote();
		else if (t == d.bottom) {
			rotn(); rotn();
		}
		if (f == d.north)r = d.west;
		else if (f == d.east)r = d.north;
		else if (f == d.south)r = d.east;
		else if (f == d.west)r = d.south;
		cout << r << endl;
	}
	return 0;
}

void rotn(void) {
	tmp = d.top;
	d.top = d.south;
	d.south = d.bottom;
	d.bottom = d.north;
	d.north = tmp;
}

void rote(void) {
	tmp = d.top;
	d.top = d.west;
	d.west = d.bottom;
	d.bottom = d.east;
	d.east = tmp;
}

void rots(void) {
	tmp = d.top;
	d.top = d.north;
	d.north = d.bottom;
	d.bottom = d.south;
	d.south = tmp;
}
void rotw(void) {
	tmp = d.top;
	d.top = d.east;
	d.east = d.bottom;
	d.bottom = d.west;
	d.west = tmp;
}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(int argc, char** argv)
{
	int n, c[101] = { 0 };
	int ans = 0;
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		int d;
		scanf("%d", &d);
		c[d] = 1;
	}
	for (i = 0; i < 101; ++i) {
		ans += c[i];
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - 753
            int x = int.Parse(Console.ReadLine());

            if (x == 3 | x == 5 | x == 7)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
 
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
 
const ll MOD = 1000000007;

int pow (int a, int b) {
   int ans = 1;
   while (b--)
      ans *= a;
   return ans;
} 

int main() {
   int n; scanf("%d", &n);
   multiset<int, greater<int>> m;
   for (int i = 0; i < pow(2, n); ++i) {
      int s; scanf("%d", &s);
      m.insert(s);
   }
   bool ans = true;
   multiset<int, greater<int>> cur;
   cur.insert(*m.begin()); m.erase(m.begin());
   for (int i = 0; i < n; ++i) {
      multiset<int, greater<int>> temp;
      multiset<int>::iterator curIt = cur.begin();
      for (int j = 0; j < cur.size(); ++j) {
         multiset<int>::iterator it = m.upper_bound(*curIt);
         if (it == m.end()) {
            ans = false;
            break;
         } else {
            temp.insert(*it);
            m.erase(it);
            ++curIt;
         }
      }
      if (ans) {
         cur.insert(all(temp));
      } else {
         break;
      }
   }
   puts(ans ? "Yes" : "No");
   return 0;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
#include <ctime>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define com(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define pri(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<endl;
#define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
/*__builtin_clz();
__builtin_ctz();
__builtin_popcount();*/
int main()
{

    speed;
    ll n;
    cin>>n;
    ll a[n];
    ll mx=0;
    vector<ll>v(1000000,1000000);
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        v[a[i]]=min(v[a[i]],i+1);
        mx=max(mx,a[i]);
    }
    ll ct=0;
    ll x=1;
    for(ll i=0;i<n;i++)
    {
        if(a[i]==x)
        {
            ct++;
            x++;
        }
    }
    if(ct==0)
    {
        cout<<"-1"<<"\n";
    }
    else
    {
        cout<<n-ct<<"\n";
    }
    

    cerr << "\nTime elapsed: " << 1000 * clock()/CLOCKS_PER_SEC << "ms\n";
}

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

using namespace std;


template <class T>
std::istream& operator>>(std::istream& in, std::vector<T>& data) {
    for (auto& item : data) {
        in >> item;
    }
    return in;
}

template <class T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& data) {
    bool first = true;
    for (const auto& item : data) {
        if (!first) {
            out << " ";
        }
        out << item;
        first = false;
    }
    return out;
}


int main() {
#ifdef LOCAL
    freopen("atcoder/input.txt", "r", stdin);
#endif

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

    vector<int> x(m);
    vector<int> y(m);
    vector<int> z(m);

    for (int i = 0; i < m; ++i) {
        cin >> x[i] >> y[i] >> z[i];
        --x[i];
        --y[i];
        --z[i];
    }

    vector<vector<int>> g(n);

    for (int i = 0; i < m; ++i) {
        g[x[i]].push_back(y[i]);
        g[y[i]].push_back(x[i]);
    }


    vector<int> dist(n, -1);
    int comp_count = 0;

    for (int node = 0; node < n; ++node) {
        if (dist[node] == -1) {
            deque<int> q = {node};

            while (!q.empty()) {
                int vertex = q.front();

                for (int child : g[vertex]) {
                    if (dist[child] == -1) {
                        dist[child] = dist[vertex] + 1;
                        q.push_back(child);
                    }
                }

                q.pop_front();
            }

            ++comp_count;
        }
    }

    cout << comp_count << "\n";




    return 0;
}











Measured memory_bytes: 8056
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x,y=parseMap(split(readline()))
    println(max(4-x,0)*100000+max(4-y,0)*100000+ifelse(x==y==1,400000,0))
end
main()

Measured memory_bytes: 166300
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

#define M 1299709 

int main() 
{
	bool t[M+1]={}; //素数ならfalse
	t[0] = true;
	t[1] = true;
	
	for(int i=2;i*i<=M;i++)
	{
		if(!t[i])
		{
			for(int j = i*2 ; j<=M ; j += i)
			{
				t[j] = true;
			}
		}
	}
	
	ll x;
	while(cin >> x && x!=0)
	{
		ll min(0),max(0);
		if(!t[x]){cout << 0 << endl;}
		else{
			for(int j=0;;j++){if(!t[x+j+1]){max=x+j+1;break;}}
			for(int j=0;;j--){if(!t[x+j-1]){min=x+j-1;break;}}
			cout << max - min << endl;
		}
	}
	return 0 ;
	
}

Measured memory_bytes: 2436
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define pb push_back
#define F first
#define S second
using namespace std;
typedef long long ll;
const int N=2e5+5;
const int MOD=1e9+7;
ll a[N];
ll sum[N];
ll gao(int l,int r){
	return sum[r]-sum[l-1];
}
ll lmax(ll x,ll y){return x<y?y:x;};
ll lmin(ll x,ll y){return x>y?y:x;};
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)sum[i]=sum[i-1]+a[i];
	ll l=1,r=3;
	ll ans=1e18+8;
	for(int i=2;i<=n-2;i++){
		while(l+1<i&&abs(gao(1,l)-gao(l+1,i))>=abs(gao(1,l+1)-gao(l+2,i)))l++;
		while(r+1<n&&abs(gao(i+1,r)-gao(r+1,n))>=abs(gao(i+1,r+1)-gao(r+2,n)))r++;
//		cout<<"i="<<i<<" l="<<l<<" r="<<r<<endl;
		ll a=(gao(1,l)),b=(gao(l+1,i));
		ll c=(gao(i+1,r)),d=(gao(r+1,n));
		ll maxx=lmax(lmax(a,b),lmax(c,d));
		ll minn=lmin(lmin(a,b),lmin(c,d));
		ans=lmin(ans,abs(maxx-minn));
//		cout<<abs(*st.begin()-*prev(st.end()))<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

use std::collections::VecDeque;

fn main() {
    input!{
        n: usize,
        c: i64,
        v: [i64; n]
    }
    let mut q: VecDeque<(i64, i64)> = VecDeque::new();
    let mut tab: Vec<i64> = vec![0; n];
    q.push_back((-2 * v[0], v[0] * v[0]));
    for i in 1..n {
        tab[i] = {
            let &(a, b) = q.front().unwrap();
            a * v[i] + b
        };
        while q.len() > 1 {
            let &(a, b) = q.get(1).unwrap();
            if tab[i] > a * v[i] + b {
                tab[i] = a * v[i] + b;
                q.pop_front();
            } else {
                break;
            }
        }
        tab[i] += v[i] * v[i] + c;
        let a = -2 * v[i];
        let b = tab[i] + v[i] * v[i];
        while q.len() > 1 {
            let l = q.len();
            let &(a1, b1) = q.get(l - 2).unwrap();
            let &(a2, b2) = q.get(l - 1).unwrap();
            if (a1 - a2) * (b - b1) <= (a1 - a) * (b2 - b1) {
                q.pop_back();
            } else {
                break;
            }
        }
        q.push_back((a, b));
    }
    println!("{}", tab[n - 1]);
}


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

public class Main {
	
	int N;

	void run() throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		N = Integer.parseInt(br.readLine());
		String[] A = br.readLine().split(" ");
		int S = Integer.parseInt(br.readLine());
		String[] B = br.readLine().split(" ");
		for (int i = 0; i < S; i++) 
			System.out.println(solve(0, Integer.parseInt(B[i]), A) ? "yes" : "no");
	}
	
	boolean solve(int i, int m, String[] A) {
		if (m == 0) return true;
		if (i > N - 1) return false;
		if (solve(i + 1, m, A) || solve(i + 1, m - Integer.parseInt(A[i]), A)) {
			return true;
		} else {
			return false;
		}
	}

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
}

Measured memory_bytes: 27484
#include <cstdio>
#include <iostream>
#include<algorithm>

using namespace std;
char s[110];
int n,ans,maxn;
int main()
{
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;++i)
    {
        if(s[i]=='I') ++ans;
        else --ans;
        maxn=max(maxn,ans);
    }
    printf("%d\n",maxn);
    return 0;
}

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

int main() {
    
	ll n, y; cin >> n >> y;
	bool end = false;
	ll ans1 = -1;
	ll ans2 = -1;
	ll ans3 = -1;
	for (ll i = 0; i <= n; i++) {
		for (ll j = 0; j <= n; j++) {
			ll k = n - i - j;
			if (k < 0) continue;
			if (10000 * i + 5000 * j + 1000 * k == y) {
				ans1 = i;
				ans2 = j;
				ans3 = k;
				end = true;
				break;
			}
		}
		if (end) break;
	}
	cout << ans1 << " " << ans2 << " " << ans3 << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstdio>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int answer = 0;
    answer += N * (N - 1) / 2;
    answer += M * (M - 1) / 2;
    cout << answer;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int p[] = new int[n];

    for (int i = 0; i < n; i++) {
      p[i] = sc.nextInt();
    }

    int max = p[0];
    int count = 1;
    for (int i = 1; i < n; i++) {
      if (max > p[i]) {
        max = p[i];
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 64744
open System

let ReadOne T = stdin.ReadLine()|> T
let ReadSplit T = stdin.ReadLine().Split()|>Array.map T
[<EntryPoint>]
let main argv =
    let N =ReadOne int
    let a=ReadSplit int
    let mutable ans=0.0f
    for i in [0..N-1] do
        ans <- ans + (if a.[a.[i]-1]=i+1 then 0.5f else 0.0f)
    ans
    |>int
    |>stdout.WriteLine
    0


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

string Calc_Bottom( string str )
{
    if( str.size() == 1 )
        return str;

    string res = "";

    int i = 0, j = 1;
    while( j < str.size() )
    {
        res += ( ( ( str[i] - '0' ) + ( str[j] - '0' ) ) % 10 ) + '0';
        i++;
        j++;
    }

    return Calc_Bottom( res );
}

int main()
{
    string str;

    while( cin >> str )
        cout << Calc_Bottom( str ) << endl;

    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

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

    vector<int> d;
    for(int i=1;i*i<=m;++i)
    {
        if(m%i==0)
        {
            d.push_back(i);
            if(i*i != m) d.push_back(m/i);
        }            
    }
    sort(d.begin(),d.end());

    for(auto di:d)
    {
        if(di >= n)
        {
            cout << m/di << endl;
            break;
        }
    }
    
    return 0;
}

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

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

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

int main(void) {
    int64_t A,B;
    cin >> A >> B;
    cout << lcm(A,B) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//Author: Ezio Sam
/* Shorthands */
#define ll long long
#define pb push_back 
#define mp make_pair
#define sp " "
#define cs "Case "
#define fi first
#define sn second 
#define po(x) x*x
/* STL */
#define vi vector<int>v
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mem(a,n) memset(a, n, sizeof(a));
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define sz(x)  (int)x.size()
#define mx(v)  *max_element(v.begin(),v.end())
#define mxi(v) distance(v.begin(),max_element(v.begin(),v.end()))
#define mxa(a) *max_element(a, a.size())
#define r(a) reverse(a.begin(),a.end())
/* loops */
#define fr(i,n)   for(__typeof(n) i=0;i<(n);i++)
#define fn(i,n)   for(__typeof(n)i=1;i<=(n);i++)
#define fa(i,a,n) for(int  i=a;i<=b;i++)
/*Special*/
#define Ezio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(something)  cerr<<#something<<" - "<<something<<"\n";         

int main()
{
  
   Ezio
   ll t,m,n,x,a,b;
   string s;
   
   cin>>n;
   
   if(n%1000==0)cout<<0<<endl;
   else cout<<((n+(1000-n%1000))-n)<<endl;
   return 0;
}
    

Measured memory_bytes: 3648
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
string str;
int n;
ll ans;
int cnt[26];
int main()
{
    cin>>str;
    n=str.size();ans=1;
    for(int i=0;i<n;i++)
    {
        ans+=i-cnt[str[i]-'a'];
        cnt[str[i]-'a']++;
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
#define MAX 200000

int main() {
	int N, A[MAX];
	long long cnt = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}

	for (int i = 0; i < N; i++) {
		if (i == 0) {
			if (A[0] != 0) {
				cnt = -1;
				break;
			}
		}
		else if (A[i] > A[i - 1] + 1) {
			cnt = -1;
			break;
		}
		else if (A[i] == A[i - 1] + 1) {
			cnt++;
		}
		else if (A[i] <= A[i - 1]) {
			cnt += A[i];
		}
	}

	printf("%lld\n", cnt);


	return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  int l[100100], r[100100];
  for(int i=0; i<q; i++) cin >> l[i] >> r[i];
  vector<int> L(n), R(n);
  for(int i=1; i<n; i++){
    if(s[i]=='C' && s[i-1]=='A') L[i] = L[i-1] + 1;
    else L[i] = L[i-1];
  }
  for(int i=0; i<q; i++){
    cout << L[r[i]-1] - L[l[i]-1] << endl;
  }
}


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

#define rep(i, k) for (ll i = 0; i < k; i++)
#define pair(x, y) make_pair((x), (y))

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int ans = 0;
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) { cin >> s[i]; }
    sort(s.begin(), s.end());
    rep(i, n) { cout << s[i]; }
}
	

Measured memory_bytes: 764