akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int n, m, d, p, r[11];

int main()
{
    while(true)
    {
        scanf("%d", &n);
        scanf("%d", &m);
        
        if(n == 0 && m == 0) { break; }
        
        for(int i = 0; i < 11; i++)
        {
            r[i] = 0;
        }
        
        for(int i = 0; i < n; i++)
        {
            scanf("%d", &d);
            scanf("%d", &p);
            
            r[p] += d;
        }
        
        for(int i = 10; i >= 0; i--)
        {
            if(m >= r[i])
            {
                m -= r[i];
                
                r[i] = 0;
            }
            else
            {
                r[i] -= m;
                
                break;
            }
        }
        
        int sum = 0;
        
        for(int i = 0; i <= 10; i++)
        {
            sum += i * r[i];
        }
        
        printf("%d\n", sum);
    }
    
    return 0;
}

Measured memory_bytes: 2576
/*dismint|jjc*/
#include <bits/stdc++.h>
using namespace std;
#define forl(V, S, E) for(int V = S; V < E; V++)
#define ford(V, S, E) for(int V = S; V >= E; V--)
#define fore(E, X) for(auto &E:X)
#define println(X) cout << X << endl
#define printe(X) for(auto &E:X) cout << E << " "; cout << endl
typedef unordered_map<int, unordered_set<int>> graph;
typedef long long ll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin >> n;
	vector<double> nums(n); fore(e, nums) cin >> e;
	double denom = 0;
	fore(e, nums) {
		denom += 1.0/e;
	}
	cout << setprecision(100) << 1.0/denom << endl;
}


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

using namespace std;

int main(){
  int minn = 2000;
  
  string a,b;
  cin >> a >>  b;
  
  int l1 = a.length();
  int l2 = b.length();
 	
  for (int i = 0; i < l1; i++){
    int total = 0;
    for (int j = 0; j < l2; j++){
  		if (i+j >= l1) {total = 2000; break;}
      	if (a[i+j] != b[j]) {total++;}
    }
    
    minn = min(total,minn);
  }
  
  cout << minn << endl;
  return 0;
}

Measured memory_bytes: 3596
# include <iostream>
# include <cmath>
# include <algorithm>
# include <stdio.h>
# include <cstdint>
# include <cstring>
# include <string>
# include <cstdlib>
# include <vector>
# include <bitset>
# include <map>
# include <queue>
# include <ctime>
# include <stack>
# include <set>
# include <list>
# include <random>
# include <chrono>
# include <deque>
# include <functional>
# include <iomanip>
# include <sstream>
# include <fstream>
# include <complex>
# include <numeric>
# include <cassert>
# include <array>
# include <tuple>
# include <cctype>
# include <unistd.h>
# include <unordered_map>
# include <unordered_set>
using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define fast_work {ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);}

const ll INF = 1e9 + 5, NMAX = 2e5 + 5, MOD = 1000000007, N = 1e9 + 5, LOG = 25;
const ld EPS = 1e-8, pi = 3.14159265358979323846;

bool used[NMAX];
set<int> g[NMAX];

int cnt = 0;

void dfs(int v) {
    ++cnt;
    used[v] = true;

    for(int to : g[v]) if(!used[to]) dfs(to);
}

signed main() {
    fast_work

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

    for(int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;

        g[x].insert(y);
        g[y].insert(x);
    }

    int answer = 1;
    for(int i = 0; i < n; ++i) {
        if(!used[i]) {
            cnt = 0;
            dfs(i);
            answer = max(answer, cnt);
        }
    }

    cout << answer;
}


Measured memory_bytes: 38168
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
using namespace std;
using Graph=vector<vector<int>>;
template<class T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, T b){ if(a>b){ a=b; return 1; } return 0; }

int main(){
    int n;
    cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;++i) cin>>a[i];

    sort(a.begin(),a.end());
    long long max=a[n-1];
    vector<bool> dp(max+1,true);
    vector<int> b(max+1,0);
    for(int i=0;i<n;++i) ++b[a[i]];

    for(int i=0;i<n;++i){
        int temp=a[i];
        for(int j=2;j*temp<=max;++j){
            dp[j*temp]=false;
        }
    }
    int ans=0;
    for(int i=0;i<n;++i){
        if(dp[a[i]]&&b[a[i]]==1) ++ans;
    }  

    cout<<ans<<endl;
}

Measured memory_bytes: 8736
// B.

#include <iostream>
#include <sstream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, d, x;
	cin >> n >> d >> x;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		x += (d - 1 + a) / a;
	}
	cout << x << endl;
	return 0;
}


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

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

const ll MOD = 10000;

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

    vector<tuple<int, int, int>> py(m);

    int tmp_p, tmp_y;
    for ( int i = 0; i < m; i++ ) {
        cin >> tmp_p >> tmp_y;
        py[i] = make_tuple(tmp_p, tmp_y, i);
    }

    sort(py.begin(), py.end());

    int pre_shi = get<0>(py[0]);
    int cnt = 1;
    for ( int i = 0; i < m; i++ ) {
        if ( pre_shi == get<0>(py[i]) ) {
            get<1>(py[i]) = cnt;
            cnt++;
        }
        else {
            cnt = 1;
            pre_shi = get<0>(py[i]);
            get<1>(py[i]) = cnt;
            cnt++;
        }
    }

    int tmp_num;
    for ( int i = 0; i < m; i++ ) {
        tmp_num = get<2>(py[i]);
        get<2>(py[i]) = get<0>(py[i]);
        get<0>(py[i]) = tmp_num;
    } 

    sort(py.begin(), py.end());

    for ( int i = 0; i < m; i++ ) {
        printf("%06d%06d\n", get<2>(py[i]), get<1>(py[i]));
    }

    return 0;
}

