akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <iomanip>
#include <functional>
typedef long long ll;
typedef long double ld;
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// 0-1 bfs
	int n, m;
	cin >> n >> m;
	int ci, cj;
	int di, dj;
	int dx[4] = { 0, -1, 0, 1 };
	int dy[4] = { -1, 0, 1, 0 };
	cin >> ci >> cj >> di >> dj;
	vector<string>v(n);
	for (int i = 0; i < n; i++)
		cin >> v[i];
	ci--; cj--;
	di--; dj--;
	deque<pair<int, int>> dq;
	vector<vector<int> > d(n, vector<int>(m, -1));
	vector<vector<int> > vis(n, vector<int>(m, 0));
	dq.push_back({ ci, cj });
	d[ci][cj] = 0;
	while (!dq.empty())
	{
		int x = dq.front().first;
		int y = dq.front().second;
		dq.pop_front();
		if (vis[x][y]) continue;
		vis[x][y] = 1;
		for (int i = 0; i < 4; i++)
		{
			int xi = x + dx[i];
			int yi = y + dy[i];
			if (xi < 0 || xi >= n || yi < 0 || yi >= m || v[xi][yi] == '#') continue;
			if (d[xi][yi] == -1 || d[xi][yi] > d[x][y])
			{
				d[xi][yi] = d[x][y];
				dq.push_front({ xi, yi });
			}
		}
		for (int xi = max(0, x - 2); xi <= min(n - 1, x + 2); xi++)
		{
			for (int yi = max(0, y - 2); yi <= min(m - 1, y + 2); yi++)
			{
				if (d[xi][yi] == -1 && v[xi][yi] == '.')
				{
					d[xi][yi] = d[x][y] + 1;
					dq.push_back({ xi, yi });
				}
			}
		}
	}
	cout << d[di][dj] << endl;
	return 0;
}


