akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
	private	static	BufferedReader	br = null;

	static {
		br = new BufferedReader(new InputStreamReader(System.in));
	}
 
    /**
     * @param args
     */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[][] map = null;

		while((map = parseMap()) != null) {
			System.out.println(calcMaxSum(map));
		}
	}

	private static int calcMaxSum(int[][] map) {
		int	max = 0;

		for (int i = 0; i < map.length; i++) {
			for (int j = 0; j < map[i].length; j++) {
				int	l = map[i][j];
				if (l * (map.length-i) > max) {
					for (int k = 0; i+k < map.length; k++) {
						l = Math.min(l, map[i+k][j]);
						if (l * (map.length-i) <= max) {
							// 理論上、これ以上最大値を更新できない場合は計算しない
							break;
						} else {
							max = Math.max(max, l * (k+1));
						}
					}
				}
			}
		}

        return max;
	}

	private static int[][] parseMap() {
		int[][]	map = null;
		int[]	len = parseLen();

        if (len != null) {
			map = new int[len[0]][len[1]];

			for (int y = 0; y < len[0]; y++) {
				String	strin = null;
		        if ((strin = parseStdin()) != null) {
		        	for (int x = len[1]-1; x >= 0; x--) {
		        		if (strin.charAt(x) == (char)'.') {
		        			map[y][x] = (x < len[1]-1) ? ((map[y][x+1] != 0) ? map[y][x+1]+1 : 1) : 1;
		        		}
		        	}
		        }
			}
        }
 
        return map;
	}

	private static int[] parseLen() {
		int[]	params = null;
        String	stdin  = null;

        if ((stdin = parseStdin()) != null) {
			if (!stdin.equals("0 0")) {
				String[]	lines = stdin.split(" ");

				params    = new int[2]; 
				params[0] = Integer.parseInt(lines[0]);
				params[1] = Integer.parseInt(lines[1]);
			}
        }
 
        return params;
	}

	private static String parseStdin() {
        String  stdin = null;
        
        try {
        	String  tmp = br.readLine();
        	if (!tmp.isEmpty()) stdin = tmp;
        }
        catch (IOException e) {}
 
        return stdin;
	}
}

Measured memory_bytes: 27600
n,h,w = gets.chomp.split(/\s/).map{|x| x.to_i}

cnt = 0
for i in 1..n
    a,b = gets.chomp.split(/\s/).map{|x| x.to_i}
    next if a < h or b < w
    aa = a / h
    bb = b / w
    cnt += (aa == 1 or bb == 1) ? 1 : aa*bb
end

puts cnt

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int N,A[MX],ori[MX];
set<int> adj[MX];
vl num[MX];

void finish(int x) {
    sort(all(num[x]));
    ll mx = 0; for (int i: num[x]) mx += i;
    if (2*num[x].back() > mx || 2*A[x] != mx) cout << "NO";
    else cout << "YES";
    exit(0);
}

queue<int> todo;

void process(int x) {
    int par = *adj[x].begin();
    
    // cout << "AH " << x << "\n";
    if (!ori[x]) {
        sort(all(num[x]));
        ll mx = 0; for (int i: num[x]) mx += i;
        ll posi = min(mx/2,mx-num[x].back());
        
        ll need = mx-A[x];
        if (need < 0 || need > posi) {
            cout << "NO";
            exit(0);
        }
        
        A[x] -= need;
    }
    
    adj[par].erase(x), adj[x].erase(par);
    num[par].pb(A[x]);
    if (sz(adj[par]) == 1) {
        // cout << x << " " << par << "\n";
        todo.push(par);
    } else if (sz(adj[par]) == 0) finish(par);
    
    // cout << "ZZ " << x << " " << par << "\n";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    FOR(i,1,N+1) cin >> A[i];
    if (N == 2) {
        if (A[1] == A[2]) cout << "YES";
        else cout << "NO";
        exit(0);
    }
    F0R(i,N-1) {
        int a,b; cin >> a >> b;
        adj[a].insert(b), adj[b].insert(a);
    }
    FOR(i,1,N+1) if (sz(adj[i]) == 1) {
        ori[i] = 1;
        todo.push(i);
    }
    while (sz(todo)) {
        int x = todo.front(); todo.pop();
        process(x);
    }
    cout << "YES";
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

Measured memory_bytes: 17792
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
    return x * fh;
}

