akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
  int A,B;
  cin >> A >> B;
  if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
    cout << "Possible" << endl;
  }
  else {
    cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    vector<int> x(N);
    vector<int> y(M);

    rep(i, N) cin >> x[i];
    rep(i, M) cin >> y[i];

    int a = -100;
    int b = 100;

    rep(i, N) if (x[i] > a) { a = x[i]; }
    rep(i, M) if (y[i] < b) { b = y[i]; }

    if(a<X || b-a<0 || b>=Y) { cout << "War" << endl; goto xyz; }

    rep(i, N) {
        if (x[i] >= b) { cout << "War" << endl; goto xyz; }
    }

    cout << "No War" <<endl;

xyz:;
}

Measured memory_bytes: 256
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

//ABC123C
int main(void) {
  int i;
  long long n, abc[5], min=1e15;
  scanf("%lld", &n);
  for(i=0; i<5; i++){
    scanf("%lld", &abc[i]);
    min=min>abc[i] ? abc[i] : min;
  }
  printf("%lld", 5+(n-1)/min);
}

Measured memory_bytes: 128
#include <cstdio>
#include <map>
#include <iostream>
#include <string> 
#include <algorithm>

using namespace std;
map<string,int> A;
map<string,int>::iterator it;
int main(){
int n;
	while(cin >> n){
		
		for(int i = 1;i <= n;i++){
			string s;
			cin >> s;
			A[s]++;
		}
		cin >> n;
		int ans = 0;
		for(int i = 1;i <= n;i++){
			string t;
			cin >> t;
			A[t]--;
		}
		for(it = A.begin();it != A.end();it++){
			int t = it -> second;
			ans = max(ans,t);
		}
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 256
<?php

class Answer
{
    public $n;
    public $A = array();

    public function __construct()
    {
        $this->n = trim(fgets(STDIN));
        // for ($i = 0; $i < $this->n; ++$i) {
        //     $this->A[] = trim(fgets(STDIN));
        // }
        ini_set('memory_limit', '-1');
        for ($i = 0; $i < $this->n; ++$i) {
            fscanf(STDIN, '%d', $d);
            $this->A[] = $d;
        }
    }

    public function showAnswer()
    {
        list($m, $gi, $cnt, $array) = $this->shellSort($this->A, $this->n);

        // m (number of Gi)
        echo $m."\n";
        // Gi
        echo join(' ', $gi)."\n";
        // cnt
        echo $cnt."\n";
        // sorted array
        for ($i = 0; $i < count($array); ++$i) {
            echo trim($array[$i])."\n";
        }
    }

    public function insertionSort($A, $n, $g, &$cnt)
    {
        for ($i = $g; $i < $n; ++$i) {
            $v = $A[$i];
            $j = $i - $g;
            while ($j >= 0 and $A[$j] > $v) {
                $A[$j + $g] = $A[$j];
                $j = $j - $g;
                ++$cnt;
            }
            $A[$j + $g] = $v;
        }

        return $A;
    }

    public function shellSort($A, $n)
    {
        $cnt = 0;
        $G = array();
        for ($i = 1; $i <= $n; $i = 3 * $i + 1) {
            $G[] = $i;
        }
        $G = array_reverse($G);

        for ($i = 0; $i < count($G); ++$i) {
            $A = $this->insertionSort($A, $n, $G[$i], $cnt);
        }

        return array(count($G), $G, $cnt, $A);
    }
}

$A = new Answer();
$result = $A->showAnswer();



Measured memory_bytes: 343444
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;

int d[51][51];

int main(){
    int tc;
    cin >> tc;
    rep(ij, 0, tc){
        int h, w;
        cin >> h >> w;
        vector<string> s(h);
        rep(i, 0, h){
            cin >> s[i];
        } 
        map<char, int> mp;
        int n = 0;
        rep(i, 0, h){
            rep(j, 0, w){
                if(s[i][j] == '.') continue;
                if(!mp.count(s[i][j])){
                    mp[s[i][j]] = n++;
                }
            }
        }
        vector<int> yMIN(n, INF), yMAX(n, -1), xMIN(n, INF), xMAX(n, -1);        
        rep(i, 0, h){
            rep(j, 0, w){
                if(s[i][j] == '.') d[i][j] = -1;
                else{
                    d[i][j] = mp[s[i][j]]; 
                    chmin(yMIN[d[i][j]], i);
                    chmax(yMAX[d[i][j]], i);
                    chmin(xMIN[d[i][j]], j);
                    chmax(xMAX[d[i][j]], j);
                }
            }
        }
        bool f = true;
        bool isPut[10][10] = {};
        rep(i, 0, n){
            rep(j, yMIN[i], yMAX[i] + 1){
                rep(k, xMIN[i], xMAX[i] + 1){
                    if(d[j][k] != i){
                        if(d[j][k] == -1) f = false;
                        else{
                            isPut[d[j][k]][i] = true;
                        }
                    }
                }
            }
        }
        if(!f){
            cout << "SUSPICIOUS" << endl;
            continue;
        }
        f = false;
        vector<int> p(n);
        rep(i, 0, n) p[i] = i;
        do{
            bool g = true;
            rep(i, 0, n){
                rep(j, 0, n){
                    if(isPut[i][j]){
                        if(p[i] < p[j]) g = false;
                    }
                }
            }
            if(g) f = true;
            // for(int ii = 0; ii < p.size(); ii++){
            //     if(ii) cout << ' ';
            //     cout << p[ii];
            // }
            // cout << endl;
        }while(next_permutation(p.begin(), p.end()));
        if(f){
            cout << "SAFE" << endl;
        }else{
            cout << "SUSPICIOUS" << endl;
        }
    }
}   


Measured memory_bytes: 3072
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
//#include <random>
//#include <unordered_set>
#include <complex>
using namespace std;
int main()
{
    int n;
    cin>>n;
    cout<<(n*800)-((n/15)*200);
    system ("pause"); 
    return 0;
}

Measured memory_bytes: 504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
//		int[] array = new int[N];
		int result = 0;
		for (int i = 0; i < N; i++) {
			int value = sc.nextInt();
			if (i + 1 == value) {
//				array[i] = sc.nextInt();
//				array[i++] = value;
				if (i + 1 != N) {
					sc.nextInt();
					i++;
				}
				result++;
			}
		}
		sc.close();
		System.out.println(result);
	}
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

ll s[2][100001];
int a[2], q;
ll mn(ll x, int p) {
	int i = lower_bound(s[p],s[p]+a[p], x) - s[p];
	ll ans = 1e18;
	if(i>0) ans = min(ans, abs(x-s[p][i-1]));
	if(i<a[p]) ans = min(ans, abs(x-s[p][i]));
	return ans;
}
int main()
{
	cin >> a[0] >> a[1] >> q;

	for(int i = 0; i < a[0]; i++) cin >> s[0][i];
	for(int i = 0; i < a[1]; i++) cin >> s[1][i];
	for(int i = 0; i <q; i++){
		ll x;
		cin >> x;
		ll ans = 1e18;
		for(int p = 0; p < 2; p++){
			int j = lower_bound(s[p],s[p]+a[p], x)-s[p];
			if(j > 0) ans =min(ans, abs(x-s[p][j-1]) +mn(s[p][j-1],p^1));
			if(j < a[p]) ans =min(ans, abs(x-s[p][j]) +mn(s[p][j],p^1));
		}
		cout << ans << endl;
	}

}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
// ==================================================
using i64 = int64_t; using u64 = uint64_t;
#define rep(i,a,b) for(i64 i=(int64_t)(a);i<(int64_t)(b);i++)
#define repn(i,n) rep(i,0,n)
#define din(t, ...) t __VA_ARGS__;_din(__VA_ARGS__)
#define stlv(t,n) vector<t> n
#define stls(t,n) set<t> n
void _din() {} void dout() { cout << endl; }
template <typename T, typename ... Args> inline void _din(T& head, Args& ... rest) { cin >> head; _din(rest...); }
template <typename T, typename ... Args> inline void dout(T head, Args ... rest) { cout << head; if (sizeof...(rest)) cout << ' '; dout(rest...); }
template <typename T>inline void vsortg(vector<T>& v) { sort(v.begin(), v.end(), greater<T>()); }
template <typename T>inline void vsortl(vector<T>& v) { sort(v.begin(), v.end(), less<T>()); }
template <typename T> inline T nmax(T f1, T f2) { return max(f1, f2); }
template <typename T, typename ... Args> inline T nmax(T first, Args ... rest) { return nmax(first, nmax(rest...)); }
template <typename T> inline T nmin(T f1, T f2) { return min(f1, f2); }
template <typename T, typename ... Args> inline T nmin(T first, Args ... rest) { return nmin(first, nmin(rest...)); }
// ==================================================
using p = pair<int, bool>;
bool comp(const p& a, const p& b)
{
	return a.first < b.first;
}
int main()
{
	din(int, n);
	if (n == 1)
	{
		din(int, h);
		dout(h);
		return 0;
	}
	stlv(p, m);
	int l = -1;
	bool ckv = false;
	stlv(int, m0);
	repn(i, n)
	{
		din(int, t);
		int mm = (int)m0.size();
		if (mm > 0 && t == m0[mm - 1]) continue;
		m0.push_back(t);
	}
	n = (int)m0.size();
	repn(i, n)
	{
		int now = m0[i];
		if (i == n - 1 && now > l)
		{
			m.push_back(make_pair(now, true));
		}
		if (i == 1 && now < l)
		{
			m.push_back(make_pair(l, true));
			ckv = true;
		}
		else if (ckv && now > l)
		{
			m.push_back(make_pair(l, false));
			ckv = !ckv;
		}
		else if (!ckv && now < l)
		{
			m.push_back(make_pair(l, true));
			ckv = !ckv;
		}
		l = now;
	}
	sort(m.begin(), m.end(), comp);
	int x = 0, d = 1;
	l = 0;
	for (auto i : m)
	{
		x += d * (i.first - l);
		l = i.first;
		if (i.second) d--;
		else d++;
	}
	dout(x);
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

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

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

	vector<ll> A(N);
	rep(i, N)
	{
		cin >> A[i];
	}

	sort(A.begin(), A.end(), greater<ll>());

	ll ans = 0;
	int count = 1;
	int j = 0;
	rep(i, N-1)
	{
		ans += A[j];

		++count;
		if (count == 2)
		{
			count = 0;
			++j;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 4840
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,st,num)for(int i=(st);i<(num);++i)
#define ll long long
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int N,A;
    ll ans=0;
    cin>>N;
    REP(i,0,N) {
        cin>>A;
        ans+=(A-1);
    }
    cout<<ans;

    return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

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

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

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


void Main() {
	int K; string S; cin >> K >> S;
	if ((int)S.size() <= K) {
		cout << S << endl;
	} else {
		cout << S.substr(0, K) << "..." << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<algorithm>
using namespace std;
int b[110];
int c[110];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%d",b+i);
	}
	int z=0;
	int y=0;
	for(int i=0;i<a;i++)if(!b[i])z++;
	for(int i=0;i<a;i++)if(b[i]==1)y++;
	if(z%2==0||y){
		int n=0;
		for(int i=0;i<a;i++)if(b[i]>1)c[n++]=b[i];
		std::sort(c,c+n);
		if(c[n-2]==2&&c[n-1]==3)swap(c[n-2],c[n-1]);
		for(int i=0;i<n;i++)printf("%d\n",c[i]);
		if(z%2==0){
			for(int i=0;i<a;i++)if(b[i]==0)printf("0\n");
			for(int i=0;i<a;i++)if(b[i]==1)printf("1\n");
		}else{
			for(int i=0;i<z-1;i++)printf("0\n");
			printf("1\n0\n");
			for(int i=0;i<y-1;i++)printf("1\n");
		}
		return 0;
	}
	int n=0;
	for(int i=0;i<a;i++)if(b[i]>1)c[n++]=b[i];
	std::sort(c,c+n);
	if(n<=1){
		if(z%2==0){
			std::sort(b,b+a);for(int i=0;i<a;i++)printf("%d\n",b[i]);
		}else if(y){
			for(int i=0;i<z-1;i++)printf("0\n");
			printf("1\n");
			printf("0\n");
			for(int i=0;i<y-1;i++)printf("1\n");
			if(n)printf("%d\n",c[0]);
		}else if(n){
			for(int i=0;i<z-1;i++)printf("0\n");
			printf("%d\n",c[0]);
			printf("0\n");
		}else{
			std::sort(b,b+a);for(int i=0;i<a;i++)printf("%d\n",b[i]);
		}
		return 0;
	}
	if(n>2&&c[n-2]==2&&c[n-1]==3)swap(c[n-2],c[n-1]);
	for(int i=1;i<n;i++)printf("%d\n",c[i]);
	for(int i=0;i<z-1;i++)printf("0\n");
	printf("%d\n",c[0]);
	printf("0\n");
}

Measured memory_bytes: 1056
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
using namespace std;

long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long H, W; cin >> H >> W;
	char a[1000][1000]; for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> a[i][j];
	long isallw[1000] = {};//係数H。


	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			//a[i][j]において
			if (a[i][j] == '.') {
			for (int h = 0; h < H; h++) if (a[h][j] == '#') {goto koko;}
             a[i][j] = 'c' ; continue;
             koko:;
			for (int w = 0; w < W; w++) if (a[i][w] == '#') {;goto soko;}
             a[i][j] = 'c' ; continue;
             soko:;
            }
        }
	}

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++) if(a[i][j] != 'c') isallw[i] = 1;
    }    
   
	for (int i = 0; i < H; i++) {
		if (isallw[i] == 0) continue;
		for (int j = 0; j < W; j++) if (a[i][j] != 'c') cout << a[i][j];
		cout << endl;
	}

}