Measured memory_bytes: 2688
// D - Knight
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define MOD 1000000007
#define MAX 1000001

ll fac[MAX]; // 累乗 n!
ll inv[MAX]; // 逆元 1/n
ll finv[MAX]; // 逆元の累乗 (n^-1)! = (1/n)!

void init(int n, int p){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	rp(i, 2, n+1){
		fac[i] = fac[i-1] * i % p;
		inv[i] = p - inv[p%i] * (p/i) % p;
		finv[i] = finv[i-1] * inv[i] % p;
	}
}

ll comb(int n, int r, int m){
	if(n<r || n<0 || r<0) return 0;
	return fac[n] * (finv[n-r] * finv[r] % m) % m;
}

int main(){
	int X,Y; cin>>X>>Y;
	int r = (2*X-Y)/3, n = (2*Y-X)/3 + r;
	if((X+Y)%3 || n<0 || r<0){puts("0"); return 0;}
	else{
		init(n+1, MOD);
		cout<< comb(n, r, MOD) % MOD << endl;
	}
}

Measured memory_bytes: 22784
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fi first
#define se second
#define pb push_back
#define re return
#define br break

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  set<int> S;
  int A,B,K;cin>>A>>B>>K;
  REP(i,A,min(B+1,A+K))S.insert(i);
  REP(i,max(A,B-K+1),B+1)S.insert(i);
  each(s,S){
    print(s);
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
using namespace std;


int main(){
    int K,T;
    cin >> K;
    cin >> T;
    int a[T];
    int ans;
    for(int i=0;i<T;i++)
        cin >> a[i];
    
    int max =0;
    for(int j=0;j<T;j++)
        if(max<a[j])
            max = a[j];
    
    ans = 2 * max - K -1;
    if(ans < 0)
        ans = 0;
    cout << ans << endl;
    }



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    long long int n,i=1,j;
    cin>>n;
    for(i=1;i<=sqrt(n);i++)
    {
    	if(n%i==0)
    	{
    		j=i+n/i;
		}
	}
	j=j-2;
	cout<<j;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>


int main(){
   const int llimit[9] = {400,800,1200,1600,2000,2400,2800,3200,4801};
   int count[9];
   for(int i=0; i<9; ++i) count[i] = 0;

   int N;
   std::cin >> N;
   int a;
   for(int i=0; i<N; ++i) {
      std::cin >> a;
      for(int j=0; j<9; ++j){
	 if(a<llimit[j]) {
	    count[j]++;
	    break;
	 }
      }
   }
   
   int min = 0;
   for(int i=0; i<8; ++i){
      if(count[i]>0) ++min;
   }
   int max = min+count[8];
   min = std::max(1,min);

   std::cout << min << ' ' << max << std::endl;
   return 0;
}


Measured memory_bytes: 256
import scala.io.StdIn.readLine

object Main {
	def main(args: Array[String]) = {
		def buildFrame: Unit = {
			val Array(a,b) = readLine().split(" ").map(_.toInt)
			if(a != 0 && b != 0) {
				for(c <- 1 to a) {
				if(c == 1 || c == a) println("#" * b)
				else println("#" + "." * (b -2) + "#")
			}
			println()
			buildFrame
		}
	}
	buildFrame
	}
}

Measured memory_bytes: 45656
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
int v[20], c[20];

void init()
{
}

void solve()
{
    int n = 0;
    int ans = 0;
    while(n < (1 << N)){
        int nn = n;
        int vall = 0, call = 0;
        int i = 0;
        while(nn > 0){
            if(nn & 1){
                vall += v[i];
                call += c[i];
            }
            nn >>= 1;
            i++;
        }
        ans = max(ans, vall - call);
        n++;
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> v[i];
    REP(i, N) cin >> c[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

char str[111111];
int ans[111111];

int main() {
  scanf("%s", str);
  int n = strlen(str);

  int i = 0;
  while (i < n) {
    int r_start = i;
    int r_end = i;
    while (r_end < n && str[r_end] == 'R') {
      r_end++;
    }
    r_end--;
    int l_start = r_end + 1;
    int l_end = l_start;
    while (l_end < n && str[l_end] == 'L') {
      l_end++;
    }
    int next_i = l_end;
    for (int j = i; j < next_i; j++) {
      if (j % 2 == r_end % 2) {
        ans[r_end]++;
      } else {
        ans[l_start]++;
      }
    }
    i = next_i;
  }

  for (int i = 0; i < n; i++) {
    printf("%d", ans[i]);
    if (i == n - 1) {
      printf("\n");
    } else {
      printf(" ");
    }
  }

  return 0;
}


Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;

class Procon {
    static void Main (string[] agrs) {
        var N = Int();
        var A = Longs();

        Console.WriteLine(gcd(A));
    }

    static string String () => Scanner.nextString ();
    static int Int () => int.Parse (Scanner.nextString ());
    static long Long () => long.Parse (Scanner.nextString ());
    static double Double () => double.Parse (Scanner.nextString ());
    static char[] Chars () => String ().ToCharArray ();
    static string[] Strings () => Console.ReadLine ().Split (' ');
    static int[] Ints () => Strings ().Select (v => int.Parse (v)).ToArray ();
    static long[] Longs () => Strings ().Select (v => long.Parse (v)).ToArray ();
    static double[] Doubles () => Strings ().Select (v => double.Parse (v)).ToArray ();
    const int M = 1000000007;


    static long gcd(long a, long b)
    {
        long tmp;
        if (b > a)
        {
            tmp = a;
            a = b;
            b = tmp;
        }

        if (b == 0)
        {
            return a;
        }

        return gcd(b, a % b);
    }

    static long gcd(long[] a)
    {
        long ans = a[0];
        for (long i = 1; i < a.Length; i++)
        {
            ans = gcd(ans, a[i]);
        }
        return ans;
    }
}

class PriorityQueue<T> where T : IComparable<T> {
    public T[] heap;
    public int size;
    public int sign;
    public PriorityQueue (int N, bool descend = false) {
        heap = new T[N];
        sign = 1;
        if (descend) sign = -1;
    }
    public int Compare (T x, T y) {
        return x.CompareTo (y) * sign;
    }
    public void Push (T x) {
        int i = size++;
        while (i > 0) {
            int p = (i - 1) / 2;
            if (Compare (x, heap[p]) >= 0) {
                break;
            }
            heap[i] = heap[p];
            i = p;
        }
        heap[i] = x;
    }
    public T Pop () {
        T ret = heap[0];
        T x = heap[--size];
        int i = 0;
        while (i * 2 + 1 < size) {
            int a = i * 2 + 1;
            int b = i * 2 + 2;
            if (b < size && Compare (heap[a], heap[b]) > 0) {
                a = b;
            }
            if (Compare (heap[a], x) >= 0) {
                break;
            }
            heap[i] = heap[a];
            i = a;
        }
        heap[i] = x;
        return ret;
    }
    public int Count () {
        return size;
    }
}

class Scanner {
    static string[] s = new string[0];
    static int i = 0;
    static int max_i = 0;
    static public string nextString () {
        if (i >= s.Length) {
            s = Console.ReadLine ().Split (' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0) {
                return "";
            }
            return s[i++];
        }
        return s[i++];
    }
}


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

int main() {
  string s;
  cin >> s;
  if (s == "a" || s == "i" || s == "u" || s == "e" || s == "o")
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


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

// ============union_find_tree===============
int MAX_N = 10000;
vector<int> par(MAX_N);//MAX_N == num of node
vector<int> tree_rank(MAX_N);

void init(int n)
{
  for (int i = 0; i < n; ++i)
  {
    par.at(i) = i;
    tree_rank.at(i) = 0;
  }
}

int find(int x)
{
  if (par.at(x) == x)
  {
    return x;
  }
  else
  {
    return par.at(x) = find(par.at(x));
  }
}

void unite(int x, int y)
{
  x = find(x);
  y = find(y);
  if (x == y)
  {
    return;
  }
  if (tree_rank.at(x) < tree_rank.at(y))
  {
    par.at(x) = y;
  }
  else
  {
    par.at(y) = x;
    if (tree_rank.at(x) == tree_rank.at(y))
    {
      tree_rank.at(x)++;
    }
  }
}

bool same(int x, int y)
{
  return find(x) == find(y);
}
// =======================================


int main()
{
  int n, q;
  cin >> n >> q;
  init(n);
  int com, x, y;
  for (int i = 0; i < q; ++i)
  {
    cin >> com >> x >> y;
    if (com == 0)
    {
      unite(x, y);
    }
    else
    {
      if (same(x, y))
      {
        cout << 1 << endl;
      }
      else
      {
        cout << 0 << endl;
      }
    }
  }
}



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

using namespace std;
const int mxN=50,M=1e9+7;
int N ;
typedef  long long ll ;
ll K;

struct Matrix{
  vector<vector<int >> a = vector<vector<int >>( N ,vector<int>(N));
  Matrix operator *(const Matrix &o){
    Matrix pro;
    //vector<vector<long long>> tem( n , vector<long long>(n));
    for(int i=0 ; i<N ; i++){
        for(int j=0 ; j<N ; j++){
            for(int k=0 ; k<N ; k++){
                //ll &tem = pro.a[i][j];
                pro.a[i][j]=(pro.a[i][j]+(long long)a[i][k]*o.a[k][j])%M;
                
            }
        }
    }
    return pro;
  }
};

Matrix expo(Matrix x , ll k){
    Matrix res;
    for(int i=0 ; i<N ;++i)res.a[i][i] =1;
     
    while(k>0){
        if(k%2)
        res = res * x;

        x = x*x;
        k/=2;
    } 
    return res;
}

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

    Matrix v;
    for(int i=0 ; i<N ; i++){
        for(int j=0 ; j<N ; j++){
            cin>> v.a[i][j];
        }
    }

    Matrix f = expo(v,K);

    ll ans = 0;
    for(int i=0 ; i< N ; i++){
        for(int j=0 ; j<N ; j++){
            ans+=f.a[i][j];
            if(ans>=M)ans-=M;
        }

    }
    cout <<  ans;




}

Measured memory_bytes: 3580
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int parent[100000];
int find(int n) {
    if (parent[n] != n) parent[n] = find(parent[n]);
    return parent[n];
}
vpii v;
int main() {
    int i;
    int N,Q,A,B,C;
    LLI M;
    scanf("%d %lld %d",&N,&M,&Q);
    for (i = 0; i < N; i++) parent[i] = i;
    for (i = 0; i < Q; i++) {
        scanf("%d %d %d",&A,&B,&C);
        if (C == 0) {
            if (find(A) != find(B)) parent[find(A)] = find(B);
        }
        else v.pb(mp(A,B));
    }

    for (i = 0; i < v.size(); i++) {
        if (find(v[i].first) == find(v[i].second)) {
            printf("No\n");
            return 0;
        }
    }
    int com = 0;
    for (i = 0; i < N; i++) {
        if (parent[i] == i) com++;
    }
    if (v.empty()) {
        if (M > N-com+(LLI) com*(com-1)/2) printf("No\n");
        else printf("Yes\n");
    }
    else {
        if (com == 2) printf("No\n");
        else if (M == N-1) printf("No\n");
        else if (M > N-com+(LLI) com*(com-1)/2) printf("No\n");
        else printf("Yes\n");
    }

    return 0;
}



Measured memory_bytes: 1784
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define p pair<int,int>
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
using namespace std;
int POW(int x,int y){return int(pow(double(x),double(y)));}



int main(){
	string s;
	cin>>s;
	if(s[0]!=s[1] &&s[2]!=s[1] &&s[0]!=s[2]){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
}


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

using namespace std;

using ll = long long;

mt19937 mt(736);


void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int n, k, s;

	cin >> n >> k >> s;

	int ns = s == (int) 1e9 ? 1 : s + 1;

	for (int i = 0; i < k; i++)
		cout << s << ' ';
	for (int i = 0; i < n - k; i++)
		cout << ns << ' ';
	cout << endl;
}


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

	cout << fixed;

#ifdef LOCAL
	auto st = clock();

	ifstream fin("../input.txt");

	solve(fin);

	cout << "clock: " << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}


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

int main()
{
  int X, Y, Z;
  while (cin >> X >> Y >> Z) {
    if ((X|Y|Z) == 0)
      break;

    vector<int> V(X);
    for (int i = 0; i < X; ++i)
      cin >> V[i];

    vector<pair<int, int> > E(Y+1, make_pair(0, 0));
    for (int i = 0; i < Z; ++i) {
      int N;
      cin >> N;
      cin >> E[N].first >> E[N].second;
    }

    const int MAX_MONEY = 5000+1;
    vector<vector<double> > dp(Y+1, vector<double>(MAX_MONEY, 0.0));
    dp[0][0] = 1.0;
    for (int i = 0; i < Y; ++i) {
      for (int j = 0; j < MAX_MONEY; ++j) {
	for (int k = 0; k < X; ++k) {
	  int next_pos = min(i+V[k], Y);
	  int next_money = j;
	  if (E[next_pos].first == 1)
	    dp[min(next_pos+E[next_pos].second, Y)][j] += dp[i][j] / X;
	  else if (E[next_pos].first == 2)
	    dp[next_pos][j+E[next_pos].second] += dp[i][j] / X;
	  else if (E[next_pos].first == 3)
	    dp[next_pos][max(j-E[next_pos].second, 0)] += dp[i][j] / X;
	  else
	    dp[next_pos][j] += dp[i][j] / X;
	}
      }
    }

    double ans = 0.0;
    for (int i = 0; i < MAX_MONEY; ++i)
      ans += dp[Y][i] * i;
    cout << static_cast<int>(ans) << endl;
  }
  return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=2005,mod=998244353;
LL read(){
	LL x=0,f=1;
	char ch=getchar();
	while (!isdigit(ch)&&ch!='-')
		ch=getchar();
	if (ch=='-')
		f=-1,ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+ch-48,ch=getchar();
	return x*f;
}
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=1LL*x*x%mod)
		if (y&1)
			ans=1LL*ans*x%mod;
	return ans;
}
int n,k,dp[N][N],C[N][N],sum[N][N];
int DP(int i,int j){
	if (j<0)
		return 0;
	return dp[i][j];
}
int Get(int v,int n,int k){
	v--;
	int ans=0;
	int lim=max(0,v/2-max(0,v-k));
	for (int i=0;i<=lim;i++)
		ans=(1LL*Pow(2,i)*C[lim][i]%mod*DP(k-lim*2+i,n-i)+ans)%mod;
	return ans;
}
int main(){
	for (int i=0;i<N;i++)
		C[i][0]=C[i][i]=1;
	for (int i=1;i<N;i++)
		for (int j=1;j<i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	k=read(),n=read();
	dp[0][0]=sum[0][0]=1;
	for (int i=1;i<=n;i++)
		sum[0][i]=1;
	for (int i=1;i<=k;i++){
		dp[i][0]=sum[i][0]=1;
		for (int j=1;j<=n;j++){
			dp[i][j]=sum[i-1][j];
			sum[i][j]=(sum[i][j-1]+dp[i][j])%mod;
		}
	}
	for (int i=2;i<=2*k;i++){
		int ans=0;
		if (i&1)
			ans=(ans+Get(i,n,k))%mod;
		else
			ans=(1LL*ans+Get(i-1,n,k-1)+Get(i-1,n-1,k-1))%mod;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 47360
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

public class Main {
	static int n, max;
	static int[] S;
	static Scanner sc = new Scanner(System.in);
	
	static boolean read() {
		n = sc.nextInt();
		if(n == 0) return false;
		S = new int[n]; max = 0;
		for(int i = 0; i < n; i++) {
			S[i] = sc.nextInt();
			max = max(max, S[i]);
		}
		return true;
	}
	
	static void solve() {
		int cnt;
		int[] C, prev, hist;
		C = S; prev = S; 
		for(cnt = 0; ; cnt++) {

			hist = new int[max+1];
			int sum;
			for(int i = 0; i <= max; i++) {
				sum = 0;
				for(int j = 0; j < C.length; j++) {
					if(C[j] == i) sum++;
				}
				hist[i] = sum;
			}
			
			prev = C.clone();
			for(int i = 0; i < C.length; i++) {
				C[i] = hist[C[i]];
				max = max(max, C[i]);
			}
			if(Arrays.equals(C, prev)) break;
		}
		
		System.out.println(cnt);
		for(int i = 0; i < C.length; i++) System.out.print(((i == C.length-1) ? "" + C[i] + "\n" : C[i] + " " ));
		
	}
	
	/*
	static boolean same(int[] a, int[] b) {
		int len = a.length;
		boolean res = true;
		for(int i = 0; i < len; i++) {
			if(a[i] != b[i]) {
				res = false;
				break;
			}
		}
		return res;
	}
	*/
	
	public static void main(String[] args) {
		while(read()) {
			solve();
		}
	}

}

Measured memory_bytes: 12000
#include<stdio.h>
int main(){
	
   int i;
   int counter = 0;
   char s[2];
   
   scanf("%s", s );
    
   for(i = 0 ; i<3 ; i++ ){
	     if(s[i] == '1'){
            counter++;
        }
    }

    printf("%d\n",counter);
    return 0;
}

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

int main(){
    ll ans = 0;
    int n; cin >> n;

    for(int i = 1; i <= n; i++){
        if(i mod 3 != 0 && i mod 5 != 0 && i mod 15 != 0){
            ans += i;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const int N = 1e6;
int a, b; 

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

Measured memory_bytes: 3140
def main():
  X, N = list(map(int, input().split()))

  ans = X;
  min_value = 202

  if N == 0:
    print(ans)
  else:
    p = list(map(int, input().split()))
    a = [i for i in range(0, 202)]

    for v in p:
      a[v] = -1

    for i in range(0, 202):
      if a[i] != -1:
        d = abs(X - a[i])

        if(min_value > d):
          min_value = d
          ans = i

    print(ans);

if __name__ == '__main__':
  main()

Measured memory_bytes: 9208
#include"bits/stdc++.h"
#define maxn 1005
using namespace std;
#define int long long
signed main()
{
    int n,a,b;cin>>n>>a>>b;
    if(a>b)swap(a,b);
    int len=b-a;
    if(len%2==0){
        cout<<(b-a)/2 <<endl;
    }
    else {
        if(a>b)swap(a,b);
        cout<<min(a-1,n-b) + (b-a-1)/2 + 1<<endl;
    }
    
    return 0;
}

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

long long mat[310][310],n,m,par[310];

struct node{
    int u,v,w;
};
bool operator < (node a,node b)
{
    return a.w < b.w;
}

vector<node> X;

int fp(int a)
{
    if(par[a]==a) return a;
    return par[a]=fp(a);
}

int main()
{
    for(int i=0;i<310;i++) par[i]=i;
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++) scanf("%lld",&mat[i][j]);
    }

    int flag=0;
    long long sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            int fg=0;
            for(int k=0;k<n;k++)
            {
                if(k==i || k==j) continue;
                if(mat[i][j]>mat[i][k]+mat[k][j])
                {
                    printf("-1");
                    return 0;
                }
                if(mat[i][j]==mat[i][k]+mat[k][j]) fg=1;
            }
            if(!fg) sum+=mat[i][j];
        }
    }
    printf("%lld",sum/2);
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
using namespace std;
vector<int>ans;
vector<int>G[1001];
int N,M;
vector<int>vis;
bool used[1001];
void dfs(int u)
{
	vis.push_back(u);
	used[u]=true;
	for(int v:G[u])
	{
		if(vis[0]==v)
		{
			if(ans.empty()||ans.size()>vis.size())ans=vis;
		}
		else if(!used[v])dfs(v);
	}
	vis.pop_back();
}
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int u,v;cin>>u>>v;
		G[u].push_back(v);
	}
	for(int i=0;i++<N;)
	{
		for(int j=0;j++<N;)used[j]=false;
		dfs(i);
	}
	cout<<(ans.empty()?-1:-9)<<endl;
}

Measured memory_bytes: 384
while True:
    re=input()
    if re=="0":
        break
    Are,Bre=0,0
    for i in range(1,len(re)):
        if re[i]=="A":
            Are+=1
        else :
            Bre+=1
    if Are>Bre:
        Are+=1
    else :
        Bre+=1
    print(Are,Bre)


Measured memory_bytes: 5556
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int[][] dp;
        char[][] map;
        while(scan.hasNext()){
            int h = scan.nextInt();
            int w = scan.nextInt();
            map = new char[h][];
            for(int i = 0;i < h;i++){
            	map[i] = scan.next().toCharArray();
            }
            dp = new int[h+1][w+1];
            for(int i = 1;i <= h;i++){
            	for(int j = 1;j <= w;j++){
            		if(i == 1){
            			dp[i][j] = dp[i][j-1] + (map[i-1][j-1] - '0');
            		}else if(j == 1){
            			dp[i][j] = dp[i-1][j] + (map[i-1][j-1] - '0');
            		}else{
            			dp[i][j] = minimum(dp[i-1][j],dp[i][j-1]) + (map[i-1][j-1] - '0');
            		}
            	}
            }
            System.out.println(dp[h][w]);
        }
    }
    public static int minimum(int a,int b){
        return (a > b)?b:a;
    }
}

Measured memory_bytes: 17392
from collections import Counter

n = int(input())
a = list(map(int, input().split()))

# new = [key for key, val in Counter(a).most_common() if val == 1]
prime = [1] * 1000010

for i in set(a):
    # if prime[i]:
    for j in range(i + i, 1000001, i):
        prime[j] = 0

c = Counter(a)
ans = 0
for i in a:
    if prime[i] and c[i] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 47488
using System;
     
    class GoodInteger {
        static void Main(string[] args)
        {
            var num = Console.ReadLine();
     
            if(num[1] == num[2])
            {
                if(num[0] == num[1] || num[2] == num[3])
                {
                    Console.WriteLine("Yes");
                    return;
                }
     
            }
     
            Console.WriteLine("No");
     
            return;
        }
     
    }

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long int a,b,c,d,e;
    int i;
    long long int count=2e9;
    long long int n;
    std::cin >> n;
    std::cin >>a ;
    std::cin >>b ;
    std::cin >>c ;
    std::cin >>d;
    std::cin >>e ;
    count=min({a,b,c,d,e});
    std::cout <<((n-1)/count)+5 << std::endl;
    }

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
Q = int(input())
B_to_C = []
for i in range(Q):
  B_to_C.append([int(x) for x in input().split()])

