akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int A,B,min=100000;
		int Asum=0,Bsum=0;
		for(A=1;A<N-1;A++) {
			B=N-A;
			if(A>=10000) {
				Asum+=(A%100000)/10000;
				Asum+=(A%10000)/1000;
				Asum+=(A%1000)/100;
				Asum+=(A%100)/10;
				Asum+=A%10;
				}
			else if(A>=1000) {
				Asum+=(A%10000)/1000;
				Asum+=(A%1000)/100;
				Asum+=(A%100)/10;
				Asum+=A%10;
			}
			else if(A>=100) {
				Asum+=(A%1000)/100;
				Asum+=(A%100)/10;
				Asum+=A%10;
				}
			else if(A>=10) {
				Asum+=(A%100)/10;
				Asum+=A%10;

			}
			else {Asum+=A%10;}

			if(B>=10000) {Bsum+=(B%100000)/10000;Bsum+=(B%10000)/1000;Bsum+=(B%1000)/100;Bsum+=(B%100)/10;Bsum+=B%10;}

			else if(B>=1000) {Bsum+=(B%10000)/1000;Bsum+=(B%1000)/100;Bsum+=(B%100)/10;Bsum+=B%10;}
			else if(B>=100) {Bsum+=(B%1000)/100;Bsum+=(B%100)/10;Bsum+=B%10;}
			else if(B>=10) {Bsum+=(B%100)/10;Bsum+=B%10;}
			else{Bsum+=B%10;}
			if((Asum+Bsum)<min) {min=Asum+Bsum;}
			Asum=0;
			Bsum=0;
		}
		if(N==2) {min=2;}
		System.out.print(min);
		//for(int i=0;i<3;i++) {

		//}
		}
	}


Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
const int MOD=1000000007;
const int INF=1000000000;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
int n,l;
int p[25];
char d[25];
int t[25];
bool escape[25];
int main(int argc,char const* argv[])
{
  while(cin >> n >> l && n)
    {
      memset(t,0,sizeof(t));
      memset(escape,false,sizeof(escape));
      int anst=-1;
      int ansindex;
      for(int i=0;i<n;i++)
	{
	  cin >> d[i] >> p[i];
	}
      while(1)
	{
	  bool clear=true;
	  for(int i=0;i<n;i++)
	    {
	      if(!escape[i])
		{
		  if(d[i]=='R')
		    {
		      p[i]++;
		      t[i]++;
		    }
		  else if(d[i]=='L')
		    {
		      p[i]--;
		      t[i]++;
		    }
		}
	    }
	  for(int i=0;i<n;i++)
	    {
	      if(p[i]==0 || p[i]==l) escape[i]=true;
	      for(int j=i+1;j<n;j++)
		{
		  if(escape[i] || escape[j]) continue;
		  if(p[i]==p[j])
		    {
		      if(d[i]=='R') d[i]='L';
		      else if(d[i]=='L') d[i]='R';
		      if(d[j]=='R') d[j]='L';
		      else if(d[j]=='L') d[j]='R';
		    }
		}
	    }
	  for(int i=0;i<n;i++)
	    {
	      if(!escape[i]) clear=false;
	    }
	  if(clear) break;
	}
      for(int i=0;i<n;i++)
	{
	  //cout << t[i] << endl;
	  if(t[i]>anst)
	    {
	      anst=t[i];
	      ansindex=i+1;
	    }
	}
      for(int i=0;i<n;i++)
	{
	  if(t[i]==anst && p[i]==0)
	    {
	      anst=t[i];
	      ansindex=i+1;
	    }
	}
      cout << anst << ' ' << ansindex << endl;
    }
  return 0;
}