Measured memory_bytes: 384
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    int o = (n+1)/2;
    cout << (double)o/(double)n << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	string a,b;
	cin>>a>>b;
	reverse(b.begin(),b.end());
	if(a==b)
		print("YES");
	else
		print("NO");
	return 0;
}



Measured memory_bytes: 764
//ABC 128 D enque

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

typedef long long ll;
ll n,k,v[55];

ll solve(ll l,ll r)
{
   vector<ll> t;
   
   for(int i=0;i<=l;i++)    
      t.push_back(v[i]);
   
   for(int i=r;i<n;i++)
      t.push_back(v[i]);
   
   sort(t.begin(),t.end());    
                              
   
   ll lim=k-t.size();          
   if(lim<0)return 0;        
   
   ll sum=0;
   for(int i=0;i<t.size();i++){
      if(t[i]<0&&lim>0){     
         lim--;
      }else                 
	     sum+=t[i];
   }
   
   return sum;
}

int main()
{
   cin>>n>>k;
   
   for(int i=0;i<n;i++)  cin>>v[i];
   
   ll ans=0;
   
   for(int i=-1;i<n;i++)
     for(int j=i+1;j<=n;j++){
        ans=max(ans,solve(i,j));
     }
   
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a[10],b[3],i;
	for(i=0;i<3;i++)a[i]=0;
	for(i=0;i<10;i++)scanf("%d",&a[i]);
	for(i=0;i<10;i++){
		if(a[i]>b[0]){
			b[2]=b[1];
			b[1]=b[0];
			b[0]=a[i];}
		else if(a[i]>b[1]){
			b[2]=b[1];
			b[1]=a[i];}
		else if(a[i]>b[2])b[2]=a[i];
	}
	printf("%d\n%d\n%d\n",b[0],b[1],b[2]);
	return 0;
}

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

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

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