dict_A = {}
sums = 0

for a in A:
  if a in dict_A:
    dict_A[a] += 1
  else:
    dict_A[a] = 1
    
for k, v in dict_A.items():
  sums += k*v
  
for B, C in B_to_C:
  if B in dict_A:
    count_of_num = dict_A[B]
    if C in dict_A:
      dict_A[C] += dict_A[B]
      del dict_A[B]
    else:
      dict_A[C] = dict_A[B]
      del dict_A[B]
      
    sums = sums - B*count_of_num + C*count_of_num
    print(sums)
    
  else:
    print(sums)

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  int flag = 1;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += a.at(i) * flag;
    flag *= -1;
  }
  cout << ans << endl;
  
  
}


Measured memory_bytes: 256
n=int(input())
a=[int(input()) for _ in range(n)]+[0]
ans=0
for i in range(n):
	ans+=a[i]//2
	a[i]=a[i]%2
	ans+=min(a[i],a[i+1])
	a[i+1]-=min(a[i],a[i+1])
print(ans)

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

int main() {
    string s; cin >> s;
    int n = s.size();
    int ans = n;
    rep(i, 26){
        char a = 'a' + i;
        int ma = 0;
        int now = 0;
        rep(j, n){
            if(s[j] != a){
                now++;
            } else {
                ma = max(ma, now);
                now = 0;
            }
            if(j == n-1){
                ma = max(ma, now);
            }
        }
        ans = min(ans, ma);
    }

    cout << ans << endl;

    return 0;
}

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