//int SG(int x) { }

void File() {
#ifdef zjp_shadow
	freopen ("d.in", "r", stdin);
	freopen ("d.out", "w", stdout);
#endif
}

int SG(int x, int k) {
	if (!(x % k)) return x / k;
	int v = x / k + 1;
	return SG(x - max(x % k / v, 1) * v, k);
}

int main () {
	File();
	int n = read(), res = 0;
	For (i, 1, n) { int a = read(), k = read(); res ^= SG(a, k); }
	puts(res ? "Takahashi" : "Aoki");
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

int dp[105][100010];

signed main() {
    int N, W;
    cin >> N >> W;

    vector<int> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    REP(i, 1, N) {
        rep(j, W + 1) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (j >= w[i - 1]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i - 1]] + v[i - 1]);
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 79360
#include "bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
using index_t = std::size_t;

namespace lib
{
	using graph_t = std::vector<std::set<index_t>>;
	template<class T>using weighted_graph_t = std::vector<std::map<index_t, T>>;

	struct max_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::max(lhs, rhs);
		}
	};
	struct min_t
	{
		template<class T>constexpr T operator()(T const& lhs, T const& rhs)const
		{
			return std::min(lhs, rhs);
		}
	};

	constexpr max_t max;
	constexpr min_t min;

	template<class T>auto order_by(T func)
	{
		return [=](auto&& lhs, auto&& rhs)
		{
			return func(lhs) < func(rhs);
		};
	}

	template<class T>constexpr auto max_v = std::numeric_limits<T>::max();
	template<class T>constexpr auto min_v = std::numeric_limits<T>::min();

	template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
	
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		auto s = 1ULL;
		for (auto i = 0; i < 63; ++i, s <<= 1)
		{
			if (p & s)
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
}

template<class T>void println(T const& v)
{
	std::cout << v << std::endl;
}

