akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<list>
#include<stack>
//#include<unordered_map>
using namespace std;
#define ll long long
#define dd cout<<endl
const long long int inf = 1e18+7;
const int mod = 998244353;

using namespace std;

inline ll int max(ll int a,ll int b) { return a>b?a:b; }
inline ll int min(ll int a,ll int b) { return a<b?a:b; }

//const int maxn=

int main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int l,r,d;
	while(cin>>l>>r>>d)
	{
		int cnt=0;
		for(int i=l;i<=r;i++)
		{
			if(i%d==0)
			{
				cnt++;
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

bool board[8][8] = {{false}};
struct Position
{
    int r;
    int c;
    Position(int r_, int c_): r(r_), c(c_) {};
};

vector<Position> queens;



void process_pos(int r, int c, vector<Position> & filled){
    if (board[r][c]) return;
    board[r][c] = true;
    filled.emplace_back(r, c);
}

vector<Position> fill_board(int row, int col){
    vector<Position> filled;
    int r, c;
    // horizontal
    for (c = 0; c != 8; ++c) process_pos(row, c, filled);
    // vertical
    for (r = 0; r != 8; ++r) process_pos(r, col, filled);
    // diagonal upper left to lower right
    for (r = row - 1, c = col - 1; r != -1 && c != -1; --r, --c) process_pos(r, c, filled);
    for (r = row + 1, c = col + 1; r != 8 && c != 8; ++r, ++c) process_pos(r, c, filled);
    // diagonal upper right to lower left
    for (r = row - 1, c = col + 1; r != -1 && c != 8; --r, ++c) process_pos(r, c, filled);
    for (r = row + 1, c = col - 1; r != 8 && c != -1; ++r, --c) process_pos(r, c, filled);
    return filled;
}

void recover_board(const vector<Position> & filled){
    for (auto pos : filled) board[pos.r][pos.c] = false;
}

bool dfs(int row, int col, int k){
    if (board[row][col]) return false;
    auto filled = fill_board(row, col);
    queens.emplace_back(row, col);
    if (k == 7) return true;
    for (int c = col + 1; c != 8; ++c){
        if (dfs(row, c, k + 1)) return true;
    }
    for (int r = row + 1; r != 8; ++r){
        for (int c = 0; c != 8; ++c){
            if (dfs(r, c, k + 1)) return true;
        }
    }
    recover_board(filled);
    queens.pop_back();
    return false;
}

void solve_8queens(int k){
    for (int i = 0; i != k; ++i) fill_board(queens[i].r, queens[i].c);
    for (int r = 0; r != 8; ++r){
        for (int c = 0; c != 8; ++c){
            if (dfs(r, c, k)){
                return;
            }
        }
    }
}

void print_board(){
    bool boardQ[8][8] = {{false}};
    for (auto queen : queens) boardQ[queen.r][queen.c] = true;
    for (int row = 0; row != 8; ++row){
        for (int col = 0; col != 8; ++col){
            cout << (boardQ[row][col] ? 'Q' : '.');
        }
        cout << endl;
    }
}

int main()
{
    int k = 0;
    cin >> k;
    for (int i = 0; i != k; ++i){
        int row, col;
        cin >> row >> col;
        queens.emplace_back(row, col);
    }
    solve_8queens(k);
    print_board();
    return 0;
}

Measured memory_bytes: 3128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int main() {
  int N;
  cin >> N;
  vector<int> A;
  A.resize(N);
  for (auto &val : A){
    cin >> val;
  }
  map<int, int> cnt;
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      cnt[A[i]]++;
    }
  }
  sort(A.begin(), A.end());
  map<int, int> cnt2;
  for (int i = 0; i < N; i++){
    if (i % 2 == 0){
      cnt2[A[i]]++;
    }
  }
  int ans = 0;
  for (auto p : cnt){
    ans += abs(p.second - cnt2[p.first]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7808
/* competitive programming circle traP */
/* template */
#include <stdio.h>

int main(){
  while(true){
    int n;
    scanf("%d",&n);
    if(n==0)break;
    int a[25],b[25];
    bool used[25];
    for(int i=0;i<n;i++){
      scanf("%d%d",&a[i],&b[i]);
      used[i] = false;
    }

    int cur = 0;
    bool success = true;
    for(int i=0;i<n;i++){
      // search minimum
      int minimumid = 0;
      for(int j=1;j<n;j++){
        if(used[j])continue;
        if(used[minimumid] || b[j]<b[minimumid]){
          minimumid = j;
        }
      }
      // use it
      used[minimumid] = true;
      cur += a[minimumid];
      if(cur > b[minimumid]){
        success = false;
        break;
      }
    }
    if(success){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
  return 0;
}

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

using namespace std;
typedef long long LL;

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  int ans=0;
  rep(i,n-2) if(p[i+1]>min(p[i],p[i+2])&&p[i+1]<max(p[i],p[i+2])) ans++;
  cout << ans << endl;

  return 0;
}


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

MOD = 10**9+7
if N == 1:
    print(0)
    exit()

def power_func(a,n,p):
    bi = str(format(n,"b"))
    res = 1
    for i in range(len(bi)):
        res = (res*res) %p
        if bi[i] == "1":
            res = (res*a) %p
    return res

a = power_func(10, N, MOD)
b = power_func(8, N, MOD)
c = power_func(9, N, MOD)
print((a+b-2*c)%MOD)


Measured memory_bytes: 9064
#include <cstdio>
#include <algorithm>

using namespace std;

long long v[100010];

int main()
{
    //freopen("file.in","r",stdin);
    //freopen("file.out","w",stdout);
    long long n,a,b;
    scanf("%lld%lld%lld",&n,&a,&b);
    for(int i=1;i<=n;i++)
        scanf("%lld",&v[i]);
    long long st=0,dr=1e9;
    while(st<=dr)
    {
        long long mid=(st+dr)/2;
        int p=0,p1=0;
        long long s=0;
        for(int i=1;i<=n;i++)
        {
            long long x=(v[i]-mid*b)/(a-b);
            if(x<0) x=0;
            if(v[i]-x*a-(mid-x)*b>0) x++;
            if(v[i]-x*a-(mid-x)*b>0) p1=1;
            s+=x;
        }
        if(s>mid or p1==1) st=mid+1;
        else dr=mid-1;
    }
    printf("%lld",st);
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin>>n;
  int x[n];
  for(int i=0; i<n; i++)
  {
    cin>>x[i];
  }
  
  sort(x,x+n);
  for(int i=0; i<n-1; i++)
  {
    if(x[i+1]==x[i])
    {
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
}

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

#define ll long long
// #define endl '\n'

void max_self(int &a, int b){ a = max(a, b);}
void min_self(int &a, int b){ a = min(a, b);}

void solve(){
	int n, x, t; cin>>n>>x>>t;
	int ans = (n / x) * t + (n%x != 0) * t;
	cout<<ans<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	for(int i = 1; i<=t; i++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
using namespace std;
long long a[100001], b[100001][3], c[100001];
int main() {
	long long n, m;
	cin >> n >> m;
	for (int i = 0; i <= n; i++) a[i] = 0;
	for (int i = 0; i < m; i++) cin >> c[i];
	for (int i = 1; i < n; i++) 
		cin >> b[i][0] >> b[i][1] >> b[i][2];
	for (int i = 0; i < m-1; i++) {
		if (c[i] < c[i + 1]) {
			for (int j = c[i]; j < c[i + 1]; j++) {
				a[j]++;
			}
		}
		else {
			for (int j = c[i]-1; j >= c[i+1]; j--)
				a[j]++;
		}
	}
	long long sum = 0;
	for (int i = 1; i <= n; i++) {
		if (a[i] * b[i][0] > a[i] * b[i][1] + b[i][2])
			sum += (a[i] * b[i][1] + b[i][2]);
		else sum += (a[i] * b[i][0]);
	}
	cout << sum << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16

ll n,k;

int main(){
  cin>>n>>k;
  if(k==0){
    cout<<n*n<<endl;
    return 0;
  }
  ll cnt=0;
  repl(b,k+1,n+1){
    for(ll p=0;p<n;p+=b){
      ll q=p+b;
      if(q>n){
        ll r=n-p;
        cnt+=max(0LL,r-k+1);
      }else{
        ll r=q-p-1;
        cnt+=max(0LL,r-k+1);
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
h,w = map(int, input().split(" "))
string = [input() for i in range(h)]

a = [i for i in range(h)]
for i in range(h):
    if string[i] == "."*w:
        a.remove(i)

stringT = [[string[j][i] for j in range(h)] for i in range(w)]

b = [i for i in range(w)]

for i in range(w):
    if "".join(stringT[i]) == "."*h:
        b.remove(i)

st = [[string[i][j] for j in b] for i in a]
for i in range(len(st)):
    print("".join(st[i]))

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


#define pb push_back
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> pii;
typedef long long ll;

struct P{
    int x,y,d;
};

int main(){
    int N,K;
    cin >> N >> K;
    vector<pair<P,P>> box(N);
    vector<ll> X,Y,D;
    for(int i=0;i<N;i++){
        cin >> box[i].first.x >> box[i].first.y >> box[i].first.d >> box[i].second.x >> box[i].second.y >> box[i].second.d;
        X.pb(box[i].first.x);
        X.pb(box[i].second.x);
        Y.pb(box[i].first.y);
        Y.pb(box[i].second.y);
        D.pb(box[i].first.d);
        D.pb(box[i].second.d);
    }
    sort(all(X));
    sort(all(Y));
    sort(all(D));
    X.erase(unique(all(X)),X.end());
    Y.erase(unique(all(Y)),Y.end());
    D.erase(unique(all(D)),D.end());


    vector<pair<P,P>> box2(N);      //??§???????????§?¨?
    for(int i=0;i<N;i++){
        box2[i].first.x = find(all(X),box[i].first.x) - X.begin();
        box2[i].first.y = find(all(Y),box[i].first.y) - Y.begin();
        box2[i].first.d = find(all(D),box[i].first.d) - D.begin();
        box2[i].second.x = find(all(X),box[i].second.x) - X.begin();
        box2[i].second.y = find(all(Y),box[i].second.y) - Y.begin();
        box2[i].second.d = find(all(D),box[i].second.d) - D.begin();
    }

    int table[110][110][110];
    for(int i=0;i<110;i++) for(int j=0;j<110;j++) for(int k=0;k<110;k++) table[i][j][k] = 0;

    for(int i=0;i<N;i++){
        for(int j=box2[i].first.x;j<box2[i].second.x;j++){
            for(int k=box2[i].first.y;k<box2[i].second.y;k++){
                for(int l=box2[i].first.d;l<box2[i].second.d;l++){
                    table[j][k][l]++;
                }
            }
        }
    }

    ll ans = 0;
    for(int i=0;i<X.size();i++){
        for(int j=0;j<Y.size();j++){
            for(int k=0;k<D.size();k++){
                if(table[i][j][k]>=K){
                    ll V = (X[i+1]-X[i])*(Y[j+1]-Y[j])*(D[k+1]-D[k]);
                    ans += V;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8364
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(){
	int sai[7];
	int i;
	char com[256];
	int temp;

	for(i=0; i<6; i++){
		scanf("%d", &sai[i+1]);
	}
	
	scanf("%s", com);
	for(i=0; i<strlen(com); i++){
		if(com[i] == 'E'){
			temp = sai[1];
			sai[1] = sai[4];
			sai[4] = sai[6];
			sai[6] = sai[3];
			sai[3] = temp;
		}
		else if(com[i] == 'W'){
			temp = sai[1];
			sai[1] = sai[3];
			sai[3] = sai[6];
			sai[6] = sai[4];
			sai[4] = temp;
		}
		else if(com[i] == 'S'){
			temp = sai[1];
			sai[1] = sai[5];
			sai[5] = sai[6];
			sai[6] = sai[2];
			sai[2] = temp;
		}
		else if(com[i] == 'N'){
			temp = sai[1];
			sai[1] = sai[2];
			sai[2] = sai[6];
			sai[6] = sai[5];
			sai[5] = temp;
		}
	}


	printf("%d\n", sai[1]);
	return 0;

}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
int a[5005][5005]={0};
int main()
{
    int n;
    char s[5005];
    scanf("%d%s",&n,s);
    int m=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(i==j)
                continue;
            if(s[i-1]==s[j-1])
                a[i][j]=a[i-1][j-1]+1;
            if(a[i][j]>m)
            {
                if(i+a[i][j]<=j)
                    m=a[i][j];
            }
        }
    }
    printf("%d\n",m);
    return 0;
}


Measured memory_bytes: 98048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
int D;
void calculate(vector<int> c, vector<vector<int>> s, int contest,int day, vector<int> &t, ll &score){
    ll p=0;
    int a[26];
    rep(i, 26){
        a[i]=0;
    }
    rep(i, D){
        if(i!=day){
            p+=s[i].at(t[i])+c[t[i]]*(i+1-a[t[i]]);
            a[t[i]]=i+1;
        }else{
            p+=s[day].at(contest)+c[contest]*(day+1-a[contest]);
            a[contest]=i+1;
        }
        
    }
    if(score<p){
        score=p;
        t[day]=contest;
    }
}

int main(){
cin>>D;
vector<int> c(26);
rep(i, 26){
    cin>>c[i];
}
vector<vector<int>> s(D);
int r;
rep(i, D){
    rep(j, 26){
        cin>>r;
        s[i].push_back(r);
    }
}
int M2=0;
vector<pair<int,int>> m2(D);
vector<int> a(26);
rep(i, 26){
    a[i]=0;
}
int M=0;
rep(i, D){
}
vector<int> t(D);

int m=0;
ll score=0;
rep(i, D){
    M=0;
    rep(j, 26){
        if(s[i].at(j)+c[j]*(i+1-a[j])>M){
            M2=M;
            M=s[i].at(j)+c[j]*(i+1-a[j]);
            m2[i].second=m;
            m=j;
        }else if(s[i].at(j)+c[j]*(i+1-a[j])>M2){
            M2=s[i].at(j)+c[j]*(i+1-a[j]);
            m2[i].second=j;
        }
    }
    m2[i].first=M-M2;
    score+=M;
    a[m]=i+1;
    t[i]=m;
}
sort(m2.begin(), m2.end());
rep(i, D){
    calculate(c, s, m2[i].second, i, t, score);
}
rep(i, D){
    cout<<t[i]+1<<endl;
}
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  string S;
  cin>>S;
  map<char,char> A;
  A['q']='p',A['p']='q',A['b']='d',A['d']='b';
  string T=S;
  reverse(T.begin(),T.end());
  for(char &c:T)c=A[c];
  if(S==T)puts("Yes");
  else puts("No");
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint,dijkstra

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n;
        cin>>n;
        ll m=1000000000000000000;
        ll res=1;
        bool check=false;
        rep(i,n){
            ll a;
            cin>>a;
            if(a==0){
                cout<<0<<endl;
                return 0;
            }
            if(a>m/res){
                res=1;
                check=true;
            }else{
                res*=a;
            }
        }
        if(check){
            cout<<-1<<endl;
        }else{
            cout<<res<<endl;
        }
    }

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;cin>>n;
	int a[n],b[100100]={};
	int cnt=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]>100000) cnt++;
		else b[a[i]]++; 
	}
	rep(i,100001){
		if(b[i]>i)cnt+=b[i]-i;
		
		else if(b[i]<i) cnt+=b[i];
		//cout<<b[i]<<" ";
	}

	cout<<cnt<<"\n";
}

Measured memory_bytes: 1024
def sort_three_numbers(a, b, c): 
    """ 
    a: int or float
    b: int or float
    c: int or float
    returns a sorted list
    """
    result = []
    
    if a < b:
        if a < c:
            result.append(a)
            if b < c: # a < b < c
                result.append(b)
                result.append(c)
            else: # a < c < b
                result.append(c)
                result.append(b)
        else:
            result.append(c)
            result.append(a)
            result.append(b)
    else:
        if b < c:
            result.append(b)
            if a < c: # b < a < c
                result.append(a)
                result.append(c)
            else: # b < c < a
                result.append(c)
                result.append(a)
        else: # c < b < a
            result.append(c)
            result.append(b)
            result.append(a)

    return result


ivals = input().split(' ')
print('{0[0]} {0[1]} {0[2]}'.format(sort_three_numbers(ivals[0], ivals[1], ivals[2])))

Measured memory_bytes: 7528
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const int N=5e6+10;
const int mod=1e9+7;
int arr[N],iarr[N];
int logi(int n){int p=0;while(n/2){n=n/2;p++;}return p;}
int poww(int x,int y){int pro=1;while(y){if(y&1)pro=((pro%mod)*(x%mod)%mod);y=y>>1;x=((x%mod)*(x%mod)%mod);}return pro;}
int poww2(int x,int y){int pro=1;while(y){if(y&1)pro=pro*x;y=y>>1;x=x*x;}return pro;}
double poww1(double x,int y){double pro=1.000000000;while(y){if(y&1)pro=((pro)*(x));y=y>>1;x=((x)*(x));}return pro;}
map<int,int> mp1,mp2;
set<int> st;
int arr1[1000001],arr2[1000001];

int solve()
{
	string s;
	cin>>s;
	if(s[2]==s[3]&&s[4]==s[5])
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}
int32_t main()																																	
{
	//fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 2304
package main

import (
	"bufio"
	"fmt"
	"os"
)

var empty = byte('.')

func main() {
	var h, w int
	fmt.Scan(&h, &w)

	rdr := NewReader()

	grid := make([][]byte, h)
	for i := 0; i < h; i++ {
		grid[i] = rdr.Bytes()
	}

	var dp [1001][1001]int
	dp[0][0] = 1

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if grid[i][j] != empty {
				continue
			}
			if i == 0 && j == 0 {
				dp[i][j] = 1
				continue
			}
			if i == 0 {
				dp[i][j] = dp[i][j-1]
				continue
			}
			if j == 0 {
				dp[i][j] = dp[i-1][j]
				continue
			}

			dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % Mod
		}
	}

	fmt.Println(dp[h-1][w-1])
}

// generated by https://github.com/murosan/gollect

const Mod = 1000000007

type Reader struct {
	r    *bufio.Reader
	size int
	sep  string
}

func NewReader() *Reader {
	size := 4096
	return &Reader{
		r:    bufio.NewReaderSize(os.Stdin, size),
		size: size,
		sep:  " ",
	}
}

func (rdr *Reader) Bytes() []byte {
	buf := make([]byte, 0, rdr.size)
	for {
		line, isPrefix, err := rdr.r.ReadLine()
		if err != nil {
			panic(err)
		}
		buf = append(buf, line...)
		if !isPrefix {
			break
		}
	}
	return buf
}


Measured memory_bytes: 12672
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,a;
    cin>>n>>a;
    ll arr[10000][n+1];
    arr[5000][0]=1;
    fr(l,n){
        ll x;
        cin>>x;
        x-=a;
        fr(i,9000){
            arr[i+x][l+1]=arr[i+x][l]+arr[i][l];
        }
    }
    cout<<arr[5000][n]-1;
}

Measured memory_bytes: 7248
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

const int N = 400;
const int M = 100 + 10;
int dp[M][N];
int w[M], v[M];

int main() {
  int n, W;
  scanf("%d%d", &n, &W);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &w[i], &v[i]);
  }
  int ret = 0;
  for (int k = 1; k <= n && (int64)w[0] * k <= W; ++k) {
    int rem = min(W - w[0] * k, 3 * k);
    memset(dp, 255, sizeof(dp));
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
      int cur = w[i] - w[0];
      for (int j = k; j >= 1; --j) {
        for (int u = rem; u >= cur; --u) {
          if (dp[j - 1][u - cur] < 0) continue;
          dp[j][u] = max(dp[j][u], dp[j - 1][u - cur] + v[i]);
        }
      }
    }
    for (int u = 0; u <= rem; ++u) {
      if (dp[k][u] < 0) continue;
      ret = max(ret, dp[k][u]);
    }
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;



int main() {
	vector<vector<int>> c(3,vector<int>(3));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> c[i][j];
		}
	}

	vector<int> a(3);
	vector<int> b(3);

	for (int i = 0; i < 3; i++) {
		b[i] = c[0][i];
	}

	for (int i = 0; i < 3; i++) {
		a[i] = c[i][0] - b[0];
	}

	bool canConsist = true;
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (a[i] + b[j] != c[i][j]) {
				canConsist = false;
				break;
			}
		}
	}

	cout << (canConsist ?  "Yes" : "No") << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <math.h>
#include <stack>
#include <cctype>
using namespace std;
#define int long long
#define pi 2*acos(0.0)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)

signed main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (b - a == c - b) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
while True:
    a, op, b=input().split()
    a=int(a)
    b=int(b)

    if op=="+":
        print(a+b)
    elif op=="-":
        print(a-b)
    elif op=="/":
        print(a//b)
    elif op=="*":
        print(a*b)
    elif op=="?":
        break


Measured memory_bytes: 5596
import sys
readline = sys.stdin.readline

N, A, B, C = map(int, readline().split())
S = [readline().strip() for _ in range(N)]


def check():
    abc = [min(2, i) for i in (A, B, C)]
    Ans = [None]*N
    for i in range(N):
        a, b, c = abc
        if S[i] == 'AB':
            if a == 0 and b == 0:
                return False
            if a == 1 and b == 1:
                if i < N-1 and S[i+1] == 'BC':
                    Ans[i] = 1
                else:
                    Ans[i] = 0
            else:
                if a < b:
                    Ans[i] = 0
                else:
                    Ans[i] = 1
            if Ans[i] == 0:
                abc = (a+1, b-1, c)
            else:
                abc = (a-1, b+1, c)
        if S[i] == 'AC':
            if a == 0 and c == 0:
                return False
            if a == 1 and c == 1:
                if i < N-1 and S[i+1] == 'BC':
                    Ans[i] = 2
                else:
                    Ans[i] = 0
            else:
                if a < c:
                    Ans[i] = 0
                else:
                    Ans[i] = 2
            if Ans[i] == 0:
                abc = (a+1, b, c-1)
            else:
                abc = (a-1, b, c+1)
        if S[i] == 'BC':
            if b == 0 and c == 0:
                return False
            if b == 1 and c == 1:
                if i < N-1 and S[i+1] == 'AB':
                    Ans[i] = 1
                else:
                    Ans[i] = 2
            else:
                if b > c:
                    Ans[i] = 2
                else:
                    Ans[i] = 1
            if Ans[i] == 1:
                abc = (a, b+1, c-1)
            else:
                abc = (a, b-1, c+1)
    return Ans
       
ans = check()     
if ans:
    print('Yes')
    R = ['A', 'B', 'C']
    print('\n'.join(R[a] for a in ans))
else:
    print('No')
    
    


Measured memory_bytes: 82560
#include<bits/stdc++.h>
using namespace std;
long long n,i,j,k,a[100000],b[100000],sum,sum1,maxs;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
//		s1[i]=s1[i-1]+a;
	}
	for(i=1;i<=n;i++)
	{
		cin>>b[i];
//		s2[i]=s2[i-1]+a;
	}
	for(i=1;i<=n;i++)
	{
		for(k=1;k<=i;k++) sum+=a[k];
		for(k=i;k<=n;k++) sum+=b[k];
		maxs=max(maxs,sum);
		sum=0;
	}
	cout<<maxs;
	return 0;
}

Measured memory_bytes: 256
num = gets.to_i

loop_count = 99 # (x,y,z) = (99,1,1)

ans = Array.new(num, 0)
for x in 1..loop_count do
  for y in 1..loop_count do
    for z in 1..loop_count do
      result = (x*x) + (y*y) + (z*z) + (x*y) + (y*z) + (z*x)
      if result <= num
        ans[result-1] += 1
      end
    end
  end
end

ans.each do |a|
  puts a
end

Measured memory_bytes: 14240
from collections import Counter

h, w = [int(i) for i in input().split()]
maze = []
c = 0
for i in range(h):
    l = list(input().strip())
    maze.append(l)
    counter = Counter(l)
    c += counter['#']


def clear_maze(sx, sy, gx, gy, maze):
    INF = 1000000000

    distance = [[INF for i in range(gy)] for j in range(gx)]

    def bfs():
        queue = []

        queue.insert(0, (sx, sy))

        distance[sx][sy] = 0

        while len(queue):
            x, y = queue.pop()

            if x == gx - 1 and y == gy - 1:
                break

            for i in range(0, 4):
                nx, ny = x + [1, 0, -1, 0][i], y + [0, 1, 0, -1][i]

                
                if (0 <= nx < gx) and (0 <= ny < gy):
                    if maze[nx][ny] != '#' and distance[nx][ny] == INF:
                        queue.insert(0, (nx, ny))
                        distance[nx][ny] = distance[x][y] + 1


        
        return distance[gx-1][gy-1]

    return bfs()


try:
  q=w * h - clear_maze(0, 0, h, w, maze)-1 - c
  if q<0:
    print('-1')
  else:
    print(w * h - clear_maze(0, 0, h, w, maze)-1 - c)
except:
  print('-1')

Measured memory_bytes: 3316
n,h=map(int,input().split())
slash=[]
throw=[]
for i in range(n):
    x,y=map(int,input().split())
    slash.append(x)
    throw.append(y)
 
slash.sort(reverse=True)
throw.sort(reverse=True)
attack=0
for i in range(n):
    if throw[i]>=slash[0]:
        h-=throw[i]
        attack+=1
        if h<=0:
            print(attack)
            exit()
    else :
        break
 
attack+=int((h+slash[0]-1)/(slash[0]))
print(attack)

Measured memory_bytes: 11348
#include <stdio.h>

int main(void) {
	long int a, b, k;

	scanf("%ld %ld %ld", &a, &b, &k);
	if (a >= k) {
		printf("%ld %ld", a - k, b);
	}
	else {
		printf("%ld %ld", 0, b+a-k>0?b+a-k:0);
	}

	return 0;
}

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

#define ll long long
#define ar array

const int mxN=5e3;
int k, q;
ll d[mxN];

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

	cin >> k >> q;
	for(int i=0; i<k; ++i) {
		cin >> d[i];
	}
	while(q--) {
		int n, x, m;
		cin >> n >> x >> m;
		ll s1=0, s2=0;
		for(int i=0; i<k; ++i) {
			ll d2=d[i]%m;
			if(!d2)
				d2=m;
			s1+=d2;
			if(i<(n-1)%k)
				s2+=d2;
		}
		ll x2=x+(n-1)/k*s1+s2;
		//cout << x2 << endl;
		//cout << s1 << " " << s2 << endl;
		cout << n-1-(x2/m-x/m) << "\n";
	}
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

#define ll long long
#define PII pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size))           \
  scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name)
#define DEBUG(...) debug(__LINE__,__VA_ARGS__)
#define MOD 1000000007

using namespace std;

string to_string(string s) { return s; }

template <class T>
string to_string(vector<T> v) {
	string ret = "{";
	FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
	if (v.size() > 0) {
		ret += to_string(LAST(v));
	}
	ret += "}";
	return ret;
}

void debug_print() { cerr << endl; }

template <class Head, class... Tail>
void debug_print(Head head, Tail... tail) {
	cerr << to_string(head) << " ";
	debug_print(tail...);
}

template <class... T>
void debug(T... args) {
	debug_print(args...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
	cout << to_string(head);
	print(tail...);
}

int main() {
	GI(N);
	map<int,int> mp;
	FOR(i,N){
		GI(A);
		mp[A]++;
	}
	int cnt=0;
	for(pair<int,int> p:mp){
		if(p.second>1)cnt+=p.second-1;
	}
	print(N-(cnt+1)/2*2);
	return 0;
}


Measured memory_bytes: 4992
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

vector<int> v;

void init_uf(int n){
    v.assign(n,-1);
}

int find_(int x){
    if(v[x]<0) return x;
    v[x]=find_(v[x]);
    return v[x];
}

int same_(int a,int b){
    if(find_(a)==find_(b)) return 1;
    return 0;
}

void union_(int a,int b){
    if(same_(a,b)) return;
    int a_p=find_(a),b_p=find_(b);
    if(a_p>b_p) swap(a_p,b_p);
    v[a_p]+=v[b_p]; v[b_p]=a_p;
}

void print_v(){
    rep(i,v.size()) cout<<v[i]<<" ";
    cout<<endl;
}

int size_(int a){
    return -v[find_(a)];
}

int main(){
    ll n,x,y,ans=1; cin>>n>>x>>y;
    vector<ll> c(n,0),w(n,0),inv(n+1,0);
    inv[0]=1;
    inv[1]=1;
    for(ll i=2;i<=n;i++){
        inv[i]=(MOD-inv[MOD%i]*(MOD/i))%MOD;
    }
    vector<vector<pair<ll,ll>>> cg(n); 
    rep(i,n){
        cin>>c[i]>>w[i];
        c[i]--;
        cg[c[i]].push_back(mk(w[i],i));
    }
    init_uf(n);
    priority_queue<pair<ll,ll>> que;
    rep(i,n){
        if(cg[i].size()==0) continue;
        sort(al(cg[i]));
        que.push(mk(cg[i][0].first,i));
        if(que.size()>3) que.pop();
        for(auto p:cg[i])
        if(p.first+cg[i][0].first<=x) union_(cg[i][0].second,p.second);
    }
    while(!(que.empty())){
        ll idx=que.top().second;
        que.pop();
        rep(i,n){
            if(idx==c[i]) continue;
            if(cg[idx][0].first+w[i]<=y) union_(cg[idx][0].second,i);
        }
    }
    map<ll,ll> cnt;
    map<pair<ll,ll>,ll> gcnt;
    rep(i,n){
        ll p=find_(i);
        if(!(cnt.count(p))) cnt[p]=0;
        cnt[p]++;
        ans=ans*cnt[p]%MOD;
        if(!(gcnt.count(mk(p,c[i])))) gcnt[mk(p,c[i])]=0;
        gcnt[mk(p,c[i])]++;
        ans=ans*inv[gcnt[mk(p,c[i])]]%MOD;
    }
    cout<<(ans+MOD)%MOD<<endl;
}


Measured memory_bytes: 49208
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a,b,x,y;
    scanf("%d %d",&a,&b);
    x=a*b;
    y=2*(a+b);
    printf("%d %d\n",x,y);
    
    return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
using vb = vector<bool> ;
using pll = pair<ll, ll> ;

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

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

ll inv(ll n){
    return fast(n,mod-2);
}


void pre(){



}

ll h,n;
ll a[maxs];
ll b[maxs];
ll dp[1001][10001];
bool vis[1001][10001];

ll go(ll pos,ll h){
    if(h <= 0)
        return 0;
    if(pos > n and h > 0)
        return oo;
    if(vis[pos][h]){
        return dp[pos][h];
    }
    vis[pos][h] = true;
    ll ans = min( go(pos+1,h) , b[pos] + go(pos,h-a[pos]) );
    return dp[pos][h] = ans;
}

void solve(){

    cin >> h >> n;
    for(ll i=1;i<=n;i++){
        cin >> a[i] >> b[i];
    }
    ll ans = go(1,h);
    cout << ans;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 91584
a,b,k = map(int,input().split())
li = []
if k*2 >= b-a+1:
    for i in range(a,b+1):
        li.append(i)
    for i in range(len(li)):
        print(li[i])
else:
    for i in range(k):
        li.append(a+i)
        li.append(b-i)
    li.sort()
    for i in range(len(li)):
        print(li[i])

Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
#define REP(i, d, n) for(int i=(d); i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n, m;
    cin >> n >> m;

    int ans = (1900 * m + (n - m) * 100) * (1 << m);
    
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main(){
	int T;
	cin >> T;
	while(T--){
		int N, prev, maxup = 0, maxdown = 0;
		cin >> N >> prev;
		while(--N){
			int height;
			cin >> height;
			if(prev < height){
				maxup = max(maxup, height - prev);
			}else{
				maxdown = max(maxdown, prev - height);
			}
			prev = height;
		}
		cout << maxup << " " << maxdown << endl;
	}
	return 0;
}

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

namespace AtCoderBeginnerContest
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // A
            var line = Console.ReadLine().Split(' ');
            foreach (var s in line)
            {
                var sw = s.ToUpper();
                Console.Write(sw[0]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		int x = sc.nextInt();

		int ans = 0;
		outer:
		for (int ia = 0; ia <= a; ia++) {
			int sum500 = ia * 500;
			if (sum500 > x) {
				break;
			}
			for (int ib = 0; ib <= b; ib++) {
				int sum100 = ib * 100;
				int rest = x - sum500 - sum100;
				if (rest < 0) {
					continue outer;
				}
				if (0 <= rest && rest <= c * 50) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}
}


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

ll cnt[60][60];
ll h, w, n, k;

ll ppow(ll a, ll b) {
	ll res = 1;
	while (b) {
		if (b & 1)res = (res*a) % k;
		a = (a*a) % k;
		b >>= 1;
	}
	return res;
}
int main() {
	cin >> h >> w >> n >> k;
	rep(i, h)rep(j, w) {
		cout << "? " << i << ' ' << j << ' ' << i << ' ' << j << endl;
		cin >> cnt[i][j];
	}
	ll ans = 0;
	rep(i, h)rep(j, w) {
		ans = (ans + cnt[i][j] * ppow(2, i*w + j)) % k;
	}
	cout << "! " << ans << endl;
}

Measured memory_bytes: 724
import sys
import os

MOD = 2019


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    L, R = list(map(int, sys.stdin.readline().split()))
    ret = float('inf')

    if R - L >= 2019:
        print(0)
        exit()

    for i in range(L, R+1):
        for j in range(i+1, R+1):
            ret = min(ret, (i * j) % MOD)

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(void) {
  int n, m, p;
  int x[100];
  int pool;

  while(cin >> n >> m >> p, n!=0 || m!=0 || p!=0) {
    pool = 0;
    for(int i = 1 ; i <= n ; i++) {
      cin >> x[i];
      pool += x[i];
    }
    if(x[m] == 0) cout << "0" << endl;
    else {
      int ans = pool * (100-p) / x[m];
      cout << ans << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
r = []

n = int(input())
for i in range(n):
    ri = int(input())
    r.append(ri)
    
minv = r[0]
maxv = -10**11

for i in range(1,n):
    maxv = max(maxv,r[i]-minv)
    minv = min(minv,r[i])
        
print(maxv)


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    ll A[n];
    for(auto& x:A){
        cin >> x;
    }
    map<ll,ll> mp;
    for(auto x:A){
        mp[x]++;
    }
    ll ret = 0;
    for(auto&& x:mp){
        ret += x.second * (x.second-1)/2;
    }
    for(i=0;i<n;i++){
        cout << ret - mp[A[i]]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 11008
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let arr: Vec<i32> = s.chars().map(|c| c.to_digit(10).unwrap() as i32).collect();
    for bit in 0..1 << 4 {
        let mut p_or_m = vec!["-"; 3];
        for i in 0..3 {
            if bit & (1 << i) != 0 {
                p_or_m[3 - 1 - i] = "+"
            }
        }
        let mut sum = arr[0];
        let mut ans = String::new();
        for j in 0..3 {
            ans += &arr[j].to_string();
            ans += p_or_m[j];
            if p_or_m[j] == "+" {
                sum += arr[j + 1];
            } else {
                sum -= arr[j + 1];
            }
        }
        ans += &arr[3].to_string();

        if sum == 7 {
            println!("{}=7", ans);
            break;
        }
    }
}


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

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

#define trace(x) cout<<#x<<" :: "<<x<<endl;
#define trace2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define trace3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
#define trace4(x,y,z,w) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\t"<<#w<<" :: "<<w<<endl;
clock_t time_p = clock();
void time()
{
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (double)(time_p)/CLOCKS_PER_SEC <<endl;
}
signed main()
{
     SPEED;
     int n;
     cin>>n;
     int res=0;
     while(n--)
     {
          int x;
          cin>>x;
          while(x%2==0)
            x/=2,res++;
     }
     cout<<res<<endl;
     time();
     return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;
vector <ll> a;
vector<ll> f;
ll n,k;
ll check(ll maxallowed)
{
   ll need = 0;
   for(ll i = 0; i<n ; i++)
   {
      if(a[i]*f[i]<=maxallowed)
         continue;
      else
      {
         need += a[i]-(maxallowed)/f[i];
      }
   }
   if(need <=k)
      return 1;
   else
      return 0;
 
}
 
int  main()
{
   // ios_base::sync_with_stdio(false); 
   // cin.tie(NULL);
   cin>>n>>k;
   ll x;
   for(ll i=0; i<n ; i++)
         {
            cin>>x;
            a.pb(x);
         }
      //cout<<"hey";
   for(ll i =0; i<n ; i++)
         {
            cin>>x;
            f.pb(x);
         }
      //cout<<"hu";
   sort(a.begin(),a.end(),greater<ll>());
   sort(f.begin(),f.end());   
   ll r = 1e12, l  = 0;
   // for(ll i = 0; i<n ; i++)
   //    if(a[i]*f[i]>r)
   //          r = a[i]*f[i];
   
      while(l<r)
      {
         ll mid = (l+r)/2;
         if(check(mid))
            r = mid;
         else
            l = mid+1;
      }
 
   cout<<r<<endl;    
 
 
   return 0;
}

Measured memory_bytes: 4848
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(0, i, N)
    {
        cin >> A.at(i);
    }

    rep(0, i, K)
    {
        if (i > 50)
        {
            break;
        }
        vector<ll> B(N, 0);
        rep(0, j, N)
        {
            ll l = max((ll)0, j - A.at(j));
            ll r = min(N - 1, j + A.at(j));
            B.at(l)++;
            if (r + 1 < N)
            {
                B.at(r + 1)--;
            }
        }
        rep(1, i, N)
        {
            B.at(i) += B.at(i - 1);
            if (B.at(i) >= N)
            {
                B.at(i) = N;
            }
            A.at(i) = B.at(i);
        }
        A.at(0) = B.at(0);
    }

    rep(0, i, N)
    {
        cout << A.at(i) << ' ';
    }
    cout << endl;
}

Measured memory_bytes: 6420
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動 されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		System.out.println(Math.max(Math.max(a+b, a-b), a*b));
		
	}

}

Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 100000000
using namespace std;
bool debug=false;

int main(){
  int n;
  string str;
  cin>>str>>n;
  rep(i,0,n){
    int a,b;
    string s;
    cin>>s;
    if(s=="replace"){
      string c;
      cin>>a>>b>>c;
      for(int i=a;i<=b;i++)str[i]=c[i-a];
    }else if(s=="reverse"){
      cin>>a>>b;
      reverse(str.begin()+a,str.begin()+b+1);
    }else if(s=="print"){
      cin>>a>>b;
      for(int i=a;i<=b;i++)cout<<str[i];
      cout<<endl;
    }

  }

  return 0;
}



Measured memory_bytes: 3192