int w,h,ret;
char mp[20][20];

void rec(int y,int x){
	if(mp[y][x]=='#')return;
	ret++;
	mp[y][x]='#';
	if(x+1<w)rec(y,x+1);
	if(y+1<h)rec(y+1,x);
	if(x-1>=0)rec(y,x-1);
	if(y-1>=0)rec(y-1,x);
}

int main(){
	int x,y;
	while(cin >> w >> h && w && h){
		ret = 0;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cin >> mp[i][j];
				if(mp[i][j]=='@'){
					y = i;
					x = j;
				}
			}
		}
		rec(y,x);
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 0
char buf[10000],out[20000];
char r[10];
sz;outsz;
main()
{
	read(0,buf,10000);
	while(buf[sz++]>='0');
	while(buf[sz]>='0')
	{
		int N=0,D=0;
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			N=N*10+k-'0';
		}
		for(;;)
		{
			char k=buf[sz++];
			if(k<'0')break;
			D=D*10+k-'0';
		}
		int ans=N&1?127*--N+D:127*N-D;
		int ri=10;
		do{
			r[--ri]=ans%10+'0';
		}while(ans/=10);
		while(ri<10)out[outsz++]=r[ri++];
		out[outsz++]='\n';
	}
	write(1,out,outsz);
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;