int main() {
 
    long long A, B,C,D;
    cin >> A >> B>>C>>D;    
    long long G = gcd(D, C);    
    long long L = D / G * C;    
      cout<< B-A+1-((B/C-(A-1)/C)+(B/D-(A-1)/D)-(B/L-(A-1)/L))<<endl;
 
 
 
}

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(), b = sc.nextInt();
        if(b % a == 0) {
            System.out.println(a + b);
        } else {
            System.out.println(b - a);
        }
    }
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>

using namespace std;

int calc_score(int D, const vector<int>& c, const vector<vector<int>>& s, const vector<int>& last, int d, int t)
{
	int v = s[d][t];
	for (int i = 0; i < 26; ++i) {
		if (i != t) {
			v -= c[i] * (d + 1 - last[i]);
		}
	}
	return v;
}

int simulate(int D, const vector<int>& c, const vector<vector<int>>& s, int t0, int t1)
{
	int score_total = 0;
	int v = 0;
	vector<int> last(26, 0);
	vector<int> t(D, -1);
	t[0] = t0;
	t[1] = t1;

	for (int d = 0; d < 2; ++d) {
		v += calc_score(D, c, s, last, d, t[d]);
		last[t0] = 1;

		score_total += max(1000 * 1000 + v, 0);
	}

	for (int d = 2; d < D; ++d) {
		int score_max = numeric_limits<int>::min();
		for (int k = 0; k < 26; ++k) {
			int score = calc_score(D, c, s, last, d, k);
			if (score_max < score) {
				score_max = score;
				t[d] = k;
			}
		}
		v += score_max;
		last[t[d]] = d + 1;

		score_total += max(1000 * 1000 + v, 0);
	}
	return score_total;
}

