akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  using namespace std;

  typedef long long int ll;
  typedef pair<int,int> pi;
  typedef pair<ll,ll> pll;
  typedef vector<int> vi;
  typedef vector<ll> vll;
  typedef vector<pi> vpi;
  typedef vector<pll> vpll;

  #define  ff           first
  #define  ss           second
  #define  pb           push_back
  #define  IOS          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define  D(x)         cout << #x << " - " << x << endl;
  #define  D2(x)        cout << "[" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]" << endl;
  #define  all(x)       (x).begin(), (x).end()
  #define  D2p(x)       cout << #x << " ~ [ "; for(auto n: x) cout << n.first << "-" << n.second << " / "; cout << "]" << endl;
  #define  ps(x,y)      fixed<<setprecision(y)<<x
  #define  rep(i,a,b)   for(ll i=a ; i<b ; ++i)

  const ll MOD = 1e9 + 7;
  const ll INF = 1e18;
  const ll maxn = 1e5 + 4;
  int n,m,k;
  vi compo(maxn);
  vi compsize(maxn);
  vi adj[maxn];
  vi vis(maxn);
  int csize=0;
  int comps=0;
  void dfs(int src){
  	vis[src]=1;
  	csize++;
  	compo[src]=comps;
  	for(int x:adj[src]){
  		if(!vis[x]){
  			dfs(x);
  		}
  	}
  }

  void solve(){
  	cin >> n >> m >> k;
  	vll ans(n+1);
  	for(int i=0;i<m;i++){
  		int a,b;
  		cin >> a >> b;
  		adj[a].push_back(b);
  		adj[b].push_back(a);
  	}
  	vi block(n+1);
  	vpi blockpair;
  	for(int i=0;i<k;i++){
  		int a,b;
  		cin >> a >> b;
  		blockpair.push_back({a,b});
  		block[a]++;
  		block[b]++;
  	}
  	for(int i=1;i<=n;i++){
  		if(!vis[i]){
  			comps++;
  			csize=0;
  			dfs(i);
  			compsize[comps] = csize;
  		}
  	}
  	for(int i=1;i<=n;i++){
  		ans[i] = compsize[compo[i]] - adj[i].size() - block[i]; 
  	}
  	for(auto x:blockpair){
  		if(compo[x.ff]!=compo[x.ss])ans[x.ff]++,ans[x.ss]++;
  	}
  	for(int i=1;i<=n;i++){
  		cout << ans[i]-1 << ' ';
  	}
  }

  int main(){
    IOS
    solve();
    cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }

// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


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

int main() {
  int A, B;
  cin >> A >> B;
  int ans = (A + B) / 2;

  if((A + B) % 2 == 0){
    cout << ans << endl;
  }else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion



int32_t main() {
    make(int, n, s);
    makev(a, n);
    VVI dp(n + 1, VI(s + 1));
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i) {
        for(int j = 0; j <= s; ++j){
            if (a[i] + j <= s){
                dp[i + 1][j + a[i]] = dp[i][j];
            }
            dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * 2) % MFFT;
        }
    }
    cout << dp[n][s];

    return 0;
}

Measured memory_bytes: 73724
#include <bits/stdc++.h>
using namespace std;
int dist[2003][2003];
int ct[2003];

int main() 
{
    int n,x,y;
    cin >> n >> x >> y;
    
    /*for(int i=1;i<=n;i++){
        for(int j=i;j<=n;j++) dist[i][j] = dist[j][i] = j - i;
    }
    
    dist[x][y] = dist[y][x] = 1;*/
    
    // i = x, k = y, j = 1...n
    
    /*int i = x, k = y;
    
    for(int j=1;j<=n;j++){
        if(dist[i][k] + dist[k][j] < dist[i][j]) {
            dist[i][j] = dist[j][i] = (dist[i][k] + dist[k][j]);
        }
    }
    
    i = y, k = x;
    for(int j=1;j<=n;j++){
        if(dist[i][k] + dist[k][j] < dist[i][j]) {
            dist[i][j] = dist[j][i] = (dist[i][k] + dist[k][j]);
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i<x && j>y){
                dist[i][j] = dist[j][i] = ((dist[i][j] - (y-x) ) + 1);
            }
        }
    } */
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dist[i][j] = min(abs(i-j), abs(x-i) + 1 + abs(y-j));
            //dist[j][i] = dist[i][j];
        }
    }
    // for(int i=1;i<=n;i++){
    //     for(int j=1;j<=n;j++){
    //         cout<<dist[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    
    for(int ii=1;ii<=n;ii++){
        for(int jj=ii+1;jj<=n;jj++) ct[dist[ii][jj]]++;
    }
    
    for(int i=1;i<=n-1;i++) cout<<ct[i]<<endl;
    
    
	return 0;
}

Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int ms = 3030;