Measured memory_bytes: 12584
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
#define MX 100005
int N,A[MX];
int main(void){
    scanf("%d",&N),ga(N,A),reverse(A,A+N);
    FT(1,N)if(A[k]>A[k-1]){
        --A[k];
        if(A[k]>A[k-1])return puts("No"),0;
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	int ans = 0;
	map<int, int> mp;
	rep(i, n) {
		ans += mp[i - a[i]];
		mp[i + a[i]]++;
	}
	cout << ans << endl;
	return 0;
}

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

typedef long long ll;
const int N = 1e5;

int n,m;
int li[N+5];
priority_queue<int> pq;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int x;
		scanf("%d",&x);
		pq.push(x);
	}
	for(int i=1;i<=m;i++){
		int cur = pq.top(); pq.pop();
		cur/=2;
		pq.push(cur);
	}
	ll ans = 0ll;
	while(!pq.empty()){
		ans+=pq.top(); pq.pop();
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main() {
  int l, r, d;
  cin >> l >> r >> d;
  int cnt = 0;
  for(int i = l; i <= r; i++){
    if(i % d == 0){
      cnt++;
    }
  }
  cout << cnt << endl;
}


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

const int MAX_LEN = 200002;

int main()
{
  char s[MAX_LEN], t[MAX_LEN];
  int i, n;
  cin >> s >> t;

  n = strlen(s);
  int ans = 0;
  rep(i, n)
  {
    if (s[i] != t[i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3952
A, B, C, K = map(int, input().split())
# デフォルトは0
result = 0
# k分のAとって
t = min(A, K)
#    0 ←　A　たす
result += t
#K →　t　引かれる
K -= t
t = min(B, K)
# 0だからresultは変動なしkは引かれる
K -= t
t = min(C, K)
# resultは引かれる　kはもうない
result -= t
print(result)

Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
int main() {
    int k;
    scanf("%d", &k);
    if (k <= 500) {
        printf("%d\n", k);
        for (int i = 0; i < k; i++)
            for (int j = 0; j < k; j++) printf("%d%c", i + 1, " \n"[j == k - 1]);
    }
    else {
        puts("500");
        for (int i = 0; i < 500; i++)
            for (int j = 0; j < 500; j++) {
                int now = (i + j) % 500;
                if (i % 2 == 0 && now + 500 < k) now += 500;
                printf("%d%c", now + 1, " \n"[j == 499]);
            }
    }
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

//const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 1'000'000'000'000'000'000ll + 7;
//const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 1'000 + 5;

i64 T;

i64 n, k;


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    string s;
    cin >> s;
    if (s == "ABC") {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        long mod=1000000007;
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        
        out.println((double)((n+1)/2)/(n));
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

class P implements Comparable<P>{
    int a,b;
    P(int a, int b) {
    	this.b=b;
    	this.a=a;
    }

    public int compareTo(P p){
        return p.a-a;//des
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() throws IOException{
        return this.nextString().toCharArray();
    }    
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll A, B;
ll h[100010];

int main () {
  cin >> N >> A >> B;
  for (auto i = 0; i < N; ++i) {
    cin >> h[i];
  }
  A = A - B;
  ll ub = 1e9 + 10;
  ll lb = 0;
  while (ub - lb > 1) {
    ll t = (ub+lb)/2;
    ll need = 0;
    for (auto i = 0; i < N; ++i) {
      ll amari = h[i] - t * B;
      if (amari <= 0) continue;
      need += (amari + (A - 1)) / A;
    }
    if (need <= t) {
      ub = t;
    } else {
      lb = t;
    }
  }
  cout << ub << endl;
}


Measured memory_bytes: 1024
#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++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int main()
{
    ll N;
    cin >> N;
    vll X(N);
    ll sum = 0;
    rep(i, N)
    {
        cin >> X[i];
        sum += X[i];
    }
    sort(all(X));
    int Pos1 = sum / N, Pos2 = sum / N - 1, Pos3 = sum / N + 1;
    int ans = 0, ans2 = 0, ans3 = 0;
    rep(i, N)
    {
        ans += (X[i] - Pos1) * (X[i] - Pos1);
        ans2 += (X[i] - Pos2) * (X[i] - Pos2);
        ans3 += (X[i] - Pos3) * (X[i] - Pos3);
    }
    cout << min({ans, ans2, ans3});
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;} return false;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;} return false;}

int main(){
    int x, y, z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;


using namespace std;


int main()
{

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

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

  int t = 2;

  int ans_1 = 0;

  while (t > 0)
  {

    int ans = max(a, b);

    if (ans == a)
    {
      ans_1 += a;
      a--;
    }

    else
    {
      ans_1 += b;
      b--;
    }

     t--;
  }

   cout<<ans_1<<endl;

}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
using namespace std;
int main(){
	int N;
	int point=0;
	string S,P;
	cin >> N >> S ;
	for(int i=0;i<N;i++){
		int clear=false;
		cin >> P;
		for(int j=1;j<P.size();j++){
			for(int k=0;k<P.size();k++){
				for(int l=0;l<S.size();l++){
					if(k+l*j<P.size()&&P[k+l*j]==S[l]){
						if(l+1>=S.size()){
						clear=true;
						}
						continue;
					}
				
					break;
				}
			}
		}
		if(clear==true){
			point+=1;
		}
	}
		
	cout << point << endl;
	return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
int n;
int main()
{
  string a,b="CODEFESTIVAL2016";
  cin>>a;
  for(int i=0; i<16; i++)
  {
    if(a[i]!=b[i])n++;
  }
  cout<<n<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <cctype>

using ll = long long;
using ull = unsigned long long;

template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    double t, x;
    cin >> t >> x;

    cout << fixed << t / x << endl;

    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, a, b;

int main() {
    cin >> n >> a >> b;
    if (a > b) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 1) {
        if (a == b) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    LL from = (LL)a * (n - 1) + b;
    LL to = a + (LL)b * (n - 1);
    cout << to - from + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/*
alias p='g++ -std=c++17 -O2 pra.cpp'
alias pg='g++ -std=c++17 -O2 -g pra.cpp'
alias s='g++ -std=c++17 -O2 -g subpra.cpp'
alias ss='g++ -std=c++17 -O2 -g sspra.cpp'
ulimit -c unlimited
alias a='./a.out'
cd programming
cd cpp
cd practice

*/
using ll = long long;
#define rep(i, n) for(int i=0; i<(n); i++)
//if (i) cout << " "; で最初のみ空白文字を出力することができる
#define Sort(v) sort((v).begin(), (v).end())
#define pb push_back
using veci = vector<int>;
using vecs = vector<string>;
using vecd = vector<double>;
using vecl = vector<long long>;
using G = vector<vector<int>>;
using P = pair<int, int>;
double PI = acos(-1);
ll lINF = LLONG_MAX; ll lmINF = LLONG_MIN;
int INF = INT_MAX; int mINF = INT_MIN;
//const ll mod = 1000000007;
int main() {
    cout.precision(10);
    cin.tie(0);//cin高速化
    string s;
    cin >> s;
  int N = s.size();
    ll ans = 0;
    ll temp;
    for (int bit=0; bit < (1<<(N-1)); bit++){//2通りある部分で、全パターンの列挙
        temp = 0;//最初に見る値まで10倍されては困る
        for (int i=0; i<N-1; i++){//+が入らない限り、10倍して1の位に入れる操作を繰り返す(この10倍して1の位に入れる、という操作は重要)
            temp *= 10;
            temp += s[i] - '0';
            if (bit&(1 << i)){//フラグが立っていれば
                ans += temp;
                temp = 0;
            }
        }
        temp *= 10;//一個前にまとめられてなければ最後もまとめられる
        temp += s.back()-'0';//最後の要素は絶対に10倍されないので別で足す
        ans += temp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3556
import java.util.Scanner;
import java.lang.Math;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int h = stdIn.nextInt();
		int w = stdIn.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
			b[i] = stdIn.nextInt();
		}
		int k = 0;
		for (int i = 0; i < n; i++) {
			if (a[i] >= h) {
				if (b[i] >= w)
					k = k + 1;
			}
		}
		System.out.println(k);
	}
}

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

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

    cout << z << " " << x << " "<< y << endl;
    return 0;
}


Measured memory_bytes: 256
module Main where

import Data.Functor

main :: IO ()
main = do
{ [a,b,c] <- getInts
; print (sum [ 1 | x <- [a .. b], mod c x == 0])

}

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

done :: IO ()
done = return ()

Measured memory_bytes: 4212
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}
		}
	}
}

void Show(vector<int> N) {
	for (int i = 0; i < N.size(); i++) {
		cout << N[i];
		if (i != N.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}


int main() {
	int N;
	cin >> N;
	vector<int> Appeared;
	vector<int> Count;
	Appeared.resize(N);
	for (int i = 0; i < N; i++) {
		cin >> Appeared[i];
	}
	sort(Appeared.begin(), Appeared.end());
	int n = Appeared[0];
	int from = 0;
	int count;
	int answer = 0;
	for (int i = 0; i < N; i++) {
		if (n != Appeared[i]) {
			count = i - from ;
			if (count < n) {
				answer += count;
			} else {
				answer += count - n;
			}
			n = Appeared[i];
			from = i;
		}
	}
	count = N - 1 - from + 1;
	if (count < n) {
		answer += count;
	} else {
		answer += count - n;
	}
	cout << answer << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int N=1e6+11,INF=~0u>>2;
int a[N],n,t[N],ans,i=1,num[N],tot;
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i) scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	for(i=1;i<=n;++i){
		int tmp=i;
		while(a[i]==a[i+1]&&i<n) i++;
		t[++tot]=i-tmp+1;
		num[tot]=a[i];
	}
	for(i=2;i<tot;++i){
		int tmp=t[i];
		if(num[i]-num[i-1]<=1) tmp+=t[i-1];
		if(num[i+1]-num[i]<=1) tmp+=t[i+1];
		ans=max(ans,tmp); 
	}
	if(tot==1) ans=n;if(tot==2){
		if(num[2]-num[1]<=1) ans=n;
		else ans=max(t[2],t[1]);
	} 
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 8704
inputs = gets.strip().split(" ").map{|i| i.to_i}
n = inputs[0]
m = inputs[1]
a = Array.new(n){Array.new(m)}
b = Array.new(m)
c = Array.new(n){0}
for i in 0..n-1
	rows = gets.strip().split(" ").map{|x| x.to_i}
	a[i][0..m-1] = rows
end
for i in 0..m-1
	row = gets.strip.to_i
	b[i] = row
end
for i in 0..n-1
	for j in 0..m-1
		c[i] += a[i][j] * b[j]
	end
	puts c[i]
end


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define sz(x) ll(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
using ll = long long;
using P = pair<ll,ll>;
using Pl = pair<ll,ll>;
using vi = vector<ll>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const ll dx[] = {0,1,0,-1,1,1,-1,-1};
const ll dy[] = {1,0,-1,0,1,-1,-1,1};
const ll inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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; }



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

  ll n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  map<ll, ll> cnt;
  rep(i,n) {
    cnt[a[i]]++;
  }
  map<ll, ll> com;
  rep(i,n) {
    com[a[i]] = cnt[a[i]] * (cnt[a[i]]-1) / 2;
  }
  ll sum = 0;
  for(auto it = com.begin(); it != com.end(); it++) {
    sum += it->second;
  }
  rep(i,n) {
    ll ans = sum - com[a[i]];
    ans += (cnt[a[i]]-1) * (cnt[a[i]]-2) / 2;
    cout << ans << endl;
  }
}

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

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

Measured memory_bytes: 3592
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion

void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


void Main(){
    int N, M;
    cin >> N;
    vec<string> s(N);
    map<string, int> mp;
    REP(i, N){
        cin >> s[i];
        mp[s[i]]++;
    }
    cin >> M;
    vec<string> t(M);
    REP(i, M){
        cin >> t[i];
        mp[t[i]]--;
    }
    int mx = 0;
    EACH(i, mp){
        chmax(mx, i.se);
    }
    cout << mx << el;
}



Measured memory_bytes: 3600
#include<stdio.h>
int main(void){
  long long int n,a,i;
  scanf("%lld",&n);
  a=0;
  for(i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0){
      a=a+i;
    }
  }
  printf("%lld\n",a);
  return 0;
}

Measured memory_bytes: 1732
N=int(input())
if N<=111:
    print(111)
elif 112<=N and N<=222:
    print(222)
elif 223<=N and N<=333:
    print(333)
elif 334<=N and N<=444:
    print(444)
elif 445<=N and N<=555:
    print(555)
elif 556<=N and N<=666:
    print(666)
elif 667<=N and N<=777:
    print(777)
elif 778<=N and N<=888:
    print(888)
elif 889<=N and N<=999:
    print(999)

Measured memory_bytes: 61744
N, M, C = map(int, input().split())
B = list(map(int, input().split()))

code_count = 0
answer = 0

while N > code_count:
    A = list(map(int, input().split()))
    sum = C
    for i in range(M):
        sum += A[i] * B[i]
    if sum > 0:
        answer += 1
    code_count += 1

print(answer)

Measured memory_bytes: 9168
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    h,a = inpm()
    ans = h//a
    if h%a != 0:
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()




Measured memory_bytes: 39020
#include <bits/stdc++.h>
#define IOS             ios::sync_with_stdio(false); cin.tie(nullptr)
#define deb(x)          cout << #x << " = " << x << endl
#define deb2(x, y)      cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)     for(i = a; i < n; i++)
#define f1(i, a, n)     for(i = a; i <= n; i++)
#define tc(t)           int t; cin >> t; while(t--)
#define ini(x, y)       memset(x, y, sizeof(x))
#define all(x)          x.begin(),x.end()
#define sz(x)           x.size()
#define ll              long long int
#define vi              vector<int>
#define si              set<int>
#define pb              emplace_back
#define ppb             pop_back
#define mp              make_pair
#define M               1000000007
#define endl            '\n'
#define bits(x)         __builtin_popcountll(x)
#define zrbits(x)       __builtin_ctzll(x)

using namespace std;

void solve() {
    ll n, i, sum = 0;
    string s;
    cin >> s;
    n = sz(s);
    f0(i, 0, n) sum += (s[i] - '0');
    cout << (sum%9 ? "No" : "Yes") << endl;
}

int main () {
    IOS;
    // tc(t)
    solve();
    return 0;
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    ll X, Y;
    cin >> X >> Y;
    cout << (abs(X - Y) <= 1 ? "Brown" : "Alice") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scan = new Scanner(System.in);
        int A = scan.nextInt();
        int B = scan.nextInt();
        int C = scan.nextInt();
        int answer = 0;
        boolean isFirstLoop = true;
        
        int a1 = A, b1 = B, c1 = C, a2, b2, c2;
        while(hasNotOdd(a1, b1, c1)) {

            a2 = a1;
            b2 = b1;
            c2 = c1;
            
            a1 = b2 / 2 + c2 / 2;
            b1 = a2 / 2 + c2 / 2;
            c1 = a2 / 2 + b2 / 2;
            
            if(isScanedValue(A, B, C, a1, b1, c1)) {
                answer = -1;
                break;
            }
            
            answer++;
        }
        System.out.println(answer);
    }
    
    static boolean hasNotOdd(int a1, int b1, int c1) {
        return (a1 % 2 != 1 && b1 % 2 != 1 && c1 % 2 != 1);
    }
    
    static boolean isScanedValue(int A, int B, int C, int a1, int b1, int c1) {
        return (A == a1 && B == b1 && C == c1);
    }
}


Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans_a,ans_b,fans;
    if ((a)%2 == 0) ans_a = ((a)/2)%2;
    else ans_a = (((a)/2)%2)^(a-1);
    if ((b+1)%2 == 0) ans_b = ((b+1)/2)%2;
    else ans_b = (((b+1)/2)%2)^b;
    fans = ans_a ^ ans_b;
    
    cout << fans << endl;
    
     
    
}



Measured memory_bytes: 384
#include<iostream>
#include<string>
using namespace std;
string a, b, c;
int main(){
  cin >> a >> b >> c;
  if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0])
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
#define MOD 1000000007

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

    int N, K;
    cin >> N >> K;

    int x = (N - 1) * (N - 2) / 2;

    if(K > x) {
        cout << -1 << endl;
        return 0;
    }

    int ans = N - 1;
    vector<p> a;

    for(int i = 1; i <= ans; i++) {
        a.push_back(make_pair(i, N));
    }

    int count = 0;
    int f = 1;
    int b = 2;

    while(count < x - K) {
        a.push_back(make_pair(f, b));
        b++;
        if(b == N) {
            f++;
            b = f + 1;
        }
        count++;
    }

    ans += count;

    cout << ans << endl;

    for(int i = 0; i < ans; i++) {
        cout << a[i].first << " " << a[i].second << endl;
    }
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#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--)
typedef long long LL;
LL N,P;

int main(){
	cin>>N>>P;
	LL ans=1;
	for(int i=2;i<1000000+10;i++){
		LL now=0;
		while(P%i==0){
			P/=i;
			now++;
		}
		now/=N;
		REP(j,now){
			ans*=i;
		}
	}
	if(N==1){
		cout<<P*ans<<endl;
	}else{
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
import fractions

a,b,c,d = map(int,input().split())

def lcm(c,d):
    return c*d//fractions.gcd(c,d)

def dev_count(n,c,d):
    x = n
    n -= x//c
    n -= x//d
    n += x//(lcm(c,d))
    return n

print (dev_count(b,c,d)-dev_count(a-1,c,d))

Measured memory_bytes: 5048
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
bitset<2000001>bb;
int main(){
    int n;R(n);
    int s=0;
    bb[0]=1;
    REP(i,n){
        int x;
        R(x);
        s+=x;
        bb|=bb<<x;
    }
    {
        int i=(s+1)/2;
        for(;!bb[i];i++);
        W(i);
    }
    return 0;
}


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

class MinCostFlow{
public:
    struct edge{
        int to;
        int cap;
        int cost;
        int rev;
    };
    int V;
    int inf;
    vector<vector<edge> > G;
    vector<int> h,dist;
    vector<int> prevv,preve;
    MinCostFlow(int node_size): V(node_size),inf(numeric_limits<int>::max()/4),G(V),h(V,0),dist(V),prevv(V),preve(V){}
    void add_edge(int from, int to,int cap,int cost){
        G[from].push_back((edge){to,cap,cost,(int)G[to].size()});
        G[to].push_back((edge){from,0,-cost,(int)G[from].size()-1});
    }
    int solve(int s,int t){
        int res = 0;
        int f = inf;
        while(1){
            priority_queue<pair<int,int>,vector<pair<int,int> > ,greater<pair<int,int>> > que;
            fill(dist.begin(),dist.end(),inf);
            dist[s] = 0;
            que.push(pair<int,int>(0,s));
            while(!que.empty()){
                pair<int,int> p = que.top();
                que.pop();
                int v = p.second;
                if(dist[v] < p.first) continue;
                for(int i=0;i<(int)G[v].size();i++){
                    edge& e = G[v][i];
                    if(e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]){
                        dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                        prevv[e.to] = v,preve[e.to] = i;
                        que.push(pair<int,int>(dist[e.to],e.to)); 
                    }
                }
            }
            if(dist[t]==inf)break;
            for(int i=0;i<V;i++){
                h[i] += dist[i];
            }
            int d = f;
            for(int v = t;v !=s;v = prevv[v]){
                d = min(d,G[prevv[v]][preve[v]].cap);
            }
            f -= d;
            res += h[t]*d;
            for(int v = t;v != s;v = prevv[v]){
                edge& e = G[prevv[v]][preve[v]];
                e.cap -= d;
                G[v][e.rev].cap += d;
            }
        }
        return res;
    }
};

int a[3][101];

bool contain(int i,int j){ // i -> j
    vector<int> p(3);
    p[0] = 0;
    p[1] = 1;
    p[2] = 2;
    bool flag = 0;
    do{
        bool fff = 1;
        rep(k,3){
            if(a[k][i] <= a[p[k]][j])fff = 0;
        }
        if(fff)flag = 1;
    }while(next_permutation(p.begin(),p.end()));
    return flag;
}
int main(){
    int n;
    while(cin >> n && n!=0){
        int sm = 0;
        rep(i,n){
            cin >> a[0][i] >> a[1][i] >> a[2][i];
            sm += a[0][i]*a[1][i]*a[2][i];
        }
        MinCostFlow mf(2*n+2);
        int s = 0;
        int t = 2*n+1;
        
        rep(i,n){
            mf.add_edge(s,i+1,1,0);
            mf.add_edge(i+n+1,t,1,0);
        }
        rep(i,n){
            rep(j,n){
                if(i==j)continue;
                if(contain(i,j)){
                    mf.add_edge(i+1,j+n+1,1,-a[0][j]*a[1][j]*a[2][j]);
                    // cerr << i << " " << j  << " " << a[0][j]*a[1][j]*a[2][j] << endl;
                }
            }
        }
        cout << sm + mf.solve(s,t) << "\n";
    }
    return 0;
}


Measured memory_bytes: 3276
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>

#define Lens 250
#define Nil -1

using namespace std;

struct Node
{
	int p, l, r;
};

int N;
Node Tr[Lens];
int D[Lens], C[Lens], H[Lens];
bool V[Lens];

//建树
void maketree()
{
	int m, l, r;
	for (int i = 0; i < N; i++)
	{
		cin >> m >> l >> r;
		Tr[m].l = l;
		Tr[l].p = m;
		Tr[m].r = r;
		Tr[r].p = m;
	}
}

//深度
void dns(int i, int p)
{
	D[i] = p;
	if (Tr[i].l != Nil)
	{
		C[i]++;
		dns(Tr[i].l, p + 1);
	}
	if (Tr[i].r != Nil)
	{
		C[i]++;
		dns(Tr[i].r, p + 1);
	}
}

int hns(int i)
{
	int h1 = 0, h2 = 0;
	if (Tr[i].l != Nil)
		h1 = hns(Tr[i].l)+1;
	if (Tr[i].r != Nil)
		h2 = hns(Tr[i].r)+ 1;
	H[i] = max(h1, h2);
	return H[i];
}

void printtree()
{
	int root;
	for (int i = 0; i < N; i++)
	{
		if (Tr[i].p == Nil)
			root = i;
	}
	dns(root, 0);
	hns(root);
	for (int i = 0; i < N; i++)
	{
		cout << "node " << i << ": parent = " << Tr[i].p << ", sibling = ";
		if (i == root)
			cout << Nil;
		else if (i == Tr[Tr[i].p].l)
			cout << Tr[Tr[i].p].r;
		else
			cout << Tr[Tr[i].p].l;
		cout << ", degree = " << C[i] << ", depth = " << D[i] << ", height = " << H[i] << ", ";
		if (i == root)
			cout << "root";
		else if (i != root&&C[i] != 0)
			cout << "internal node";
		else
			cout << "leaf";
		cout << endl;;
	}

}

int main()
{
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		Tr[i].p = Tr[i].l = Tr[i].r = Nil;
		V[i] = false;
	}
	maketree();
	printtree();
	return 0;
}


Measured memory_bytes: 3100
n, k = map(int, input().split())

s = []

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for i in range(d):
        s.append(a[i])
        
t = sorted(s)
a = len(t)
x = n

for i in range(n):
    for k in range(a):
        if i + 1 == t[k]:
            x -= 1
            break
        elif i + 1 < t[k]:
            break
        
print(x)


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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    cout << *max_element(a.begin(), a.end()) - *min_element(a.begin(), a.end()) << endl;

    return 0;
}


Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline()[:-1]

from collections import defaultdict

N = int(input())
S = input()

def is_pos(n,S,N):
    dd = defaultdict(int)
    flag =True
    for i in range(N-n+1):
        s = dd[S[i:i+n]]
        if s!=0:
            if i+1-s>=n:
                flag=False
                break
        else:
            dd[S[i:i+n]]=i+1
    return flag


def bisect(i,j,S,N):
    while j-i>1:
        if is_pos((i+j)//2,S,N):
            j = (i+j)//2
        else:
            i = (i+j)//2
    return i

print(bisect(0,N//2 + 1, S, N))

Measured memory_bytes: 153992
#include <iostream>
#include <cstdio>
#define INF 2000000000
#define J 10000
#define MIN(a,b) ((a>b)?(b):(a))
using namespace std;

int main(void){
	int N,W,dp[101][J+1],v[101],w[101];
	cin>>N>>W;
	for(int i=1;i<=N;i++)cin>>v[i]>>w[i];
	for(int i=0;i<=N;i++){
		for(int j=0;j<=J;j++)dp[i][j]=INF;
	}
	for(int i=0;i<=N;i++)dp[i][0]=0;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=J;j++){
			if(j-v[i]>=0&&dp[i-1][j-v[i]]+w[i]<=W)dp[i][j]=MIN(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	for(int j=J;j>=0;j--){
		if(dp[N][j]!=INF&&dp[N][j]<=W){
			cout<<j<<endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 7008
#include <iostream>
#include <vector>
#include <utility>
using namespace  std;

void fnInput(int &rnMaxSiz, vector<int> &rvnNum)
{
  cin >> rnMaxSiz;

  rvnNum.resize(rnMaxSiz);
  for (int i = 0; i < rnMaxSiz; i++)
    cin >> rvnNum[i];
}

void fnPartition(vector<int> &rvnNum, int nStart, int nEnd, int &nCur)
{
  for (int i = nStart; i < nEnd; i++)
    if (rvnNum[i] <= rvnNum[nEnd])
      swap(rvnNum[nCur++], rvnNum[i]);

  swap(rvnNum[nCur], rvnNum[nEnd]);
}

void fnResult(const vector<int> &cnrvnNum, int nCur)
{
  for (int i = 0; i < cnrvnNum.size(); i++)
  {
    if (i)  cout << " ";
    if (i == nCur) cout << "[";
    cout << cnrvnNum[i];
    if (i == nCur) cout << "]";
  }
  cout << endl;
}

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

  int nMaxSiz;
  vector<int> vnNum;

  fnInput(nMaxSiz, vnNum);
  int nStart = 0;
  int nEnd = vnNum.size() - 1;
  int nCur = nStart;

  fnPartition(vnNum, nStart, nEnd, nCur);
  fnResult(vnNum, nCur);

  return 0;
}

Measured memory_bytes: 1524
<?php

$line = str_split(fgets(STDIN));

$count = 0;
$result = 0;
foreach($line as $n){
    if($n=='R'){
        $count++;
    }else{
        if($count>$result){
            $result=$count;
            $count=0;
        }
    }
}
echo $result."\n";


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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

int a[505][505];

int main(){
	ios::sync_with_stdio(0);
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if(H%h == 0 && W%w == 0){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	for(int i=0; i < H; i += h)
		for(int j=0; j < W; j += w){
			a[i][j] += 1000000;
		}
	for(int i=h-1; i < H; i += h)
		for(int j=w-1; j < W; j += w){
			a[i][j] -= 1000001;
		}
	rep(i,0,H){
		rep(j,0,W){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 3328
from sys import stdin
from itertools import combinations
from math import factorial
import numpy as np

a = int(stdin.readline().rstrip())
b = int(stdin.readline().rstrip())
c = int(stdin.readline().rstrip())
x = int(stdin.readline().rstrip())
kai = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+50*k == x:
                kai += 1

print(kai)


Measured memory_bytes: 12396
#include <stdio.h>
#include <stdlib.h>

int	intcmp(const void *n1, const void *n2)
{
	return (*(int *)n1 - *(int *)n2);
}

int	main()
{
	int	N;
	int	x;
	int	count;
	int	kids[101];
	int	i;

	i = 0;
	count = 0;
	scanf("%d %d\n", &N, &x);
	while (i < N)
	{
		scanf("%d ", &kids[i]);
		i++;
	}
	qsort(kids, i, sizeof(int), intcmp);
	i = 0;
	while (i < N)
	{
		x -= kids[i];
		if (x < 0)
			break ;
		count++;
		i++;
	}
	if (x > 0)
		count--;
	printf("%d\n", count);
	return (0);
}

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define mt make_tuple
#define eb emplace_back
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define LB(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define UB(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef unsigned long long ull;
typedef long double ld; 
typedef tuple<int,int,int> State;

ll mod = 1e9 + 7;

#define citc(tc) int tc; cin>>tc; while(tc--){solve();}
#define each(a,x) for( auto &a:(x))
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rep2(i, l, r) for (ll i = (l); i < (r); i++)
#define rep2r(i, l, r) for (ll i = (r) - 1; i >= (l); i--)
#define range(a) a.begin(), a.end()
#define deb(x) cout<<#x<<" "<<x<<endl;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); rep(i, n) { cin>>a[i]; }
#define cinal(a, n) vl a(n); rep(i, n) { cin>>a[i]; }
#define coutai(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define coutal(a, n) rep(i, n) { cout<<a[i]<<" "; } ent;
#define ent cout<<endl;

void solve()
{
	cinll(n);
	cinll(m);
	if(min(m, n) == 1)
		cout<<1<<endl;
	else
		cout<<(m*n/2)+((m*n)%2)<<endl;
}
int main()
{
	fastio();
	// citc(tc);
	solve();
}

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

int main(void)
{
	int k,a,b;
	long long ans;
	scanf("%d %d %d",&k,&a,&b);
	
	if (a+2>=b || k<=a) {
		printf("%d\n",k+1);
		return 0;
	}
	
	k = k-a+1;
	ans = a;
	if (k%2==0) {
		ans += (long long)(b-a)*k/2;
	} else {
		ans += (long long)(b-a)*(k-1)/2 + 1;
	}

	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define FOR(var,start,end) for(int var=start; var<end; var++)
#define REP(var,cnt) FOR(var,0,cnt)

int main(void) {
	
	int X, Y, Z;
	cin >> X >> Y >> Z;
	
	if ( X < (Y+Z+Z) ) { cout << "0" << endl; return 0; }
	
	X -= Z;
	int kos = X / (Y+Z);
	
	cout << kos << endl;
}


Measured memory_bytes: 256
//
//  main.cpp
//  cf
//
//  Created by Dong Truong on 6/3/19.
//  Copyright © 2019 Dong Truong. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>

using namespace std;
#define maxn 1000001

int n,a,b,c,d;string s;

void nhap()
{
    cin>>s;
    int64_t kq=0,t=0;
    for (int i=0;i<s.length()-1;++i)
    {
        if (s[i]=='A')
            ++t;
        else
            if (s[i]=='B' && s[i+1]=='C')
            {
                kq+=t;i++;
            }
            else t=0;
    }
    cout<<kq;
}
int main(int argc, const char * argv[]) {
    //freopen("a.inp","r",stdin);
    nhap();
    return 0;
}


Measured memory_bytes: 640
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto nxm = readln.split.to!(long[]);
    auto N = nxm[0];
    auto X = nxm[1];
    auto M = nxm[2];

    long res;
    long[] DP;
    long[long] MEMO;
    foreach (i; 0..N) {
        if (X == 0) {
            writeln(res);
            return;
        }
        if (X in MEMO) {
            auto s = MEMO[X];
            DP = DP[s..$];
            foreach (j; 1..DP.length) DP[j] += DP[j-1];
            auto rr = N - i;
            auto d = rr / DP.length;
            res += DP[$-1] * d;
            if (rr % DP.length != 0) {
                res += DP[rr % DP.length - 1];
            }
            writeln(res);
            return;
        }
        DP ~= X;
        MEMO[X] = i;
        res += X;
        X = X^^2 % M;
    }
    writeln(res);
}

Measured memory_bytes: 6488
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll ;
 
int main()
{
   ll n ;
   cin >> n ;
     string s = "";
     string p = "01";
     if( n == 0 )s="0";
 
     while(n)
     {
       
       int remainder = n % -2 ;
       n = n / -2 ;
       if( remainder < 0)
       {
        remainder = remainder + 2 ;
        n = n + 1 ;
       }
       s = p[remainder] + s ;
     }
     cout<<s<<endl;
}

Measured memory_bytes: 384