void Main()
{
	std::int64_t X, K, D;
	std::cin >> X >> K >> D;
	auto must = std::abs(X) / D;
	if (must >= K)
	{
		if (X < 0)
		{
			println(std::abs(X + D * K));
		}
		else
		{
			println(std::abs(X - D * K));
		}
	}
	else
	{
		K -= must;
		if (K % 2 == 1)
		{
			++must;
		}
		if (X < 0)
		{
			X += must * D;
		}
		else
		{
			X -= must * D;
		}
		println(std::abs(X));
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 3644
class Main{
  public static void main(String[] a){
    
    int x,y,p;
    for(x=1;x<10;x++){
      
      for(y=1;y<10;y++)
      {
        p=x*y;
        System.out.printf("%dx%d=%d\n", x, y, p);
      }               
    } 
  }
}

Measured memory_bytes: 17924
#include <stdio.h>

int main( void )
{
	int a, b;
	char op;
	
	while( 1 )
	{
		scanf( "%d %c %d", &a, &op, &b );
		
		if( op == '?' )
		{
			break;
		}
		else
		{
			if( op == '+' )
			{
				printf( "%d\n", a + b );
			}
			else
			if( op == '-' )
			{
				printf( "%d\n", a - b );
			}
			else
			if( op == '*' )
			{
				printf( "%d\n", a * b );
			}
			else
			if( op == '/' )
			{
				printf( "%d\n", a / b );
			}
		}
	}

	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll l,r,d;
  cin >> l >> r >> d;
  ll ans=0;
  REP(i,l,r+1) {
    if(i%d==0) ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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


int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while(A[i] != key) i++;
    return i != n;
}

int main() {
    int i, n, A[10000+1], q, key, sum = 0;

    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &A[i]);

    scanf("%d", &q); // T はすべてを入力してからではなく、１つ１つ入力し、その値をkey にして存在を確かめる
    for (i = 0; i < q; i++) {
        scanf("%d", &key);
        if (search(A, n, key)) sum++;
    }
    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 3240
#include<stdio.h>
char c;
int f;
int nextInt();

int N, n, i, t;
int A[100001];
int main(){
	N=nextInt();
	for(i=1; i<=N; i++){
		A[i]=nextInt();
	}
	i=0;
	n=1;
	do{
		t = A[n];
		A[n] = 1;
		n = t;
		i++;
	}while(n!=1 && n!=2);
	if(n==2){
		printf("%d\n", i);
	}else{
		printf("-1\n");
	}
}

int nextInt(){
	f=0; c=getchar();
	while(c!=10){f=f*10+(c-'0'); c=getchar();}
	return f;
}


Measured memory_bytes: 512
k,n = map(int,input().split())
a = list(map(int,input().split()))
gap = [a[0]]

for i in range(1,n-1):
    gap.append(a[i+1]-a[i])

gap.append(k-a[-1])
m = max(max(gap),gap[0]+gap[-1])
print(k-m)


Measured memory_bytes: 25840
#include <bits/stdc++.h>
#include <iomanip>
#define ll long long
using namespace std;
 
int main() {
  ll W, H, x, y;
  cin >> W >> H >> x >> y;
  cout << fixed << setprecision(15) << double(W * H) / 2 << " ";
  if((W % 2 == 1) || (H % 2 == 1)) cout << 0 << endl; 
  else {
    if((W / 2 == x) && (H / 2 == y)) cout << 1 << endl;
    else cout << 0 << endl;
  }
}

Measured memory_bytes: 256
N = int(input())


es = [[] for _ in range(N)]
for i in range(N):
    A = int(input())
    for n in range(A):
        x,y = map(int, input().split())
        es[i].append((x-1,str(y)))


# それぞれの人が正直かどうかについて全探索する
ans = 0
for i in range(2**N):
    bnum = (bin(i)[2:]).zfill(N)

    f = True
    for j in range(N):
        # j番目のひとが正直なら
        if bnum[j] == "1":
            # 人jの証言について調べる
            for x,y in es[j]:
                # 証言内容と仮定した正直かどうか(bnumのこと)に矛盾があるなら飛ばす
                #print(j,x,y,bnum[x])
                if bnum[x] != y:
                    f = False
    #print(bnum, f)
    if f:
        ans = max(ans, bnum.count("1"))
    
print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

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

        int n = sc.nextInt();
        int x = sc.nextInt();

        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = Math.abs(x - sc.nextInt());
        }

        sc.close();

        int ans = a[0];

        for (int i = 1; i < n; i++) {
            ans = gcd(a[i], ans);
        }

        System.out.println(ans);
    }

    public static int gcd(int x, int y) {
        if (y == 0) {
            return x;
        }

        return gcd(y, x % y);

    }
}

Measured memory_bytes: 49180
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int N;

int main() {

	cin >> N;



	cout << (N + 1) / 2 << endl;

	return 0;
}


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

int main() {
  string r,s,t;
  cin >> r >> s >>t;
  	int n= s.size();
   char a='a';
  
  if(s.at(0)<a){
    if(n>=1 && n<=100) {
  		if(n==1){
          cout<<r.at(0)<<s.at(0)<<t.at(0)<<endl;
        }
        for(int i=1; i<n; i++){
   			if(s.at(i)<a){
    				break;
  				}
         if(i<(n-1)){ 
           continue;
         }
        
         cout << r.at(0) << s.at(0) << t.at(0) << endl;
        
        }
  }
 
}
}





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

const int p=1e9+7;
const int maxn=1e5+999;