int a[ms];
std::vector<int> edges[ms];

bool dp(int on, int par) {
	for(auto to : edges[on]) {
		if(to == par) continue;
		if(a[on] > a[to] && !dp(to, on)) return true;
	}
	return false;
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	for(int i = 1; i < n; i++) {
		int u, v;
		std::cin >> u >> v;
		u--;v--;
		edges[u].push_back(v);
		edges[v].push_back(u);
	}
	bool wtf = false;
	for(int i = 0; i < n; i++) {
		if(dp(i, i)) {
			if(wtf) std::cout << ' ';
			wtf = true;
			std::cout << i + 1;
		}
	}
	std::cout << '\n';
}

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

#define show(x) cerr << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

struct Graph {
    Graph(ll n)
    {
        edge.resize(n);
    }
    void addEdge(ll from, ll to)
    {
        edge[from].push_back(to);
    }
    vector<vector<ll>> edge;
};

ll N;
pair<ll, ll> dfs(const Graph& g, ll s, const vector<bool>& cycle, vector<ll>& value)
{
    multiset<ll> st;
    for (const ll p : g.edge[s]) {
        if (cycle[p]) {
            continue;
        }
        const ll child = dfs(g, p, cycle, value).first;
        st.insert(child);
    }
    ll first = -1;
    ll second = -1;
    for (ll i = 0; i <= 2 * N; i++) {
        if (st.find(i) == st.end()) {
            if (first == -1) {
                first = i;
            } else if (second == -1) {
                second = i;
                break;
            }
        }
    }
    value[s] = first;
    assert(first >= 0 and second > first);
    return make_pair(first, second);
}

int main()
{
    cin >> N;
    Graph g(N);
    Graph rev(N);

    for (ll i = 0; i < N; i++) {
        ll from;
        cin >> from;
        from--;
        g.addEdge(from, i);
        rev.addEdge(i, from);
    }

    ll pos = 0;
    for (ll i = 0; i < 2 * N; i++) {
        pos = rev.edge[pos][0];
    }
    vector<bool> cycle(N, false);
    vector<ll> comp;
    for (ll i = 0; i < 2 * N; i++) {
        if (cycle[pos]) {
            break;
        }
        comp.push_back(pos);
        cycle[pos] = true;
        pos = rev.edge[pos][0];
    }
    const ll size = comp.size();

    for (ll i = 1; i < size; i++) {
        assert(rev.edge[comp[i - 1]][0] == comp[i]);
    }
    assert(rev.edge[comp[size - 1]][0] == comp[0]);

    vector<ll> value(N, 0);
    const auto pi = dfs(g, comp[0], cycle, value);

    for (ll d = 0; d < 2; d++) {
        ll prev = (d == 0) ? pi.first : pi.second;
        const ll start = prev;
        for (ll i = 1; i <= size; i++) {
            if (i == size) {
                i = 0;
            }
            const ll p = comp[i];
            const auto q = dfs(g, p, cycle, value);
            prev = (q.first == prev) ? q.second : q.first;
            value[comp[i]] = prev;
            if (i == 0) {
                i = size + 1;
            }
        }
        if (start == value[comp[0]]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;

    return 0;
}


Measured memory_bytes: 23916
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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




/******************************************************************************************/



int a[100055];//R
int b[100055];//L
int ans[100055];

int main() {

	
	string s;
	cin >> s;
	s = " " + s;

	//cout << s << endl;

	

	
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] == 'R') {
			a[i] = 1;
		}

		if (s[i] == 'L') {
			b[i] = 1;
		}
	}

	for (int i = 0; i <= s.size(); i++)
	{
		if (b[i+1] == 0)continue;
		b[i + 1] += b[i];
	}


	for (int i = s.size()+1; i >= 0; i--)
	{
		if (a[i-1] == 0)continue;
		a[i - 1] += a[i];
	}


	




	for (int i = 1; i < s.size(); i++)
	{
		if (s[i] == 'R') {
			if ((a[i] % 2) == 0) {
				//移動先が答え
				ans[i + a[i]]++;
			}
			else
			{
				//1個戻る
				ans[i + a[i] - 1]++;
			}
		}
		else
		{
			if ((b[i] % 2) == 0) {
				ans[i - b[i]]++;
			}
			else
			{
				ans[i - b[i] + 1]++;
			}
		}
	}


	for (int i = 1; i < s.size(); i++)
	{
		if (i == 1) {
			cout << ans[i];
		}
		else
		{
			cout << " " << ans[i];
		}
	}
	cout << endl;






	return 0;
}


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

