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

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        final boolean poor = (a == b && a != c) ||
                (a == c && a != b) || (b == c && b != a);
        if (poor) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


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

#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string

#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mp make_pair

#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>

#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >

#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>


#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)

const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);

ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}

ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}

int bfs(int s,vector<int> v[],int r,int c)
{
    int vis[r*c+1];
    queue<int> q;
    for(int i=1;i<=(r*c);i++)
     vis[i]=-1;
    q.push(s);
    vis[s]=0;
    while(!q.empty())
    {
        int r=q.front();
        q.pop();
        for(int i=0;i<v[r].size();i++)
        {
            int ch=v[r][i];
            if(vis[ch]==-1)
            {
                vis[ch]=vis[r]+1;
                q.push(ch);
            }
        }
    }
    int max=0;
    for(int i=1;i<=r*c;i++)
    {
        if(vis[i]>max)
         max=vis[i];
    }
    return max;
}
int main()
{
    int r,c;
    cin>>r>>c;
    char arr[r+1][c+1];
    for(int i=1;i<=r;i++)
     for(int j=1;j<=c;j++)
      cin>>arr[i][j];
     int maxn=0;
     vector<int> v[r*c+1];
     int f=0;
     for(int i=1;i<=r;i++)
     {
         for(int j=1;j<=c;j++)
         {
             if(arr[i][j]!='#')
             {
             int key=c*(i-1)+j;
             if(i!=1)
             {
                 if(arr[i-1][j]!='#')
                 {
                     int k1=c*(i-2)+j;
                     v[key].pb(k1);
                 }
             }
              if(i!=r)
             {
                 if(arr[i+1][j]!='#')
                 {
                     int k1=c*(i)+j;
                     v[key].pb(k1);
                 }
             }
              if(j!=1)
             {
                 if(arr[i][j-1]!='#')
                 {
                     int k1=c*(i-1)+j-1;
                     v[key].pb(k1);
                 }
             }
              if(j!=c)
             {
                 if(arr[i][j+1]!='#')
                 {
                     int k1=c*(i-1)+j+1;
                     v[key].pb(k1);
                 }
             }
             }
         }
     }
     for(int i=1;i<=(r*c);i++)
     {
         int tmp=bfs(i,v,r,c);
         if(tmp>maxn)
          maxn=tmp;
     }
     cout<<maxn<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<ll,ll>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvll            vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define wh(x)           int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
#define deb(x)          cout <<#x << " is "<<x<<endl;
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}
int x,n;
vi A;
int help(){
	unordered_set<int> s;
	rep(i,n) s.insert(A[i]);
	int l,r;
	for(int i=x;i>x-300;i--){
		if(s.count(i)) continue;
		l=i;
		break;
	}
	for(int i=x+1;i<x+300;i++){
		if(s.count(i)) continue;
		r=i;
		break;
	}
	if(abs(x-l)==abs(x-r)) return l;
	if(abs(x-l)>abs(x-r)) return r;
	return l;
}
int main(){
	fio
  i_o();
  cin>>x>>n;
  A=vi(n);
  rep(i,n) cin>>A[i];
  d1(help());

  return 0;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
namespace my_std {
using namespace std;
#define reg register
#define Rint register int
#define FOR(i, a, b) for (register int i = (a), ed_##i = (b); i <= ed_##i; ++i)
#define ROF(i, a, b) for (register int i = (a), ed_##i = (b); i >= ed_##i; --i)
typedef long long i64;
#define Templ(T) template <typename T>
Templ(_Tp) inline int chkmin(_Tp &x, _Tp y) { return x > y ? x = y, 1 : 0; }
Templ(_Tp) inline int chkmax(_Tp &x, _Tp y) { return x < y ? x = y, 1 : 0; }
const int mod = 998244353;
inline void inc(int &x, const int &y) { x += y; if (x >= mod) x -= mod; }
inline void dec(int &x, const int &y) { x -= y; if (x < 0) x += mod; }
} // namespace my_std
using namespace my_std;

#define N 350
char s[N];
int n;
int dp[N][N][N];
bool tr[N][N][N];
//[i][c0][c1]: 剩下 i 个字符没有匹配，多了 c0 个 0 和 c1 个 1

int main() {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    tr[0][0][0] = 1;
    FOR(i, 1, n){
        ROF(c0, n, 0) ROF(c1, n, 0){
            if(i == n && !c0 && !c1) continue;
            tr[i][c0][c1] |= tr[i - 1][c0][c1];
            if(s[i] == 48) tr[i][c0][c1] |= tr[i][c0][c1 + 1];
            if(s[i] == 49) tr[i][c0][c1] |= tr[i][c0 + 1][c1];
            //删掉两个把第二个加回原来位置
            //加回去的可能还是多出来的字符
        }
        if(i > 1) FOR(c0, 0, n) FOR(c1, 0, n){
            if((s[i - 1] == 48 || s[i] == 48) && c0){
                tr[i][c0][c1] |= tr[i - 2][c0 - 1][c1];
                //前面两个都不是多余的，把'0'扔到多余的位置
            }
            if(s[i - 1] == 48 && s[i] == 48 && c0){
                tr[i][c0][c1] |= tr[i - 1][c0 - 1][c1 + 1];
                //前面是"10"（'1'是多余的），并把'0'扔到多余的位置
            }
            if((s[i - 1] == 49 || s[i] == 49) && c1){
                tr[i][c0][c1] |= tr[i - 2][c0][c1 - 1];
                //前面两个都不是多余的，把'1'扔到多余的位置
            }
            if(s[i - 1] == 49 && s[i] == 49 && c1){
                tr[i][c0][c1] |= tr[i - 1][c0 + 1][c1 - 1];
                //前面是"01"（'0'是多余的），并把'1'扔到多余的位置
            }
        }
    }
    dp[n][0][0] = 1;
    ROF(i, n, 1){
        FOR(c0, 0, n) FOR(c1, 0, n){
            Rint t(dp[i][c0][c1]);
            inc(dp[i - 1][c0][c1], t);
            if(s[i] == 48) inc(dp[i][c0][c1 + 1], t);
            if(s[i] == 49) inc(dp[i][c0 + 1][c1], t);
        }
    }
    Rint ans(0);
    FOR(i, 0, n){
        FOR(c0, 0, i) FOR(c1, 0, i){
            if(tr[i][c0][c1]) inc(ans, dp[i][c0][c1]);
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    for (int i = 0;;i++){
        if (s.front() != 'A'){
            s.erase(0,1);
        }
        if (s.back() != 'Z'){
            s.pop_back();
        }
        if (s.front() == 'A' && s.back() == 'Z'){
            break;
        }
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <map>

#define all(x) (x).begin(), (x).end()
#define mkp make_pair
#define fr first
#define sc second
using namespace std;

int N;

void solve();

int main() {
	while (cin >> N, N)
		solve();
	
	return 0;
}

void solve() {
	istringstream iss;
	string sdt, stm, stp, sid;
	int hr, mn, tm, id;
	map< int, int > tx, sum;
	
	for (int i = 0; i < N; ++i) {
		cin >> sdt >> stm >> stp >> sid;
		
		stm[2] = ' ', iss.clear(), iss.str(stm);
		iss >> hr >> mn, tm = 60 * hr + mn;
		iss.clear(), iss.str(sid);
		iss >> id;
		
		if (stp == "I")
			tx[id] = tm;
		else {
			if (id == 0) {
				for (auto itr = tx.begin(); itr != tx.end(); ++itr)
					if (itr->fr != 0 && itr->sc != 0)
						sum[itr->fr] += tm - max(tx[0], itr->sc);
			}
			else {
				if (tx[0] != 0)
					sum[id] += tm - max(tx[0], tx[id]);
			}
			
			tx[id] = 0;
		}
	}
	
	int res = 0;
	for (auto itr = sum.begin(); itr != sum.end(); ++itr)
		res = max(res, itr->sc);
	cout << res << "\n";
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
int n, a[maxn], pos[maxn];
long long k;
bool vis[maxn];
int main() {
	cin>>n>>k;
	k++;
	for(int i = 0; i < n; i++) {
		cin>>a[i];
		--a[i];
	}
	vis[0] = true;
	pos[0] = 0;
	vector<int> v;
	v.push_back(0);
	int xx;
	while(1) {
		int now = v.back();
		int to = a[now];
		if(!vis[to]) {
			vis[to] = true;
			pos[to] = pos[now] + 1;
			v.push_back(to);
		}else {
			xx = pos[to];
			break;
		}
	}
	if((long long)v.size() >= k) {
		cout<<v[k - 1] + 1<<endl;
		return 0;
	}
	k -= (long long)v.size();
	int len = v.size() - xx;
	k %= (long long)len;
	if(k == 0ll) {
		cout<<v.back() + 1<<endl;
	}else {
		cout<<v[xx + k - 1] + 1<<endl;
	}
	return 0;
}

Measured memory_bytes: 6016
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;


int INF = 2e9;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, m;
    cin >> n >> m;
    vector<int> dp(n+1, -INF); // dp[i] : ちょうどi本のマッチ棒を使うときの最大桁数
    
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    
    vector<int> table2num ={-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    
    for (int i = 1; i < n+1; ++i)
    {
        rep(j, m)
        {
            int idx = i - table2num[a[j]];
            if (idx < 0) continue;
            else
            {
                if (idx == 0)
                {
                    dp[i] = max(dp[i], 1);
                }
                else
                {
                    dp[i] = max(dp[i], dp[idx] + 1);
                }
            }
            
        }
    }
    
    dp[0] = 0;
    
    
    
    sort(a.begin(), a.end(), std::greater<int>());
    int match_idx = n;
    for (int i = dp[n]; i>0; --i)
    {
        for (int j : a)
        {
            if (match_idx - table2num[j] < 0) continue;
            if (dp[match_idx - table2num[j]] == dp[match_idx] - 1)
            {
                match_idx -= table2num[j];
                cout << j;
                break;
            }
        }
    }
    
    cout << endl;
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	string s;
	cin >> s;
	ll sum = 0;
	rep(i, 0, sz(s))sum += (s[i] - '0');
	if (sum % 9 == 0)cout << "Yes"; else cout << "No";
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



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

using namespace std;


const int Mod = 1e9 + 7, Nmax = 1e5;

typedef long long ll;


int n, A, B, C;
int fact[Nmax], ifact[Nmax];


void add_to(int &x, int y)
{
    x += y; if(x>=Mod) x-=Mod;
}
int inm(int x, int y)
{
    return (ll) x*y%Mod;
}
int inm(int x, int y, int z)
{
    return (ll) x*y%Mod*z%Mod;
}

int comb(int n, int k)
{
    if(!k) return 1;
    return inm( fact[n], ifact[n-k], ifact[k] );
}

int permuta(int x, int y, int z, int t)
{
    return inm( inm(fact[x+y+z+t], ifact[x]), inm(ifact[y], ifact[z], ifact[t] ));
}

int power(int a, int b)
{
    int ans = 1;
    while(b)
    {
        if(b&1) ans = inm(ans, a);
        a = inm(a, a); b >>= 1;
    }
    return ans;
}

void prec(int lim)
{
    int i;
    fact[0] = ifact[0] = 1;

    for(i=1; i<=lim; ++i) fact[i] = inm(fact[i-1], i);

    ifact[lim] = power(fact[lim], Mod - 2);
    for(i=lim-1; i; --i) ifact[i] = inm(ifact[i+1], i+1);
}


int main()
{
 //   freopen("input", "r", stdin);
    cin.sync_with_stdio(false); cin.tie(0);

    cin >> n >> A >> B >> C;

    prec(5*n);

    if(B&1)
    {
        cout << 0 << '\n';
        return 0;
    }

    int x, y, z, t;

    y = B / 2;

    int ans = 0;

    for(x=0; x<=A; ++x)
        for(z=0; 3*z<=C; ++z)
        {
            t = A - x;

            int rest = C - 3*z - t;
            if(rest < 0) continue;

            int ways = comb(y + rest - 1, rest);
            int perm = permuta(x, y, z, t);

            add_to(ans, inm(ways, perm));
        }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 512
/*
Sharif Hasan - CSE, PUST
Apr 24, 2020 02: 14 PM
*/
#include<bits/stdc++.h>
#define br cout<<"\n"
#define what(x) cout<<"in here var= "<<x<<"\n";

/*STL definations*/
#define pb push_back

#define FOR(i,n) for(long long i=0;i<n;i++)
#define FROM(a,i,n) for(long long i=a;i<n;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;
/*Main function*/
int main()
{
    long long x;
    cin>>x;
    long long k=pow(x,1/5.0)+1000;
   // cout<<k<<endl;
    for(long long i=-k-2;i<=k+2;i++){
       // cout<<i;br;
        long long k=-(x-pow(i,5));
        long long tmp=k;

        k=pow(abs(k),1/5.0);
        
        k=k*(tmp/abs(tmp));
        
        if(pow(i,5)-pow(k,5)==x){
            cout<<i<<" "<<k;br;
            break;
        }
    }
    
    
}


Measured memory_bytes: 4096
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace jugyo1024
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine();
            var str = Console.ReadLine();

            char c = '\0';
            int cnt = 0;
            for (int i = 0; i < str.Length; i++)
            {
                if (c != str[i])
                {
                    c = str[i];
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 11232
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e14;
const int ZERO = 0;
const double PI = 3.14159265359;

signed main() {
  double a,b,c,e,f,g;
  cin>>a>>b>>c;
  if(a*a*b/2<c){
    double d=(a*a*b-c);
    d/=(a*a/2);
    e=atan(d/a);
    f=(180.0/PI);
    g=e*f;
    cout << fixed;
    cout << setprecision(10) << g << endl;
  }
  else{
    double d=c/(a*b/2);
    e=atan(d/b);
    f=(180.0/PI);
    g=90-e*f;
    cout << fixed;
    cout << setprecision(10) << g << endl;
  }
}

Measured memory_bytes: 256
import java.lang.Math

fun main(args: Array<String>) {
  val n = readLine()
  val s = readLine()!!
  var b = 0
  var w = s.count { c -> c == '.' }
  var ans = b + w
  for(c in s) {
    when(c) {
      '#' -> b++
      '.' -> w--
    }
    ans = Math.min(ans, b + w)
  }
  println(ans)
}

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

using namespace std;

int N;
int in[100];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++)cin >> in[i];
	int cost = 1145141919, tmp = 0;
	for (int i = -100; i <= 100; i++) {
		for (int j = 0; j < N; j++) {
			tmp += (in[j] - i) * (in[j] - i);
		}
		cost = min(cost, tmp);
		tmp = 0;
	}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll x;
    cin >> x;
    if (x >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}

Measured memory_bytes: 3616
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>

const int MaxN = 1e5;
const double E = 2.718281828459;
typedef long long LL;
using namespace std;

int main(){
	string n;
	cin >> n;
	int a=0;
	for(int i=0;i<n.size();i++){
		a+=(n[i]-'0');
	}
	int m=((int)n[0]-(int)'0'-1)+((n.size()-1)*9);
	cout << max(a,m);
}

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> B, C;
    int b;
    ll c;
    rep(i, M) {
        cin >> b >> c;
        B.push_back(b);
        C.push_back(c);
    }

    sort(A.begin(), A.end());
    
    vector<int> id(M);
    iota(id.begin(), id.end(), 0); // 0 start index
    sort(id.begin(), id.end(), [&](int i, int j) {
        return C[i] > C[j];});

    ll ans = 0;
    ll K = 0;
    for (auto i : id) {
        for (int j = 0; j < B[i]; j++) {
            if (K >= N) break;
            ans += max(A[K], C[i]);
            K++;
        }
    }
    for (int i = K; i < N; i++) {
        ans += A[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;
int w,h;
vector<vector<int>> field;
vector<vector<bool>> seen;

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

void dfs(pair<int,int> v)
{
  seen[v.first][v.second]=true;
  for (int i = 0; i < 8; ++i)
  {
    int nx=v.first+dx[i];
    int ny=v.second+dy[i];
    if(nx<0||nx>=h||ny<0||ny>=w) continue;
    if(field[nx][ny]==0) continue;
    if(seen[nx][ny]) continue;
    dfs({nx,ny});
  }
}

int main()
{while(true){
  
  cin>>w>>h;
  if(w==0&&h==0) break;
  field.resize(h);
  for (int i = 0; i < h; ++i)
  {
    field[i].resize(w);
    for (int j = 0; j < w; ++j)
    {
      cin>>field[i][j];
    }
  }
  seen=vector<vector<bool>>(h,vector<bool>(w,false));

  int cnt=0;
  for (int i = 0; i < h; ++i)
  {
    for (int j = 0; j < w; ++j)
    {
      if(seen[i][j]) continue;
      if(field[i][j]==0) continue;
      dfs({i,j});
      cnt++;
    }
  }
  cout<<cnt<<endl;
}}


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

int main(){
    int N;
    cin >> N;
    vector<long long int> H(N);
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    
    bool flag = true;
    bool flag_up = true;
    /*
    for(int i=0; i<N-2; i++){
        // 減少2回
        if(H[i+2] < H[i+1] && H[i+1] < H[i]){
            flag = false;
            break;
        }
    }
    */

    for(int i=0; i<N-1; i++){
        // 大幅減少
        // 減少2回
        if(H[i+1] < H[i]-1){
            flag = false;
            break;
        }

        if(H[i+1] < H[i]){
            if(!flag_up){
                flag = false;
                break;
            }
            flag_up = false;
        }else if(H[i+1] > H[i]){
            flag_up = true;
        }
    }

    if(flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<unordered_map>
#define ll long long
#define M 1000000007

#define pb push_back
#define fs first
#define se second
using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //  #ifndef ONLINE_JUDGE
    //     freopen("mengawasi_sample_1.in", "r", stdin);
    //     freopen("mengawasi_sample_1.out", "w", stdout);
    // #endif
    ll k,p;
    cin>>k>>p;
    ll l=max((ll)(-1000000),p-k+1);
    ll u=min((ll)(1000000),p+k-1);
    for(ll i=l;i<=u;i++)
        cout<<i<<" ";
    cout<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, n);
  Cins(int, n, a1);
  Cins(int, n, a2);

  int ans = 0;
  rep(i, n) {
    int tmp = 0;
    for (int j = 0; j <= i; ++j) tmp += a1[j];
    for (int j = i; j < n; ++j) tmp += a2[j];
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//q1.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000


int main(){
    
  int a,b,c,d,e;
  int ans = 0;
  
  cin >> a >> b >> c >> d >> e;

  ans += min(a,0) * -1 * c;
  a = max(a,0);
  
  if(a == 0) ans += d;

  ans += (b-a) * e;
    
  cout << ans << endl;
  
  return 0;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  
  int h = H;
  int w = W;
  
  vector<vector<char>> data(H, vector<char>(W));  

  for(int i=0; i<H;i++){
    for(int j=0;j<W;j++){
      char tmp;
      cin >> tmp;
      data.at(i).at(j) = tmp;
    }
  }

  
  vector<bool> row(h,false);
  vector<bool> col(w, false);
  for(int i=0; i<H;i++){
    for(int j=0;j<W;j++){
      if (data.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  for(int i=0; i<H;i++){
    if (row.at(i) == false) continue;
    for(int j=0;j<W;j++){
      if (col.at(j) == false) continue;
      
      cout << data.at(i).at(j);
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += j
    
    return table

n=int(input())
print(sum(num_divisors_table(n)))

Measured memory_bytes: 145912
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
/*
time:
wa:
反省:
考察:
*/
int main() {
    int n; cin >> n;
    vector<long long> L(n+1);
    L[0] = 2;
    L[1] = 1; 
    for(int i = 2; i < n+1; i++){
        L[i] = L[i-1] + L[i-2];
    }
    cout << L[n] << endl;
    return 0;
}

Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	List<int> G => Strs.Select(int.Parse).ToList();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve() => WriteLine(Calc(G, G, G));
	long Calc(List<int> I, List<int> A, List<int> B)
	{
		int N = I[0], M = I[1];
		A.Sort(); B.Sort();
		for (var i = 1; i < N; i++) if (A[i] == A[i - 1]) return 0;
		for (var j = 1; j < M; j++) if (B[j] == B[j - 1]) return 0;
		A.Add(N * M + 1);
		B.Add(N * M + 1);
		int p = N, q = M;
		var ans = 1L;
		for (var i = N * M; i >= 1; i--)
		{
			if (p > 0 && A[p - 1] == i) p--;
			if (q > 0 && B[q - 1] == i) q--;
			if (A[p] == i && B[q] == i) continue;
			if (A[p] == i) ans = ans * (M - q) % MOD;
			else if (B[q] == i) ans = ans * (N - p) % MOD;
			else ans = ans * ((N - p) * (M - q) - (N * M - i)) % MOD;
			if (ans == 0) return 0;
		}
		return ans;
	}
}


Measured memory_bytes: 13388
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t,u;
  int a,b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if( s == u){
    cout << a - 1 << endl;
    cout << b << endl;}
  else{cout << a << endl;
       cout << b - 1 << endl;}
  return 0;
}

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

int main(){
    int p,r,t;
    char c;
    int n;
    cin >> n;
    string ss;
    vector<char> s;
    cin >> ss;
    for (int i = 0; i < n;i++){
        s.push_back(ss[i]);
    }
        int q;
    cin >> q;
    string alphabet;
    alphabet = "abcdefghijklmnopqrstuvwxyz";
    vector<set<int>> set_vector(26);
    for (int i = 0; i < n;i++){
        for (int j = 0; j < 26; j++){
            {
                if(s[i] == alphabet[j]){
                    set_vector[j].insert(i);
                }
            }
        }
    }
    for (int i = 0; i < q; i++)
    {
        cin >> p >> r;
        if(p==1){
            cin >> c;
            for (int j = 0; j < 26;j++){
                if(s[r-1]==alphabet[j]){
                    set_vector[j].erase(r - 1);
                }
                if(c==alphabet[j]){
                    set_vector[j].insert(r - 1);
                }
            }   
            s[r-1] = c;
        }
        else{
            cin >> t;
            int cnt = 0;
            for (int j = 0; j < 26;j++){
                auto itr = set_vector[j].lower_bound(r-1);
                if(itr != set_vector[j].end()){
                    if((*itr) <= t-1){
                        cnt += 1;
                    }
                }
            }
            cout << cnt << endl;
        }
    }
}

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


int main() {
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	
	printf("%d %d %d",C,A,B);
	
	return 0;
}

Measured memory_bytes: 128
n = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(n-1):
    if i+1 == P[i]:
        P[i], P[i+1] = P[i+1], P[i]
        ans+=1
if P[n-1]==n:
    ans += 1
print(ans)


Measured memory_bytes: 14008
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()

using namespace std;

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

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	string S; cin >> S;
	ll sum = 0;
	for (int i = 0;i < S.size();i++) {
		sum += S[i] - '0';
	}
	if (stoi(S)%sum  == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
S = input()

if S == S[::-1]:
    rhalf = S[0:int((len(S)-1)/2)]
    if rhalf == rhalf[::-1]:
        lhalf = S[int((len(S)+3)/2)-1:]
        if lhalf == lhalf[::-1]:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n;cin>>n;
    string s[3];rep(i,0,2)cin>>s[i];
    ll ans=0;
    rep(i,0,n-1){
        if(s[0][i]==s[1][i] && s[2][i]==s[1][i]){
            continue;
        }else if(s[0][i]==s[1][i]){
            ans++;
        }else if(s[2][i]==s[1][i]){
            ans++;
        }else if(s[2][i]==s[0][i]){
            ans++;
        }else{
            ans+=2;
        }
            
    }
    cout<<ans<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

int main(){
  int X, N;
  scanf("%d", &X);
  scanf("%d", &N);
  std::vector<int > p(N);
  std::vector<bool> used(N+4, false);
  for (int i=0; i<N; i++){
    scanf("%d", &p[i]);
    used[p[i]]=true;
  }
  int mindiff=1000000;
  int opt=-1;
  for (int i=0; i<105; i++){
    if (used[i]) continue;
    if (mindiff>abs(X-i)){
      mindiff=abs(X-i);
      opt=i;
    }
  }
  std::cout << opt << std::endl; 
  return 0;
}


Measured memory_bytes: 3288
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;


#define REP(i, n) for(ll i = 0; i < n; i++)


























int main(){
    ll x;
    cin >> x;
    cout << ((x >= 30)? "Yes" : "No") << endl;
}

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

int main() {
  int N;
  string S;
  cin>>N;
  vector<int> m(4);
  for(int i=0;i<N;i++){
   cin>>S;
   if(S=="AC"){
    m.at(0)+=1;
   }
    if(S=="WA"){
     m.at(1)+=1;
   }
   if(S=="TLE"){
     m.at(2)+=1;
   }
   if(S=="RE"){
     m.at(3)+=1;
   }  
  }
  cout<<"AC x "<<m.at(0)<<endl;
  cout<<"WA x "<<m.at(1)<<endl;
  cout<<"TLE x "<<m.at(2)<<endl;
  cout<<"RE x "<<m.at(3)<<endl;
}

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

using namespace std;

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

using Weight = int;
using Flow = int;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;

void addArc(Graph &g, int s, int d, Weight w = 1)
{
    g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1)
{
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

int yui;

int dfs(Graph &g, vector<int> &data, vector<int> &visited,int pos,int bef)
{
    visited[pos] = 1;
    for (auto i : g[pos]) {
        if (i.d != bef) {
            if (visited[i.d]) {
                yui = i.d;
                data[i.d] = 1;
                data[pos] = 1;
                return 1;
            } else {
                int status = dfs(g, data, visited, i.d, pos);
                if (status) {
                    if (pos == yui) {
                        status = 2;
                    }
                    if (status == 1) {
                        data[pos] = 1;
                    }
                    return status;
                }
            }
        }
    }
    return 0;
}
    
void FunamiYui(Graph &g, vector<int> &data)
{
    vector<int> visited(g.size(), 0);
    dfs(g, data, visited, 0ll, -1ll);
}

signed main(void)
{
    int n; cin >> n;
    Graph g(n);
    rep(i, n) {
        int a, b; cin >> a >> b;
        a--; b--;
        addEdge(g, a, b);
    }

    vector<int> cycle(n, 0);
    FunamiYui(g, cycle);

    int qu; cin >> qu;
    while (qu--) {
        int a, b; cin >> a >> b;
        a--; b--;
        if (cycle[a] && cycle[b]) cout << 2 << endl;
        else cout << 1 << endl;
    }


    return 0;
}




Measured memory_bytes: 22360
c=[]
for i in range(3):
	c.append(list(map(int,input().split())))
if c[1][0]-c[0][0]==c[1][1]-c[0][1]==c[1][2]-c[0][2] and c[2][0]-c[1][0]==c[2][1]-c[1][1]==c[2][2]-c[1][2]:
	print('Yes')
else: print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main() {
    std::vector<int> hills;
    for (int i = 0; i < 10; i++) {
        std::string input;
        std::cin >> input;
        int height = std::stoi(input);
        hills.push_back(height);
    }

    std::sort(hills.begin(), hills.end(), std::greater<int>());
    for (int i = 0; i < 3; i++) {
        std::cout << hills[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3180
#include <stdio.h>

int main()
{
	int N, Q;
	char S[500001];
	scanf("%d", &N);
	scanf("%s", S);
	scanf("%d", &Q);
	
	int i, j, count[501][26] = {};
	for (i = 0; i < N / 1000; i++) {
		for (j = 0; j < 1000; j++) count[i][S[i*1000+j] - 'a']++;
	}
	for (j = 0; j < N % 1000; j++) count[i][S[i*1000+j] - 'a']++;

	int l, r, q, type, flag[26], ans;
	char c;
	for (q = 0; q < Q; q++) {
		scanf("%d", &type);
		if (type == 1) {
			scanf("%d %c", &i, &c);
			i--;
			count[i/1000][S[i] - 'a']--;
			count[i/1000][c - 'a']++;
			S[i] = c;
		} else {
			scanf("%d %d", &l, &r);
			l--;
			r--;
			for (j = 0; j < 26; j++) flag[j] = 0;
			for (i = (l + 999) / 1000; i < (r + 1) / 1000; i++) {
				for (j = 0; j < 26; j++) if (count[i][j] > 0) flag[j] = 1;
			}
			for (j = l; j <= r && j % 1000 != 0; j++) flag[S[j] - 'a'] = 1;
			for (j = r; j >= l && (j + 1) % 1000 != 0; j--) flag[S[j] - 'a'] = 1;
			for (j = 0, ans = 0; j < 26; j++) ans += flag[j];
			printf("%d\n", ans);
		}
	}
	
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 2244
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
pair<pair<string,int>,int>a[114];
signed main(){
	int n,k;
	cin>>n>>k;
	if(k==1)c(0)
	else c(n-k)
}	

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  
 	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] dp 	= new int[N+1][3];
		int[][] abc	= new int[N+1][3];

		for(int i=1;i<=N;i++){
			for(int j=0;j<3;j++){
				abc[i][j] = sc.nextInt();
				for(int k=0;k<3;k++){
					if(j==k){
						continue;
					}
					dp[i][j] = chmax(dp[i][j],dp[i-1][k]+abc[i][j]);
				}
			}
		}

		int ans = 0;
		for(int i=0;i<3;i++){
			ans = chmax(ans,dp[N][i]);
		}

		System.out.println(ans);
	}

	public static int chmax(int a,int b){

		if(a >= b){
			return a;
		}else{
			return b;
		}
	}
}

Measured memory_bytes: 99800
#include <iostream>
#include <cmath>

using namespace std;

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

  int t;
  cin >> t;
  float a;
  cin >> a;

  int mini = 0;
  float h;
  cin >> h;
  float mindiff = abs(a - (t - h * 0.006));

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

    float tmp = abs(a - (t - h * 0.006));
    if (tmp < mindiff) {
      mini = i;
      mindiff = tmp;
    }
  }
  cout << (mini + 1) << endl;
}


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

typedef long long ll;
typedef pair<int, int> pii;
const int maxN = 1e5;

int a[maxN];
int mar = 3;
int cnt[maxN + 100];

void upd(int x) {
	cnt[x + mar]++;
}

int out(int x) {
	return cnt[x + mar];
}

int main() {
	int i, j, n, ans = 0; cin >> n;
	for (i = 0; i < n; i++) {
		scanf("%d", a + i);
		upd(a[i] - 1), upd(a[i]), upd(a[i] + 1);
	}
	for (i = 0; i < n; i++) {
		for (j = -1; j <= 1; j++)
			ans = max(ans, out(a[i] + j));
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 1024
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
l = LI()
l.sort()
print(l[0]+l[1])

Measured memory_bytes: 38640
#include <cstdio>
#include <algorithm>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>

using namespace std;

int main() {
    string S,T;
    bool alpha[26][26]={false};
    cin>> S>>T;

    for(int i=0; i<S.size(); i++){
        alpha[S[i]-'a'][T[i]-'a']=true;
    }

//    for(int i=0; i<26; i++){
//        alpha[i][i]=false;
//    }

    int count=0;
    for(int j=0; j<26; j++){
        count = 0;
        for(int i=0; i<26; i++){
            if(alpha[i][j]){
                count++;
            }
        }
        if(count>1 ){
            printf("No");
            return 0;
        }
    }
    for(int i=0; i<26; i++){
        count = 0;
        for(int j=0; j<26; j++){
            if(alpha[i][j]){
                count++;
            }
        }
        if(count>1){
            printf("No");
            return 0;
        }
    }
    printf("Yes");

    return 0;

}


Measured memory_bytes: 776
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;
const int INF=1e9;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

signed main(){
  int n;
  int ans;
  cin>>n>>ans;
  for(int i=0;i<n-1;i++){
    int a;
    cin>>a;
    ans=euclidean_gcd(ans,a);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9

def main():
    n,y = map(int, input().split())

    summary = 0
    for i in range(n+1):
        for j in range(n+1):
            if i+j > n:
                continue
            summary = 10000*i+5000*j+1000*(n-i-j)
            if summary == y:
                print(i,j,n-i-j)
                return
    print(-1,-1,-1)


if __name__ == '__main__':
    main()


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

typedef long long ll;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll N, pwned = 0;
    vector<ll> towns, heroes;
    cin >> N;
    for (ll temp, i = 0; i < N + 1; i++) {
        cin >> temp;
        towns.push_back(temp);
    }
    for (ll temp, i = 0; i < N; i++) {
        cin >> temp;
        heroes.push_back(temp);
    }
    for (ll i = 0; i < N; i++) {
        // iterate through the heroes
        if (heroes[i] > towns[i]) {
            pwned += towns[i];
            pwned += min(towns[i + 1], heroes[i] - towns[i]);
            heroes[i] - towns[i] - towns[i + 1] >= 0 ? towns[i + 1] = 0 : towns[i + 1] = towns[i + 1] - heroes[i] + towns[i];
        } else {
            pwned += heroes[i];
        }
    }

    cout << pwned << "\n";
    return 0;
}

Measured memory_bytes: 2548
S = input()
Slist = []
for i in range(len(S)):
    Slist.append(S[i]) 

count = 0
##print(len(S))

for i in range(len(S)//2):
    ##print(Slist[i],Slist[-i-1])
    if Slist[i] != Slist[len(S)-1-i]:
        count +=1
    
    

print(count)

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

using namespace std;

typedef long long ll;

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  string S;
  ll K;
  cin >> S >> K;
  char res;
  int ones = 0;
  for (int i = 0; i < S.size(); ++i) {
    if (S[i] == '1') ones++;
    else break;
  }
  if (K <= ones) res = '1';
  else res = S[ones];
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ii pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define si set<ll>
#define endl "\n"
#define pb(a) push_back(a)
#define x first
#define y second
//g++-9 -std=c++11 -Wall -Wextra -pedantic-errors main.cpp -o main
const ll ms = 1e4 + 5, base = 31, mod = 1e9 + 9;
using namespace std;

int main(){
	ios::sync_with_stdio(false), cin.tie(0);
	
	int N; cin >> N;
	
	vi vec;
	
	while(N--){
		int aux; cin >> aux;
		vec.pb(aux);
	}
	
	int c = 0, biggest = INT_MAX;
	for (int i = 0; i < vec.size(); i++){
		bool valid = (vec[i] <= biggest);
		biggest = min(biggest, vec[i]);
		c += valid;
		//if (valid) cout << vec[i] << endl;
	}
	cout << c << endl;

	return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//main code

int main(int argc, char const* argv[])
{
	int n,k;
	cin >> n >> k;
	double ans = 0.0;
	for (int i = 1; i <= n; i++) {
		double tmp = 1.0;
		for (int j = 0; j < 20; j++) {
			if (i * pow(2,j) >= k) {
				ans += double(1.0/n)*tmp;
				break;
			}
			tmp /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
    int a;
 /* ????????°a ?????¢?????¬?????????????????¢?????¨?????¢?????\?????????????????´??°????????????????´???????????????????????????????*/
      scanf("%d", &a);
      printf("%d", a/3600);
      printf(":");
      printf("%d", (a%3600)/60);
      printf(":");
      printf("%d\n", (a%3600)%60);
    return 0;
}

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

using namespace std;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0) {
        cout << "No" << endl;
        return;
    }
    cout << ((c * c + a * a + b * b - 2 * c * a - 2 * c * b + 2 * a * b - 4 * a * b > 0) ? "Yes" : "No") << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  int N;
  cin >> N;
  
  if (N < 100) {
    cout << min(9,N) << endl;
  }
  else if (N < 10000) {
    cout << min(909,N-90) << endl;
  }
  else {
    cout << min(90909,N-9090) << endl;
  }
  return 0;
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	ll a, b, x;
	cin >> a >> b >> x;

	if(a % x == 0){
		cout << b/x - a/x + 1 << endl;
	}else{
		cout << b/x - a/x << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;


public class Main{
   int count;

    public static void main(String[] args){
			new Main();
    }

		public Main(){
			Scanner scan = new Scanner(System.in);
				int n = scan.nextInt();
				int arr[] = new int[1000000];

				for(int i=0;i<n;i++){
						arr[i] = scan.nextInt();
				}
				shellSort(arr, n);
				printArray(arr, n);
		}


    public void insertSort(int arr[], int n, int g){
        for(int i=g;i<n;i++){
            int v = arr[i];
            int j = i - g;
            while(j >=0 && arr[j] > v){
                arr[j+g] = arr[j];
                j = j -g;
                count++;
            }

            arr[j+g] = v;
        }
    }

    public void shellSort(int arr[], int n){
        count = 0;
        int i, j, m;
        int G[] = new int[100];
        if(n < 3){
            G[0] = n;
            G[1] = n-1;
            G[2] = 1;
            m = n;
        }else{
            j = 0;
            for(i=1;i<n;i=i*3+1){
                G[j++] = i;
            }
            m = j;
        }
        System.out.println(m);
        for(i=m-1;i>=1;i--){
            System.out.print(G[i] + " ");
        }
        System.out.println(G[i]);

        for(i=m-1;i>=0;i--){
            insertSort(arr, n, G[i]);
        }
        System.out.println(count);
    }

    public static void printArray(int arr[], int n){
        int i;
        for(i=0;i<n;i++){
            System.out.println(arr[i]);
        }
    }
}



Measured memory_bytes: 298724
#!/usr/bin/env ruby

def bubble(ary)
  flg = true
  n = ary.length
  cnt = 0

  while flg
    flg = false
    (n - 1).downto(1) do |i|
      next if ary[i] >= ary[i - 1]
      ary[i], ary[i - 1] = ary[i - 1], ary[i]
      cnt += 1
      flg = true
    end
  end

  puts ary.join(' ')
  puts cnt
end

gets

bubble(gets.chomp.split.map(&:to_i))

Measured memory_bytes: 6868