struct mat{
	int a[5][5];
	mat(){memset(a,0,sizeof(a));}
	int* operator[](int i){return a[i];}
	friend mat operator*(mat x,mat y){
		mat z;
		for(int i=1;i<=3;i++)
			for(int j=1;j<=3;j++)
				for(int k=1;k<=3;k++)
					z[i][j]=(z[i][j]%p+x[i][k]*y[k][j]%p)%p;
		return z;
	}
}f,f2,g,F;
mat poww(mat a,int b){
	mat ans;for(int i=1;i<=3;i++)ans[i][i]=1;
	while(b){
		if(b&1)ans=ans*a;
		a=a*a;b>>=1;
	}
	return ans;
} 
int n,m,a[maxn],s[maxn];
signed main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	a[++m]=n;
	f[1][1]=2;f[1][2]=1;f[1][3]=1;f[2][1]=2;f[2][2]=1;f[3][1]=1;f[3][2]=1;f[3][3]=1;
	f2=f;f2[1][1]--;f2[1][2]--;f2[1][3]--;
	g[1][1]=g[1][2]=g[1][3]=1;
	for(int i=1;i<=3;i++)F[i][i]=1;
	for(int i=1;i<=m;i++){
		F=F*poww(f,a[i]-a[i-1]-1);
		if(a[i]==n)break;
		F=F*f2;
	}
	g=g*F;
	cout<<g[1][1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <utility>

using namespace std;

int t1, t2, r1, r2;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> t1 >> t2 >> r1 >> r2;
	if(r1 == -1 || r2 == -1){
		r1 = -t1, r2 = -t2;
	}
	
	if(r1 > r2){
		cout << "Alice" << endl;
	}
	else if(r1 < r2){
		cout << "Bob" << endl;
	}
	else cout << "Draw" << endl;
	
	return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int main() {
	run();
	ll n;
	cin >> n;
	ll number_of_char = 1, po = 26;
	while (po < n) {
		n -= po;
		po *= 26;
		number_of_char++;
	}
	string rt(number_of_char, 'a');
	n--;
	int j = number_of_char - 1;
	while (n) {
		rt[j] += (n % 26);
		n /= 26;
		j--;
	}
	cout << rt << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <stack>
#include <cstring>
using namespace std;
stack<int> S;
	int a, b, x;
	char s[1000];
int main()
{
	
	
	while(cin >> s)
	{	
		if( s[0] == '+')
		{
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		}
		else if( s[0] == '-')
		{
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(b - a);
		}
		else if( s[0] == '*')
		{
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a * b);
		}else
		{
			int sum = 0;
			for (int i = 0; i < strlen(s); i++) { sum = sum * 10 + (int)(s[i] - '0'); }
			S.push(sum);
		}
	}
	cout << S.top() << endl;
	return 0;
} 
 


Measured memory_bytes: 3108
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();

		int n = s.length;
		int mod = 1000000007;
		long[] dp0 = new long[n + 1];
		long[] dp1 = new long[n + 1];
		dp0[0] = 1;
		for (int i = 0; i < n; i++) {
			int d = s[i] - '0';
			dp0[i + 1] = dp0[i] * (d + 1);
			dp0[i + 1] %= mod;
			dp1[i + 1] = dp1[i] * 3 + dp0[i] * d;
			dp1[i + 1] %= mod;
		}
		System.out.println((dp0[n] + dp1[n]) % mod);
	}
}


Measured memory_bytes: 25964
import java.io.*;
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String s;
		try{
			while((s=br.readLine())!=null){
				String[] str=s.split(" ");
				int n=Integer.parseInt(str[0])+Integer.parseInt(str[1]);
				System.out.println(Integer.toString(n).length());
			}
			br.close();
		}catch(Exception e){
		}
	}
}

Measured memory_bytes: 17000
import java.util.*; 
import java.lang.*; 

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		
		int X = scan.nextInt();
		int Ans = 0;	
		
		while(X>=500){
			X = X-500;
			Ans = Ans + 1000;
		}
		
		while(X>=5){
			X = X - 5;
			Ans = Ans + 5;
		}
		
		System.out.println(Ans);
	}
}

Measured memory_bytes: 23252
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;