namespace AtCoder
{
    class Pair
    {
        public int num;
        public int count;
    }

    class Program
    {
        static void Main()
        {
            //ここから

            int[] str = ReadLineToIntArray();
            int a = str[0];
            int b = str[1];
            int c = str[2];

            int ans = 0;

            int max =Math.Max(c, Math.Max(a, b));
            if (max == a)
            {
                ans = a * 10 + b + c;
            }else if (max == b)
            {
                ans = b * 10 + a + c;
            }else if (max == c)
            {
                ans = c * 10 + a + b;
            }

            //ここまで
            Console.WriteLine(ans);
            Console.ReadKey();
        }

        long mod = 1000000007;
        static public void Swap<T>(ref T a,ref T b) { T temp = a;a = b;b = temp; }
        static public long GCD(int a, int b){ return b != 0 ? GCD(b, a % b) : a;}
        static public long LCM(int a, int b){ return (long)a * b / GCD(a, b); }
        static public int Factorial(int a) { return a == 1 ? a : a * Factorial(a - 1); }
        static public int Conbin(int n,int m) { return Factorial(n) / (Factorial(n - m) * Factorial(m)); }


        
        static public string ReadLineToString(){return Console.ReadLine();}
        static public int ReadLineToInt(){return int.Parse(Console.ReadLine());}
        static public long ReadLineToLong() { return long.Parse(Console.ReadLine()); }
        static public string[] ReadLineToStringArray(){return Console.ReadLine().Split(' ').ToArray();}
        static public int[] ReadLineToIntArray(){return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();}
        static public long[] ReadLineToLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<string> ReadLineToStringList(){return Console.ReadLine().Split(' ').ToList();}
        static public List<int> ReadLineToIntList(){return Console.ReadLine().Split(' ').Select(int.Parse).ToList();}
        static public List<long> ReadLineToLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
    }
    
}


