akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <iomanip>




using namespace std;



using ll = long long;
const ll INF = 1e18L + 5;
const int mod = 1e9 + 7;



vector<int> edge[1000000];
int a, b, n;

//first - black; second - white
pair<int,int> dfs(int a, int partent){
    long long allWhite = 1;
    long long sthBlack = 0;
    for(auto v : edge[a]){
        if(v != partent){
            pair<int, int> p = dfs(v, a);
            //p.first is the number of ways to color subtree such that b is black
            sthBlack = (allWhite * p.first) % mod + (sthBlack * (p.first + p.second));
            sthBlack %= mod;
            allWhite = (allWhite * p.second) % mod;
        }
    }
    //dynamic here
    return make_pair(allWhite, (allWhite + sthBlack) % mod);
}

int main(){

    cin.tie(0);
    ios_base::sync_with_stdio(0);
    
    
    cin >> n;
    
    for(int i = 0; i < n - 1; i++){
        cin >> a >> b;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    
    
    pair<int,int> p = dfs(1, -1);
    
    cout << (p.first + p.second) % mod;
}



Measured memory_bytes: 33792
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <math.h> // sqrt
using namespace std;
typedef long long ll;

int main() {
    ll D;
    cin >> D;
    vector<ll> c(26);
    for (int i = 0; i < 26; i++) {
        cin >> c.at(i);
    }
    vector<vector<ll>> s(D, vector<ll>(26));
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s.at(i).at(j);
        }
    }
    vector<ll> v(26, 0);
    vector<ll> last;
    for (ll i = 0; i < D; i++) {
        ll pointd = 0;
        int vd = 0;
        for (int j = 0; j < 26; j++) {
            last = v;
            last.at(j) = i + 1;
            ll sumd = 0;
            for (int k = 0; k < 26; k++) {
                if (k == j) {
                    sumd += s.at(i).at(k);
                }
                else {
                    sumd -= (i - last.at(k) + 1) * c.at(k);
                }
            }
            if (pointd < sumd) {
                vd = j + 1;
            }
            if (j == 0) {
                pointd = sumd;
                vd = 1;
            }
            else {
                pointd = max(pointd, sumd);
            }
        }
        v.at(vd - 1) = i + 1;
        cout << vd << endl;
    }
}


Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <array>

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

using namespace std;

#define ll long long
#define all(v) v.begin(),v.end()
#define bootstrap ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);


void solve() {
    int N;
    cin >> N;
    vector<int> A, B;
    // transform for Mannhatan distance ,so no need for pair-wise comparison.
    rep(i, N) {
        int a,b;
        cin >> a >> b;
        A.push_back(a + b);
        B.push_back(a -b );
    }
    sort(all(A));
    sort(all(B));
    //rep(k, N) {
    //    cout << B[k] << endl;
    //}
    int res = max(A[N - 1] - A[0], B[N - 1] - B[0]);
    cout << res << endl;
}

int main() {
    bootstrap
    solve();
}