Measured memory_bytes: 3068
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
	bool operator<(const P &b) const{ return cost < b.cost; }
	bool operator>(const P &b) const{ return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const{ return cost < b.cost; }
	bool operator>(const E &b) const{ return cost > b.cost; }
};
struct H {
	ll x, y;
	bool operator<(const H &b) const{
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const{
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const{ return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const{ return (*this) != b; }
};
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[1000];
H b[1000];
signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	int m = 0;
	for (int i = 0; i < n;) {
		int j = i;
		while (j < n&&a[j] == a[i]) j++;
		b[m++] = H{ a[i],j - i };
		i = j;
	}
	bool l = 1;
	int mi = a[0], ma = a[n - 1];
	if (mi != ceil(ma / 2.0)) l = 0;
	if (n > 2 && ma == 1) l = 0;
	for (int i = 0; i < m; i++) {
		if (i == 0) {
			if (ma % 2 == 0 && b[0].y != 1) l = 0;
			if (ma % 2 == 1 && b[0].y != 2) l = 0;
		}
		else {
			if (b[i].y < 2) l = 0;
			if (b[i - 1].x != b[i].x - 1) l = 0;
		}
	}
	if (l) cout << "Possible\n";
	else cout << "Impossible\n";
}

Measured memory_bytes: 256
//	Totally unrelated and not AT ALL stolen from hohohaha's, generic_placeholder_name's or katoriyuu's template
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
#include <ext/rope>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gcd __gcd
#define rep(i,s,end) for(int i = (s); i <  (end); ++i)
#define rep1(i, end) for(int i =   1; i <= (end); ++i)
#define lb lower_bound
#define ub upper_bound

#define vt vector
#define endl "\n"

#define fileopen(filename, in_type, out_type) if (fopen(filename in_type, "r")) {freopen(filename in_type, "r", stdin);freopen(filename out_type, "w", stdout);}
#define local_input(x) if (x && fopen("input.txt","r")) freopen("input.txt","r",stdin);
#define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)

#define fscan(x)   scanf("%d",  &x)
#define fscandb(x) scanf("%lf", &x)
#define fscanll(x) scanf("%lld",&x)
//	Until next time, remember:
//			You are closer than you think.
//						_Dan Lok_

typedef double db;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define pi 3.1415926535897932	//faster than pi = acos(-1); but sometimes doesn't work?
//	srand(chrono::steady_clock::now().time_since_epoch().count());
//	freopen("input.txt","r",stdin);
#define int unsigned
#define mn 5002
constexpr int mod = 1e9+7;
int n,m; 
int dp[mn][mn];
int add(const int& a, const int& b){
	return (a+b) % mod;
}

int input(){
	string s; cin >> n >> s;
	return s.length();
}

signed main()
{
	fastio;
	m = input(), dp[0][0] = dp[1][0] = 1;
	rep1(i,n) rep(j,0,i+1) if(!dp[i][j]){
		if(j == 0){
			dp[i][j] = add(dp[i-1][1] << 1, dp[i-1][j]);
		}
		else{
			dp[i][j] = add(dp[i-1][j-1], dp[i-1][j+1] << 1);
		}
	}
	cout << dp[n][m];
	return 0;
}
// with the aura of Dora, AC!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Why is there a one in my row of exclamation marks?


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

int main() {
    ll N,s=0,r=1e15,t=0;
    cin >> N;
    vector<int> a(N);

    rep(i,N) {
        cin >> a.at(i);
        s += a.at(i);
    }

    rep(i,N-1) {
        t += a.at(i);
        s -= a.at(i);
        r = min(r, abs(s-t));
    }

    cout << r << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) (x+mo_num)%mo_num
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=1e5+5;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
int nextL[maxn],prevR[maxn];
int32_t main()
{
    IOS
    string k;
    cin>>k;
    int len=k.length();
    fu(i,1,len)a[i]=1;
    int num=0;
    int now=len+1;
    fd(i,len,1)
    {
        nextL[i]=now;
        if(k[i-1]=='L')now=i;
    }
    now=0;
    fu(i,1,len)
    {
        prevR[i]=now;
        if(k[i-1]=='R')now=i;
    }
    fu(i,1,len-1) {
        if (k[i - 1] == 'R') {
            if (nextL[i] == (len + 1)) {
                a[i] = 0, a[len]++;
                continue;
            }
            if ((nextL[i] - i) % 2)a[nextL[i] - 1]++, a[i]--;
            else a[nextL[i]]++, a[i]--;
        } else {
            if (prevR[i] == 0) {
                a[i] = 0, a[1]++;
                continue;
            }
            if ((i - prevR[i]) % 2) {
                a[prevR[i] + 1]++, a[i]--;
            } else a[prevR[i]]++, a[i]--;
        }
    }
    int i=len;
    if (k[i - 1] == 'L') {
        if (prevR[i] == 0) {
            a[1]++, a[i] = 0;
        }else if ((i - prevR[i]) % 2) {
            a[prevR[i] + 1]++, a[i]--;
        } else a[prevR[i]]++, a[i]--;
    }
    fu(i,1,len)cout<<a[i]<<" ";
    return 0;
}

Measured memory_bytes: 3024
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<complex>
using namespace std;

int main() {
    char s[111];
    int ans=0;
    while(scanf("%s",s)!=EOF) {
        int tmp=strlen(s);
        int f=1;
        for (int i=0;i<tmp/2;++i) {
            if (s[i]!=s[tmp-(i+1)]) {
                f=0;
                break;
            }
        }
        if (f) ans++;
    }

    printf("%d\n",ans);
    return 0;
}

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

int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}	
	int Max = a[0];
	int Min = a[0];
	for(int i = 1; i < N; i++){
		Max = max(Max, a[i]);
		Min = min(Min, a[i]);
	}
	cout << Max - Min << endl;
}

Measured memory_bytes: 256
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <map>
#include <deque>
#include <math.h>
#include <cstring>
#include <string.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <list>//
#include <regex> // gcd;
#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(int n)
{
    return (1ll*n*(n+1))/2;
}
string s;

inline ll fact(int n)
{
    ll sum=1;
    for(int i=1; i<=n; ++i)
    {
        sum*=i;
    }
    return sum;
}
ll permtution(string s)
{
    ll tot=1;
    int arr[26]= {};
    for(int i=0; i<s.size(); ++i)
    {
        arr[s[i]-'a']++;
    }
    for(int i=0; i<26; ++i)
    {
        if(arr[i]>1)
            tot*=fact(arr[i]);
    }
    int sz=s.size();
    ll per =fact(sz);
    ll ans=per/tot;
    return ans;
}

bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}
int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);