Measured memory_bytes: 13268
#include<stdio.h>
#pragma GCC optimize("O2")
static inline int comp(const int a,const int b,int desc){return a<b?(!desc?a:b):(!desc?b:a);}
int main(void)
{
  int N,i=scanf("%d",&N)-1,u,v;long x=1l*N*(N+1)*(N+2)/6;
  while(i<N-1){i+=scanf("%d %d",&u,&v)>>1;x=x-1l*comp(u,v,0)*(N-comp(u,v,1)+1);}
  return printf("%ld",x),0;
}

Measured memory_bytes: 1684
def main_v2():
    N = int(input())
    f_list = [0 for _ in range(N)]

    for x in range(1, 101):
        for y in range(1, 101):
            for z in range(1, 101):
                ans = x*x + y*y + z*z + x*y + y*z + z*x
                if ans <= N:
                    f_list[ans - 1] += 1

    for i in range(N):
        print(f_list[i])


if __name__ == "__main__":
    main_v2()


Measured memory_bytes: 9256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
const int MOD = 1000000007;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    rep(i,4){
        if (s.at(i) == '+'){
            ans++;
        }
        else {
            ans--;
        }
    }
    cout << ans << endl;
}

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

namespace AtCoder
{
    class ABC141
    {
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }

        static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        static double ReadDouble()
        {
            return double.Parse(Console.ReadLine());
        }