int main()
{
	int D;
	cin >> D;
	vector<int> c(26);
	for (auto& x : c) {
		cin >> x;
	}
	vector<vector<int>> s(D, vector<int>(26));
	for (auto& v : s) {
		for (auto& x : v) {
			cin >> x;
		}
	}

	vector<int> last(26, 0);
	vector<int> t(D, -1);

	int v = 0;

	for (int d = 0; d < D - 2; ++d) {
		int score_max = numeric_limits<int>::min();
		for (int k = 0; k < 26; ++k) {
			int score = calc_score(D, c, s, last, d, k);
			if (score_max < score) {
				score_max = score;
				t[d] = k;
			}
		}
		v += score_max;
		last[t[d]] = d + 1;
	}

	int score_max = numeric_limits<int>::min();

	for (int t0 = 0; t0 < 26; ++t0) {
		for (int t1 = 0; t1 < 26; ++t1) {
			int score1 = calc_score(D, c, s, last, D - 2, t0);
			last[t0] = D - 1;
			int score2 = calc_score(D, c, s, last, D - 1, t1);
			last[t1] = D;

			if (score_max < score1 + score2) {
				score_max = score1 + score2;
				t[D - 2] = t0;
				t[D - 1] = t1;
			}
		}
	}

	for (auto x : t) {
		cout << x + 1 << endl;
	}
}