int n=RD(),pos=RD();
string s=RS();
s[pos-1]=tolower(s[pos-1]);
cout<<s<<"\n";

}
/*
int n=RD(),m=RD(),mn=0,mx=0,arr[m+2],k=0,nc=n,arr1[m+3],l=m;
ll sum=0;
  for(int i=0;i<m;++i){
   cin>>arr[i];

  }
  for(int i=1;i<=m;++i){

   arr1[i]=arr[i-1];
  }
 sort(arr,arr+m);
 sort(arr1+1,arr1+1);
   while(nc>0){
    mn+=arr[k],arr[k]--,nc--;
    if(arr[k]==0)
    k++;
   }

   while(n>0){
    mx+=arr1[l],arr[l]--,n--;

    if(arr[l]<arr[l-1])
     l=l-1;
     if(l==0)
      l=m;
   }
   cout<<mx<<" "<<mn;
   */



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n, x, t;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> x >> t;
	cout << (n+x-1)/x * t << endl;
	
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    vector<int>ver(h + 3, 0), hor(w + 3, 0);
    set<pair<int, int> >st;
    for(int i = 1; i <= m; i++){
        int x, y;
        cin >> x >> y;
        st.insert({x, y});
        ver[x]++;
        hor[y]++;
    }
    int mxhor = 0, mxver = 0;
    for(int i = 1; i <= h; i++){
        if(ver[i] > mxver){
            mxver = ver[i];
        }
    }
    for(int i = 1; i <= w; i++){
        if(hor[i] > mxhor){
            mxhor = hor[i];
        }
    }
    vector<int>horlist, verlist;
    for(int i = 1; i <= h; i++){
        if(ver[i] == mxver){
            verlist.push_back(i);
        }
    }
    for(int i = 1; i <= w; i++){
        if(hor[i] == mxhor){
            horlist.push_back(i);
        }
    }
    int ans = mxver + mxhor - 1;
    int p = verlist.size(), q = horlist.size();
    if(p * q > 2 * m){
        cout << ans;
        return 0;
    }
    for(int i = 0; i < p; i++){
        for(int j = 0; j < q; j++){
            if(st.find({verlist[i], horlist[j]}) == st.end()){
                cout << mxver + mxhor;
                return 0;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 23808
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<functional>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
	int n;
	char k;
	vector< pair<string,int> >m;//stringを出てきた回数順に並べるための連想配列
	vector<string>words;//まずは出てきた単語をすべて格納
	while(cin>>n,n){//13と入力された場合、13がnに入り、次の改行は、getlineに行ってしまう
	cin.ignore();//
	for(int i=0;i<n;i++){
		string now,tmp;
		now.clear();tmp.clear();
		getline(cin,now);
		for(int j=0;j<now.size();j++){
			if(now[j]!=' ')tmp+=now[j];
			else {
				words.push_back(tmp);
				tmp.clear();
			}
			if(j==now.size()-1)words.push_back(tmp);
		}
}
	cin>>k;
	for(int i=0;i<words.size();i++){
		if(words[i][0]==k){
			bool flag=false;
			for(int j=0;j<m.size();j++){
				if(m[j].first==words[i]){
				m[j].second--;
				flag=true;
				}
			}
		if(flag==false)m.push_back(pair<string,int>(words[i],-1));
		}
	}
	//sort(m.begin(),m.end(),greater<pair< string,int> >());
	for(int i=0;i<m.size();i++){
		for(int j=0;j<m.size();j++){
			if(m[i].second<m[j].second)swap(m[i],m[j]);
		}
	}
	//for(int i=0;i<m.size();i++)cout<<m[i].first<<" "<<m[i].second<<endl;
	
	for(int i=0;i<m.size();i++){
		for(int j=0;j<m.size();j++){
			if(m[i].first<m[j].first&&m[i].second==m[j].second)swap(m[i],m[j]);
		}
	}
		int x=5, ms=m.size();
	if(ms==0)cout<<"NA"<<endl;

	else{
		for(int i=0;i<min(ms,x);i++){
			if(i!=min(ms,x)-1)cout<<m[i].first<<" ";
			else 	cout<<m[i].first<<endl;
		}
	}
	m.clear();words.clear();
	}
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,d;
  cin >> n >> d;
  long int x,y,count=0;
  for(int i=0;i<n;i++){
    cin >> x >> y;
    if(sqrt((x*x)+(y*y)) <= d){
      count++;
    }
    x=0;
    y=0;
  }
  cout << count << endl;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#include<string>
using namespace std;
int main()
{
    int n,p;
    cin>>n;
    p=n%10;
    if(p==3)
        cout<<"bon"<<endl;
    else if(p==0 || p==1||p==6||p==8)
        cout<<"pon"<<endl;
    else
        cout<<"hon"<<endl;
    return 0;
}


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

main(){
  int n,s=0;
  cin>>n;
  for(int i=1;;i++){
    s+=i;
    if(s>=n){
      int p=i;
      while(n){
        if(n>=p){
          n-=p;
          cout<<p<<endl;
        }
        p--;
      }
      break;
    }
  }
}

Measured memory_bytes: 256
from collections import deque
H, W = map(int, input().split())
m = [list(input()) for _ in range(H)]
numdot = sum([line.count('.') for line in m])

q = deque([[0, 0, 1]])
m[0][0] = '#'
goal = False
while q:
    i, j, score = q.popleft()
    if i == H-1 and j == W-1:
        goal = True
        break

    for movei, movej in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        ni = i + movei; nj = j + movej
        if ni < 0 or H <= ni or nj < 0 or W <= nj or m[ni][nj] == '#':
            continue
        m[ni][nj] = '#'
        q.append([ni, nj, score+1])

if goal:
    print(numdot - score)
else:
    print(-1)

Measured memory_bytes: 3316
#include <stdio.h>
#include <string.h>

void printArr(int arr[], int n) {
  char space[2] = "";
  for (int i = 0; i < n; i++) {
    printf("%s", space);
    printf("%d", arr[i]);
    strcpy(space, " ");
  }
  printf("\n");
}

int main(void) {
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  printArr(a, n);
  for (int i = 1; i < n; i++) {
    int tmp = a[i];
    int j;
    for (j = i - 1; j >= 0 && a[j] > tmp; j--) {
      a[j + 1] = a[j];
    }
    a[j + 1] = tmp;
    printArr(a, n);
  }
}


Measured memory_bytes: 2080
from collections import deque
n,a,b=int(input()),deque(map(int,input().split())),deque()
for i in range(n):
  if n%2==0:
    if i%2==0:
      b.append(a[i])
    else:
      b.appendleft(a[i])
  else:
    if i%2==0:
      b.appendleft(a[i])
    else:
      b.append(a[i])
print(*b,sep=' ')

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

//#include <iostream>
//#include <vector>

using namespace std;

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

typedef long long ll;

signed main()
{
    int x, n; cin >> x >> n;
    vector<int> p(n); rep(i,n) cin >> p[i];
    if (n == 0) {cout << x << endl; return 0;}
    int i;
    bool ipe, ime;
    for (i = 0; i < 101; ++i){
        int ip = x + i;
        int im = x - i;
        ipe = false;
        ime = false;
        rep(i,n) {if (p[i] == ip) ipe = true; if (p[i] == im) ime = true; }
        if (!ipe) break;
        if (!ime) break; 
    }

    int ans;
    if (!ipe) ans = x + i;
    if (!ime) ans = min(ans, x - i);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <queue>

using namespace std;



int R;
int W1, W2, H1, H2;
int X1, X2, Y1, Y2;
int map1[550][550], map2[550][550];

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

struct Hole {
	int level;
	int x, y;
	
	Hole(int _l, int _x, int _y) : level(_l), x(_x), y(_y) {}
};

bool operator < (const Hole& h1, const Hole& h2) { return h1.level < h2.level; }
bool operator > (const Hole& h1, const Hole& h2) { return h1.level > h2.level; }
bool operator == (const Hole& h1, const Hole& h2) { return h1.level == h2.level; }
bool operator <= (const Hole& h1, const Hole& h2) { return h1.level <= h2.level; }
bool operator >= (const Hole& h1, const Hole& h2) { return h1.level >= h2.level; }

struct Data {
	int need, rooms;
	Data(int _n, int _r) : need(_n), rooms(_r) {}
};

int solver() {
	priority_queue<Hole, vector<Hole>, greater<Hole> > q1, q2;
	q1.push(Hole(1, X1-1, Y1-1)); q2.push(Hole(1, X2-1, Y2-1));
	map1[Y1-1][X1-1] = -1; map2[Y2-1][X2-1] = -1;
	
	vector<Data> v1, v2;
	
	int lev = 0;
	int cnt = 0;
	do {
		Hole h = q1.top(); q1.pop();
		if (h.level <= lev) {
			cnt++;
		} else {
			v1.push_back(Data(lev, cnt));
			lev = h.level;
			cnt++;
		}
		
		for (int d=0; d<4; d++) {
			int x = h.x + dx[d], y = h.y + dy[d];
			if (!(0<=x && x<W1 && 0<=y && y<H1)) continue;
			if (map1[y][x]==-1) continue;
			q1.push(Hole(map1[y][x], x, y));
			map1[y][x] = -1;
		}
		
	} while(!q1.empty());
	v1.push_back(Data(lev, cnt));
	
	lev = 0;
	cnt = 0;
	do {
		Hole h = q2.top(); q2.pop();
		if (h.level <= lev) {
			cnt++;
		} else {
			v2.push_back(Data(lev, cnt));
			lev = h.level;
			cnt++;
		}
		
		for (int d=0; d<4; d++) {
			int x = h.x + dx[d], y = h.y + dy[d];
			if (!(0<=x && x<W2 && 0<=y && y<H2)) continue;
			if (map2[y][x]==-1) continue;
			q2.push(Hole(map2[y][x], x, y));
			map2[y][x] = -1;
		}
		
	} while(!q2.empty());
	v2.push_back(Data(lev, cnt));
	
	int ret = 1e8;
	int i = 0, j = (int)v2.size()-1;
	while (i<(int)v1.size() && j >= 0) {
		Data d1 = v1[i], d2 = v2[j];
		if (d1.rooms + d2.rooms >= R) {
			ret = min(ret, d1.need + d2.need);
			j--;
		} else {
			i++;
		}
	}
	
	return ret;
}

int main() {
	while (1) {
		cin >> R; if (R==0) break;
		cin >> W1 >> H1 >> X1 >> Y1;
		for (int i=0; i<H1; i++) {
			for (int j=0; j<W1; j++) {
				cin >> map1[i][j];
			}
		}
		
		cin >> W2 >> H2 >> X2 >> Y2;
		for (int i=0; i<H2; i++) {
			for (int j=0; j<W2; j++) {
				cin >> map2[i][j];
			}
		}
		
		cout << solver() << endl;
	}
	
	return 0;
}

Measured memory_bytes: 6344
#include <iostream>
#include <assert.h>
#include <algorithm>

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

    int32_t N, M;
    std::cin >> N >> M;
    int32_t gcd = 1;
    for(int32_t k = 1; k <= M/N && k*k <= M; k++){
        //std::cout << gcd <<"," << k << std::endl;
        if(M % k == 0){
            gcd = std::max(gcd, k);
            if(M/k <= M/N){
                gcd = std::max(gcd, M/k);
            }
        }
    }
    std::cout << gcd;

    return 0;

}


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

int main(){
  string S;
  cin >> S;
  /*サイズ*/
  size_t size = S.length();
  int s = (int)size;
  /*条件*/
  bool ans = 1;

  for(int i = 0;i < s/2;i++){
    if(S[i] != S[s - i - 1]){
      ans = 0;
    }
  }
  for(int i = 0;i < (s - 1)/4;i++){
     if(S[i] != S[(s - 1)/2 - i - 1]){
      ans = 0;
    }
  }
  
  for(int i = (s + 3)/2 - 1;i < (s - 3)/4;i++){
     if(S[i] != S[s - i - 1]){
      ans = 0;
    }
  }

  /*答え*/
  if(ans){
    cout << "Yes\n";
  }
  else{
    cout << "No\n";
  }

  return 0;
}


Measured memory_bytes: 256
// Bismillah .Ya Allah...
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
typedef pair<int,int> PII;
const int mod = 1e9+7,INF = 1e9;
const int mx = 1e6+5;
bool flag[mx];
int a[200005];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,coun=0;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];

     sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    {
        if(a[i]==a[i-1])
        flag[a[i]] = true;
    }
    for(int i=1;i<=n;i++)
    {
        if(!flag[a[i]])
            coun++;
        if(a[i]!=a[i-1])
        {
            for(int j= a[i]*2;j<mx;j+= a[i])
                flag[j] = true;
        }
    }
    cout<<coun<<endl;
    return 0;
}


Measured memory_bytes: 5360
/*
dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
*/

#include <fstream>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <climits>
#define N_MAX 100001
using namespace std;

int dp[N_MAX];
int h[N_MAX];
int n;
int k;
int res;
int tmpMin;

void solve()
{
    dp[1] = 0; 
    for(int i = 2;i<=n;i++)
    {
        tmpMin = INT_MAX;
        for(int j = 1;j<=k;j++){
            if(i-j<1){
                break;
            }
            tmpMin = min(tmpMin,dp[i-j]+abs(h[i]-h[i-j]));
        }
        dp[i] = tmpMin;
    }
    //for(int i = 1;i<=n;i++)cout<<dp[i]<<" ";
    //cout<<endl;
    res = dp[n];

}

int main()
{
    cin>>n>>k;
    for(int i = 1;i<=n;i++)cin>>h[i];
    solve();
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    string n;
    int i,j,k=0,sum=0;
    cin>>n;
    for(i=0;;i++)
    {
        if(n[i]=='\0')
        {
            j=i;
            break;
        }
        if(n[i]=='9')
            k++;
    }
    if(k==j)
    {
        for(i=0;i<j;i++)
        {
            sum += (n[i]-48);
        }
    }
    else if(k==j-1&&n[0]!='9')
    {
            for(i=0;i<j;i++)
        {
            sum += (n[i]-48);
        }
    }
    else if(j==1)
    {
        sum=n[0]-48;
    }
    else
    {
        sum += (n[0]-49);
        for(i=0;i<j-1;i++)
        {
            sum += 9;
        }
    }
    printf("%d",sum);
    return 0;
}


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

using namespace std;


int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];

    }

    for(int i = 0; i < n; i++)
    {
        cin >> c[i];

    }

    for(int i = 0; i < n; i++)
    {
        if(v[i] - c[i] > 0)
        {
            ans += v[i] - c[i];
        }
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    int x,i,j,max = 1;
	cin >> x;
	for(i = 2; i <= x/2; i++){
		for(j = 1; pow(i,j) <= x; j++){}
		if(pow(i,j-1) > max)
			max = pow(i,j-1);
	}
	cout << max <<endl;
}


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