template<typename T> T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T> T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T> bool chmin(T& a, const T& b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T> bool chmax(T& a, const T& b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int64 ans(int64 h) {
    if (h == 1) return 1;
    return 1 + 2 * ans(h / 2);
}

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int64 h;
    cin >> h;

    print(ans(h));

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int X, u1000, u5;
  cin >> X;
  u1000 = X / 500;
  X %= 500;
  u5 = X / 5;
  cout << u1000 * 1000 + u5 * 5 << endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
N,M,Q = map(int, input().split())
tr = [list(map(int, input().split())) for i in range(M)]
num = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(M):
  a,b = tr[i]
  num[a][b] += 1
acc = [[0 for i in range(N+1)] for j in range(N+1)]
for i in range(1,N+1):
  for j in range(1,N+1):
    acc[i][j] += acc[i-1][j]+num[i][j]
for i in range(1,N+1):
  for j in range(1,N+1):
    acc[i][j] += acc[i][j-1]
query = [list(map(int,input().split())) for i in range(Q)]
for l,r in query:
  print(acc[r][r]-acc[l-1][r]-acc[r][l-1]+acc[l-1][l-1])

Measured memory_bytes: 79396
#include<stdio.h>

int main()
{
    int a,i;
    scanf("%d",&a);
    printf("%d:",a);
    for(i=2;i<=a;i++){
    	if(i>1000){
    		printf(" %d\n",a);
                return 0;
        }
    	if(a%i==0){
    		printf(" %d",i);
    		a /= i;
    		i = 1;
    	}
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main()
{
  int a, b, cnt = 0;
  cin >> a >> b;
  FOR(i, a, b + 1) {
    int o, p, q, r;
    o = i % 10;
    p = i / 10 % 10;
    q = i / 1000 % 10;
    r = i / 10000 % 10;
    if (o == r && p == q)
      ++cnt;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
fn getline() -> String{
	let mut __ret=String::new();
	std::io::stdin().read_line(&mut __ret).ok();
	return __ret;
}

fn main(){
	let s=getline();
	let a:Vec<_>=s.trim().split(' ').collect();
	let x:i32=a[0].parse().unwrap();
	let y:i32=a[1].parse().unwrap();
	let mut ans:i32 = x+y;
	if ans >= 24 {
	    ans = ans - 24;
	}
	print!("{} \n",ans);
}

Measured memory_bytes: 4352
a, b, c, k = map(int, input().split())

ans = 0
if k < a:
    ans = k
else:
    ans += a
    k = k - a
    if k < b:
        ans = ans
    else:
        ans = ans
        k = k - b
        if k < c:
            ans -= k
        else:
            ans = a - c

print(ans)

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

int main() {
  int h, w;
  cin >> h >> w;

  char a[51][51] = {};
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      cin >> a[i][j];
    }
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){

      if(a[i][j] == '#')
        continue;
      else if(a[i][j] == '.'){
        int c = 0;
        if(a[i-1][j-1] == '#')
          c++;
        if(a[i-1][j] == '#')
          c++;
        if(a[i-1][j+1] == '#')
          c++;
        if(a[i][j-1] == '#')
          c++;
        if(a[i][j+1] == '#')
          c++;
        if(a[i+1][j-1] == '#')
          c++;
        if(a[i+1][j] == '#')
          c++;
        if(a[i+1][j+1] == '#')
          c++;
        a[i][j] = c + '0';//ok
        // a[i][j] = (char)c;//ng 内部表現の複製のみが行われる
      }
    }
    cout << endl;
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
       cout << a[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 384
using AtCoderBeginnerContest148.Questions;
using AtCoderBeginnerContest148.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest148.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var a = inputStream.ReadIntArray();
            var b = inputStream.ReadIntArray();
            yield return new[] { 1, 2, 3, }.Except(a).Except(b).Single();
        }
    }
}


namespace AtCoderBeginnerContest148
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest148.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest148.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	while(cin>>N) {
		ll ans = INF;
		RANGE(A, 1, N) {
			ll B=N-A;
			string s = to_string(A)+to_string(B);
			ll lans = 0;
			REP(i, s.size()) lans+=s[i]-'0';
			ans = min(ans, lans);
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//#pragma GCC optimize("Ofast")
//1.0 * clock() / CLOCKS_PER_SEC

#define fi first
#define se second
#define ll long long
#define dl double long

using namespace std;

const int NN = 1e6 + 7;
const int N = 2e5 + 7;
const int M = 20;
const int mod = 998244353;
const ll inf = 1e18 + 7;
const dl rf = 1e-14;

ll p;

ll bnp( ll x , ll y )
{
    if( y == 0 )return 1;
    else{
        ll b = bnp( x , y / 2 );
        b = b * b % p;
        if( (y & 1) )b = b * x % p;
        return b;
    }
}

void solve1()
{
    int n;
    cin >> n >> p;
    ll ans = 0;
    vector < ll > v(p);
    vector < ll > f(n + 1);
    for( int i = 1; i <= n; i++ ){
        char c;
        cin >> c;
        int x = c - '0';
        f[i] = ( f[i - 1] * 10 + x ) % p;
        if( p == 2 || p == 5 ){
            if( f[i] == 0 )ans += i;
        }
        else{
            v[f[i - 1] * bnp( bnp( 10 , i - 1 ) % p , p - 2 ) % p] += 1;
            ans += v[ f[i] * bnp( bnp( 10 , i ) % p , p - 2 ) % p ];
        }
    }
    cout << ans;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0); srand(time(0));
    //freopen( "input.txt" , "r" , stdin );
    //freopen( "output.txt" , "w" , stdout );

    int cghf = 1;//cin >> cghf;
    while( cghf-- ){
        solve1();
    }
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a[100];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	int ma = 0;
	inc(i, n) {
	inc(j, i) {
		setmax(ma, abs(a[i] - a[j]));
	}
	}
	
	cout << ma << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);

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

  ll current_max = 0;
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    if (a[i] >= current_max) {
      current_max = a[i];
    } else {
      ans += current_max - a[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4400
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int cons = 1e9 + 7;

int n;
vector<double> v;
vector<double> l;
vector<double> r;
double speed(double t) {
	double maxV = 100;
	rep(0, n + 2) {
		double reti = 0;
		if (t <= l[i]) reti = v[i] + l[i] - t;
		else if (r[i] <= t) reti = v[i] + t - r[i];
		else reti = v[i];
		maxV = min(maxV, reti);
	}
	return maxV;
}

//D

int main(void) {
	
	cin >> n;	
	v = vector<double>(n + 2);
	l = vector<double>(n + 2);
	r = vector<double>(n + 2);
	v[0] = 0; l[0] = 0; r[0] = 0;
	v[n + 1] = 0;
	int T= 0;
	rep(1, n+1) {
		int ti = 0;
		cin >> ti;
		r[i] = r[i - 1] + ti;
		l[i] = r[i - 1];
		T += ti;
	}
	l[n] = r[n - 1];
	rep(1, n + 1) {
		cin >> v[i];
	}
	l[n + 1] = T; r[n + 1] = T;
	double ans = 0;
	for (double i = 0; i < T; i += 0.5) {
		double s1 = speed(i);
		double s2 = speed(i + 0.5);
		ans += 0.25*(s1 + s2);
	}
	cout << fixed << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<string> s(n);
    for(int i = 0; i < n; ++i)  cin >> s[i];
    ll ans = 0;
    int ab = 0, a = 0, b = 0;
    for(int i = 0; i < n; ++i){
        int sz = s[i].length();
        for(int j = 0; j + 1 < sz; ++j){
            if(s[i][j] == 'A' && s[i][j + 1] == 'B')    ++ans;
        }
        if(s[i][0] == 'B' && s[i][sz - 1] == 'A')   ++ab;
        else if(s[i][sz - 1] == 'A')    ++a;
        else if(s[i][0] == 'B') ++b;
    }
    if(ab > 0){
        if(a > 0 && b > 0){
            ans += ab + 1;
            --a, --b;
        }
        else if(a > 0){
            ans += ab;
            --a;
        }
        else if(b > 0){
            ans += ab;
            --b;
        }
        else{
            ans += ab - 1;
        }
        ab = 0;
    }
    if(a > 0 && b > 0){
        ans += min(a, b);
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
from collections import deque
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))



tmptime = 0
limitA = len(A) -1
for i,a in enumerate(A):
    
    if tmptime + a > K:
        limitA = i - 1 
        break
    tmptime += a

max_len = limitA
bi = 0
# print(tmptime)
while limitA >= -1:
    while bi < len(B) and tmptime + B[bi] <= K:
        # print(tmptime,B[bi])
        tmptime += B[bi]
        bi += 1


    max_len = max(limitA + 1 + bi, max_len)

    if limitA >= 0:
        tmptime -= A[limitA]
        limitA -= 1
    else:
        break
print(max_len)



Measured memory_bytes: 114340
#include <bits/stdc++.h>
using namespace std;
int main () {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        int b;
        cin >> b;
        mp[b]--;
        if (mp[b] < 0) {
            puts("NO");
            return 0;
        }
    }
    puts("YES");
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
const int N = 1e6 + 10;
const ll inf = 1e18 + 10, mod = 1e9 + 7;
int n, m[N], a[N], ans;
int main()
{
    ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("lca_rmq.in", "r", stdin);
    //freopen("lca_rmq.out", "w", stdout);
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        m[a[i]]++;
    }
    for(int i = 1; i <= n; i++)
    {
        int t = 0;
        for(int j = 2; j * j <= a[i]; j++)
        {
            if(a[i] % j == 0)
            {
                if(m[j])t = 1;
                if(j * j != a[i] && m[a[i] / j])t = 1;
            }
        }
        if(m[1] && a[i] != 1)t = 1;
        if(!t && m[a[i]] <= 1)ans++;
    }
    cout << ans;
}

















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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, c, k;
    cin >> n >> c >> k;
    int ans = 0;
    ll t[100000];
    for (int i = 0; i < n; i++) {
        cin >> t[i];
    }
    sort(t, t + n);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (t[j] - t[i] > k || j - i + 1 > c) {
                ans++;
                // cout << t[i] << " " << t[j] << endl;
                i = j - 1;
                break;
            }
        }
    }
    cout << ans + 1 << endl;
    return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
}

public class Main {
  private static int solve(char[] x) {
    ArrayDeque<Character> stack = new ArrayDeque<>();
    for (char c : x) {
      if (c == 'T' && !stack.isEmpty() && stack.peekLast() == 'S') {
        stack.pollLast();
      } else {
        stack.addLast(c);
      }
    }
    return stack.size();
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    char[] x = reader.next().toCharArray();
    out.println(solve(x));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}



Measured memory_bytes: 23952
//https://abc055.contest.atcoder.jp/tasks/arc069_b
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
string str;
int cond[100005],n,i;
bool a[100005];
int main()
{
	scanf("%d\n",&n);
	cin>>str;
	for (i=0;i<n;i++)
	{
		if (str[i]=='o') a[i+1]=0;
		else a[i+1]=1;
	}
	for (cond[1]=0;cond[1]<=1;cond[1]++)
	{
		for (cond[2]=0;cond[2]<=1;cond[2]++)
		{
			for (i=3;i<=n;i++)
			{
				cond[i]=cond[i-2]^cond[i-1]^a[i-1];
			}
			if (cond[1]==cond[n]^cond[n-1]^a[n] && cond[2]==cond[n]^cond[1]^a[1])
			{
				for (i=1;i<=n;i++)
				{
					if (cond[i]) printf("W");
					else printf("S");
				}
				printf("\n");
				return 0;
			}
		}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;




int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b==c||a+c==b||b+c==a)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N,K;
	char S[100001];
	int i;

	scanf("%d %d",&N,&K);
	scanf("%s",S);

	int score=0;
	for(i=0; i<N-1; i++) if(S[i]==S[i+1]) score++;

	int ans = (score+2*K>N-1) ? N-1 : score+2*K;
	printf("%d\n",ans );
}

Measured memory_bytes: 256
# x1〜xjからk枚選んでsになる組み合わせ dp[j][k][s]
n, a = gets.chomp.split.map(&:to_i)
x = gets.chomp.split.map(&:to_i)
#dp = Array.new(n+1).map{Array.new(n+1).map{Array.new(n*50+1, 0)}}
dp = Array.new(n+1).map{Array.new(n*50+1, 0)}

dp[0][0] = 1
for j in 1..n
    n.downto(0) do |k|
        (50*n).downto(x[j-1]) do |s|
            dp[k][s] = dp[k][s] + dp[k-1][s-x[j-1]]
       end
    end
end


ans = 0
for i in 1..n
    ans += dp[i][i*a]
end
puts ans             

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

int main(){
  
  int N,W;
  cin >>N>>W;
  vector<int> w(N),v(N);
  for(int i=0;i<N;i++){
    int x,y;
    cin >>x>>y;
    w[i] = x;
    v[i] = y;
  }
  
  vector<vector<long long>> dp(N+1,vector<long long>(1000000,0));
  
  for(int i=1;i<N+1;i++){
    for(int j=1;j<1000000;j++){
      long long res1 = dp[i-1][j]; //①直前の品物までの最善手
      long long res2 = 0; //②初期値
      if (j>=w[i-1]) res2 = dp[i-1][j-w[i-1]]+v[i-1];
      //②重さに余裕があれば、「その品物を入れる前までの最善手」にプラス
      dp[i][j] = max(res1,res2); //①と②を比較した本当の最善手
    }
  }
  
  //for(int i=0;i<N+1;i++){
  //  for(int j=0;j<sum+1;j++){
  //    cout << dp[i][j] << " ";
  //  }
  //  cout << endl;
  //}
  
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 797440
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef vector<int>vi;
typedef pair<int,int>pi;
typedef vector<pi>vpi;
typedef vector<vi>vvi;
#define double long double
#define pow powl
#define sqrt sqrtl
#define cbrt cbrtl
#define floor floorl
#define ceil ceill
#define pb push_back
#define ep emplace_back
#define PB pop_back
#define pf push_front
#define ef emplace_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)-a.begin()
#define lb(a,b) lower_bound(all(a),b)-a.begin()
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) FOR(i,0,n-1) cin>>a[i]
#define in1(a,n) FOR(i,1,n) cin>>a[i]
#define ff first
#define ss second
#define out(a,n) FOR(i,0,n-1) cout<<a[i]<<" ";cout<<endl;
#define out1(a,n) FOR(i,1,n) cout<<a[i]<<" ";cout<<endl;
#define clr(a) a.clear()
#define pow2(a) (1LL<<a)
#define all(a) a.begin(),a.end()
#define all1(a) a.begin()+1,a.end()
#define rall(a) a.rbegin(),a.rend()
#define rall1(a) a.rbegin(),a.rend()
#define sz(a) ((int)a.size())
#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define NFOR(i,a,b) for(auto i=a;i>=b;i--)
const int mod=1e9+7;

inline int add(int a,int b){return (a%mod + b%mod)%mod;}
inline int sub(int a ,int b){return (a%mod - b%mod + mod)%mod;}
inline int mul(int a,int b){a%=mod;b%=mod;return a*b%mod;}
inline int power(int a,int b,int MOD){a%=mod;int res=1;while(b){if(b&1){res*=a;res%=MOD;}a=a*a;a%=MOD;b>>=1;}return res;}

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     string s;
     cin>>s;
     int n=s.length();
     int ans=1e18;
     for(int i=0;i<n-2;i++)
     {
     	  string t;
     	  t+=s[i];
     	  t+=s[i+1];
     	  t+=s[i+2];
     	  int res=stoll(t);
     	  ans=min(ans,abs(res-753));
     }
     cout<<ans<<endl;
     time();
     return 0;
}



Measured memory_bytes: 256
from math import sqrt

N, M = map(int, input().split())
sqrtm = int(sqrt(M) + 1)
D = set()
for i in range(1, sqrtm):
    if M % i == 0:
        D.add(i)
        D.add(M // i)
D = sorted(list(D))
ans = 0
for d in D:
    if d * N <= M:
        ans = d
print(ans)


Measured memory_bytes: 38768
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(),(obj).end()

using namespace std;


int main() {
	speed;
	int n, m, c;
	cin >> n >> m >> c;
	int b[21];
	int a[21][21];
	rep(i, m) {
		cin >> b[i];
	}
	rep(i, n) {
		rep(j, m) {
			cin >> a[i][j];
		}
	}
	int ans = 0;
	rep(i, n) {
		int sum = 0;
		rep(j, m) {
			sum += a[i][j] * b[j];
		}
		if (sum+c > 0)ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256