Measured memory_bytes: 3676
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        int n = sc.nextInt();
        int r=n;
        int[] array=new int[n];
        for(int i=0;i<n;++i){
            array[i] = sc.nextInt();
        }
        for(int i=n-1;i>0;--i){
            for(int j=i-1;j>=0;--j){
                if(array[j]>array[i]) {
                    r--;
                    break;
                }
            }
        }
        // 出力
        System.out.println(r);
    }
}


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

int main(){
    long long n;
    cin>>n;
    for(long long i=1;i<=3500;i++)for(long long j=i;j<=3500;j++){
        if(4*i*j-n*i-n*j>0 && (n*i*j)%(4*i*j-n*i-n*j)==0 ){
            cout<<i<<" "<<j<<" "<<(n*i*j)/(4*i*j-n*i-n*j)<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l=[0]*(n+1)
p=0
for _ in range(m):
  a,b=list(input().split())
  if str(b)=="AC" and l[int(a)]!=-1:
    p+=l[int(a)]
    l[int(a)]=-1
  elif str(b)=="WA" and l[int(a)]!=-1:
    l[int(a)]+=1
print(l.count(-1),p)

Measured memory_bytes: 51664
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()
#pragma endregion

vector<pair<ll, ll>> prime_factorization(ll x)
{
	vector<pair<ll, ll>> res;
	for (ll i = 2; i*i <= x; ++i)
	{
		if (x%i != 0)continue;

		ll num = 0;
		while (x%i == 0)
		{
			++num;
			x /= i;
		}
		res.push_back({ i,num });
	}
	if (x != 1)res.push_back({ x,1 });
	return res;
}

#pragma region GCD
ll gcd(ll a, ll b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion


int main()
{
	ll a, b; cin >> a >> b;
	ll c = gcd(a, b);
	cout << prime_factorization(c).size() + 1 << endl;
}

Measured memory_bytes: 256
#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=100005;
int n,ans;
int a[maxn],dp[maxn];

int main()
{
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i]);
	sort(a,a+n);
	ll cur=0;
	rep(i,n-1)
	{
		cur+=(ll)a[i];
		if((ll)a[i+1]>cur*2)ans=i+1;
	}
	printf("%d",n-ans);
	return 0;
}

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

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

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)
#define MOD 1000000007

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

ll N, M, Q;
vll a, b, c, d;

ll calc_score(vll& A){
  ll res = 0;
  rep(q, Q){
    if(A[b[q]-1] - A[a[q]-1] == c[q])
      res += d[q];
  }
  return res;
}

ll max_score(vll A, ll n){
  A.push_back(n);
  if(A.size() == N) return calc_score(A);
  else{
    ll res = -1, tmp;
    repi(i, n, M+1){
      tmp = max_score(A, i);
      if(tmp > res) res = tmp;
    }
    return res;
  }
}

int main(){
  ll a_, b_, c_, d_;
  cin >> N >> M >> Q;
  rep(i, Q){
    cin >> a_ >> b_ >> c_ >> d_;
    a.push_back(a_);
    b.push_back(b_);
    c.push_back(c_);
    d.push_back(d_);
  }
  vll A;
  cout << max_score(A, 1) << endl;
  return 0;
}



Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=1;i<n;i++)a[i]+=a[i-1];
  int mx=1000000000;
  for(int i=0;i<n-1;i++)mx=min(mx,abs(a[i]-(a[n-1]-a[i])));  
                           
                           cout<<mx;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;