Measured memory_bytes: 5156
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    ll N,D,A; cin >> N >> D >> A;
    vector<pair<ll,ll>> XH(N); REP(i,N) cin >> XH[i].first >> XH[i].second;
    SORT(XH);
    ll ans = 0, now=0;
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> q1, q2;
    REP(i,N){
        while(q2.size() && q2.top().first < XH[i].first){
            auto p = q2.top(); q2.pop();
            now -= p.second;
        }
        if(XH[i].second-now > 0){
            if((XH[i].second-now)%A){
                q2.push(MP(XH[i].first + 2*D, ((XH[i].second-now)/A + 1) * A));
                ans += (XH[i].second-now)/A + 1;
                now += ((XH[i].second-now)/A + 1) * A;
            }
            else{
                q2.push(MP(min(XH[i].first + 2*D, INF), XH[i].second-now));
                ans += (XH[i].second-now)/A;
                now += XH[i].second-now;
            }
            
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5492
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int sum = String.valueOf(n).chars().map(x -> x - '0').sum();
            out.println(n % sum == 0 ? "Yes" : "No");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



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

//定数
const int mod = 1000000007;

//dpテーブルを宣言
long long dp[100001][13];

int main(){

    //入力
    string s; cin >> s;

    reverse(s.begin(),s.end());

    dp[0][0] = 1;
    int mul = 1;

    for(int i=1; i<=s.size(); i++){

        //i桁目が?でない時
        if(s[i-1] != '?'){
            for(int j=0; j<13; j++){
                
                //char型からint型に変換
                int S = s[i-1] - '0';

                dp[i][(S*mul + j) % 13] += (dp[i-1][j] % mod);
                
            }
        }else{
            for(int j=0; j<13; j++){
                for(int k=0; k<10; k++){
                    dp[i][(k*mul + j) % 13] += (dp[i-1][j] % mod);
                }
            }
        }

        mul = (mul*10)%13;
    }

    cout << dp[s.size()][5]%mod << endl;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        ll l, r;
        cin >> l >> r;
        r = min(l + 4038, r);
        ll ans = 2018;
        for (ll i = l; i <= r; i++) {
            for (ll j = i + 1; j <= r; j++) {
                ll x = i * j % 2019;
                if (ans > x) {
                    ans = x;
                }
            }
        }
        cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
namespace io
{
	int F()
	{
		 int F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
	long long G()
	{
		 long long F=1,n=0;
		 char ch;
		 while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		 ch=='-'?F=0:n=ch-'0';
		 while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0';
		 return F?n:-n;
	}
}
int R(int l,int r)
{
	return (rand()<<15|rand())%(r-l+1)+l;
}
template <class F> struct heap
{
	long long h[222222];
	int tot;
	long long add;
	void push(long long v)
	{
		h[++tot]=v-add;
		std::push_heap(h+1,h+tot+1,F());
	}
	long long pop()
	{
		std::pop_heap(h+1,h+tot+1,F());
		return h[tot--]+add;
	}
	long long top()
	{
		return h[1]+add;
	}
};
heap<std::less<long long> >hl;
heap<std::greater<long long> >hr;
int main()
{
	unsigned long long s0=0,len;
	long long x;
	int n=io::F();
	{
		int l=io::F(),r=io::F();
		hl.push(l);
		hr.push(l);
		len=r-l;
		x=0,s0=l;
	}
	for(register int i=2;i<=n;++i)
	{
		int l=io::F(),r=io::F();
		hr.add+=len;
		len=r-l;
		hl.add-=len;
		x-=len;
		if(hl.top()<=l&&l<=hr.top())hl.push(l),hr.push(l);
			else if(hl.top()>l)
			{
				hr.push(hl.pop());
				hl.push(l);
				hl.push(l);
			} 
			else
			{
				hl.push(hr.pop());
				hr.push(l);
				hr.push(l);
			}
		s0+=l-x;
	}
	std::sort(hl.h+1,hl.h+hl.tot+1);
	int sl=-n;
	for(register int i=1;i<=hl.tot;++i)
		s0+=sl*(hl.h[i]+hl.add-x),x=hl.h[i]+hl.add,++sl;
	printf("%lld\n",s0);
	return 0;
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
  ll to, cost;
};

int main() {
  string S; cin >> S;
  if(S == "KIHBR") {
    cout << "YES" << endl;
  } else if(S == "AKIHBR" || S == "KIHABR" || S == "KIHBAR" || S == "KIHBRA") {
    cout << "YES" << endl;
  } else if(S == "AKIHABR" || S == "AKIHBAR" || S == "AKIHBRA") {
    cout << "YES" << endl;
  } else if(S == "KIHABAR" || S == "KIHABRA") {
    cout << "YES" << endl;
  } else if(S == "KIHBARA" || S == "AKIHABARA") {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int n, k, a[200010];
int cum[200010];

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < k; i++) {
		fill(cum, cum + n, 0);
		for (int j = 0; j < n; j++) {
			cum[max(0, j - a[j])]++;
			cum[min(n, j + a[j] + 1)]--;
		}
		for (int j = 1; j < n; j++)cum[j] += cum[j - 1];
		bool bl = true;
		for (int j = 0; j < n; j++) {
			a[j] = cum[j];
			if (a[j] != n)bl = false;
		}
		if (bl)break;
	}
	for (int i = 0; i < n; i++)cout << a[i] << " ";
	cout << endl;
}

Measured memory_bytes: 5152
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#include<string>
#include<vector>
#include <stdio.h>
#define ll long long
#include<cstring>
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>QUE;//きゅー

int length(char* str) {
	int len = strlen(str);
	return len;
}

int main(void)
{
	int A, B;
	cin >> A >> B;
	double ans = (double)A / B;
	cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

signed main(){
	string s;cin>>s;
	int a=count(s.begin(),s.end(),'+');
	cout<<a-int(s.size()-a)<<endl;
}


Measured memory_bytes: 764
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	string S;
	cin >> S;

	string T;
	int OK = 0;
	rep(i, 10) {
		T += "hi";
		if (S == T) OK = 1;
	}

	if (OK) co("Yes");
	else co("No");



	Would you please return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

const ll mod = 1e9 + 7;

int main(){
    ll N; cin >> N; map<ll, ll> ctr;
    FOR(i, 2, N + 1){
        ll t = i;
        FORMAP(it, ctr){
            ll m = it->first;
            while(t % m == 0 && t > 0){
                t /= m; ctr[m]++;
            }
        }
        if(t == i) ctr[t]++;
    }
    ll ret = 1;
    FORMAP(it, ctr){
        ret *= (it->second + 1);
        ret %= mod;
    }
    cout << ret << endstr;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// #define int long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//SUNEET KUMAR -->  ਸੁਨੀਤ  
int power(int a,int n)//binary expo
{
    int r;
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
        r=power(a,n/2);
    if(n%2==0)
        return ((r)%mod)*((r)%mod)%mod;
    else
        return ((((r)%mod)*((r)%mod))%mod*((a)%mod))%mod;
}
int max(int a,int b)
{
    if(a>b)
        return a;
    else
        return b;
}
vector<int>v[100007];
int visit[100007],dist[100007];
void dfs(int start)
{
     visit[start]=1;
     for(int i=0;i<v[start].size();i++)
     {
         if(visit[v[start][i]]==0)
         {
             dfs(v[start][i]);
         }
          dist[start]=max(dist[start],1+dist[v[start][i]]);
     } 
}
 signed main()
 {
     int n,m;
     cin>>n>>m;
     int x,y;
     for(int i=1;i<=m;i++)
     {
         cin>>x>>y;
         v[x].pb(y); 
     }
     for(int i=1;i<=n;i++)
     {
         if(visit[i]==0)
         {
             dfs(i);
         }
     }
     int ax=-1999;
     for(int i=1;i<=n;i++)
     {
        //  cout<<dist[i]<<endl;
         if(dist[i]>ax)
         {

             ax=dist[i];
         }
     }
     cout<<ax<<endl;  
 }

Measured memory_bytes: 8576
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    cout << (n - 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int serch(int [],int);

int n,q;

int main()
{
  int a,i,S[10000],T[500],count = 0;

  scanf("%d",&n);
  for(i = 0;i < n;i++)
    {
      scanf("%d",&S[i]);
    }
  scanf("%d",&q);
  for(i = 0;i < q;i++)
    {
      scanf("%d",&T[i]);
      a = serch(S,T[i]);
      if(a == T[i]) count++;
    }
  printf("%d\n",count);
  return 0;
}
int serch(int S[],int a)
{
  int i;
  for(i = 0;i < n;i++)
    {
      if(S[i] == a)
	return a;
    }
  return 1;
}
	
    
  
  



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

const int MOD = 1000000000 + 7;

long long modpow(long long x, long long y) {
    if (y == 0) return 1;
    if (y % 2 == 0) {
        long long res = modpow(x, y / 2);
        return res * res % MOD;
    } else {
        return x * modpow(x, y - 1) % MOD;
    }
}

long long combination(int x, int y) {
    long long res = 1;
    for (int i = 0; i < y; i++) {
        res *= (x - i);
        res %= MOD;
    }
    for (int i = 1; i <= y; i++) {
        res *= modpow(i, MOD - 2);
        res %= MOD;
    }
    return res;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    long long answer = modpow(2, n) - 1;
    answer -= combination(n, a);
    answer -= combination(n, b);
    cout << (answer % MOD + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-2;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

#include<cstring>
struct edge { int to, cap, rev; };
vector<edge> G[100000];
bool used[100000];
void add_edge(int from, int to, int cap) {
	G[from].push_back(edge{ to, cap, (int)G[to].size() });
	G[to].push_back(edge{ from, 0, (int)G[from].size() - 1 });
}
int dfs(int v, int t, int f) {
	if (v == t)return f;
	used[v] = true;
	for (int i = 0; i < (int)G[v].size(); i++) {
		edge &e = G[v][i];
		if (!used[e.to] && e.cap > 0) {
			int d = dfs(e.to, t, min(f, e.cap));
			if (d > 0) {
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s, int t) {
	int flow = 0;
	for (;;) {
		memset(used, 0, sizeof(used));
		int f = dfs(s, t, mod);
		if (f == 0)return flow;
		flow += f;
	}
}
vector<P> v[2];
int main() {
	int n, a, b; cin >> n >> a >> b;
	int cnt = 0;
	rep(i, n) {
		int x, y; cin >> x >> y;
		int z = abs(x - y);
		if (z <= a || (b <= z && z <= 2 * a))cnt++;
		else {
			if (x-y>0) {
				v[0].push_back({ x,y });
			}
			else {
				v[1].push_back({ x,y });
			}
		}
	}
	int m = v[0].size(); int len = v[1].size();
	int sta = m + len, goa = m + len + 1;
	rep(i, m)add_edge(sta, i, 1);
	rep(i, len)add_edge(i + m, goa, 1);
	rep(i, m) {
		rep(j, len) {
			int z = v[0][i].first - v[0][i].second + v[1][j].first - v[1][j].second;
			z = abs(z);
			if (z <= a || (b <= z && z <= 2 * a)) {
				add_edge(i, m + j,1);
			}
		}
	}
	int ans = cnt + max_flow(sta,goa);
	cout << ans << endl;
	//stop
	return 0;
}


Measured memory_bytes: 6688
s = str(input())

result = 0


for i in  range(2**(len(s)-1)):
    b = []
    x = 0#範囲を覚えておく
    for j in range(len(s)-1):
        if ((i >> j) & 1):
            b.append(s[x:j+1])
            x = j+1
    b.append(s[x:len(s)])
    for k in b:
        result += int(k)
            
print(result)

Measured memory_bytes: 9204
import java.util.Scanner;
import java.util.Arrays;

public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);

		// input
		int[] nums = new int[3];
		for(int i = 0; i < 3; i++){
			nums[i] = scan.nextInt();
		}
		
		// check
		int count = 0;
		while(true){
			Arrays.sort(nums);
			
			if(nums[0] == nums[1] && nums[1] == nums[2]){
				break;
			}
			
			if(nums[2] - nums[0] >= 2){
				nums[0] += 2;
			} else if(nums[0] == nums[1]){
				nums[0] += 1;
				nums[1] += 1;
			} else if(nums[1] == nums[2]){
				nums[1] += 1;
				nums[2] += 1;
			} else {
				nums[0] += 1;
				nums[1] += 1;
			}
			count++;

		}
		
		System.out.println(count);
		
	}
}

Measured memory_bytes: 24020
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {          
                int n = int.Parse(Console.ReadLine());
                int[,,] residence = new int[4,3,10]; //4?£?3???10????????¢????????????Z??????
                int b, f, r, v = 0;

                for (int z = 0; z < 4; z++)
                {
                    for (int x = 0; x < 3; x++)
                    {
                        for (int y = 0; y < 10; y++)
                        {
                            residence[z, x, y] = 0;
                        }
                    }
                }


                    for (int i = 0; i < n; i++)
                    {
                        string input = Console.ReadLine();
                        string[] array = input.Split(' ');

                        b = int.Parse(array[0]);
                        f = int.Parse(array[1]);
                        r = int.Parse(array[2]);
                        v = int.Parse(array[3]);

                        if (v > 0)
                        {
                            residence[b - 1, f - 1, r - 1] = residence[b - 1, f - 1, r - 1] + v;
                        }
                        else
                        {
                            residence[b - 1, f - 1, r - 1] = residence[b - 1, f - 1, r - 1] + v;
                        }                      
                    }


                    for (int z = 0; z < 4; z++)
                    {
                        for (int x = 0; x < 3; x++)
                        {
                            for (int y = 0; y < 10; y++)
                            {
                                Console.Write(string.Format(" {0}", residence[z, x, y]));
                                if (y == 9)
                                    break;
                            }
                            Console.WriteLine();
                        }
                        if (z == 3)
                            break;
                        Console.WriteLine("####################");
                    }

        }
    }
}

Measured memory_bytes: 9140
#include<iostream>
#include<string>
#include<stdio.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	string s;
	cin >> s;
	vector<int> dp(12);
	if (s.at(0) == 'A' || s.at(0) == 'C' || s.at(0) == 'G' || s.at(0) == 'T') dp[0] = 1;
	else dp[0] = 0;
	int ans = dp[0];
	for (int i = 1; i < s.size(); i++) {
		if (s.at(i) == 'A' || s.at(i) == 'C' || s.at(i) == 'G' || s.at(i) == 'T') {
			dp[i] = dp[i - 1] + 1;
			ans = max(ans, dp[i]);
		}
		else {
			dp[i] = 0;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s,a,b;
  cin >> s;

  int g = sz(s);
  for(int i = i; i <= g - 2;i = i + 2)
  {
    s = s.substr(0,sz(s) - 2);
    a = s.substr(0,sz(s) / 2 );
    b = s.substr(sz(s) / 2 );
    if(a == b)
    {
      cout << sz(s) << endl;
      return 0;
    }
  }

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max() / 2;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourd; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<vector<Edge>>g;
vector<edge>edges;
vector<Pll>v;
map<string, LL>ma;
multiset<LL>st;
LL h, w, n, m, k, t, s, p, q, last, cnt, sum, ans, a[210000], b[210000], d[200000];
string str[110000], ss;
bool f[110000];
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
int main() {
	cin >> n >> m;
	cout << max({n*m,n-m,n+m}) << endl;
	return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
#define pb push_back
#define mp make_pair

const int MAX_N = 2e5+10;
int N, K;
ll a[MAX_N];
ll b[MAX_N];
ll tree[MAX_N];

bool ok()
{
	for(int i=1;i<=N;++i)if(a[i]<N)return false;
	return true;
}
 
void update(int x, ll val)
{
    while (x <= N)
    {
        tree[x] += val;
        x += (x & -x);
    }
}
 
ll query(int x)
{
    ll sum=0;
    while (x>0)
    {
        sum+=tree[x];
        x -= (x & -x);
    }
    return sum;
}

void solve()
{
	while(K--){
		memset(tree,0,sizeof(tree));
		for(int i=1;i<=N;++i){
			update(max(1,(int)(i-a[i])),1);
			update(min(N,(int)(i+a[i]))+1, -1);
		}
		for(int i=1;i<=N;++i) a[i]=query(i);
		if(ok()) break;
	}
	for(int i=1;i<=N;++i) cout << a[i] << ' ';
	cout << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin >> N >> K;
	for(int i=1;i<=N;++i) cin >> a[i];
	solve();
    return 0;
}

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

int main() {
  int A, B,C,D;
  cin >> A >> B>>C>>D;
  if(A+B>C+D)
    cout<<"Left"<<endl;
  else if(A+B==C+D)
    cout<<"Balanced"<<endl;
  else
    cout<<"Right"<<endl;

}


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

namespace ABC136_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split().Select(long.Parse).ToArray();

            var ans = true;
            for (int i = N - 1; i >= 1; i--)
            {
                if (H[i] < H[i - 1])
                {
                    H[i - 1]--;
                    if (H[i] < H[i - 1])
                    {
                        ans = false;
                        break;
                    }
                }
            }

            Console.WriteLine(ans ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 29276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    string s;cin >> s;
    vi num;
    rep(i,(int)s.size()){
        if(s[i]=='A') num.push_back(0);
        else if(s[i]=='B') num.push_back(1);
        else num.push_back(2);
    }
    int n=(int)num.size();
    ll c=0;
    ll prec=0;
    bool pre=false;
    ll ans=0;
    int i=0;
    while(i<n-1){
        if(num[i]==0){
            c++;
            i++;
        }
        else{
            if(num[i]==1&&num[i+1]==2){
                if(pre){
                    ans+=prec+c;
                }
                else ans+=c;
                pre=true;
                prec=prec+c;
                c=0;
                i+=2;
            }
            else{
                pre=false;
                c=0;
                prec=0;
                i++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1532
N,T = map(int,input().split())
A = list(map(int,input().split()))

data = [0]*(N-1)
M = [0]*N
M[N-1] = A[N-1]
M_index = [N-1]*N

for i in range(2,N+1):
    if A[N-i] > M[N-i+1]:
        M[N-i] = A[N-i]
        M_index[N-i] = N-i
    else:
        M[N-i] = M[N-i+1]
        M_index[N-i] = M_index[N-i+1]
    data[N-i] = M[N-i] - A[N-i]

m = max(data)
l = []
for i in range(N-1):
    if data[i] == m:
        l.append(i)

ans = [0]*N
for x in l:
    ans[M_index[x]] = 1

#####
#print("A",A)
#print("M",M)
#print("M_index",M_index)
#print("data",data)
#print("ans",ans)
#####

print(sum(ans))

Measured memory_bytes: 15612
def main():
    k = int(input())
    ab = list(map(int, input().split()))

    c = False
    for i in range(ab[0],ab[1]+1):
        if i % k == 0:
            c = True
            break
    print('OK' if c else 'NG')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9172
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N, K = map(int, input().split())
A = [0] + [int(input()) - K for _ in range(N)]

# print (A)
for i in range(N):
    A[i + 1] += A[i]

B = sorted(A)
dic = dict()
for i, b in enumerate(B):
    dic[b] = i + 1

N += 1
bit = [0] * (N + 1)
def total(i):
    s = 0
    while i > 0:
        s += bit[i]
        i -= i & -i
    return s

def add(i, x):
    while i <= N:
        bit[i] += x
        i += i & -i
    return

ans = 0
for a in A:
    b = dic[a]
    ans += total(b)
    # print ('tmp')
    add(b, 1)

print (ans)
# print (A)
# print (dic)

Measured memory_bytes: 40960
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

vector<long long int> divisor(long long int n) {
	vector<long long int> res;
	for (long long int i = 1; i * i <= n; ++i) {
		if (n % i == 0) {
			res.push_back(i);
			if (i * i != n) res.push_back(n / i);
		}
	}
	sort(begin(res), end(res));
	return res;
}

int main() {
	while (1) {
		long long int N; cin >> N;
		if (!N)break;
		auto v(divisor(N));
		long long int sum = accumulate(v.begin(), v.end(), 0ll);
		if (sum > 2 * N)cout << "abundant number" << endl;
		else if (sum == 2 * N)cout << "perfect number" << endl;
		else cout << "deficient number" << endl;

	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
ll n , k , rr ,ss ,pp;
char win(char x)
{
    if(x=='s')
        return 'r';
    if(x=='r')
        return 'p';
    if(x=='p')
        return 's';
}
ll score(char x)
{
    if(x=='s')
        return ss;
    if(x=='r')
        return rr;
    if(x=='p')
        return pp;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>n>>k>>rr>>ss>>pp>>s;
    char w;
    ll ans=0;
    string ansa="";
    for(int i = 0 ; i < s.size() ;i++)
    {
        w=win(s[i]);
        if((i-k)>=0)
        {
            if(w==ansa[i-k])
            {
                ansa+='X';
            }
            else
            {
                ans+=score(w);
                ansa+=w;
            }
        }
        else
        {
            ans+=score(w);
            ansa+=w;
        }
    }
    cout << ans ;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i=0;i<n;i++) cin >> s[i];
    sort(s.begin(), s.end());
    for(int i=0;i<n;i++) cout << s[i];
    cout << endl;
}


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


#define li          long long int
#define uli         unsigned long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n, x, m;

map<li, li> prevv;

li sum[100100];

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

    li res = 0;
    li now = x;
    li steps = 0;
    sum[0] = 0;
    while (steps < n && prevv.count(now) == 0) {
        res += now;
        sum[steps + 1] = sum[steps] + now;
        prevv[now] = steps;
        steps++;
        now = (now * now) % m;
    }

    if (steps == n) {
        cout << res << endl;
        return 0;
    }


    li loop_length = steps - prevv[now];
    li loop_num = (n - steps) / loop_length;

    res += loop_num * (sum[steps] - sum[prevv[now]]);
    steps += loop_length * loop_num;
    while (steps < n) {
        res += now;
        now = (now * now) % m;
        steps++;
    }
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 7088
/*
 © 2020-07-05 06:57:04 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;

int main(){ _
  lli n; cin >> n;
  cout << (2000ll - (n % 1000ll)) % 1000ll << ENDL;
  return 0;
}


Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;

int main(){
    int A,B,C,K;
    cin >> A >> B >> C >> K;
    int result = A + B + C;
    int D = max({ A , B , C });
    result = result - D;
    for (int i = 0;i < K;i++){
        D = D + D;
    }
    cout << result + D << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int n = sc.nextInt();

		int[] V = new int[n];

		for(int i=0;i<n;i++){
			V[i] = sc.nextInt();
		}

		int sum = 0;

		for(int i=0;i<n;i++){
			int vi = V[i];
			int ci = sc.nextInt();
			if(vi>ci)sum = sum + vi -ci;
		}

		// 出力
		System.out.println(sum);
	}
}

Measured memory_bytes: 24020
"""
    音　１回　A円
    高橋君所持金　B円
    満足する回数　C円　
    出力：お気に入りの音を何回聴けるか？
        B円での何回聴けるかを問いている。
"""

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

if c < (b//a):
    print(c)
else:
    print(b//a)

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

int main()
{
    int     a, b;
    char    op;
    while (cin >> a >> op >> b) {
        if (op == '?') break;
        if (op == '+') cout << a + b << endl;
        if (op == '-') cout << a - b << endl;
        if (op == '*') cout << a * b << endl;
        if (op == '/') cout << a / b << endl;
    }
}


Measured memory_bytes: 3092
N, x = list(map(int, input().split()))
ais = list(map(int, input().split()))

s = 0
cnt = 0
ais.sort()

for ai in ais:
    if(s+ai>x):
        break
    else:
        s += ai
        cnt += 1

if((cnt==N) & (s < x)):
    cnt -= 1

print(cnt)

Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int High = 0;
		int Width = 0;
		String Preserved = "";
		ArrayList<String> Array = new ArrayList<>();
		Scanner scan = new Scanner(System.in);

		High = scan.nextInt();
		Width = scan.nextInt();

		for (int i = 0; i < High; i++) {
			Array.add(scan.next());
			Preserved = Array.get(Array.size() - 1);
			Array.add(Preserved);
		}

		for (int i = 0; i < 2 * High; i++) {
			System.out.println(Array.get(i));
		}
	}
}

Measured memory_bytes: 23508
T = int(input())
for _ in range(T):
    N = int(input())
    A = [int(i) for i in input().split()]
    S = input()

    B = []
    ans = 0
    for a, s in zip(reversed(A), reversed(S)):
        for b in B:
            a = a if a < (b := a ^ b) else b

        if a:
            if s == "1":
                ans = 1
                break
            B.append(a)

    print(ans)

Measured memory_bytes: 9152
#include <stdio.h>

int main(void){
  	int a, b, c = 1;
	scanf("%d", &a);
  	scanf("%d", &b);
  	c = b;
  	a--;
  	while(a > 0){
      c *= b - 1;
      a--;
    }
  	printf("%d\n", c);
  
  	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cstring>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn=200010;
int num[maxn];
int main(){
    int n,k,x,cnt=0,i;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        num[x]++;
    }
    sort(num,num+n+1);
//    for(int i=0;i<=n;i++)cout<<num[i]<<" ";cout<<endl;
    i=n;
    int ans=0;
    while(i>=0&&num[--i]);
    cnt=n-i;i++;
    while(cnt>k){
        ans+=num[i++];
        cnt--;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>

using namespace std;

typedef pair<long long int,int> P;


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

	int a[3];
	cin >> a[0] >> a[1] >> a[2];

	sort(a,a+3);



	cout << (a[1]-a[0]) + (a[2] - a[1]) << "\n";
	return 0;
}

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

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w)<<endl;
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=1e9+7;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair<ll,ll> &a,const pair<ll,ll> &b){
    if(a.first>b.first)return true;
    if(a.first==b.first)return a.second<b.second;
    return false;
}

ll power(ll x, ll y){
    ll res = 1;x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        y=y>>1;x=(x*x)%mod;}
    return res;
}

mkv vin(int n){
    mkv v;
    fo(i,n){
        int t;cin>>t;v.pb(t);
    }
    return v;
}

vector<int>ch;
void solve()
{
    string s,t;cin>>s>>t;
    int n=s.size(),m=t.size();
    int c=m;
    for(int i=0;i<=n-m;i++){
        int tmp=0;
        for(int j=i;j<i+m;j++){
            if(s[j]!=t[j-i]){
                tmp++;
            }
        }
        c=min(c,tmp);
    }
    print(c)
}

int main()
{
  //  fastio();
  //  test
    solve();
}


Measured memory_bytes: 3628