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

using namespace std;
#define ii pair<int,int>
#define fi first
#define se second

const int Max=1e5+5;
vector<int> a[Max];

int dp[Max];
bool used[Max];

bool comp(ii a,ii b){
	if(a.se!=b.se)
		return a.se>b.se;
	return a.fi<b.fi;
}

int main(){
	int n,m;
	cin>>n>>m;
	priority_queue<int> q;
	for(int i=0;i<n;i++){
		int ta,tb;
		cin>>ta>>tb;
		if(ta>m){
			continue;
		}
		a[m-ta].push_back(tb);
	}
	long long ans=0;
	for(int i=m-1;i>=0;--i){
		for(int b:a[i]){
			q.push(b);
		}
		if(!q.empty()){
			ans+=q.top();
			q.pop();
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

long long int sth[101][101];//next straight height [????????????????????????][????????????????????????]
long long int cuh[101][101];//next curve height [????????????????????????][????????????????????????]
long long int stw[101][101];//next straight width [????????????????????????][????????????????????????]
long long int cuw[101][101];//next curve width [????????????????????????][????????????????????????]

int main() {

    int w,h;


    while(1) {

        cin >> w >> h;

        if(w==0&&h==0){
            break;
        }

        w--;h--;

        for(int i=0;i<101;i++){
            sth[i][0] = 1;
            sth[0][i] = 0;//sth[0][0] = 0
            cuh[i][0] = 0;
            cuh[0][i] = 1;//cuh[0][0] = 1
            stw[i][0] = 1;
            stw[0][i] = 0;//stw[0][0] = 0
            cuw[i][0] = 0;
            cuw[0][i] = 1;//cuw[0][0] = 1
        }

        for(int i=1;i<=h;i++){
            for(int j=1;j<=w;j++){
                sth[j][i] = cuw[i][j-1] % 100000;
                stw[i][j] = cuh[j][i-1] % 100000;
                cuh[j][i] = (cuh[j][i-1] + sth[j][i-1] ) % 100000;
                cuw[i][j] = (cuw[i][j-1] + stw[i][j-1] ) % 100000;
            }
        }
 
        cout << (cuh[w][h-1] + sth[w][h-1] + cuw[h][w-1] + stw[h][w-1]) % 100000 << endl;

    }


    return 0;
}

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

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

    int n , k , q;
    cin >> n >> k >> q;
    unordered_map<int , int > store;

    for(int i = 0; i < q; ++i){
        int winner;
        cin >> winner;
        store[winner]++;
    }

    for(int i = 1; i <= n; ++i){

        int last_point = k - q + store[i];
        if(last_point > 0){
            cout << "Yes\n";
        }
        else{
            cout << "No\n";
        }

    }

return 0;}


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

int main() {
  int n,count;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a.at(i);
  count=0;
  
  for(int i=0;i<101;i++){
    for(int j=0;j<n;j++){
      if(j==0){
        if(a.at(j)>0)count++;
      }
      else if(a.at(j)>0 && a.at(j-1)<=0)
        count++;
    }
    for(int k=0;k<n;k++)a.at(k)--;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

const int MAX_N = 1e5+10;
vector<int> d[MAX_N];

int main(){
	int n;
	cin >> n;
	vi x(n);
	rep(i, n) cin >> x[i];
	int l;
	cin >> l;
	rep(i, n) d[i].resize(31);
	rep(i, n) {
		d[i][0] = upper_bound(all(x), x[i]+l) - x.begin();
		d[i][0]--;
	}
	rep(i, 30){
		rep(j, n) d[j][i+1] = d[d[j][i]][i];
	}
	int q;
	cin >> q;
	rep(i, q) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if(a > b) swap(a, b);
		ll ans = 0LL, nxt = a;
		while(1) {
			if(d[nxt][0] >= b) {
				ans+=1;
				break;
			} 
			auto it = lower_bound(all(d[nxt]), b);
			--it;
			ans += (1LL<<(int)(it - d[nxt].begin()));
			nxt = *it;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 17664
# E - Divisible Substring
N,P = map(int,input().split())
S = input()
ans = 0
if P==2 or P==5:
    for i in range(N):
        if int(S[i])%P==0:
            ans += i+1
else:
    l = [1]+[0]*(P-1)
    tmp = 0
    r10 = 1
    for i in range(N-1,-1,-1):
        tmp = (r10*int(S[i])+tmp)%P
        l[tmp] += 1
        r10 = (r10*10)%P
    for x in l:
        ans += x*(x-1)//2
print(ans)

Measured memory_bytes: 9456
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
using namespace std;
long long dp[305][90005] = {}, dp2[305][90005] = {}, res = 0;
long long int rui(long long int a, long long int b, long long mod) {
	int memo[65] = {};
	long long int A[65] = {};
	long long int tmp = 1;
	for (int i = 0; i < 65; i++) {
		memo[i] = b % 2;
		b /= 2;
	}

	A[0] = a;
	A[0] %= mod;

	for (int i = 1; i < 65; i++) {
		A[i] = A[i - 1] * A[i - 1];
		A[i] %= mod;
	}
	for (int i = 0; i < 65; i++) {
		if (memo[i] == 1) {
			tmp *= A[i];
			tmp %= mod;
		}
	}
	tmp %= mod;
	return tmp;
}

int main() {
	map<long long int, long long int>mp;
	//cout << fixed << setprecision(10);
	long long int n, m = 0, a[200005] = {}, p[200005] = {}, sosu[100005], sum = 0, d, w, h;
	
	cin >> n;

	for (int i = 1; i <= n;i++) {
		cin >> a[i];
		sum += a[i];
	}
	dp[0][0] = 1;
	dp2[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= sum; j++) {
			dp[i][j + a[i]] += dp[i - 1][j];
			dp[i][j] += 2 * dp[i - 1][j];
			dp[i][j] %= 998244353;

			dp2[i][j + a[i]] += dp2[i - 1][j];
			dp2[i][j] += dp2[i - 1][j];
			dp2[i][j] %= 998244353;
		}
	}
	res = rui(3, n, 998244353);
	for (int j = sum; j*2 >=sum; j--) {
		res -= 3*dp[n][j];
		res = (res % 998244353) + 998244353;
		if (j * 2 == sum) {

			res +=3 * dp2[n][j];
		}
	}
	cout << res%998244353;
}



Measured memory_bytes: 429184
///////////////////////////////////////////
//                                       //
//      Gagan_Sharma : DTU               // 
//                                       //                   
///////////////////////////////////////////
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define int        long long
// #define mp      make_pair
#define eb         emplace_back
#define pb         push_back
#define ss         second
#define ff         first
#define IOS        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod        998244353
#define MOD        (1000*1000*1000+7)
#define MN         LLONG_MIN
#define MX         LLONG_MAX
#define v1d        vector<int>
#define v2d        vector<vector<int>>
#define vip        vector<pair<int,int> >
#define v1s        vector<string>
#define pa         pair<int,int>
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define print(v)   for(auto i:v)cout<<i<<" ";cout<<"\n";
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)     for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)     for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define endl       '\n'
#define input(b,n) for(int i=0;i<n;i++)cin>>b[i+1];
#define Sort(v)    sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v)     v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s = bitset<64>(a).to_string();
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define fbo find_by_order // iterator to the kth element
#define ook order_of_key  //number of items that are strictly smaller than our item k
// #define T pair<int, int>
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
 
void read(int n=12){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
}
 
//____________________________________________________________________________________
 
 
void solve(){
    int n,k;cin>>n>>k;
    v1d h(n+5);input(h,n);
    v1d dp(n+5,MX);
    dp[1] = 0;
    //dp[2] = abs(h[2]-h[1]);
    for(int i=2;i<=n;i++){
      for(int j=1;j<=k && i-j >= 1;j++)
      	dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
    }
    cout<<dp[n]<<"\n";
 
}
 
int32_t main(){
    read();
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    
 
 
    return 0;
}  


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;



int main(void) {
    ll n,m;
    cin>>n>>m;
    if(min(n,m) == 1){
        if(max(n,m)==1) cout<<1<<endl;
        else cout<<(max(n,m)-2)<<endl;
    }
    else{
        cout<<(n-2)*(m-2)<<endl;
    }
	return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

using P = pair<int,int>;
random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////


int main(){
  ini(N,A,B);
  ins(S);
  int x = 0 , y = 0;
  rep(i,N){
    if(S[i] == 'a'){
      if(x + y < A + B){
        out("Yes"); x++;
      }
      else out("No");
    }
    else if(S[i] == 'b'){
      if(x + y < A + B && y < B){
        out("Yes"); y++;
      }
      else out("No");
    }
    else{
      out("No");
    }
  }

}

Measured memory_bytes: 848
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

ll n,m,k;
vvint a,b;
vint d;
int namer = 0;
vvint mem;
int dfs(int par){
	d[par] = namer;
	mem[namer].push_back(par);
	int ret = 1;
	rep(i, a[par].size()){
		if(d[a[par][i]]==-1){
			ret += dfs(a[par][i]);
		}
	}
	return ret;
}


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	cin>>n>>m>>k;
	a = vector<vint>(n);
	b = vector<vint>(n);
	d = vint(n, -1);
	rep(i, m){
		int p,q;cin>>p>>q;
		a[p-1].push_back(q-1);
		a[q-1].push_back(p-1);
	}
	
	rep(i, k){
		int p,q;cin>>p>>q;
		b[p-1].push_back(q-1);
		b[q-1].push_back(p-1);
	}
	//sort();
	vint nl;
	rep(i, n){
		if(d[i]==-1){
			mem.push_back(vint());
			nl.push_back(dfs(i));
			sort(all(mem[namer]));
			namer++;
		}
	}
	rep(i, namer){
		debug("i: %d\n", i);
		rep(j, nl[i]){
			debug("%d %d\n", j, mem[i][j]);
		}
	}
		debug("\n");
	rep(i, n){
		if(i!=0)cout << ' ';
		int bcou = 0;
		rep(j, b[i].size()){
			if(d[i]==d[b[i][j]]){
			//if(binary_search(all(mem[d[i]]), b[i][j])){
				bcou++;
			}
		}
		cout << nl[d[i]] - a[i].size() - 1 - bcou;
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 24456
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{	
    int n;
    cin>>n;
    vector<ll> A(n+1,0),B(n,0);
    for(int i=0;i<n+1;i++){
        cin>>A[i];
    }
    for(int i=0;i<n;i++){
        cin>>B[i];
    }
    
    ll res = 0;
    for(int i=0;i<n;i++){
        res += min(A[i],B[i]);
        if(A[i]<=B[i]){
            B[i] -= A[i];
            res += min(A[i+1],B[i]);
            if(A[i+1]<=B[i]){
                A[i+1] = 0;
            }
            else{
                A[i+1] -= B[i];
            }
        }
    }
    cout<<res<<endl;
    
	return 0;
}

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

h = []
for _ in range(N):
    h.append(int(input()))

h.sort()

res = h[K-1] - h[0]

for i in range(N-K+1):
    h_min = h[i]
    h_max = h[i+K-1]
    res = min(res, h_max - h_min)

print(res)

Measured memory_bytes: 7384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define K 1000000000
#define ll long long
using namespace std;

int main(){
	ll X;cin >> X;
	ll i,j;
	for(i=-500;i<=500;i++){
		for(j=-500;j<=500;j++){
			if((i*i*i*i*i) - (j*j*j*j*j) == X){
				cout << i << " " << j << endl;
				return 0;
			}
		}
	}
}


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

int main(){
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    typedef pair<int, int> trans;
    vector<trans> Trans{trans(-1, 0),trans(1, 0),trans(0, -1),trans(0, 1)};
    rep(i,H)cin>>a[i];
    
    rep(i,H){
        for(int j=0; j<W; j++){
            char c = a[i][j];
            if(c=='.')continue;

            int x, y;
            bool is_paint = false;
            for(trans xy: Trans){
                x = j + xy.first;
                y = i + xy.second;

                if(x >= 0 && x < W && y >= 0 && y < H){
                    if(a[y][x] == '#'){
                        is_paint = true;
                    }
                }
            }

            if(is_paint == false){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


int main() {
	string S;
	cin >> S;
	cout << S[0] << (S.size() - 2) << S.rbegin()[0];

	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
class Main {
	public void kami() {
		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		
		while(H != 0 || W != 0){
			
			for(int j = 1; j <= H; j++){
				for(int i = 1; i <= W; i++){
					if(j % 2 == 0){
						if(i % 2 == 0){
							System.out.print("#");
						}else{
							System.out.print(".");
						}
						
					}else{
						if(i % 2 == 0){
							System.out.print(".");
						}else{
							System.out.print("#");
						}
					}
				}
				System.out.println();
			}
			System.out.println();
			H = sc.nextInt();
			W = sc.nextInt();
		}
		
	
	}

	public static void main(String[] args) {

		new Main().kami();
	}

}

Measured memory_bytes: 26840
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数


int main()
{
  int n ;
  cin >> n ;
  string s ;
  cin >> s ;
  int ans = 1;
  REP(i,n-1){
    if(s.at(i)!=s.at(i+1)){
      ans++ ;
    }
  }
  
  cout << ans <<endl ;


  return 0 ;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n; cin >> n; vector<int> a(n);
	for (int i = 0; i < n;i++) cin >> a[i];
	for (auto i = a.rbegin();;) {
		cout << *i;	i++;
		if (i == a.rend()) { cout << endl; return 0; }
		cout << " ";
	}
}

Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <iomanip> 
#include <stack>
#include <stdlib.h>	
#include <stdio.h>
#define INF 0x3f3f3f3f
#include <set> 
#include <map>  
#include <queue>
#define maxn 300
using namespace std;
typedef long long ll;
struct node {
	int x,y;
}a[205],b[160];
int girl[160];
vector<int>v[maxn];
bool used[160];
int n,x,y;

bool found(int x){
	for(int i=0;i<v[x].size();i++){
		int t=v[x][i]; 
		if(!used[t]){
			used[t]=1;
			if((girl[t]==0)||found(girl[t])){
				girl[t]=x;
				return 1;
			}
		}
	}
	return 0;
}
int main(){
	scanf("%d",&n);
	//to be empty 
	for(int i=0;i<=n;i++) v[i].clear();
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		a[i].x=x;
		a[i].y=y;
	}
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		b[i].x=x;
		b[i].y=y;
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if((a[i].x<b[j].x)&&(a[i].y<b[j].y)){
				v[i].push_back(j);
			}
		}
	}
	memset(girl,0,sizeof(girl));
	int sum=0;
	for(int i=1;i<=n;i++){
		memset(used,0,sizeof(used));
		if(found(i)) sum++;
	}
	printf("%d\n",sum);
	return 0;
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
    string a;
	while(cin>>a)
	{
			int panduan=0;
	for(int i=0;i<a.length();i=i+2)
	{
		if(a[i]!='h'||a[i+1]!='i')
		{
			panduan=1;
		}
	 }
	 if(panduan==1)
	 {
	 	cout<<"No"<<endl;
	  }
	  else
	  {
	  	cout<<"Yes"<<endl;
	   } 
	}

    
    return 0;
}

Measured memory_bytes: 256
X,Y,Z,K = list(map(int,input().split()))
A = [(sorted(list(map(int,input().split())))[::-1]) for i in range(3)]

import heapq

heap = []
item = (0,(0,0,0))
heapq.heappush(heap, item)
considered_dict = set(item[1])

ret = []
max_ = A[0][0]+A[1][0]+A[2][0]
while len(ret) < K:
    task  = heapq.heappop(heap)
    score,(x,y,z) =task
    ret.append(score)
    # assign next task
    if x+1 != X and (x+1,y,z) not in considered_dict:
        heapq.heappush(heap, (max_-A[0][x+1]-A[1][y]-A[2][z],(x+1,y,z) ))
        considered_dict |= {(x+1,y,z)}
        
                       
    if y+1 != Y and (x,y+1,z) not in considered_dict:
        heapq.heappush(heap, (max_-A[0][x]-A[1][y+1]-A[2][z],(x,y+1,z) ))
        considered_dict |= {(x,y+1,z)}
                       
    if z+1 != Z and (x,y,z+1) not in considered_dict:
        heapq.heappush(heap, (max_-A[0][x]-A[1][y]-A[2][z+1],(x,y,z+1) ))
        considered_dict |= {(x,y,z+1)}


for i in ret:
    print(max_-i)


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

int main(){
  int num[181];
  for(int i=0;i<181;i++){
    num[i]=(i+1)*(i+1);
  }

  int n;
  while(cin>>n,n){
    int cnt=0;
    int a,b,c;
    for(int i=0;i<181;i++){
      if((a=num[i])>n) continue;
      if(a==n){ cnt++; break;}
      for(int j=i;j<181;j++){
	if((b=a+num[j])>n) continue;
	if(b==n) {cnt++; break;}
	for(int k=j;k<181;k++){
	  if((c=b+num[k])>n) continue;
	  if(c==n){ cnt++; break;}
	  for(int m=k;m<181;m++){
	    if((c+num[m])==n) cnt++;
	  }
	}
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"A":"B")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int x,a,b;
	int ans=0;
	cin >>x>>a>>b;
	cout<<solve(abs(x-a)<(abs(x-b)))<<endl;
}

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

int main(){
    string s;
    cin >> s;

    int n = s.size();
    vector<int> d(n);
    int ten = 1;
    for(int i=n-1;i>=0;i--){
        int a = (s[i] - '0') * ten % 2019;
        d[i] = (d[i+1] + a) % 2019;
        ten *= 10;
        ten %= 2019;
    }

    vector<int> cnt(2019);
    int ans = 0;
    cnt[0]++;
    for(int i=0;i<n;i++){
        ans += cnt[d[i]];
        cnt[d[i]]++;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 4372
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,l,r) for(ll i=l;i<r;i++)
#define rrep(i,l,r) for(ll i=(r)-1;i>=l;i--)
#define LINF (ll)1e18
#define INF (int)1e9
#define range(i) i.begin(),i.end()
#define sum(i) accumulate(range(i),0)
struct start { start() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }start;
inline void in() {}
template <class Head, class... Tail>
inline void in(Head&& head, Tail&&... tail) {
	cin >> head;
	in(move(tail)...);
}
template <class T>
inline void out(T t) {
	cout << t << '\n';
}
template <class Head, class... Tail>
inline void out(Head head, Tail... tail) {
	cout << head << ' ';
	out(move(tail)...);
}
template <class T>
inline void out(vector<T> a){
    rep(i,0,a.size()-1)cout<<a[i]<<' ';
    out(a.back());
}


int main() {
    int n;
    in(n);
    string s;
    in(s);
    rep(j,0,4){
    vector<bool> wolf(n);
    wolf[0]=j&1;
    wolf[1]=j&2;
    rep(i,2,n){
        wolf[i]=wolf[i-2]^(s[i-1]=='x')^wolf[i-1];
    }
    if(wolf[0]==wolf[n-2]^(s[n-1]=='x')^wolf[n-1]&&wolf[1]==wolf[n-1]^(s[0]=='x')^wolf[0]){
        rep(i,0,n)cout<<(wolf[i]?'W':'S');
        cout<<'\n';
        return 0;
    }
    }
    out(-1);
}









Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
bool iskaibun(string s){
	string t(s);
	reverse(t.begin(),t.end());
	return t==s;
}

int main(){
	string s;
	cin >> s;
	
	int n=s.size();
	if(iskaibun(s)){
		if(iskaibun(s.substr(0,(n-1)/2))){
			if(iskaibun(s.substr((n+3)/2-1,(n-3)/2+1))){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
const ll MAX_V=114514LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

struct edge {
    ll to;
    ll cost;
};

ll V;
vector<edge> G[MAX_V];
ll d[MAX_V];
ll back[MAX_V];
void dijkstra(ll s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        if (d[v] < p.first) continue;

        for (ll i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                back[e.to]=v;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
int main(){
  cin>>V;
  ll m;cin>>m;
  rep(i,m){
    ll a,b;cin>>a>>b;
    a--;b--;
    edge e1;
    e1.to=b;e1.cost=1;
    G[a].push_back(e1);
    edge e2;
    e2.to=a;e2.cost=1;
    G[b].push_back(e2);
  }
  dijkstra(0);
  cout<<"Yes"<<endl;
  for(ll i=1;i<V;i++)cout<<back[i]+1<<endl;
}

Measured memory_bytes: 19888
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <unordered_set>
using namespace std;

int main(void){
    double N, K;
    cin >> N >> K;
    cout << (int)floor(log(N)/log(K))+1 << endl;
    return 0;
}

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

struct Node {
	int key;
	struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
Node * find(Node *u, int k){
	while(u!=NIL&&k!=u->key){
		if(k<u->key){
			u=u->left;
		}else{
			u=u->right;
		}
	}
	return u;
}
  
int main(void) {
	int n, i, x;
	char com[16];
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		scanf("%s",com);
		if(!strcmp(com,"find")){
			scanf("%d",&x);
			Node *t=find(root,x);
			if(t!=NIL){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}else if(!strcmp(com,"insert")) {
			scanf("%d",&x);
			insert(x);
		} else if(!strcmp(com,"print")) {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


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

using namespace std;

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

    int ans = 1;
    for (int i = 0; i < n; ++i) {
        ans = fmin(ans * 2, ans + k);
    }
    cout << ans << endl;
    return 0;
}


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

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {


        public void Calc()
        {
            var NM = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            Console.WriteLine(NM[0] == NM[1] ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    map<vector<int>,ll> mp;
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        string s;cin>>s;
        vector<int> tmp(26);
        for(int j=0;j<s.size();j++){
            tmp[s[j]-'a']++;
        }
        mp[tmp]++;
    }
    ll ans=0;
    for(auto i=mp.begin();i!=mp.end();i++){
        ans+=(i->second*i->second-i->second)/2;
    }
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e15;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 2e5 + 100;
const int LOG = 20;
const int mod = 1e9 + 7;
const int MX = 1e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

struct Fenwick_tree{
    ll t[MAXN];

    Fenwick_tree(){
        memset(t,0,sizeof t);
    }

    void upd(int pos,ll val){
        for(;pos < MAXN;pos = (pos|(pos+1))){
            t[pos] = max(t[pos],val);
        }
    }
    ll get(int r){
        ll res = 0;
        for(;r>=0; r=(r&(r+1))-1){
            res = max(res, t[r]);
        }
        return res;
    }
} tree;

int h[MAXN];
int a[MAXN];
void solve() {
    int n;
    cin >> n;
    for(int i=1;i<=n;++i){
        cin >> h[i];
    }
    for(int i=1;i<=n;++i){
        cin >> a[i];
    }
    ll ans = 0;
    for(int i=1;i<=n;++i){
        ll cur = a[i] + tree.get(h[i]-1);

        tree.upd(h[i],cur);
        ans = max(ans,cur);
    }
    cout << ans;

}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;

    while (t--)
        solve();
    dout << endl << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n,m;
    cin>>n>>m;
    int a[n+2]={0};
    ffor(i,0,m)
    {
        int l,r;
        cin>>l>>r;
        a[l]+=1;
        a[r+1]+=-1;
    }
    ffor(i,1,n+2) a[i]+=a[i-1];
    int ans=0;
    ffor(i,1,n+1) if(a[i]==m) ans++;
    cout<<ans;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    int length = s.length();
    for (int offset = 0; offset < length; ++offset) {
        bool flag = true;
        for (int i = 0; i < length; ++i) {
            if (s[(i + offset) % length] != t[i]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}


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

public class Main {
	public static void main (String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arr = br.readLine().split(" ", 2);
		int n = Integer.parseInt(arr[0]);
		int m = Integer.parseInt(arr[1]);
		int[] menues = new int[m + 1];
		for (int i = 0; i < n; i++) {
			arr = br.readLine().split(" ");
			int k = Integer.parseInt(arr[0]);
			for (int j = 1; j <= k; j++) {
				int a = Integer.parseInt(arr[j]);
				menues[a]++;
			}
		}
		int count = 0;
		for (int x : menues) {
			if (x == n) {
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 22996
#include <stdio.h>

int main(void)
{
	int n, residence[4][3][10];
	int b, f, r, v, i,j,k;

	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				residence[i][j][k] = 0;
			}
		}
	}

	scanf("%d",&n);

	i = 0;

	while(i<n){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		residence[b-1][f-1][r-1] += v;
		i++;
	}

	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",residence[i][j][k]);
			}
			printf("\n");
		}
		if(i<3){
			printf("####################\n");
		}
	}

	return 0;
}


Measured memory_bytes: 612
#include <iostream>
#include <utility>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	int n,a[10000],ans;
	while(cin>>n&&n){
		for(int i=0;i<n;i++)cin>>a[i];
		sort(a,a+n);
		if(a[n-1]<=1){
			cout<<"NA"<<endl;
			continue;
		}
		ans=n-(lower_bound(a,a+n,1)-a)+1;
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1216
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        String format = "%.6f %.6f%n";

        while ((line = br.readLine()) != null) {
            String[] input = line.split(",");
            double x1 = Double.parseDouble(input[0]);
            double y1 = Double.parseDouble(input[1]);
            double x2 = Double.parseDouble(input[2]);
            double y2 = Double.parseDouble(input[3]);
            double xq = Double.parseDouble(input[4]);
            double yq = Double.parseDouble(input[5]);

            if (x1 == x2) {
                double x = (x1 - xq) + x1;
                System.out.printf(format, x, yq);
            } else if (y1 == y2) {
                double y = (y1 - yq) + y1;
                System.out.printf(format, xq, y);
            } else {
                double alpha = (y2 - y1) / (x2 - x1);
                double x = ((1 - alpha * alpha) * xq + 2 * alpha * yq + 2 * alpha * alpha * x1 - 2 * alpha * y1)
                        / (alpha * alpha + 1);
                double y = (xq - x) / alpha + yq;
                System.out.printf(format, x, y);
            }

        }
    }
}


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

using namespace std;

int N, a[100009];
long long ma[100009];

void fail ()
{
    printf ("-1\n");
    exit (0);
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=0; i<=N; i++)
    scanf ("%d", &a[i]);
ma[N] = 0;
for (int i=N - 1; i>=0; i--)
    ma[i] = ma[i + 1] + a[i + 1];
long long cnt = 1, ans = 1;
if (a[0] > 0)
{
    if (N == 0 && a[0] == 1) printf ("1\n");
    else fail ();
    exit (0);
}
for (int i=1; i<=N; i++)
{
    cnt = min (cnt * 2LL - a[i], ma[i]);
    if (cnt < 0)
        fail ();
    ans += cnt + a[i];
}
printf ("%lld\n", ans);
return 0;
}


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

using namespace std;

const int md = 1e9 + 7;
const int mxn = 3e5;

long long a[mxn + 11];
int main(){
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%lld", a + i);
	}
	long long cur = 1;
	long long ans = 0;
	for (int i = 1; i <= 60; i++){
		int cnt = 0;
		for (int j = 0; j < n; j++){
			if (a[j] & cur)
				cnt++;
		}
		long long now = cnt * 1LL * (n - cnt) % md;
		now = now * 1LL * (cur % md) % md;
		ans = (ans + now) % md;
		cur <<= 1;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define t(x) cerr<<#x<<":"<<x<<'\n';
#define t2(a,n) { cerr<<#a<<" = "; for(int i=0; i<n; ++i){ cerr << a[i] << ' '; } ; cerr <<'\n'; }
#define t3(a){ cerr<<#a<<" = "; for(auto i: a){ cerr<<i<<" "; } cerr<<'\n'; }
const ll mod = 1e9+7;
// A G C T
// 0 1 2 3
// Not Allowed : AGC
// Return true if state is bad
bool check(int a, int b, int c, int d){
	if( b == 0 and c == 1 and d == 2 ){ return true; } // AGC
	if( b == 0 and c == 2 and d == 1 ){ return true; } // ACG
	if( b == 1 and c == 0 and d == 2 ){ return true; } // GAC
	if( a == 0 and c == 1 and d == 2 ){ return true; } // AXGC
	if( a == 0 and b == 1 and d == 2 ){ return true; } // AGXC
	return false;
}

ll dp[105][4][4][4];


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin>>n;
	memset(dp,0,sizeof(dp));
	for(int a=0; a<4; ++a){
		for(int b=0; b<4; ++b){
			for(int c=0; c<4; ++c){
				if( a == 0 and b == 1 and c == 2 ){ continue; }
				if( a == 0 and b == 2 and c == 1 ){ continue; }
				if( a == 1 and b == 0 and c == 2 ){ continue; }
				dp[3][a][b][c] = 1;
			}
		}
	}

	for(int i=3; i<=n; ++i){
		for(int a=0; a<4; ++a){
			for(int b=0; b<4; ++b){
				for(int c=0; c<4; ++c){
					for(int d=0; d<4; ++d){
						if( check(a,b,c,d) ){ continue; }
						dp[i+1][b][c][d] += dp[i][a][b][c];
						dp[i+1][b][c][d] %= mod;
					}
				}
			}
		}
	}

	ll ans = 0;
	for(int a=0; a<4; ++a){
		for(int b=0; b<4; ++b){
			for(int c=0; c<4; ++c){
				ans += dp[n][a][b][c];
				ans %= mod;
			}
		}
	}
	cout<<ans<<endl;

	#ifdef LOL
	    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	#endif
	return 0;
}


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

int main() {
  string a;
  cin>>a;
  
  int k=0;
    
  for(int i=0;i<4;i++){
    if(a.at(i)=='+'){
      k+=1;
    }
    else{
      k+=-1;
    }
  }
  
  cout<<k<<endl;
}

Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
scs = m.times.map do
  s, c = gets.chomp.split(" ").map(&:to_i)
  [s, c]
end

h = {}
dupli = false

scs.each do |s, c|
  if h[s] && (h[s] != c)
    dupli = true
    break
  end

  h[s] = c
end

if dupli
  puts "-1"
  exit 0
end

str = ""

(1..n).each do |i|
  if h[i]
    str << h[i].to_s
  else
    if i == 1 && n > 1
      str << 1.to_s
    else
      str << 0.to_s
    end
  end
end

if str == "0"
  puts 0
elsif str[0] == "0"
  puts(-1)
else
  puts str
end


Measured memory_bytes: 1788
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, int(n) + 1)
#define RREP(i, n) RFOR(i, 0, n)
#define RREP1(i, n) RFOR(i, 1, int(n) + 1)
#define ALL(c) begin(c), end(c)

int _ = (
#ifndef LOCAL
    std::cin.tie(nullptr), std::ios::sync_with_stdio(false),
#endif
    std::cout.precision(10), std::cout.setf(std::ios::fixed));

using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T> using vec = std::vector<T>;
using namespace std;

int main() {
  ll N, M, p;
  cin >> N >> M;
  string S;
  vec<vec<string>> submits(N + 1, vec<string>{});
  REP(i, M) {
    cin >> p >> S;
    submits[p].emplace_back(S);
  }
  ll ac = 0, wa = 0;
  REP1(i, N) {
    bool is_ac = false;
    ll pwa = 0;
    for (const auto submit : submits[i]) {
      if (submit == "AC") {
        ac++;
        is_ac = true;
        break;
      } else {
        pwa++;
      }
    }
    wa += is_ac ? pwa : 0;
  }
  cout << ac << " " << wa << endl;
  return 0;
}


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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(M);
    vector<char> result(M, true);
    REP(n, N){
        scanInt(K);
        scanVecInt(A, K);
        vector<char> result_temp(M, false);
        for (auto& a : A){
            result_temp[a - 1] = true;
        }
        REP(m, M){
            result[m] &= result_temp[m];
        }
    }
    cout << accumulate(result.begin(), result.end(), 0) << endl;
}


Measured memory_bytes: 256
n= int(input())
h1=list(map(int,input().split()))
dp=[-1 for i in range(n)]
def fun(i):
    if dp[i]!=-1:
        return dp[i]
    if i==n-1:
        best=0
    elif i==n-2:
        best=abs(h1[n-1]-h1[n-2])
    else:
        best=min(fun(i+1)+abs(h1[i+1]-h1[i]),fun(i+2)+abs(h1[i+2]-h1[i]))
    dp[i]=best
    return best
for k in range(n):
    fun(n-1-k)

print(fun(0))  
        

Measured memory_bytes: 13924
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define abs(x) ((x) > 0 ? (x) : -(x))
#define MOD (ll)1000000007 //10^9 + 7
#define endl printf("\n")
typedef long long ll;
#define MAX_N (1 << 17)

int
main(int argc, char *argv[])
{
  ll n, k, a[2010];
  scanf("%lld %lld", &n, &k);
  for (int i = 0; i < n; i++) scanf("%lld", &a[i]);

  ll f[2010] = {}, b[2010] = {};
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (a[i] > a[j]) f[i]++;
    }
    for (int j = i + 1; j < n; j++) {
      if (a[i] > a[j]) b[i]++;
    }
    //printf("%lld %lld\n", f[i], b[i]);
  }

  ll sb = 0, st = 0;
  for (int i = 0; i < n; i++) {
    sb += b[i];
    st += f[i] + b[i];
  }
  //printf("%lld %lld\n", sb, st);
  sb %= MOD;
  st %= MOD;
  k %= MOD;

  printf("%lld\n", ((k * sb) % MOD + (((k*(k - 1)/2) % MOD)*st) % MOD) % MOD);

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define N 100010
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,a[N]; 
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	sort(a+1,a+n+1,greater<int>());
	for(int i=1;i<=n;++i){
		if(i+1>a[i+1]){
			int j=0;
			while(a[i+j+1]==i)++j;
			if(((a[i]-i)&1)||(j&1)){
				printf("First\n");
			}
			else{
				printf("Second\n");
			}
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 640
import math
n = int(input())
lis = [list(map(int,input().split())) for i in range(n)]
num = 0
for i in range(n):
    for j in range(n):
        num += math.sqrt((lis[i][0]-lis[j][0])**2 + (lis[i][1]-lis[j][1])**2)
print(num/n)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(3 * n);
	for (int i = 0; i < 3 * n; ++i) {
		scanf("%d", &a[i]);
	}
	vector<ll> rec(3 * n), rec2(3 * n);
	ll sum = 0;
	multiset<int> S;
	for (int i = 0; i < 3 * n; ++i) {
		S.insert(a[i]);
		sum += a[i];
		while (S.size() > n) {
			sum -= *S.begin();
			S.erase(S.begin());
		}
		rec[i] = sum;
	}
	S.clear();
	sum = 0;
	for (int i = 3 * n - 1; i >= 0; --i) {
		S.insert(a[i]);
		sum += a[i];
		while (S.size() > n) {
			sum -= *prev(S.end());
			S.erase(prev(S.end()));
		}
		rec2[i] = sum;
	}
	ll ans = LLONG_MIN;
	for (int i = 0; i < 3 * n; ++i) {
		if (i >= n - 1 && 3 * n - i - 1 >= n) {
			ans = max(ans, rec[i] - rec2[i + 1]);
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 10752
/*author: hyperion_1724
  date: 
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	

	long long N;
	cin>>N;
	cout<<180*(N-2)<<endl;

	return 0;
}

Measured memory_bytes: 256