int main()
{
	int n;
	cin >> n;
	int* p = new int[n];

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

	int count = 0;
	for (int i = 1; i < n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1])
			count++;
		else if (p[i + 1] < p[i] && p[i] < p[i - 1])
			count++;
	}

	cout << count;

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
 int a;
  int count = 0;
 cin >> a;
 vector<int> data(a);
  for(int i = 0;i<a;i++){
   cin >> data.at(i);
   if(i%2==0&&data.at(i)%2==1)count++;
  }
  cout << count << endl;
}


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

int main() {
  ll n;
  cin >> n;
  vector<pair<ll,ll>> k;
  rep(i,n){
    ll a,b;
    cin >> a >> b;
    k.push_back(make_pair(a+b,a-b));
  }
  sort(k.begin(),k.end());
  ll ans=1;
  pair<ll,ll> p=k[0];
  ll r=p.first;
  rep(i,n-1){
    int y=i+1;
    if(k[y].second<r)continue;
    ans++;
    r=k[y].first;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2420
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int main() {
  string s;
  cin >> s;
  bool result = s.size() >= 4 && s.substr(0, 4) == "YAKI";
  printf(result ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

import heapq

def solve():
    n, m = MI()
    A = LI()
    hp = []
    memo = {}
    for a in A:
        if memo.get(a, 0) == 0:
            hp.append(-a)
            memo[a] = 1
        else:
            memo[a] += 1
    # print(memo)
    heapq.heapify(hp)

    for i in range(m):
        b, c = MI()
        if memo.get(c, 0) == 0:
                heapq.heappush(hp, -c)
                memo[c] = b
        else:
            memo[c] += b

    # print(memo)
    ans = 0
    left = n
    while left > 0:
        val = - heapq.heappop(hp)
        t = memo[val]
        # print(val, t)
        ans += val * min(t, left)
        left -= t
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 37696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c =='o')
    cout << "vowel" << endl;
  
  else 
    cout << "consonant" << endl;
  
}

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


int main()
{
	int n;
	cin >> n;
	int a[n],b[n],c[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n-1; ++i)
	{
		cin >> c[i];
	}
	int res = 0;
	for (int i = 0; i < n; ++i)
	{
		if((i+1) != n && a[i+1] - a[i] == 1)
		{
			res += c[a[i]-1];
		}
		res += b[a[i]-1];
	}
	cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define MAX 1000001
ll prime[MAX];
long long mod;

ll rec(vector<vector<ll> >& dp,vector<ll>& arr,int n,int i,int k,int w)
{
  ll ans=0;
  if(i>=n)
    return 0;

  if(dp[i][k]!=-1)
    return dp[i][k];


  if(k!=0)
  ans=max(rec(dp,arr,n,i+1,w,w),arr[i]+rec(dp,arr,n,i+1,k-1,w));
  else
  ans=max(rec(dp,arr,n,i+1,k,w),rec(dp,arr,n,i+1,w,w));

  return dp[i][k]=ans;

}

ll t[400008];
void build(vector<ll>& a, int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v] = max(t[v*2] ,t[v*2+1]);
    }
}

ll maxi(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(maxi(v*2, tl, tm, l, min(r, tm)) ,maxi(v*2+1, tm+1, tr, max(l, tm+1), r));
}



void update(int v, int tl, int tr, int pos, ll new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2] ,t[v*2+1]);
    }
}

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

int a[n];

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

sort(a,a+n);

int ans=0;
for(int i=0;i<k;i++)
ans+=a[i];

cout<<ans;

return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A[100][100],B[100][100],dp[82][82][6482];