int n;
cin >> n;

int count = 0;

if(n<2)cout << 1 << endl;
else if(n<4)cout << 2 << endl;
else if(n<8)cout << 4 << endl;
else if(n<16)cout << 8 << endl;
else if(n<32)cout << 16 << endl;
else if(n<64)cout << 32 << endl;
else cout << 64 << endl;


  return 0;

}

Measured memory_bytes: 256
import math

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

c = 1
while True:
    if math.floor(c*0.08) == a and math.floor(c*0.1) == b:
        print(c)
        break
    
    if c == 100000:
        break
    
    c += 1

if c == 100000:
    print(-1)

Measured memory_bytes: 3060
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	hour := n / 3600
	minit := (n - (hour * 3600)) / 60
	second := (n - ((hour * 3600) + (minit * 60)))

	fmt.Printf("%d:%d:%d\n", hour, minit, second)
}



Measured memory_bytes: 1152
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<numeric>
#include<unistd.h>
#define PI 3.14159265359


using namespace std;
int main()
{

    int W,H;
    while(1){
        cin >> H >> W;

        if(H==0 && W==0) break;
        
        for(int i=0; i<H;i++){
            if(i%2 == 0){
                for(int j=0;j<W;j++){
                    if(j%2 == 0)cout << "#";
                    else cout << ".";
                }
            }
            else{
                for(int j=0;j<W;j++){
                    if(j%2 == 0)cout << ".";
                    else cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;

    }

    return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N + 1);
	for (int i = 1; i <= N; ++i) { cin >> a[i]; }

	vector<int> dl(N + 1, 0), dr(N + 2, 0);
	for (int i = 1; i <= N; ++i) {
		dl[i] = max(dl[i-1], a[i]);
	}
	for (int i = N; i > 0; --i) {
		dr[i] = max(dr[i+1], a[i]);
	}
	for (int i = 1; i <= N; ++i) {
		cout << max(dl[i-1], dr[i+1]) << endl;
	}

	return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n, k;
    constexpr i64 mod = 1000000007;
    std::cin >> n >> k;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    std::vector<i64> dp(k + 1);
    dp[k] = 1;
    for (int i = 0; i < n; i++) {
        auto ss(dp);
        for (int j = 1; j <= k; j++) ss[j] = (ss[j] + ss[j - 1]) % mod;
        for (int j = 0; j <= k; j++) {
            dp[j] = (ss[std::min(k, j + a[i])] + mod - (j ? ss[j - 1] : 0)) % mod;
        }
    }

    std::cout << dp[0] << std::endl;

    return 0;
}

Measured memory_bytes: 1792
val = input()
val = [int(x.strip()) for x in val.split(" ")]
k = int(input())
A = val[0]
B = val[1]
C = val[2]
ans = sum(val)
D = ((A if A > B else B) if (A if A > B else B) > C else C)
ans -= D
ans += D * 2 ** k
print(ans)


Measured memory_bytes: 3060
import java.util.*;

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

        int n = sc.nextInt();

        double[] a = new double[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextDouble();
            a[i] = 1 / a[i];
        }

        double ans = 0;

        for(int i = 0;i < n; i++){
            ans += a[i];
        }

        System.out.println(1 / ans);
        return;
    }
}