        static double[] ReadDoubles()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }

        static string ReadString()
        {
            return Console.ReadLine();
        }

        static string[] ReadStringSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        static void A()
        {
            var s = ReadString();
            switch (s)
            {
                case "Sunny":
                    Console.WriteLine("Cloudy");
                    break;
                case "Cloudy":
                    Console.WriteLine("Rainy");
                    break;
                case "Rainy":
                    Console.WriteLine("Sunny");
                    break;
            }
        }

        static void B()
        {
            var S = ReadString();
            for (int i = 0; i < S.Length; ++i)
            {
                if (i % 2 == 0)
                {
                    if (S[i] == 'L')
                    {
                        Console.WriteLine("No");
                        return;
                    }
                }
                else
                {
                    if (S[i] == 'R')
                    {
                        Console.WriteLine("No");
                        return;
                    }

                }
            }
            Console.WriteLine("Yes");
        }

        static void C()
        {

        }

        static void D()
        {

        }

        static void Main(string[] args)
        {
            //A();
            B();
            //C();
            //D();
        }
    }
}


Measured memory_bytes: 25712
#include<stdio.h>

int main(){
  int a,b,ans=0;
  scanf("%d%d",&a,&b);
  if(a>b){
    ans=2*a-1;
  }else if(b>a){
    ans=2*b-1;
  }else{
    ans=a+b;
  }
  printf("%d",ans);

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    cout << N * N * N << endl;
}

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

int q;
int A[10];
int a[50], b[50], c[50], d[50];

int solve(int i, int m, int minA, int n)
{
    if (i == n)
    {
        int ans = 0;
        for (int j = 0; j < q; j++)
        {
            if (A[b[j] - 1] - A[a[j] - 1] == c[j])
                ans += d[j];
        }
        /*
        for (int j = 0; j < n; j++)
            cout << A[j];
        */
        //cout << endl;
        return ans;
    }

    int ans = 0;
    for (int j = minA; j <= m; j++)
    {
        A[i] = j;
        ans = max(ans, solve(i + 1, m, j, n));
    }
    return ans;
}

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

    for (int i = 0; i < q; i++)
        cin >> a[i] >> b[i] >> c[i] >> d[i];

    int ans = solve(0, m, 1, n);

    cout << ans << endl;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";

signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int n, x, t;
	cin >> n >> x >> t;
	cout << ((n + x - 1) / x) * t ;
	
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<string>
#include<tuple>
#include<algorithm>

