akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def factor(n):
    res=[]
    for d in range(1,n+1):
        if d*d>n:break
        if n%d==0:
            res.append(d)
            res.append(n//d)
        if res[-1]==res[-2]:res.pop()
    return res[1:]

def main():
    n=II()
    ff=factor(n)
    ans=len(factor(n-1))
    for k in ff:
        for b in range(1,40):
            pw=pow(k,b)
            if n%pw==0 and (n//pw-1)%k==0:
                ans+=1
                #print(k,(n//pw-1)%k,b)
    print(ans)

main()

Measured memory_bytes: 41052
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    int n;
    scanf("%d", &n);
    int L[n];
    rep(i, n) scanf("%d", &L[i]);
    sort(L, L+n);

    lint ans = 0;
    rep(i, n)For(j, i+1, n){
        lint tmp = lower_bound(L+j+1, L+n, L[i]+L[j]) - (L+j+1);
        ans += tmp;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<stdlib.h>
#include<time.h>
int main(void){
	int n,i,j,k,len=0,count=0, f;
	char seek[100], ring[100];
	scanf("%s", seek);
	scanf("%d", &n);
	
	while(seek[len]!='\0') ++len;
	
	for(i=0; i<n; i++){
		scanf("%s", ring);
		f=0;
		
		for(j=0;j<10&&f==0;j++) {
			f=1;
			for(k=0; k<len; k++){
				if(ring[(j+k)%10]!=seek[k]){
					f=0;
					break;
				}
			}	
		}
		
		count+=f;
	}
	printf("%d\n", count);
	
	return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <functional>
#include <set>
#include <numeric>
#include <queue>
#define ll long long int
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define PI 3.14159265358979323846264338327950


int main() {
	ll N, num=0, ans=0;
	string a, t;
	const char *x;

	cin >> a ;
	N = a.length();
	
	rep(i, N){
		t = a[i];
		x = t.c_str();
		num += atoi(x);
	}

	if (num % 9 == 0){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
#define ld long double

using namespace std;	

int main() {
	int a, b, c;
	scanf ("%d%d%d", &a, &b, &c);
	int ans = 0;
	while (!(a & 1) & !(b & 1) & !(c & 1)) {
		if (a == c) {
			printf ("-1\n");
			return 0;
		}
		int x = (a + b) / 2;
		int y = (b + c) / 2;
		int z = (a + c) / 2;
		ans++;
		a = x, b = y, c =z;
	}
	printf ("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<set>
#include<stack>
#include<map>
#include<queue>
#include<cstring>
#include<vector>
#include <type_traits>
typedef long long int ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef pair<ll, ll>P;
template<typename T, typename U>
std::enable_if_t<std::rank<T>::value == 0> fill_all(T& arr, const U& v) {
	arr = v;
}
template<typename ARR, typename U>
std::enable_if_t<std::rank<ARR>::value != 0> fill_all(ARR& arr, const U& v) {
	for (auto& i : arr) {
		fill_all(i, v);
	}
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}
#define yo 100001
//------------------変数-----------------------//
ll d, n, t[300] = {}, W;
P p[101] = {};
ll mini;
map<P, ll> dp;
//-------------------関数----------------------//
ll DP(ll num,ll weight) {
	if (weight > W) { return -INF; }
	if (num == n) { return 0; }
	if (dp.count(P(num, weight))) { return dp[P(num,weight)]; }
	return dp[P(num, weight)] = max(DP(num + 1, weight), DP(num + 1, weight + p[num].first)+p[num].second);
}

int main() {
	cin >> n >> W;
	REP(i, n) {
		ll w, v; cin >> w >> v;
		p[i].first = w; p[i].second = v;
	}
	sort(p, p + n);
	mini = p[0].first;
	cout << DP(0,0) << endl;
	return 0;
}




Measured memory_bytes: 6272
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main ( void ) {
    
    char word[10];
    char input[1000];
    int counter = 0;
    
    scanf ( "%s", word );
    
    while ( 1 ) {
        scanf ( "%s", input );
        if ( strcmp ( input, "END_OF_TEXT" ) == 0 ) {
            break;
        } else {
            for ( int i = 0; input[i] != '\0'; i++ ) {
                input[i] = tolower( input[i] );
            }
        }
        if ( strcmp ( word, input ) == 0 ) counter += 1;
    }

    printf ( "%d\n", counter );

    return 0;
}


Measured memory_bytes: 2672
#include <stdio.h>

#define MAX 3

int main()
{
 	char s[MAX+1];
  
  	scanf("%s",s);
  
  if(s[0]==s[1] && s[1]==s[2])
    printf("No\n");
  else
    printf("Yes\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 2147483647
#include <math.h> /* M_PI */
int main()
{
    ll a, v, b, w, T;
    cin >> a >> v;
    cin >> b >> w;
    cin >> T;
    if (labs(a - b) <= T * (v - w))
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define PI 3.14159265
#define ll long long
#define ld long double
#define vi vector<int>
#define pb push_back
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 300000000000000001
#define infx 9223372036854775806
#define all(c) c.begin(),c.end()
#define mk(x,yy) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define ff first
#define ss second
#define re return
// #define endl "\n"
#define max2(x,y)           (x>y)?x:y
#define min2(x,y)           (x<y)?x:y
#define mid(s,e)               (s+(e-s)/2)
#define mini                   INT_MIN
#define maxo                   INT_MAX
#define rep(i,a,b) for(int i=a;i<(int)(b);++i)
#define read(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define show(a,n) for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl
#define ene cout<<"\n";

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
}
ll power(ll x,  ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 
 
bool compr(std::vector<ll> a, std::vector<ll> b)
{
    if(a[0]==b[0])
        return a[1]<b[1];
    else
        return a[0]<b[0];
}

bool comp(std::vector<ll> a, std::vector<ll> b)
{
    if(a[1]==b[1]&&a[2]==b[2])
        return a[0]<b[0];
    else if(a[1]==b[1])
        return a[2]>b[2];
    else
        return a[1]<b[1];
}

void add_self(ll &a, ll b)
{
    a = (a+b);
    if(a>=mod)
        a-=mod;
}
int main()
{
    #ifdef SHIVANSH 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string k;
    cin>>k;
    ll d;
    cin>>d;
    ll dp[d][2] = {};
    dp[0][0] = 1;

    for(ll i=0;i<k.size();i++)
    {
        ll new_dp[d][2] = {};
        for(ll sum = 0; sum<d;sum++)
        {
            for(ll sm_already=0;sm_already<2;sm_already++)
            {
                for(ll digit=0;digit<10;digit++)
                {
                    if(k[i]-'0'<digit&&sm_already==0)
                        break;
                    add_self(new_dp[(sum+digit)%d][sm_already||(k[i]-'0'>digit)],dp[sum][sm_already]);
                }
            }
        }
        for(ll j=0;j<d;j++)
        {
            for(ll r=0;r<2;r++)
                dp[j][r] = new_dp[j][r];
        }
    }
    ll ans = dp[0][0]+dp[0][1];
    ans--;
    if(ans<0)
        ans+=mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
int main(){
    int W,H,N;
    cin >> W >> H >> N;
    int x,y,a,i;
    int left = 0, right = W, down = 0, up = H;
    for(i=0;i<N;i++){
        cin >> x >> y >> a;
        switch(a){
            case 1:
                left = max(left,x);
                break;
            case 2:
                right = min(x,right);
                break;
            case 3:
                down = max(down,y);
                break;
            case 4:
                up = min(up,y);
                break;
            default:
                break;
        }
    }
    cout << max(0,right - left) * max(0, up - down) << endl;
    return 0;
}

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

int main()
{
  long long R,B,N,count,amari;
  long long b;
  
  cin>>N>>B>>R;
  
  count=N/(B+R);
  b=count*B;
  amari=N%(B+R);
  if(amari>=B)
  {
    b+=B;
  }
  else
  {
    b+=amari;
  }
  cout<<b;
}


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

using namespace std;

typedef long long ll;
const ll MAXN = 1000010;

ll N, X, ans;

ll gcd(ll, ll);

int main() {
    scanf("%lld%lld", &N, &X); 
    ll ans = gcd(min(X, N-X), max(X, N-X)) + N;
    printf("%lld\n", ans);
    return 0;
}

ll gcd(ll x, ll n) {
    if (x == 0) return -n;
    ll tem = n / x;
    ll ret = tem * 2 * x;
    return gcd(n % x, x) + ret;
}

Measured memory_bytes: 3776
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
int mod;
inline int add(int a, int b) {
    int s = a + b;
    if (s >= mod) s -= mod;
    return s;
}
inline int mult(int a, int b) {
    return (1LL * a * b) % mod;
}
inline int sub(int a, int b) {
    int s = a - b;
    if (s < 0) s += mod;
    return s;
}
const int maxN = 5005;
ll dp[maxN][maxN];
void calc(int cnt, int at_most) {
    for (int i = 1; i < cnt; i++) {
        for (int sum = at_most; sum >= 0; sum--) {
            ll p0 = 0;
            ll p1 = 0;
            for (int new_last = 0; ; new_last++) {
                if (new_last * (cnt - i + 1) + sum > at_most) break;
                p0 += dp[new_last][sum];
                p1 += new_last * dp[new_last][sum];
                dp[new_last][sum + new_last] = (((new_last + 1) * p0) - p1) % mod;
                if (dp[new_last][sum + new_last] < 0) dp[new_last][sum + new_last] += mod;
            }
        }
    }
}
int c2[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n >> mod;
    for (int i = 0; i <= n + 1; i++) {
        c2[i] = ((1LL * i * (i - 1)) / 2) % mod;
    }
    if (n == 2) {
        cout << 3;
        return 0;
    }
    if (n % 2 == 1) {
        for (int last = 0; last <= n; last++) {
            dp[last][last] = 1;
        }
    }
    else {
        for (int last = 0; last <= n; last++) {
            dp[last][last] = last + 1;
        }
    }
    calc((n - 1) / 2, n);
    int ans = 0;
    for (int last = 0; last <= n; last++) {
        for (int sum = 0; sum + last <= n + 1; sum++) {
            if (dp[last][sum] == 0) continue;
            ans = add(ans, mult(dp[last][sum], c2[n - sum - last + 1]));

        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 194944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String args[]) {
        FastReader sc = new FastReader();
        int n = sc.nextInt();
        int ma = sc.nextInt();
        int mb = sc.nextInt();
        int[][][] dp = new int[41][411][411];
        for(int i = 0; i < 41; i++)
            for (int j = 0; j < 401; j++)
                for (int k = 0; k < 401; k++)
                    dp[i][j][k] = 10000;
        int[] as = new int[n];
        int[] bs = new int[n];
        int[] cs = new int[n];
        for (int i = 0; i < n; i++) {
            as[i] = sc.nextInt();
            bs[i] = sc.nextInt();
            cs[i] = sc.nextInt();
        }
        dp[0][0][0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < 400; j++) {
                for (int k = 0; k < 400; k++) {
                    dp[i + 1][j + as[i]][k + bs[i]] =
                            Math.min(dp[i + 1][j + as[i]][k + bs[i]],
                            dp[i][j][k] + cs[i]);
                    dp[i + 1][j][k] = Math.min(
                            dp[i + 1][j][k], dp[i][j][k]);
                }
            }
        }
        int ans = 10000;
        for (int i = 1; i < 400; i++) {
            int a = ma * i;
            int b = mb * i;
            if (a > 400 || b > 400) break;
            ans = Math.min(ans, dp[n][a][b]);
        }
        if (ans == 10000) System.out.println(-1);
        else System.out.println(ans);
    }

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 56404
using System;
class Program
{
    static void Main(string[] args)
    {
        bool isFirst = true;
        int[] coins = new int[] { 10, 50, 100, 500 };
        int bill, ownedMoney, changeMoney;
        int[] ownedCoins = new int[4], changeCoins = new int[4], paymentCoins = new int[4];

        while (true)
        {
            bill = int.Parse(Console.ReadLine());
            if (bill == 0) break;
            if (isFirst) { isFirst = false; } else { Console.WriteLine(); }
            ownedCoins = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            ownedMoney = 0;
            for (int i = 3; i >= 0; i--)
                ownedMoney += coins[i] * ownedCoins[i];

            changeMoney = ownedMoney - bill;

            for (int i = 3; i >= 0; i--)
            {
                changeCoins[i] = changeMoney / coins[i];
                changeMoney = changeMoney % coins[i];
                paymentCoins[i] = ownedCoins[i] - changeCoins[i];
            }
            for (int i = 0; i < 4; i++)
                if (paymentCoins[i] > 0) Console.WriteLine("{0} {1}", coins[i], paymentCoins[i]);
        }
    }
}


Measured memory_bytes: 9436
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
#define fil(x) memset(x, 0, sizeof(x))
#define fillb(x) memset(x,false,sizeof(x))
#define fillm(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define pll pair<int, int>
#define pf printf
#define sf scanf
#define all(x) x.begin(),x.end()
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define np std::string::npos
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<n;i++)
#define fof(i,a,b) for(int i=a;i<=b;i++)
#define off(i,a,b) for(int i=a;i>=b;i--)
#define of(i,n) for(int i=n-1;i>=0;i--)
#define stl(i,x) for(auto i=x.begin(); i!=x.end();i++)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define nl endl

typedef unsigned long long lll;
typedef long long ll;
int knigtx8[] = {2, 2, -2, -2, 1, 1, -1, -1}; ///knight move in chess
int knigty8[] = {1, -1, 1, -1, 2, -2, 2, -2}; ///knight move in chess
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}; ///for 8 directions
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1}; ///for 8 directions
int dx4[] = {0, 0, 1, -1}; ///for 4 directions
int dy4[] = {1, -1, 0, 0}; ///for 4 directions
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}
ll pw(ll a, ll b)
{
    ll ans = 1;
    for(ll i = 1; i <= b; ++i)
        ans = (ans * a);
    return ans;
}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

int main()
{
    IOS;
    int n;
    cin>>n;
    map<string,int>m;
    string tt[4]={"AC","WA","TLE","RE"};
    int num[4];
    fil(num);
    string s;
    fo(i,n)
    {
        cin>>s;
        m[s]++;
    }
    stl(i,m)
    {
        if((*i).first=="AC")num[0] = (*i).second;
        else if((*i).first=="WA")num[1] = (*i).second;
        else if((*i).first=="TLE")num[2] = (*i).second;
        else if((*i).first=="RE")num[3] = (*i).second;
    }
    fo(i,4)
    {
        cout<<tt[i]<<" x "<<num[i]<<endl;
    }
}

///Alhamdulillah


Measured memory_bytes: 3660
n, m, x, y = map(int, input().split())
X = [int(i) for i in input().split()]
Y = [int(i) for i in input().split()]

X.append(x)
Y.append(y)

X.sort()
Y.sort()

print('War' if max(X) >= min(Y) else 'No War')

Measured memory_bytes: 3060
import java.util.*;
//import java.math.BigDecimal;

public class Main{
    public static void main(String args[]){

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[] m = new int[n];
        long answer = 1;
        //BigDecimal answer = BigDecimal.valueOf(1);

        if(sc.nextInt() != 0) answer = 0;
        //if(sc.nextInt() != 0) answer = BigDecimal.valueOf(0);
        else m[0]++;
        for(int i = 1; i < n; i++){
            int x;
            if((x = sc.nextInt()) == 0){
                answer = 0;
                //answer = BigDecimal.valueOf(0);
                break;
            }
            m[x]++;
        }

        for(int i = 1; i < n; i++){
            //answer *= ((long)Math.pow(m[i-1], m[i]) % 998244353);
            //answer = answer.multiply(BigDecimal.valueOf(Math.pow(m[i-1], m[i])));
            for(int j = 0; j < m[i]; j++){
                answer = m[i-1] * answer % 998244353;
            }
        }

        //System.out.println(answer % 998244353);
        //System.out.println(answer.remainder(BigDecimal.valueOf(998244353)).toBigInteger());
        System.out.println(answer);

    }

}


Measured memory_bytes: 50188
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<algorithm>
#include<map>
#include<unordered_map>
#pragma warning(disable: 4996)
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;


int main() {

	int m, f, b;
	cin >> m >> f >> b;
	if (b > m + f) {
		cout << "NA" << endl;
		return 0;
	}
	if (m >= b) {
		cout << '0' << endl;
		return 0;
	}
	cout << b - m << endl;
	return 0;
}


Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main() {
    char x, y;
    cin >> x >> y;
    int a, b;
    a = x - 'A';
    b = y - 'A';
    if (a > b)
        cout << ">" << endl;
    else if (a < b)
        cout << "<" << endl;
    else
        cout << "=" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            string [] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            if(a < b){
            Console.WriteLine("a < b");
            }

            if (a > b)
            {
                Console.WriteLine("a > b");
            }

            if (a == b)
            {
                Console.WriteLine("a == b");
            }

           
        }
    }
}

Measured memory_bytes: 8908
#include<bits/stdc++.h>
#define ll long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define pb push_back
#define MAX 1000000007
using namespace std;
int main()
{
 	speed_up
    ll n,m;cin>>n>>m;
     ll lo,hi;cin>>lo>>hi;
     for(ll i=1;i<m;i++)
     {
     	ll x,y;cin>>x>>y;
     	if(x>lo) lo=x;
		 if(y<hi) hi=y; 
	 }
	 if((hi-lo+1)>0) cout<<hi-lo+1;
	 else cout<<0;
    
     
	
	
	
	
	
	
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

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

  string str;
  cin >> str;

  switch (str[k - 1]) {
  case 'A':
    str[k - 1] = 'a';
    break;
  case 'B':
    str[k - 1] = 'b';
    break;
  case 'C':
    str[k - 1] = 'c';
    break;
  }

  cout << str << endl;
}

Measured memory_bytes: 256
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

int fact(int x){
  int res = 1;
  for(int i = 1; i <= x; i++){
    res *= i; res %= MOD;
  }
  return res;
}

int dp[101][101][256]; // i個目までからj個とってXORがk

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

  int N, K, a[100]; cin >> N >> K;
  REP(i, N) cin >> a[i];

  for(int i = 0; i <= N; i++) dp[i][0][0] = 1;

  for(int i = 1; i <= N; i++){
    for(int j = 1; j <= i; j++){
      for(int k = 0; k < 256; k++){
        if(j > 0) dp[i][j][k] += dp[i-1][j-1][k^a[i-1]] + dp[i-1][j][k];
        else dp[i][j][k] += dp[i-1][j][k];
        dp[i][j][k] %= MOD;
      }
    }
  }

  int ans = 0;

  for(int i = 0; i <= N; i++){
    ans += (dp[N][i][K] * fact(i)) % MOD;
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
int N,Ans=0;
vector<int> Primes,Index;
bool P[110];
int Solve(int X)
{
	int A=N/X,Cnt=0;
	while(A)
	{
		Cnt+=A;
		A/=X;
	}
	return Cnt;
}
int main()
{
	cin>>N;
	memset(P,true,sizeof(P));
	P[0]=P[1]=false;
	for(int i=2;i<=N;i++)
		if(P[i])
		{
			Primes.push_back(i);
			for(int j=i*i;j<=N;j+=i) P[j]=false;
		}
	for(int i=0;i<Primes.size();i++) Index.push_back(Solve(Primes[i]));
	int Cnt=0;
	for(int i=0;i<Index.size();i++) if(Index[i]>=74) ++Cnt;
	Ans+=Cnt;
	int Cnt1=0,Cnt2=0;
	for(int i=0;i<Index.size();i++)
		if(Index[i]>=24)++Cnt1,++Cnt2;
		else if(Index[i]>=2) ++Cnt1;
	Ans+=(Cnt1-1)*Cnt2;
	Cnt1=0,Cnt2=0;
	for(int i=0;i<Index.size();i++)
		if(Index[i]>=14)++Cnt1,++Cnt2;
		else if(Index[i]>=4) ++Cnt1;
	Ans+=(Cnt1-1)*Cnt2;
	Cnt1=0,Cnt2=0;
	for(int i=0;i<Index.size();i++)
		if(Index[i]>=4)++Cnt1,++Cnt2;
		else if(Index[i]>=2) ++Cnt1;
	Ans+=(Cnt1-2)*(Cnt2*(Cnt2-1)/2);
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
#define mod 1000000007
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define loop(x,y,z) for(int x=y;x<z;x++)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x,y;
    cin>>x>>y;
    vector<vector<ll>>v;
    v.resize(x);
    while(y--){
        ll z;
        cin>>z;
        f(i,z){
            ll k;
            cin>>k;
            k--;
            v[k].pb(i);
        }
    }
    ll ans=0;
    f(i,v.size()){
        if(v[i].size()==0){
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

bool pal(string s) {
  string s2 = s;
  reverse(s2.begin(), s2.end());
  return s == s2;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;

  ll n = s.length();

  string s1 = s.substr(0, n / 2);

  string s2 = s.substr(n / 2 + 1, n / 2);

  cout << ((pal(s) && pal(s1) && pal(s2)) ? "Yes" : "No") << en;
  return 0;
}


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

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

Measured memory_bytes: 3620
using System;
public class P{
  public static void Main(){
    int i=1;
    char? p1=null, p2=null;
    var s=Console.ReadLine().ToCharArray();
    foreach(char x in s){
        if(x==p1){Console.WriteLine($"{i-1} {i}");return;}
       if(x==p2){Console.WriteLine($"{i-2} {i}");return;}
        p2=p1;
        p1=x;
        i++;
    }
   Console.WriteLine($"-1 -1");
  }
}

Measured memory_bytes: 13536
import math
while True:
    num = int(input())
    if num == 0: break
    array = [int(i) for i in input().split()]
    mean = sum(array) / num
    a = 0
    for i in range(num):
        a += (array[i] - mean) ** 2
    a /= num
    a = math.sqrt(a)
    print(a)

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

vector<int> t;

long long part(int b,int e){
	long long count=0,aans=0,ii;
	for(ii=b;ii<=e;ii++){
		if(t[ii]==1){
			aans+=count;
		} else {
			count++;
		}
	}
	return aans;
}

int main() {
	int n,m,i,s[200005];
	long long ans=0;
	char ss[200005];
	cin >> ss;
	n=strlen(ss);
	for(i=0;i<n;i++){
		if(ss[i]=='A') s[i]=0;
		if(ss[i]=='B') s[i]=2;
		if(ss[i]=='C') s[i]=3;
	}
	for(i=1;i<n;i++){
		if(s[i-1]==2&&s[i]==3){
			s[i-1]=4;
			s[i]=1;
		}
	}
	for(i=0;i<n;i++){
		if(s[i]<=3) t.push_back(s[i]);
	}
	m=t.size();
	int begin=0,end=0;
	for(i=0;i<m;i++){
		if(t[i]<=1){
			if(i==m-1){
				ans+=part(begin,m-1);
			} else {
				end=i;
			}
		} else {
			if(i==0){
				begin=1;
				end=1;
			} else if(t[i-1]>1){
				begin=i+1;
				end=i+1;	
				continue;
			} else {
				ans+=part(begin,end);
				begin=i+1;
				end=i+1;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	string s;
	cin >> s;
	bool ans = true;
	for (int i = 0; i < s.size() - 1; i++) {
		if (s.at(i) == s.at(i + 1)) ans = false;
	}
	if (ans) cout << "Good";
	else cout << "Bad";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
pair <int,int> mas[200001];
queue <pair<int,int> > q;
main() {
    int n,d,a;
    cin>>n>>d>>a;d*=2;
    for (int i=1;i<=n;i++)
        cin>>mas[i].first>>mas[i].second;
    sort(mas+1,mas+n+1);
    int s=0,ans=0;
    //q.push({2000000000,0});
    for (int i=1;i<=n;i++) {
        while (q.size() &&q.front().first<mas[i].first) {
            s-=q.front().second;
            q.pop();
        }
        int hey=0;
        if (mas[i].second-a*s>0)
            hey=(mas[i].second-a*s+a-1)/a;
        ans+=hey;
        s+=hey;
        q.push({mas[i].first+d,hey});
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6656
N = int(input())
abc = []
for _ in range(N):
    abc.append(list(map(int, input().split())))

dp = [[0] * 3 for _ in range(N)]
dp[0] = abc[0]
# print(dp)

for day in range(N - 1):
    for todo in range(3):
        for did in range(3):
            if todo != did:
                dp[day + 1][todo] = max(dp[day][did] + abc[day + 1][todo], dp[day + 1][todo])
print(max(dp[N - 1]))

Measured memory_bytes: 74328
# 整数列A 
# 3箇所で切って、４つに
# それぞれの総和の最大値と最小値の差の絶対値の最小値

# 中央を固定することを考える(結局、その固定を全検索するが)
# 中央固定後、左側について、両方が同じくらいの値になるのが最適と考えて良いらしい

from itertools import accumulate

N=int(input())
A=list(map(int,input().split()))
SumA=list(accumulate(A))

tmpP=tmpQ=tmpR=tmpS=0
P=Q=R=S=0
ans=10e9
l = 0
r = 2

# midとmid+1の間が中間の切断
for mid in range(1,N-2):

	# l,rは、単調増加であるため、全ての中間点を求めるループの間、クリアの必要がないらしい

	# 次のやつよりも、今のやつの方が大きい限り、継続
	# 必ず、それが逆転する時が最小のはず、という考え。。。
	while l < mid and abs(SumA[l+1]-(SumA[mid] - SumA[l+1])) < abs(SumA[l]-(SumA[mid] - SumA[l])):
		l += 1

	# 次のやつよりも、今のやつの方が大きい限り、継続
	# 必ず、それが逆転する時が最小のはず、という考え。。。
	while r <= mid or (r < N and abs((SumA[r+1]-SumA[mid]) - (SumA[N-1]-SumA[r+1])) < abs((SumA[r] - SumA[mid]) - (SumA[N-1] - SumA[r]))):
		r += 1

	#print("{},{}".format(mid,l))

	P=SumA[l]
	Q=SumA[mid]-SumA[l]
	R=SumA[r]-SumA[mid]
	S=SumA[N-1]-SumA[r]

	#print(P,Q,R,S)
	diff=max(P,Q,R,S)-min(P,Q,R,S)
	diff=abs(diff)
	ans = min(ans,diff)

print(ans)


Measured memory_bytes: 24180
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)(1e9)+7)

int main(){
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int w=tx-sx, h=ty-sy;
	for(int i=0; i<w;   i++) cout << "R";
	for(int i=0; i<h;   i++) cout << "U";
	for(int i=0; i<w;   i++) cout << "L";
	for(int i=0; i<h+1; i++) cout << "D";
	for(int i=0; i<w+1; i++) cout << "R";
	for(int i=0; i<h+1; i++) cout << "U";
	for(int i=0; i<1;   i++) cout << "L";
	for(int i=0; i<1;   i++) cout << "U";
	for(int i=0; i<w+1; i++) cout << "L";
	for(int i=0; i<h+1; i++) cout << "D";
	for(int i=0; i<1;   i++) cout << "R";
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N, A, B;
  cin >> N >> A >> B;
  long long C = N / (A + B);
  long long ans = C * A;
  long long R = N - C * (A + B);
  ans += min(R, A);
  cout << ans;
}

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

class Program {
    static int Main(string[] args) {
        string W = Console.ReadLine();

        List<string> T = new List<string>();
        while (true) {
            string t = Console.ReadLine();
            if (t == "END_OF_TEXT") { break; }

            string[] ts = t.ToLower().Split(' ');
            T.AddRange(ts);
        }

        int cnt = 0;
        for (int i = 0; i < T.Count; i++) {
            if (T[i] == W) { cnt++; }
        }
        
        Console.WriteLine(cnt);

        return 0;
    }
}


Measured memory_bytes: 15880
import java.util.Scanner;

class Main{

	public static void main(String[] args) {

	int[] n;
	n = new int[3];

	Scanner scan = new Scanner(System.in);

	n[0] = scan.nextInt();
	n[1] = scan.nextInt();
	n[2] = scan.nextInt();

	if(n[0] < n[1] && n[1] < n[2]) System.out.println("Yes");
	else System.out.println("No");

	scan.close();
	}
}

Measured memory_bytes: 26400
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

const ll maxn=100000;

int main(){
    
    string s;
    cin >> s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
        cout << "Bad"<<endl;
    }else{
        cout << "Good"<<endl;
    }
    
    return 0;
}


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

int main(){
  long long N,a,c=1,A[100002]={};A[0]=3;
  cin>>N;
  for(int i=0;i<N;i++){
    scanf("%d",&a);
    c*=(A[a]-A[a+1]++);
    c%=1000000007;
  }
  cout<<c<<endl; 
}

Measured memory_bytes: 4508
# ABC_087_B_Coins
A = int(input())  # 500coins
B = int(input())  # 100coins
C = int(input())  # 50coins
X = int(input())
count = 0
for a in range(0, A+1):
	for b in range(0, B+1):
		for c in range(0, C+1):
			sum = 500*a + 100*b + 50*c
			if sum == X:
				count += 1
print(count)


Measured memory_bytes: 67516
fn main() {
    let s = input();
    println!("{}", solve(s));
}

fn input() -> Vec<char> {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.pop();
    let s = buf.chars();
    s.collect()
}

fn solve(s: Vec<char>) -> String {
    let mut a = 0;
    let mut b = 0;
    for c in s.iter() {
        if *c == 'A' { a += 1; }
        else if *c == 'B' { b += 1; }
    }
    if a != 0 && b != 0 {
        return String::from("Yes");
    }
    String::from("No")
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
    #include <math.h>
 
    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846
 
 
    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    long long mul(long long a, long long b){
        return mod(mod(a)*mod(b));
    }
 
    ll modPow(ll a, ll b){
        if(b==0)
            return 1LL;
        if(b==1)
            return a%M;
        ll res=1;
        while(b){
            if(b%2==1)
                res=mul(res,a);
            a=mul(a,a);
            b=b/2;
        }
        return res;
    }
    
    ll ok(ll n){
        ll ans=(n*(n+1))/2;
        return ans;
    }

    void solve (){
        ll n;
        cin>>n;
        ll l=1;
        ll r=1e9+5;
        while(l<r){
            ll mid=(l+r)/2;
            ll ans=ok(mid);
            if(ans>n)
                r=mid;
            else if(ans<n){
                l=mid+1;
            }
            else{
                l=mid;
                break;
            }
        }
        cout<<l;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
        // cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0LL)
#define mapmin(v) v.rbegin()->first
#define mapmax(v) v.begin()->first
#define pb push_back
#define pf push_front
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK cerr<<"OK\n"
#define OK1 cerr<<"OK1\n"
#define OK2 cerr<<"OK2\n"
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);
const int mod=1000000007;
const int mod2=998244353;

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

void YES(bool b) {cout << ((b)?"YES\n":"NO\n");}
void Yes(bool b) {cout << ((b)?"Yes\n":"No\n");}
void yes(bool b) {cout << ((b)?"yes\n":"no\n");}
void Yay(bool b) {cout << ((b)?"Yay!\n":":(\n");}

ll powmod(ll a,ll b){ll c=1; while(b>0){ if(b&1){ c=a*c%mod; } a=a*a%mod; b>>=1; } return c;}
ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll h,w,k,ans=INF;
	cin >> h >> w >> k;
	vs s(h);
	rep(i,h) cin >> s[i];
	rep(div,1<<(h-1)){
		ll g=0;
		vll id(h);
		rep(i,h){
			id[i]=g;
			if(div>>i&1) g++;
		}
		g++;
		vvll c(g,vll(w,0));
		rep(i,h){
			rep(j,w) c[id[i]][j]+=s[i][j]-'0';
		}
		ll num=g-1;
		vll now(g);
		auto add=[&](ll j){
			rep(i,g) now[i]+=c[i][j];
			rep(i,g){
				if(now[i]>k) return false;
			}
			return true;
		};
		rep(j,w){
			if(!add(j)){
				num++;
				now=vector<ll>(g);
				if(!add(j)){
					num=INF;
					break;
				};
			}
		}
		chmin(ans,num);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

int main(void)
{
	int i, j, a, b;
	while(std::cin >> i >> j){
		if(i == 0 && j == 0)
			break;
	for(a = 0; a < i; a++){
		for(b = 0; b < j; b++){
			std::cout << "#";
		}
		std::cout << std::endl;
	}
	std::cout << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3128
# coding: utf-8
N=int(input())
A=list(map(int,input().split()))

dp=[0 for i in range(N)]
dp[0]=1000

for i in range(1,N):
    for j in range(i,N):
        #print(i,j,dp[i-1]+(dp[i-1]//A[i-1])*(A[j]-A[i-1]))
        dp[j]=max(dp[j-1],dp[j],dp[i-1]+(dp[i-1]//A[i-1])*(A[j]-A[i-1]))
        
print(dp[-1])

Measured memory_bytes: 9072
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class BRobotArms {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;

      vector<P> vec(n);
      rep(i, n) {
        ll x, l; cin >> x >> l;
        vec[i].second = x-l;
        vec[i].first = x+l;
      }

      sort(all(vec));

      ll right = LLONG_MIN;
      int ans = 0;
      rep(i, n) {
        if (vec[i].second >= right) {
          right = vec[i].first;
          ans++;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  BRobotArms solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 1792
H, W, K = map(int, input().split())

S = [list(map(int, input())) for _ in range(H)]
accS = [[0] * (W + 1) for _ in range(H + 1)]

for h in range(H):
    for w in range(W):
        accS[h + 1][w + 1] = accS[h + 1][w] + accS[h][w + 1] - accS[h][w] + S[h][w]

def isOk(L, left, right):
    for top, bot in zip(L, L[1:]):
        if accS[bot][right] - accS[bot][left] - accS[top][right] + accS[top][left] > K:
            return False
    return True

ans = 10**18

for mask in range(1 << H):
    L = [0] + [d + 1 for d in range(H - 1) if (mask & (1 << d)) > 0] + [H]

    cnt = len(L) - 2
    left = 0
    while left < W:
        if not isOk(L, left, left + 1):
            cnt = 10**18
            break

        right = left + 1
        while right < W and isOk(L, left, right + 1):
            right += 1

        cnt += 1
        left = right

    ans = min(ans, cnt - 1)

print(ans)

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

typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1e18+7;
#define rep(i,N) for(ll i=0; i<(N); i++)
#define rep1(i,N) for(ll i=1; i<(N); i++)
#define pb push_back

ll A,B;
char grid[105][105];

int main(){

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

cin>>A>>B;

ll a=0,b=0;
rep(h,100){
	ll hh=99-h;
	if(hh%2==1){
		rep(w,100){
		if(w%2==0&&b<B-1){
			grid[hh][w]='#'; b++;
		}else{
			grid[hh][w]='.';
		}
		}
	}else{
		rep(w,100) grid[hh][w]='.';
		if(b==B-1) break;
	}
}
rep(h,100){
	if(grid[h][0]=='.') break;
	if(h%2==0){
		rep(w,100){
		if(w%2==0&&a<A-1){
			grid[h][w]='.'; a++;
		}else{
			grid[h][w]='#';
		}
		}
	}else{
		rep(w,100) grid[h][w]='#';
	}
}

cout<<100<<" "<<100<<endl;
rep(h,100){
	rep(w,100){
		cout<<grid[h][w];
	}
	cout<<endl;
}

}
	


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<queue>

using namespace std;


//品質管理

int main() {
	int C, N;
	string S[1000];
	bool ok[500][500];
	cin >> C >> N;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
	}

	int ans = 0;
	int wrong = 0;
	vector<pair<int, int>> X;
	for (int i = 0; i < N/2; i++) {
		for (int j = 0; j < N/2; j++) {
			if (!(S[i][j] == S[i][N - j - 1] && S[i][j] == S[N - i - 1][j] && S[i][j] == S[N - i - 1][N - j - 1])) {
				wrong++;
				ok[i][j] = false;
			}
			else {
				ok[i][j] = true;
			}
		}
	}

	if (wrong == 0)
		ans++;

	for (int i = 0; i < C-1; i++) {
		int D;
		cin >> D;
		for (int j = 0; j < D; j++) {
			int r, c;
			cin >> r >> c;
			r--;
			c--;
			if (S[r][c] == '0')
				S[r][c] = '1';
			else if (S[r][c] == '1')
				S[r][c] = '0';

			if (r >= N / 2) r = N - r - 1;
			if (c >= N / 2) c = N - c - 1;

			if (!(S[r][c] == S[r][N - c - 1] && S[r][c] == S[N - r - 1][c] && S[r][c] == S[N - r - 1][N - c - 1])) {
				if (ok[r][c]) {
					ok[r][c] = false;
					wrong++;
				}
			}
			else {
				if (!ok[r][c]) {
					ok[r][c] = true;
					wrong--;
				}
			}
		}
		if (wrong == 0) ans++;
	}

	cout << ans << endl;

	return 0;
}



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

A =list(map(int,input().split()))
B =list(map(int,input().split()))
C =list(map(int,input().split()))


b=sum(B)

for i in range (N-1):
    if (A[i]+1==A[i+1]):
        b=b+C[A[i]-1]


print(b)


Measured memory_bytes: 9160
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

int main(){
    ll a,b;
    cin >> a >> b;
    cout << a*a-b << endl;
}


Measured memory_bytes: 256