int main(){
  ll H,W;
  cin  >> H >> W;
  rep(i,H){
    rep(j,W){
      cin >> A[i+1][j+1];
    }
  }
  rep(i,H){
    rep(j,W){
      cin >> B[i+1][j+1];
      A[i+1][j+1]=abs(A[i+1][j+1]-B[i+1][j+1]);
    }
  }
  ll ma=INF;
  dp[1][1][0]=1;
  Rep(i,1,H+1){
    Rep(j,1,W+1){
      rep(k,6481){
        if(dp[i][j][k]==1){
          if(k+A[i][j]<=6480){
            dp[i+1][j][k+A[i][j]]=1;
            dp[i][j+1][k+A[i][j]]=1;
            if(i==H&&W==j){
              ma=min(ma,k+A[i][j]);
            }
          }
          dp[i+1][j][abs(k-A[i][j])]=1;
          dp[i][j+1][abs(k-A[i][j])]=1;
          if(i==H&&j==W){
            ma=min(ma,abs(k-A[i][j]));
          }
        }
      }
    }
  }
  cout << ma  <<  endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    string S;
    cin>>S;
    rep(i,3){
        if(S[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3628
//https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_A

#include <iostream>

void insertSort(int *A, int N)
{
    int v, j;
    for (int i = 0; i < N; i++)
    {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;

        for (int i = 0; i < N; i++)
        {
            if (i < N - 1)
                std::cout << A[i] << " ";
            else
                std ::cout << A[i] << std::endl;
        }
    }
}

int main()
{
    int N;
    std::cin >> N;
    int A[N] = {};
    for (int i = 0; i < N; i++)
        std::cin >> A[i];
    insertSort(A, N);
}



Measured memory_bytes: 3120
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val max = sc.nextInt() match {
    case 1 => 1
    case x =>
      (for {
        i <- 2.to(x).view
        j <- 2.to(x).view
      } yield math.pow(i, j).toInt).filter(_ <= x).max
  }
  println(max)
}


Measured memory_bytes: 57108
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
typedef pair<int,int>P;
typedef pair<int,P>P2;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};
 
signed main(){
	int n,m,sum=0,mod=1000000007;
	cin>>n>>m;
	int a[n+1],b[m+1];
	r(i,n)cin>>a[i+1];
	r(i,m)cin>>b[i+1];

	int dp[n+1][m+1]={};

	dp[0][0]=1;

	for(int i=1;i<=n;i++){
		int t=0;
		for(int j=0;j<=m;j++){
			if(a[i]==b[j]){
				dp[i][j]=t;
				dp[i][j]%=mod;
			}
			else{
				//dp[i][j]=t;
				//dp[i][j]%=mod;
			}
			t+=dp[i-1][j];
		}
		for(int j=0;j<=m;j++){
			dp[i][j]+=dp[i-1][j];
			dp[i][j]%=mod;
		}
	}
	r(i,m+1){
		sum+=dp[n][i];
		sum%=mod;
	}
	cout<<sum<<endl;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>N;
    cout<<(N/2)*((N+1)/2)<<endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

const long long MOD = 1000000007;

long long fact[1000000];
long long inv[1000000];
long long invfact[1000000];
void pre() {
    fact[0] = 1;
    inv[0] = 0;
    inv[1] = 1;
    invfact[0] = 1;
    loop(i, 1, 1000000) fact[i] = (i * fact[i - 1]) % MOD;
    loop(i, 2, 1000000) inv[i] = MOD - ((MOD / i) * inv[MOD % i] % MOD);
    loop(i, 1, 1000000) invfact[i] = (invfact[i - 1] * inv[i]) % MOD;
}

long long nPr(int n, int r) { return (fact[n] * invfact[n - r]) % MOD; }

long long nCr(int n, int r) {
    return (((fact[n] * invfact[r]) % MOD) * invfact[n - r]) % MOD;
}

void solve(long long N, long long M) {
    pre();
    long long ans = 0;
    rep(i, N + 1) {
        long long a = (nCr(N, i) * nPr(M, i)) % MOD;
        a = (a * nPr(M - i, N - i)) % MOD;
        a = (a * nPr(M - i, N - i)) % MOD;
        if (i % 2 == 0)
            ans = (ans + a) % MOD;
        else
            ans = (ans - a + MOD) % MOD;
    }
    cout << (ans + MOD) % MOD << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 27152
import java.util.*;

public class Main{
  
  public static void main (String[] args){
  
  	Scanner scanner = new Scanner (System.in);
  
   	String x = scanner.nextLine();
    int numx = Integer.parseInt(x);
    String[] array = x.split("");
    
    int sum = 0;
    
    for (int i=0; i<x.length(); i++){
      int temp = Integer.parseInt(array[i]);
      sum += temp;
    }
    
    if (numx%sum == 0){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

using namespace std;
using ll = long long;

int main() {
  ll n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  string out = "";
  for(ll i = 0; i < m; i++){
    out += "1";
  }

  // cout << "s:  " << s.size() << endl;

  if(s.find(out) != string::npos){
    cout << -1;
    return 0;
  }

  vector<ll> r(n, 0);
  ll ri = 0;
  ll ni = n;
  while(ni > 0){
    for(ll i = 0; i < m; i++){
      /*
      cout << "ri: " << ri << endl;
      cout << "ni: " << ni << endl;
      cout << "i:  " << i << endl;
      cout << "m:  " << m << endl;
      cout << "s:  " << s.size() << endl;
      */
      if(ni < m) {
        r[ri] = ni;
        ni = 0;
        break;
      }
      if(s[ni - m + i] == '0'){
        r[ri] = m - i;
        ni -= m - i;
        ri++;
        break;
      }
    }
  }
  for(ll i = n-1; i >= 0 ; i--){
    if(r[i] == 0) continue;
    cout << r[i] << " ";
  }
}




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

ll x, ans;

inline ll read(){															//å¿«è¯»
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	x = read();																//è¾“å…¥æ•´æ•°x
	ans += x / 500 * 1000;													//è§åˆ†æž
	x %= 500;																//è§åˆ†æž
	ans += x / 5 * 5;														//è§åˆ†æž
	x %= 5;																	//è§åˆ†æž
	printf("%lld\n", ans);													//è¾“å‡ºç­”æ¡ˆ
}

int main(){
	work();
	return 0;
}

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


def solve(a: int, b: int):
    n1 = str(a) * b
    n2 = str(b) * a
    if n1 < n2:
        return n1
    else:
        return n2


def main():
    a, b = map(int, input().split())
    answer = solve(a, b)
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9032
from math import sqrt

N = int(input())

def div_count(n):
    count = 0
    for i in range(1,int(sqrt(n))+1):
        if n % i == 0:
            count += 2
    if n == int(sqrt(n))**2:
        count -= 1
    return count

ans = 0
for i in range(1,N+1):
    if div_count(i) == 8 and i % 2 != 0:
        ans += 1

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		UL N; cin >> N;
		vector<UL> A(N); rep(i, N) cin >> A[i];
		sort(A.begin(), A.end());
		UL Ai = A[N - 1];
		UL Aj = A[0];
		rep(i, N - 1) {
			UL dj = max(Aj * 2, Ai) - min(Aj * 2, Ai);
			UL d = max(A[i] * 2, Ai) - min(A[i] * 2, Ai);
			if (dj > d) Aj = A[i];
		}
		cout << Ai << " " << Aj << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


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

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	set<int> unused;
	string s, next;
	cin >> s;
	for (int i = 0; i < 26; ++i) unused.insert(i);
	for (int i = 0; i < s.size(); ++i){
		unused.erase(s[i]-'a');
	}
	int pt1 = 1;
	if (unused.empty()){
		while (pt1 <= s.size() && (unused.empty() || (s[s.size()-pt1]-'a') - *(--unused.end()) > 0)){
			unused.insert(s[s.size()-pt1]-'a');
			pt1++;
		}
		if (pt1 == s.size()+1){
			cout << -1 << '\n';
		}
		else{
			for (int i = 0; i < s.size()-pt1; ++i){
				next = next + s[i];
			}
			next = next + (char)((char)(*unused.lower_bound(s[s.size()-pt1]-'a'))+'a');
		}
		
	}
	else{
		next = s;
		next = next + (char)((*unused.begin())+'a');
	}
	cout << next << '\n';
	cout << flush;
	//for (int i = 0; i < 1e9; ++i){for (int j = 0; j < 1e9; ++j){}}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a==b && b==c) cout << 1 << endl;
  else if (a==b || b==c || c==a) cout << 2 << endl;
  else cout << 3 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 330030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
using namespace std;

int main() {
int n;
int x[n],y[n];
map<pair<int,int> ,int > m;
cin>>n;
rep(i,0,n)
{
  cin>>x[i]>>y[i];
	
}
rep(i,0,n)
{
	rep(j,0,n)
	{
		if(i!=j)
		{
			m[{x[i]-x[j],y[i]-y[j]}]++;
		}
	}
}
int ans=n;
for(auto z:m)
{
	ans=min(ans,n-z.second);
}

cout<<ans;
}


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

int main() {
	// your code goes here
	int a,b,c;
	//int n = 1;
	int sum = 0;
	int count = 1;
	cin >> a >> b;
	
	while (a-- > 0) {
		
		cin >> c;
		
		sum = sum + c;
		
		if (sum <= b) {
			
			count++;
			
		}
		
		
		
	}
	
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256