Measured memory_bytes: 23248
import java.util.Scanner;

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

		int k = sc.nextInt();
		int N = sc.nextInt();
		int A[] = new int[N];
		
		for(int i=0; i<N; i++) {
			A[i] = sc.nextInt();
		}
		
		int X = 0;
		int Y = A[0]+(k-A[N-1]);
		for(int i=0; i<N-1; i++) {
			X = A[i+1]-A[i];
		if(X>=Y) {
			Y = X;
		}	
		}
		System.out.print(k-Y);
	}
}

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

int main()
{
  int n;
  cin>>n;
  int ans;
  int a;
  a = n/1000;
  if(n%1000 == 0)
    cout<<"0";
  else
  {
  a++;
  a = a*1000;
  ans = a - n;
  cout<<ans;
  }
  return 0;
}


Measured memory_bytes: 3620
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i=(a); i<(int)(b); i++)
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define st first
#define nd second
using namespace std;
 
const int maxN = 1 << 19;

void solve()
{
	int n;
	scanf ("%d", &n);
	printf("%d\n", (n-1) / 2);
}
 
int main()
{
	int t;
	t = 1;//scanf ("%d", &t);
	while (t--)
		solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>

const int maxn=300000;
const int inf=0x3f3f3f3f;

char s[maxn+10];
int n,f[maxn+10],g[maxn+10],ans;

int main()
{
  scanf("%d%s",&n,s+1);
  for(int i=2; i<=n; ++i)
    {
      f[i]=f[i-1]+(s[i-1]=='W');
    }
  for(int i=n-1; i; --i)
    {
      g[i]=g[i+1]+(s[i+1]=='E');
    }
  ans=inf;
  for(int i=1; i<=n; ++i)
    {
      if(f[i]+g[i]<ans)
        {
          ans=f[i]+g[i];
        }
    }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 2816
#include<stdio.h>
int main(){

int i,j,n,m=0;
scanf("%d",&n);
int s[n];

for(i=0;i<n;i++){
    scanf("%d",&s[i]);
}

for(i=1;i<n;i++)
for(j=0;j<n-1;j++){
    if(s[j]>s[j+1]){
        int temp =s[j];
        s[j]=s[j+1];
        s[j+1]=temp;
        m++;
    }
}


for(i=0;i<n;i++)
    if(i==n-1)
printf("%d\n",s[i]);
else printf("%d ",s[i]);


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


}



Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
#define CoutV(vec)        \
    for (auto v : vec)    \
    {                     \
        cout << v << " "; \
    }                     \
    cout << endl;
#define CoutVV(vecvec)      \
    for (auto vec : vecvec) \
        CoutV(vec);

using ll = long long;
using P = pair<int, int>;
#define INF 10000000;

ll MOD = 1e9 + 7;

int main()
{


    int n;
    cin >> n;
    const int MAX = 100000;
    vector<P> E(MAX), O(MAX);

    for (int i = 0; i < n / 2; i++)
    {
        int e, o;
        cin >> e >> o;
        e--;
        o--;
        E[e].first++;
        E[e].second = e + 1;
        O[o].first++;
        O[o].second = o + 1;
    }
    sort(E.rbegin(), E.rend());
    sort(O.rbegin(), O.rend());

    int ans = n;

    ans -= E[0].second != O[0].second ? E[0].first + O[0].first : max(E[0].first + O[1].first, E[1].first + O[0].first);
    Cout(ans);
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
 
const int MAX = 200010;
 
int main(){
    int N;
    int A[MAX];
    map<long long,long long> table;
    int ans = 0;
 
    cin >> N;
    for(int i = 0;i < N;i++){
        cin >> A[i];
        if(table.count(A[i]) == 0)table[A[i]] = 0;
        table[A[i]]++;
    }
    sort(A,A+N);
 
    for(int i = N - 1;i >= 0;i--){
        long long n = 1;
        while(n <= A[i])n <<= 1;
        if(A[i] * 2 == n){
            if(table[A[i]] >= 2){
                ans++;
                table[A[i]] -= 2;
            }
        }else if(table[A[i]] >= 1 && table[n - A[i]] >= 1){
            ans++;
            table[A[i]]--;
            table[n - A[i]]--;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> field(h);
    vector<string> field_1;
    vint index;
    rep(i,h) cin >> field[i];
    rep(i,h) {
        bool ok = false;
        rep(j,w) if (field[i][j] == '#') ok = true;
        if (ok) field_1.push_back(field[i]);
    }
    rep(i,w) {
        bool ok = false;
        rep(j,field_1.size()) if (field_1[j][i] == '#') ok = true;
        if (ok) index.push_back(i);
    }
    rep(i,field_1.size()) {
        rep(j,index.size()) {
            cout << field_1[i][index[j]];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long double Pi=acos(-1.0);

int main()
{
  cout<<fixed<<setprecision(7);
  long double a,b,x;
  cin>>a>>b>>x;
  if(x<=a*a*b*0.5)cout<<90-atan(x*2/a/b/b)/Pi*180;
  else cout<<90-atan(a/(2*b-x*2/a/a))/Pi*180;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD=998244353;
int add(int a,int b){
	return (a+b)%MOD;
}
int sub(int a,int b){
	return (a-b+MOD)%MOD;
}
int mul(int a,int b){
	return (LL)a*b%MOD;
}
int ksm(int a,int b){
	if(b==0){
		return 1;
	}
	else{
		int x=ksm(a,b>>1);
		return mul(mul(x,x),b&1?a:1);
	}
}
int inv(int a){
	return ksm(a,MOD-2);
}
void dadd(int &a,int b){
	a=add(a,b);
}
void dmul(int &a,int b){
	a=mul(a,b);
}
int mul(int a,int b,int c){
	return mul(mul(a,b),c);
}
int gcd(int a,int b){
	return b==0?a:gcd(b,a%b);
}
const int N=400400;
int n,m;
char s[N];
int cnt[N];
int solve(int x){
	// cerr<<"solve "<<x<<endl;
	int g=gcd(n,x);
	int ans=0;
	int cc=1;
	for(int i=g;i>=1;i--){
		if(s[n-i]=='1'){
			// cerr<<i<<" "<<cc<<endl;
			dadd(ans,cc);
		}
		dmul(cc,2);
	}
	int l=-1;
	bool ok=true;
	for(int i=n-1;i>=n-g;i--){
		int t=n/g;
		int j=i;
		while(t--){
			int k=j%n;
			char c=s[i]^(j!=k);
			if(k>l&&c!=s[k]){
				l=k;
				ok=c<s[k];
			}
			j=(j+x)%m;
		}
		assert(j==i);
	}
	if(ok){
		dadd(ans,1);
	}
	return ans;
}
int main(){
	scanf("%d",&n);
	scanf("%s",s);
	reverse(s,s+n);
	m=2*n;
	for(int i=1;i<=m;i++){
		if(m%i==0&&n%i!=0){
			cnt[i]=solve(i);
		}
	}
	for(int i=1;i<=m;i++){
		if(m%i!=0){
			cnt[i]=0;
		}
		// cerr<<i<<" "<<cnt[i]<<endl;
		for(int j=2*i;j<=m;j+=i){
			cnt[j]=sub(cnt[j],cnt[i]);
		}
	}
	int ans=0;
	for(int i=1;i<=m;i++){
		dadd(ans,mul(cnt[i],i));
	}
	printf("%d\n",ans);
	return 0;
}

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

int ctoi(char c) {
	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}


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

    for (int pattern=0; pattern<(1<<3); pattern++) {
        int result = ctoi(S.at(0));
        for (int i = 0; i < 3; i++) {
            if (pattern & (1 << i)) result += ctoi(S.at(i+1));
            else result -=  ctoi(S.at(i+1));
        }
        if (result == 7) {
            cout << S.at(0);
            for (int i = 0; i < 3; i++) {
                if (pattern & (1 << i)) cout << "+";
                else cout << "-";
                cout << S.at(i+1);
            }
            cout << "=7" << endl;
            break;
        }
    }
}

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

using namespace std;

char s1[100010], s2[500010];

int main() {
	
	int l = 300000, r, i, cnt = 0, n, a, b;
	char c;
	
	scanf("%s", s1);
	
	r = l + strlen(s1);
		
	for (i = l; i < r; i++)
		s2[i] = s1[i - 300000];
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a);
		
		if (a == 1)
			cnt = 1 - cnt;
		else
		{
			scanf("%d %c", &b, &c);
			
			if ((b == 1 && cnt == 0) || (b == 2 && cnt == 1))
			{
				s2[--l] = c;
			}
			else
			{
				s2[r++] = c;
			}
		}
	}
	
	if (cnt == 0)
	{
		for (i = l; i < r; i++)
			printf("%c", s2[i]);
	}
	else
	{
		for (i = r - 1; i >= l; i--)
			printf("%c", s2[i]);
	}
	
	return 0;
}

Measured memory_bytes: 896
#include "bits/stdc++.h"
#define ll long long
#define inf 1000000007 //10^9+7
#define sort(vec) sort((vec).begin(),(vec).end());
#define rever(vec) reverse((vec).begin(),(vec).end());
#define unsort(vec) sort((vec)); rever((vec));
using namespace std;

int main() {
  ll n;
  cin>>n;
  if(n==25) {
    cout<<"Christmas"<<endl;
  }
  else if(n==24) {
    cout<<"Christmas Eve"<<endl;
  }
  else if(n==23) {
    cout<<"Christmas Eve Eve"<<endl;
  }
  else{
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <cstring>
#include <ctime>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
const int maxn = 5005;
const int maxm = 205;

ll f[maxn][maxn],c[maxn];
int n,m;
int a[maxn],b[maxn][maxm];

struct P{
  int l,r,val;
  P(){}
  P(int l,int r,int val):l(l),r(r),val(val){}
};

deque<P> d[maxm];

int main() {
 // freopen("in.cpp","r",stdin);
  while(cin>>n>>m) {
    for(int i=1;i<n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)
      for(int j=1;j<=m;j++)
        cin>>b[i][j];
    memset(f,0,sizeof(f));
    memset(c,0,sizeof(c));
    for(int i=1;i<=m;i++){
      while(!d[i].empty())d[i].pop_back();
    }
    for(int i=n;i>=1;i--){
      for(int j=1;j<=m;j++){
        int l=i,r=i;
        while(!d[j].empty()){
          if(d[j].back().val<=b[i][j]){
            r=d[j].back().r;
            c[d[j].back().l]-=d[j].back().val;
            c[d[j].back().r+1]+=d[j].back().val;
            d[j].pop_back();
          } else break;
        }
        d[j].push_back(P(l,r,b[i][j]));
        c[l]+=b[i][j];
        c[r+1]-=b[i][j];
      }
      ll sum=0;
      for(int j=i;j<=n;j++){
        sum+=c[j];
        f[i][j] = sum;
      }
    }
    ll ret = -1000000000LL * 205;
    for(int i=1;i<=n;i++){
      ll sum=0;
      for(int j=i;j<=n;j++){
        if(j>i)sum+=a[j-1];
        ret=max(ret,f[i][j]-sum);
      }
    }
    cout<<ret<<endl;
  }
  return 0;
}


Measured memory_bytes: 200320
#include "bits/stdc++.h"
using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;


int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++)cin >> a[i] >> b[i];
	int res = 0;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for (int i = 0; i <= n; i++) {
		int u=a.end()-upper_bound(a.begin(), a.end(), i+1);
		auto it = lower_bound(b.begin(), b.end(), i+1);
		int l = it - b.begin();
		if (n - l - u>=i)
			res = max(i, res);
	}
	cout << res << endl;
	return 0;
}

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

int d[100];

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> d[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans+=d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int H, N;
  cin >> H >> N;
  int sum = 0;
  int a;
  for  (int i = 0; i < N; i++) {
    cin >> a;
    sum += a ;
  }
  if(H <= sum){cout <<"Yes";}
  else{cout << "No";}
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"os"
)

type IOTp struct {
	iBuffer []byte
	iPos int
}
func (this *IOTp) GetChar() byte {
	res:=this.iBuffer[this.iPos]
	this.iPos++
	return res
}
func (this *IOTp) ReadInt() int {
	res:=0
	k:=1
	for ch:=this.iBuffer[this.iPos]; !(ch>='0' && ch<='9'); ch=this.iBuffer[this.iPos]{
		if ch=='-' {
			k=-1
		}
		this.iPos++
	}
	for ch:=this.iBuffer[this.iPos]; ch>='0' && ch<='9'; ch=this.iBuffer[this.iPos]{
		res=res*10+int(ch-'0')
		this.iPos++
	}
	res*=k
	return res
}
func NewIOTp() *IOTp {
	now:=new(IOTp)
	//inputFile,_:=os.Open("in.txt")
	inputFile:=os.Stdin
	now.iBuffer,_=ioutil.ReadAll(inputFile)
	now.iBuffer=append(now.iBuffer, '\n')
	now.iPos=0
	return now
}
var cin *bufio.Reader
var cout *bufio.Writer
func main() {
	IO:=NewIOTp()
	cout=bufio.NewWriter(os.Stdout)
	n,a,b,c,d:=IO.ReadInt(),IO.ReadInt(),IO.ReadInt(),IO.ReadInt(),IO.ReadInt()
	for i:=0; i<n; i++ {
		if a+i*d-(n-i-1)*c>=b && a+i*c-(n-i-1)*d<=b {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
	cout.Flush()
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL a,b;
    cin >> a >> b;

    if((a*b)%2 == 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

long long h, w, d[SM][SM], x[2], y[2];
char board[SM][SM];

bool legal(long long x, long long y){
    return board[x][y] == '.' && x >= 1 && h >= x && y >= 1 && w >= 1;
}

int main(){
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> h >> w >> x[0] >> y[0] >> x[1] >> y[1];

    for(long long i = 1; i <= h; i++){
        for(long long j = 1; j <= w; j++){
            cin >> board[i][j];
            d[i][j] = INF;
        }
    }

    deque<pair<long long, long long>> q;
    q.push_front({x[0], y[0]});
    d[x[0]][y[0]] = 0;

    while(!q.empty()){
        long long vx = q.front().first, vy = q.front().second;
        q.pop_front();

        for(long long i = 0; i < 4; i++){
            long long nx = vx + dx[i], ny = vy + dy[i];
            if(legal(nx, ny) && d[nx][ny] > d[vx][vy]){
                d[nx][ny] = d[vx][vy];
                q.push_front({nx, ny});
            }
        }

        for(long long i = vx - 2; i <= vx + 2; i++){
            for(long long j = vy - 2; j <= vy + 2; j++){
                if(legal(i, j) && d[i][j] > d[vx][vy] + 1){
                    d[i][j] = d[vx][vy] + 1;
                    q.push_back({i, j});
                }
            }
        }
    }

    if(d[x[1]][y[1]] >= INF) cout << "-1";
    else cout << d[x[1]][y[1]];

    return 0;
}


Measured memory_bytes: 12608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) (v).begin(),(v).end()
#define debug(x) cout << #x << '=' << x << '\n'
const long long MOD=1e9+7;
//const long long MOD=998244353;
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};
const double pi=acos(-1);

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?'\n':' ');
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    cout << '(' << p.first << ',' << p.second << ')';
    return os;
}

template<class T> inline bool chmin(T &a,T b){
    if (a>b){a=b; return true;} return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){a=b; return true;} return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double R; cin >> R;
    cout << 2*R*pi << '\n';
}

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


using namespace std;
#define out(s) cout<<(s)<<endl;
using ll = long long;
int main()
{
	int N;
	ll ans;
	ll T_sum=1, A_sum=1;
	cin >> N;
	for (size_t i = 0; i < N; i++)
	{
		int Ti, Ai;
		cin >> Ti >> Ai;
		ll k;
		k = max((T_sum-1) / Ti+1, (A_sum-1) / Ai+1);
		T_sum = Ti*k;
		A_sum = Ai*k;
	}
	ans = T_sum + A_sum;
	out(ans);
	return 0;
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

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

    int r0,w0,c,r;
    while(cin>>r0>>w0>>c>>r,r0|w0|c|r)
    {
        cout<<max(0,(c*w0-r0+r-1)/r)<<endl;
    }
}

Measured memory_bytes: 3128