typedef long long ll;
typedef pair<int,int> P;
typedef map<int,int> M;
typedef vector<int> V;
typedef queue<int> Q;
typedef pair<long,long> PLL;
typedef map<long,long> MLL;
typedef vector<long> VLL;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
/*--------------------------------------------*/

int main(){
    string s;int k;
    cin>>s;cin>>k;
    vector<string>vec;
    for(int i=0;i<(int)s.size();i++){
        for(int j=1;j<=k;j++){
            string tmp=s.substr(i,j);
            vec.PB(tmp);
        }
    }
    sort(ALL(vec));
    //重複を除く
    vec.erase(unique(ALL(vec)),vec.end());
    //rep(i,(int)vec.size())cout<<vec[i];
    //cout<<endl;
    cout<<vec[k-1]<<endl;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
using bll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(v) (v).begin(), (v).end()
#define uniq(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
template<typename T> inline void pv(vector<T> v) { for(ll i=0, N=v.size()-1; i<=N; i++) if(i!=N) cout << v[i] << ' '; else cout << v[i] << endl; }
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

//文字列Sが与えられた時、各 i について「S と S[i:|S|-1] の最長共通接頭辞の長さ」の配列を返す
vector<ll> zalgorithm(const string &s) {
	ll ssize = s.size();
	vector<ll> ans(ssize);
	ans[0] = ssize;
	ll i = 1, j = 0;
	while (i < ssize) {
		while (i + j < ssize && s[j] == s[i+j]) ++j;
		ans[i] = j;
		if (!j) {
			++i;
			continue;
		}
		ll k = 1;
		while (i + k < ssize && k + ans[k] < j) ans[i+k] = ans[k], ++k;
		i += k;
		j -= k;
	}
	return ans;
}

signed main() {
	ll N;
	string S;
	cin>>N>>S;
	ll ans=0;
	rep(i,N-1){
		vector<ll> z=zalgorithm(S.substr(i,N-i));
		for(ll size=z.size(),j=1;j<size;j++){
			ll t=z[j];
			if(t>j)t=j;
			chmax(ans,t);
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main(){
	string S, T;
  	cin >> S >> T;
  	bool seikai = false;
  	if(S.size() + 1== T.size()){
    	for(int i=0; i < S.size();i++){
        	if(S.at(i) != T.at(i)){
            	cout << "No" << endl;
              	break;
            }
          	else if( i == S.size() -1){cout << "Yes" << endl;}
        }
    }
  	else{cout << "No" << endl;}
  
}


Measured memory_bytes: 3632
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int x = int.Parse(str);
            int ans = (int)Math.Pow(x, 3);
            Console.WriteLine(ans);
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 19976
n, m, x = map(int, input().split())
list_CA = [ list(map(int,input().split(" "))) for _ in range(n)]
ans = pow(10, 10)

for i in range(2**n):
    l = [0]*m
    h = 0
    for j in range(n):
        if ((i >> j) & 1):
            for p in range(m):
                l[p] += list_CA[j][p+1]
            h += list_CA[j][0]
    cnt = 0
    for k in l:
        if k >= x:
            cnt += 1
    if cnt == m:
        ans = min(ans, h)

if ans == pow(10, 10):
    print(-1)
else:
    print(ans)

Measured memory_bytes: 9168
X = int(input())

while True:
  if X==2:
    break # Xが2の場合素数なのでwhileのループを抜ける
  for n in range(2, X):
    if X%n==0: # 2以上x未満の自然数nでxを割り切れるものが存在したのでxは素数ではない
      X+=1
      break # 一度forループを抜けて次のX+1を素数判定する 
  if n==X-1:
    break # 2以上x未満のすべての自然数でｘを割り切れなかった場合whileのループを抜ける
print(X)

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

int main() {
    string S;
    getline(cin, S);
    for (int i = 0; i < S.size(); i++) {
        if ('A' <= S[i] && S[i] <= 'Z') S[i] += 'a' - 'A';
        else if ('a' <= S[i] && S[i] <= 'z') S[i] -= 'a' - 'A';
    }
    cout << S << endl;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
#define LL long long int
using namespace std;
int main(void)
{
	int i,j,k,n,a[100010],x,f1[100010]={0},f2[100010]={0},f3[100010]={0},sum=-1;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	for(i=0;i<n;i++) {
		f1[a[i]]++;
		f1[a[i]-1]++;
		f1[a[i]+1]++;
	}
	for(i=0;i<100001;i++) sum=max(sum,f1[i]);
	cout<<sum<<endl;
}

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

int main() {
  int N,M,all=0;
  cin>>N>>M;
  vector<int>A(N);
  rep(i,N) cin>>A[i];
  rep(i,N) all+=A[i];
  sort(A.begin(),A.end(),greater<int>());
  if(A[M-1]*4*M<all){
    cout<<"No";
    return 0;
  }
  cout<<"Yes";
}

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

int main()
{
    int n,temp,max=0,i,j;
    char s[1000];
    int f[50]={0},q[50]={0};
    scanf("%d",&n);
    scanf("%s",s);
    for(i=0;i<n;i++)
    {
        f[s[i]-'a']=1;
        for(j=0;j<26;j++)
            q[j]=0;
        for(j=i+1;j<n;j++)
            q[s[j]-'a']=1;
        temp=0;
        for(j=0;j<26;j++)
        {
            if(f[j]==1&&q[j]==1)
                temp++;
        }
        if(temp>max)
            max=temp;
    }
    printf("%d\n",max);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        for(int i = 1; i <= 10; i++){
            x *= r;
            x -= d;
            System.out.println(x);
        }
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 25376
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int N,K;  cin>>N>>K;
  string s; cin>>s;
  int cnt=0;
  rep(i,0,N-1) if(s[i]==s[i+1]) cnt++;
  cnt += 2*K;
  cout<< min(cnt, N-1) << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
   
   int N;
   
   scanf("%d",&N);

   int W[N];
   int tot_sum = 0;
   int i;
   
   for (i = 0; i < N; i++) {
      scanf("%d", &W[i]);
      tot_sum = tot_sum + W[i];
   }
   
   int Diff[N];
   
   Diff[0] = tot_sum;
   
   for (i = 1; i < N; i++) {
      Diff[i] = Diff[i - 1] - 2*W[i - 1];
   }
   
   int ans = tot_sum + 10;
   for (i = 1; i < N; i++) {
      if (ans > abs(Diff[i])) {
         ans = abs(Diff[i]);
      }
   }
   
   printf("%d\n",ans);
   
   return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int x,t;
  cin>>x>>t;
  cout<<max(0,x-t)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

char c[200000];

int main(){
    int n;
    int i;
    scanf("%d\n", &n);
    for(i = 0; i < n; ++i)
        scanf("%c", &c[i]);
    int l = 0, r = n - 1;
    int ans = 0;
    while(true){
        while(l < n && c[l] == 'R'){
            ++l;
        }
        if(l == n){
            printf("%d\n", ans);
            return 0;
        }
        while(r >= 0 && c[r] == 'W'){
            --r;
        }
        if(r == -1 || l > r){
            printf("%d\n", ans);
            return 0;
        }
        c[l] = 'R';
        c[r] = 'W';
        ++ans;
    }
    return 0;
}

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

int main() {
    ll N;
    cin >> N;
    ll ans =0;
    vector<ll> C(N),S(N),F(N);
    for(int i=0;i<N-1;i++){
        cin >> C[i] >>S[i] >>F[i];
        
    }
    for(int i=0;i<N;i++){
        ll ans =0;
        for(int j=i;j<N-1;j++){
            if(ans<=S[j]){
                ans = S[j];
            }else{
                ll n= (ans-S[j] +F[j]-1)/F[j];
                ans   = S[j]+F[j]*n;
            }
            ans += C[j];
        }
        cout << ans << endl;
        

    }
    

    return 0;
}

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

int main(void){
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i,n-1){
        cin >> b[i];
    }
    b[n-1] = INF;
    int sum = b[0];
    rep1(i,n-1){
        sum += min(b[i-1],b[i]);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for (int i = 0;i < (n); i++)
using namespace std;
typedef long long ll;
 
int main(){
  int N,Y;
  cin >> N >> Y;
  int a=-1,b=-1,c=-1;
  bool ok = false;
  bool flag = true;
  for(int i=0;i<=N;i++){ //一万円札の枚数i
    
    for(int j = 0;i+j<=N;j++){ //五千円札の枚数j
      if(Y == i*10000+j*5000+(N-i-j)*1000){
        a = i; b = j; c = N - i - j;
        ok = true;
        flag = false;
        break;
        }
    }
    if(!flag) break;
  }
  cout << a << " " << b << " " << c << endl;
}

Measured memory_bytes: 256
import java.lang.Math.min

fun main(args: Array<String>) = yorukatsu22e()

fun yorukatsu22e() {
    operator fun List<Int>.component6() = this[5]
    val (a, b, c, d, e, f) = readLine()!!.split(' ').map { it.toInt() }

    val sugarSet = mutableSetOf<Int>()
    for (cw in 0..f step c) for (dw in 0..f step d) sugarSet.add(cw + dw)
    val sugarPatterns = sugarSet.sorted().toIntArray()

    fun upperBound(list: IntArray, key: Int): Int {
        var ng = -1
        var ok = list.size

        while (ok - ng > 1) {
            val mid = (ok + ng) / 2
            if (list[mid] > key) ok = mid else ng = mid
        }
        return ok
    }

    var pair = a * 100 to 0
    var maxPercentage = 0.0

    for (aw in 0..f step a * 100) for (bw in 0..f step b * 100) {
        val waterWeight = aw + bw
        val maxOfSugarWeight = min(e * waterWeight / 100, f - waterWeight)
        if (maxOfSugarWeight < 0) continue

        val ub = upperBound(sugarPatterns, maxOfSugarWeight) - 1
        if (ub !in sugarPatterns.indices) continue

        val sugarWeight = sugarPatterns[ub]
        val sumWeight = sugarWeight + waterWeight

        val percentage = sugarWeight.toDouble() * 100 / sumWeight.toDouble()

        if (percentage > maxPercentage) {
            maxPercentage = percentage
            pair = sumWeight to sugarWeight
        }
    }

    val answer = "${pair.first} ${pair.second}"

    println(answer)
}


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

using namespace std;
typedef unsigned long long int ll;

int main()
{
    int n;
    cin>>n;
    int arr[n];
    int sum =0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum = sum + arr[i];
    }
    int avg = sum/n;
    int ans =0;
    float av = float(sum)/n;
    float x = float(avg) + 0.5000;
    if(av>x)
        avg = avg + 1;

    for(int i=0;i<n;i++)
    {
        int x = avg - arr[i];
        ans = ans + x*x;
    }
    cout<<ans;
}


Measured memory_bytes: 3520
#include<iostream>
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;

    int ans = 0;
    if (A > B) {
        ans += A;
        A--;
    } else {
        ans += B;
        B--;
    }

    if (A > B) {
        ans += A;
        A--;
    } else {
        ans += B;
        B--;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
ll modpow(long long a, long long n, long long mod2) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod2;
        a = a * a % mod2;
        n >>= 1;
    }
    return res;
}

int main() {
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define si size()
#define mp make_pair 
#define mt make_tuple
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound

#define ask(i,m,n) for(lli i=m;i<n;i++)
#define anket ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
#define endl "\n"
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
using namespace std;

#define prime1 1000000007
#define prime2 998244353

lli modadd(lli n,lli m , lli mod){
    lli sum = ((n+m)%mod+mod)%mod;
    return sum;
}

lli modsub(lli n,lli m,lli mod){
    lli diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}

lli modpro(lli n,lli m, lli mod){
    lli pro = ((n*m)%mod+mod)%mod;
    return pro;
}

lli powmod(lli x,lli y,lli mod){
    x %= mod;
    y %= mod;
    lli res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}

lli moddiv(lli n,lli m,lli mod){
    //return n/m mod (mod) or n*(m)^-1 mod (mod)
    lli a = powmod(m,mod-2,mod);
    //this is because of fermats thm i.e. a^-1 = a^p-2 mod(p) check
    //multiplying p on both sides
    lli res = modpro(a,n,mod);
    return res;
}




int main() {
	anket;
	lli n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2 + m*(m-1)/2;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = int(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = int(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
using ll = long long;
using namespace std;

ll solve(int n, vector<ll> const & a) {
    vector<ll> acc(n + 1);
    partial_sum(ALL(a), acc.begin() + 1);
    unordered_map<ll, int> cnt;
    ll result = 0;
    REP (i, n) {
        cnt[acc[i]] += 1;
        if (cnt.count(acc[i + 1])) {
            result += cnt[acc[i + 1]];
        }
    }
    return result;
}

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    REP (i, n) cin >> a[i];
    cout << solve(n, a) << endl;
    return 0;
}


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

int main() {
    ll s, c, ans = 0;
    cin >> s >> c;

    if (s * 2 <= c ) {
        c -= s * 2;
        ans += s;
        ans += c / 4;
        cout << ans << endl;
    } else {
        cout << c / 2 << endl;
    }
    return 0;
}

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

ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	ll N;
	cin>>N;
    vector<ll> A(N);
    vector<ll> L(N),R(N);
    rep(i,N){
        cin>>A[i];
    }
    rep(i,N){
        if(i==0){
            R[N-1]=A[N-1];
        }else{
            R[N-1-i] = gcd(R[N-1-i+1],A[N-1-i]);
        }
    }
    rep(i,N){
        if(i==0){
            L[0]=A[0];
        }else{
            L[i] = gcd(L[i-1],A[i]);
        }
    }
    ll ans = 1;
    rep(i,N){
        if(i==0){
            ans=max(ans,R[1]);
        }else if(i==N-1){
            ans = max(ans,L[N-2]);
        }else{
            ans = max(ans,gcd(L[i-1],R[i+1]));
        }
    }
    cout<<ans<<"\n";
    // cout<<ans<<"\n";
	return 0;
}


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

int N;
int D[int(2e5)];
int M;
int T[int(2e5)];

signed main() {
  ios::sync_with_stdio(false);
  cin >> N;
  multiset<int> bag;
  for (int i = 0; i < N; ++i) {
    cin >> D[i];
    bag.emplace(D[i]);
  }
  cin >> M;
  for (int i = 0; i < M; ++i) {
    cin >> T[i];
    if (!bag.count(T[i])) {
      cout << "NO" << endl;
      exit(0);
    }
    bag.erase(bag.find(T[i]));
  }
  cout << "YES" << endl;
  return 0;
}


Measured memory_bytes: 13184
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <iomanip>
#include <climits>
#include <string>
#include <sstream>
#include <numeric>
#include <stack>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
pii dfs(string &S, vector< pii > &dp, int x) {
	if (dp[x] != pii(-1, -1))
		return dp[x];
	int d;
	if (S[x] == 'L')
		d = -1;
	else
		d = 1;
	if (x + d < 0 || x + d > N - 1)
		return dp[x] = pii(-1, x);
	if (S[x] == 'L' && S[x + d] == 'R' || S[x] == 'R' && S[x + d] == 'L') {
		if (x % 2 == 0)
			return dp[x] = pii(x, x + d);
		else
			return dp[x] = pii(x, x + d);
	}
	dp[x] = dfs(S, dp, x + d);
	swap(dp[x].first, dp[x].second);
	return dp[x];
}
signed main() {
	string S;
	cin >> S;
	N = S.size();
	vector< pii > dp(N, pii(-1, -1));
	rep(i, N) dfs(S, dp, i);
	vector< int > ans(N, 0);
	rep(i, N) {
		pii p = dp[i];
		if (p.first == -1)
			ans[p.second]++;
		else
			ans[p.first]++;
	}
	rep(i, N) cout << ans[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 7680
def main():
    h, w, k = map(int, raw_input().split())
    c = [map(int, raw_input().strip()) for _ in xrange(h)]
    def go(a):
        if not res:
            return 0
        return go(a) * 2 + res
    ans = 0
    for ii in xrange(h):
        for jj in xrange(w):
            a = [c[i][:] for i in xrange(h)]
            a[ii][jj] = 0
            r = 0
            e = 1
            while 1:
                for j in xrange(w):
                    st = [a[i][j] for i in xrange(h) if a[i][j]]
                    for i in xrange(h):
                        a[i][j] = 0
                    i = -1
                    for x in reversed(st):
                        a[i][j] = x
                        i -= 1
                res = 0
                for i in xrange(h):
                    j = 0
                    while j < w:
                        t = j + 1
                        while t < w and a[i][j] == a[i][t]:
                            t += 1
                        if t - j >= k:
                            for j in xrange(j, t):
                                res += a[i][j]
                                a[i][j] = 0
                        j = t
                if not res:
                    break
                r += res * e
                e *= 2
            if ans < r:
                ans = r
    print ans
main()


Measured memory_bytes: 24812
#include <stdio.h>

int main(void)
{
    int n=0,m=0;
    long int sum=0;
    int array[10000]={};
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d",&array[i]);
        sum+=array[i];
    }

    if(n-sum<0){
        printf("-1");
    } else {
        printf("%ld",n-sum);
    }

    return 0;
}


Measured memory_bytes: 1752
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cstring>
#define maxn 120
const int inf=2e9;
using namespace std;
struct XY{
	int xx,yy;
}node;
char c[55][55];
int step[55][55],fx[4][2]={{-1,0},{0,1},{1,0},{0,-1}},n,m;
int read(){
	int w=0;char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') w=w*10+c-48,c=getchar();
	return w;
}
void bfs(){
	queue <XY> q;
	 node.xx=1;node.yy=1;q.push(node);
	 while(step[n][m]==inf&&!q.empty()){
	 	int x=q.front().xx,y=q.front().yy;q.pop();
	 	for(int i=0;i<4;i++){
	 		if(c[x+fx[i][0]][y+fx[i][1]]!='#'&&step[x+fx[i][0]][y+fx[i][1]]==inf){
	 			step[x+fx[i][0]][y+fx[i][1]]=step[x][y]+1;
	 			node.xx=x+fx[i][0];node.yy=y+fx[i][1];
				 q.push(node); 
	 		}
	 	}
	 }
}
int main(){
	int i,j,black=0;
	n=read();m=read();
	memset(c,'#',sizeof(c));
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			scanf(" %c",&c[i][j]);
			if(c[i][j]=='#') black++;
		}
	}
	for(i=0;i<=n;i++){
		for(j=0;j<=m;j++)
		step[i][j]=inf;
	}
	step[1][1]=1;
	bfs();
	if(step[n][m]!=inf) printf("%d",n*m-step[n][m]-black);
	else printf("-1");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <istream>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define vec vector<int>a(n)
#define soot(a) sort(a.begin(),a.end())
/*int n;
cin >> n;
vector<int>a(n);
rep0(i, n - 1)cin >> a[i];*/
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = a *100+ b * 10 + c ;
	if (ans % 4 == 0)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(a+1):
    for j in range(b+1):
        z = x-(500*i+100*j)
        if(z < 0):
            break
        if(z/50 <= c):
            cnt += 1

print(cnt)


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

int main()
{
    ll q, h, s, d, n;
    cin>>q>>h>>s>>d>>n;
    q*=4;
    h*=2;
    if(q<s) s=q;
    else if(h<s) s=h;
    if(s*2 < d) cout<<s*n<<'\n';
    else if(n%2==0) cout<<n/2*d<<'\n';
    else cout<<(n/2*d)+s<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL =LONG_LONG_MAX;
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


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

    double val = 0;
    
    rep(i,n){
        double c;string s;cin>>c>>s;
        
        if(s=="JPY") val +=c;
        else val += c*380000.0;
        
    }
    
    printf("%.10lf\n",val);
    
    
    return 0;
}








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

int main(void)
{
	string a,b;
	cin >> a>>b;
	short l = a.length();
	bool t = false;
	for (int x = 0; x < l; x++)
	{
		if (a == b) { 
			t = true; break;
		}
		a = a[l-1] + a;
		a.pop_back();
	}
	if (t) { cout << "Yes"; }
	else { cout << "No"; }
	return 0;
}

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

using namespace std;

char x[] = {'L', 'R'};
char y[] = {'D', 'U'};

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  for (int i = min(sy, ty); i < max(sy, ty); i++) {
    cout << y[(sy < ty)];
  }
  for (int i = min(sx, tx); i < max(sx, tx); i++) {
    cout << x[(sx < tx)];
  }
  for (int i = min(sy, ty); i < max(sy, ty); i++) {
    cout << y[(sy > ty)];
  }
  for (int i = min(sx, tx); i < max(sx, tx); i++) {
    cout << x[(sx > tx)];
  }
  if (sx < tx) cout << "L";
  else cout << "R";
  for (int i = min(sy, ty); i < max(sy, ty); i++) {
    cout << y[(sy < ty)];
  }
  cout << y[(sy < ty)];
  if (sx < tx) cout << "R";
  else cout << "L";
  for (int i = min(sx, tx); i < max(sx, tx); i++) {
    cout << x[(sx < tx)];
  }
  cout << y[(sy > ty)];

  if (sx < tx) cout << "R";
  else cout << "L";
  for (int i = min(sy, ty); i < max(sy, ty); i++) {
    cout << y[(sy > ty)];
  }
  cout << y[(sy > ty)];
  if (sx < tx) cout << "L";
  else cout << "R";
  for (int i = min(sx, tx); i < max(sx, tx); i++) {
    cout << x[(sx > tx)];
  }
  cout << y[(sy < ty)];
  cout << endl;
}


Measured memory_bytes: 256
#include <map> 
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
string s;
int ans;
int main()
{
	fast;
	cin>>s;
	for (int i=0;i<=s.size();i++)
	   if (s[i]=='1')
	      ans++;
	cout<<ans<<endl;
	return 0;
}


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

#define ll long long

using namespace std;
const int inf = 0x3f3f3f3f;

inline ll pow(ll a) { return a * a;}

int main(){
//	freopen("in","r",stdin);
	int n; cin >> n; 
	vector<int> a(n);
	for(int i = 0;i < n;i++) cin >> a[i];
	ll sum = 0;
	for(int i = 0;i < n;i++) sum += a[i];
	ll res = inf;
	for(int avg = 1;avg <= 100;avg++){
		ll s = 0;
		for(int i = 0;i < n;i++) s += pow(a[i]-avg);
		res = min(s,res);
	}
	cout << res << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	string S;
	string front_S = "";
	string back_S = "";
	int Q;
	cin >> S >> Q;
	bool flag = true;

	for (int i = 0; i < Q; i++)
	{
		int order, f;
		string c;

		cin >> order;

		if (order == 1)
		{
			flag = !flag;
		}
		else
		{
			cin >> f >> c;
			if (f == 1)
			{
				if (flag)
				{
					front_S = front_S + c;
				}
				else
				{
					back_S = back_S + c;
				}
			}
			else
			{
				if (flag)
				{
					back_S = back_S + c;
				}
				else
				{
					front_S = front_S + c;
				}
			}
		}
	}

	if (flag)
	{
		reverse(all(front_S));
		cout << front_S << S << back_S << endl;
	}
	else
	{
		reverse(all(S));
		reverse(all(back_S));
		cout << back_S << S << front_S << endl;
	}
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 1440
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
using namespace std;

int main() {
    unsigned long N;
    cin >> N;
    string S;
    cin >> S;

    vector<int> list(S.length(), 0);
    int key = 0;
    for (int i=0; i < S.length() ; i++){
        char ith_char = S[i];
        if (isdigit(ith_char)){
            continue;
        }
        int count = 1;
        for (int j= i+1; j < S.length() ; j++){
            if (S[i] == S[j]){
                S[j] = '0';
                count = count + 1;
            }
        }
        S[i] = i;
        list[key] = count;
        key = key + 1;
    }
    unsigned long long total = 1;
    unsigned long long mod = 1000000000 + 7;
    for (int i : list){
        total = ( ( total % mod) * ((i + 1) % mod) ) % mod;
    }
    total = total -1;
    unsigned long long a;
    
    a = total;
    //a = total % ( 1000000000 + 7 );



    cout << a << endl;
}

Measured memory_bytes: 896