using namespace std;

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

    int lf, rf;
    cin >> lf >> rf;

    for(int i=0; i<m-1; i++)
    {        
        int l, r;
        cin >> l >> r;
        if(lf < l)
        {
            lf = l;
        }
        if(rf > r)
        {
            rf = r;
        }
    }
    if(rf -lf >= 0)
    {
        if(rf <= n)
        {
            cout << rf-lf+1 << endl;
        }else{
            cout << n-lf+1 << endl;
        }
    }else{
        cout << "0" << endl;
    }
}

Measured memory_bytes: 256
IDENTIFICATION                   DIVISION.
PROGRAM-ID.                      ABC_095_A.
ENVIRONMENT                      DIVISION.
DATA                             DIVISION.
WORKING-STORAGE                  SECTION.
    01 INP    PIC X(10).
    01 K      PIC 9(2).

    01 maxlen PIC 9(1)  VALUE 3.

    01 i      PIC 9(18) VALUE 1.
    01 j      PIC 9(18).
    01 len    PIC 9(2)  VALUE 1.

    01 x      PIC 9(4).

    01 ans    PIC X(4).
    01 ZS     PIC Z(5).
    01 S1.
        03 S11 OCCURS 3.
            05 S PIC X(1).

    01 DUMMY  PIC X(1).

PROCEDURE                        DIVISION.
MAIN.
    ACCEPT INP.

    PERFORM maxlen TIMES

        MOVE INP(i:len) TO S11(i)

        ADD 1 TO i

    END-PERFORM.

    MOVE 700 TO x.
    PERFORM VARYING j FROM 1 BY 1 UNTIL 3 < j
        IF S(j) = 'o' THEN
           ADD 100 TO x
        END-IF
    END-PERFORM.

    MOVE x TO ZS.

    PERFORM UNANS.

    DISPLAY ans(1:FUNCTION STORED-CHAR-LENGTH(ans)).
    STOP RUN.

UNANS                            SECTION.
    UNSTRING
        ZS DELIMITED BY ALL SPACE
        INTO DUMMY ans
    END-UNSTRING.


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

class BinaryIndexedTree
{
private:
    int n;
    vector<int> data;
public:
    BinaryIndexedTree(int n){ // ?????????????????????
        this->n = n;
        data.assign(n+1, 0);
    }
    void add(int k, int x){ // k?????????????´????x???????????????
        ++ k;
        while(k <= n){
            data[k] += x;
            k += k & -k;
        }
    }
    int sum(int k){ // ??????[0,k]??????????????????
        ++ k;
        int ret = 0;
        while(k > 0){
            ret += data[k];
            k -= k & -k;
        }
        return ret;
    }
    int sum(int a, int b){ // ??????[a,b]??????????????????
        return sum(b) - sum(a-1);
    }
};

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    vector<vector<int> > index(128);
    for(int i=0; i<n; ++i)
        index[s[i]].push_back(i);

    vector<int> a(128);
    for(char c='a'; c<='z'; ++c){
        if(index[c].size() % 2 != 0){
            cout << -1 << endl;
            return 0;
        }
        a[c] = index[c].size() - 1;
    }

    BinaryIndexedTree bit(n);
    for(int i=0; i<n; ++i)
        bit.add(i, 1);

    long long ans = 0;
    for(int i=0; i<n; ++i){
        if(index[s[i]][a[s[i]]] < i)
            continue;
        ans += bit.sum(index[s[i]][a[s[i]]] + 1, n - 1);
        bit.add(index[s[i]][a[s[i]]], -1);
        -- a[s[i]];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7004
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	var a int
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		if a%2 == 0 && a%3 != 0 && a%5 != 0 {
			fmt.Println("DENIED")
			return
		}
	}
	fmt.Println("APPROVED")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using st=string;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
st abc="abcdefghijklmnopqrstuvwxyz";
st ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  ll H,W;
  cin >> H >> W;
  vvc s(H,vc(W));
  rep(i,H){
    rep(j,W){
      cin >> s[i][j];
    }
  }
  vvl a(H,vl(W)),b(H,vl(W));
  rep(i,H){
    rep(j,W){
      ll cnt=0;
      if(s[i][j]=='#'){
        a[i][j]=0;
      }
      else{
        if(j==0||(j!=0&&s[i][j-1]=='#')){
          cnt=0;
          ll nj=j;
          while(nj<W&&s[i][nj]=='.'){
            cnt++;
            nj++;
          }
          a[i][j]=cnt;
        }
        else{
          a[i][j]=a[i][j-1];
        }
      }
    }
  }
  rep(j,W){
    rep(i,H){
      ll cnt=0;
      if(s[i][j]=='#'){
        b[i][j]=0;
      }
      else{
        if(i==0||(i!=0&&s[i-1][j]=='#')){
          cnt=0;
          ll ni=i;
          while(ni<H&&s[ni][j]=='.'){
            cnt++;
            ni++;
          }
          b[i][j]=cnt;
        }
        else{
          b[i][j]=b[i-1][j];
        }
      }
    }
  }
  ll ans=0;
  rep(i,H){
    rep(j,W){
      if(s[i][j]=='.'){
        ans=max(ans,a[i][j]+b[i][j]-1);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 66944