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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int a, b, c; cin >> a >> b >> c;
	int t = 0;
	rep(i, 0, 120) {
		if (t % 60 + a >= c&&t % 60 <= c) {
			t += (c + 60 - t % 60) % 60;
			cout << t << endl;
			return 0;
		}
		t += a + b;
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

char G[55][55];
int dist[55][55];
queue<pair<int,int>> que;
// North, west, south, east
int dy[] = {-1, 0, 1, 0};
int dx[] = {0, -1, 0, 1};



int main(){
    int h, w;
    cin >> h >> w;
    int num = 0;

    rep(i,h){
        rep(j,w){
            cin >> G[i][j];
            if(G[i][j] == '#') num++;
            dist[i][j] = -1;
        }
    }

    dist[0][0] = 0;
    que.push(P(0,0));

    while(!que.empty()){
        P p = que.front();
        que.pop();

        rep(i,4){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];

            if(-1 < ny && ny < h && -1 < nx && nx < w && G[ny][nx] == '.' && dist[ny][nx] == -1 ){
                dist[ny][nx] = dist[p.first][p.second] + 1;
                que.push(P(ny,nx));
            }

        }

    }

    if(dist[h-1][w-1] == -1){
        dunk(-1);
    }

    else dunk(h*w - num - dist[h-1][w-1] -1);
}

Measured memory_bytes: 256
def get_num(n, x):
    ans = 0
    for n3 in range(min(n, x), (x + 2) / 3, -1):
        for n2 in range(min(n3 - 1, x - n3), (x - n3 + 1) / 2 - 1, -1):
            for n1 in range(min(n2 - 1, x - n3 - n2), 0, -1):
                if n1 + n2 + n3 == x:
                    ans += 1
                    break
    return ans


data = []
while True:
    [n, x] = [int(m) for m in raw_input().split()]
    if [n, x] == [0, 0]:
        break
    if x < 3:
        data.append(0)
        # print(0)
    else:
        data.append(get_num(n, x))
        # print(get_num(n, x))

for n in data:
    print(n)

Measured memory_bytes: 6356
import sys
sys.setrecursionlimit(40000)

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    nCr[(n,r)]=nCr[(n,r)]
    return nCr[(n,r)]


def f(a,b):
    #print(a,b)
    if b<0 or a<0:    
        return 0
    return cmb(a+b-1,b-1)

def acinput():
    return list(map(int, input().split(" ")))

N,K=acinput()

B=K
R=N-K


for i in range(1,K+1):
    _B=B-i
    _R=R-i+1

    PR=f(_R,i+1)
    if PR>0:
        PB=f(_B,i)
    else:
        PB=1
    

    #print("b r",_B,_R)
    #print(PB,PR)
    print(int(PB*PR)%(10**9+7))


Measured memory_bytes: 166116
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n;
  cin>>n;
  int a[n];
  rep(i,n) cin>>a[i];
  int mi = MOD;
  sort(a, a+n);
  FOR(i, a[0], a[n-1] + 1) {
    int cost = 0;
    rep(j,n) {
      cost += (int)pow(a[j] - i, 2);
    }
    mi = min(mi, cost);
  }
  cout << mi << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0 , f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{if(ch == '-')	f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
const int N = 3e5 + 5;
int n;
int a[N];
namespace BIT
{
	int tr[N];
	#define lowbit(x) ((x) & -(x))
	inline void add(int x) { while(x <= n) tr[x] ++ , x += lowbit(x);}
	inline int ask(int x) { int ans = 0; while(x) ans += tr[x] , x -= lowbit(x); return ans;}
}
using namespace BIT;
inline ll solve(int x,int k)
{
	ll ans = 0; memset(tr,0,sizeof tr);
	for(int i = n - x;i >= 1;i -= k) ans += ask(a[i] - 1) , add(a[i]);
	return ans;
}
int main()
{
	n = read();
	for(int i = 1;i <= n;i ++)
	{
		a[i] = read();
		if((a[i] & 1) ^ (i & 1)) return puts("No") , 0;
	}
	if(solve(0,1) % 3 != 0) return puts("No") , 0;
	if(solve(0,1) != (solve(1,2) + solve(0,2)) * 3) return puts("No") , 0;
	return puts("Yes") , 0;
}

Measured memory_bytes: 2688
/*
    And I know I may end up failing too
*/




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

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

#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pf           push_front
#define pi           acos(-1)
#define all(x)       x.begin(),x.end()
#define fast         ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define INF          0x3f3f3f3f

struct hash_pair
{
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1> {}(p.first);auto hash2 = hash<T2> {}(p.second);return hash1 ^ hash2;
    }
};

ll t;
ll mod=N;
ll BigMod(ll base,ll pow,ll mod)
{
    if(pow==0||base==1)return 1;
    else if(pow==1)return base;
    else if(pow%2)return BigMod(base,pow-1,mod)*base%mod;
    else {ll x=(BigMod(base,pow/2,mod)%mod);x=(x*x)%mod;return x;}
}



int main()
{
    fast;
    ll a,b,c,d,e,f,g,i,j;
    ll n,m,k;
    vector<ll>v;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>a;
        v.pb(a);
    }
    sort(all(v));
    f=0;
    for(i=0;i<m;i++)
    {
        f+=v[i];
    }
    cout<<f<<endl;
    return 0;
}


Measured memory_bytes: 3656
'''
参考
https://qiita.com/c-yan/items/f7c99c8f8ec418a58c42

棒の全長をL、切断箇所をCとすると、かかるコストは|2C-L|となる
（左端から切断箇所までの長さを2倍し、元の棒の全長を引いたものの絶対値）
∵
・CがL/2よりも左にある場合（=棒の左端からCまでの長さのほうが短い）
⇒Cよりも左側に2C-L足すか、右側を2C-L減らす
・CがL/2よりも右にある場合（=棒の左端からCまでの長さのほうが長い）
⇒Cよりも左側を2C-L減らすか、右側に2C-L足す

与えられたリストAのうち、どの地点をCとするかは
リストAの先頭の要素からN-1個の要素をそれぞれ調べ、
先頭要素から現在の要素までの合計（累積和）を格納するリストを別途作成、
そのリストに対して|2C-L|が最小となるケースを調べる
'''
N = int(input())
A = list(map(int, input().split()))
L = sum(A)
#tmp = []
tmp = A[:-1]

for i in range(1, N-1):
#    tmp.append(sum(A[:i+1]))       # 実行時間超過してしまうためコメントアウト
    tmp[i] += tmp[i-1]

cost = min(abs(c*2-L) for c in tmp)
print(cost)


Measured memory_bytes: 26024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>
using namespace std;
using uint = unsigned int;
using ull = unsigned long long;

int main() {
	uint N;
	cin >> N;
	
	vector<ull> C(N);
	for(uint i=0; i<N; i++) cin >> C[i];
	
	sort(C.begin(), C.end(), greater<uint>());
	
	ull mod = pow(10, 9) + 7;
	ull ans = 0;
	
	for(uint i=0; i<N; i++) {
		ull tans = C[i] * (i + 2) % mod;
		ans = (ans + tans) % mod;
	}
	
	for(uint i=1; i<N; i++) {
		ans = (ans * 4) % mod;
	}
	
	cout << ans;
	
	return 0;
}


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

int main() {
    ll n,q,num[110000]={0};
    ll sum=0;
    cin>>n;
    int a;
    rep(i,n){
        cin>>a;
        sum+=a;
        num[a]++;
    }
    cin>>q;
    ll b,c;
    rep(i,q){
        cin>>b>>c;
        sum=sum-b*num[b]+c*num[b];
        printf("%lld\n",sum);
        num[c]+=num[b];
        num[b]=0;
    }

}


Measured memory_bytes: 4620
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Tile
{
public:
    vector<int> color;
    Tile(vector<int> c)
    {
        color = c;
        for(int i=0; i<3; ++i){
            rotate(c.begin(), c.begin() + 1, c.end());
            color = min(color, c);
        }
    }
    int getCount()
    {
        if(color == vector<int>(4, color[0]))
            return 4;
        else if(color[0] == color[2] && color[1] == color[3])
            return 2;
        else
            return 1;
    }
    bool operator<(const Tile& t) const{
        return color < t.color;
    }
};

int main()
{
    int n;
    cin >> n;
    vector<Tile> tile;
    map<Tile, int> m;
    for(int i=0; i<n; ++i){
        vector<int> v(4);
        for(int j=0; j<4; ++j)
            cin >> v[j];
        Tile t(v);
        tile.push_back(t);
        ++ m[t];
    }

    long long ans = 0;
    for(int a=0; a<n; ++a){
        -- m[tile[a]];
        for(int b=a+1; b<n; ++b){
            -- m[tile[b]];

            for(int r=0; r<4; ++r){
                vector<Tile> t;
                for(int i=0; i<4; ++i){
                    vector<int> v(4);
                    v[0] = tile[a].color[(i+r)%4];
                    v[1] = tile[b].color[(4-i)%4];
                    v[2] = tile[b].color[3-i];
                    v[3] = tile[a].color[(i+1+r)%4];
                    t.push_back(Tile(v));
                }

                long long cnt = 1;
                for(int i=0; i<4; ++i){
                    if(m.find(t[i]) == m.end()){
                        cnt = 0;
                    }
                    else{
                        cnt *= m[t[i]];
                        cnt *= t[i].getCount();
                        -- m[t[i]];
                    }
                }
                ans += cnt;

                for(int i=0; i<4; ++i){
                    if(m.find(t[i]) != m.end())
                        ++ m[t[i]];
                }
            }

            ++ m[tile[b]];
        }
        ++ m[tile[a]];
    }

    ans /= 3;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
def main():
    N,M = map(int, raw_input().split())
    conf = [[0 for i in range(N)]for j in range(N)] 
    visit = [0]*N
    c = 0
    for i in range(M):
        s,g = map(int , raw_input().split())
        conf[s-1][g-1] = 1
        conf[g-1][s-1] = 1
    visit[0] = 1
    return dfs(conf, visit, 0, c)

def dfs(conf, visit, s, c):
    if 0 not in visit:
        visit[s] = 0
        c += 1
        return c
    for i in xrange(len(visit)):
        if conf[s][i] == 1 and visit[i] == 0:
            visit[i] = 1
            c = dfs(conf, visit , i, c)
            visit[i] = 0
    return c
print main()

Measured memory_bytes: 2696
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ar array
 
const int mxN=1e7;
int n, c[mxN+1];
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	cin >> n;
	for(int i=1; i<=n; ++i)
		for(int j=0; (j+=i)<=n; )
			++c[j];
	ll ans=0;
	for(int i=1; i<=n; ++i)
		ans+=(ll)i*c[i];
	cout << ans;
}

Measured memory_bytes: 42676
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;
#define zei 1.08

int main()
{
    int N;
    double X=0.0;
    double test;

    cin >> N;

    X = N / zei;
    test = fmod(X, 1.0);

    if(fmod(X, 1) != 0) {
        if(floor((floor(X)+1)*zei) == N) cout << floor(X)+1 << endl;
        else cout << ":(" << endl;
    }
    else {
            cout << X << endl;
    }
}


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

int main(){
    string s;
    int evenzero = 0, evenone = 0,oddzero=0,oddone=0;
    int ans = 0;
    int odd=0,even=0;
    cin >> s;
     for(int i = 0; i < s.size(); i++){
        if(i % 2 == 0 && s[i] == '0'){
            odd += 1;
        } else if(i % 2 == 0 && s[i] == '1'){
            even += 1;
        } else if(i % 2 == 1 && s[i] == '0'){
            even += 1;
        } else{
            odd += 1;
        }
        ans = min(odd,even);
     }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main() {
    int x = -1, y = -1, z = -1;

    int N, Y;
    scanf("%d %d", &N, &Y);

    for (int i = 0; i <= N; i++) {
        for(int j = 0; i + j <= N; j++) {
            int k = N - i - j,  a = 10000 * i + 5000 * j + 1000 * k;
 
            if (a == Y) {
                x = i;
                y = j;
                z = k;
            }
        }
    }

    printf("%d %d %d\n", x, y, z);
    return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		vector<pair<int, int> > hist(m);
		for(int i=0; i<m; ++i)
			hist[i] = make_pair(n, i+1);

		for(int i=0; i<n; ++i){
			for(int j=0; j<m; ++j){
				int a;
				scanf("%d", &a);
				hist[j].first -= a;
			}
		}

		sort(hist.begin(), hist.end());
		
		for(int i=0; i<m; ++i)
			printf("%s%d", i?" ":"", hist[i].second);
		puts("");
	}

	return 0;
}

Measured memory_bytes: 0
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int D = sc.nextInt();
		int count = 0;

		count = (int) N / (1 + 2 * D);
		if (N % (1 + 2 * D) != 0)
			count++;

		System.out.println(count);

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


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

int main()
{
    int n, a[101];
    cin >> n;
    for(int i=0; i<n; ++i) cin >> a[i];
    
    for(int j=n-1; j>=0; --j)
    {
        cout << a[j];
        if(j > 0)
        {
            cout << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3012
# AGC 025 A - Digits Sum
N = int(input())

def sum_of(num): 
    list_b = []
    k = 0
    while num > 0:
        list_b.append(num%10)
        num //= 10
    for i in range(len(list_b)):
        k += list_b[i]
    return k 

list_a =[]
if N <= 10:
    print(str(N))
if N > 10:
    for i in range(2,(N-1)//2+1):
        A = i
        B = N - i
        list_a.append(sum_of(A) + sum_of(B))
    print(min(list_a))

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

int main() {
  
  vector<int> cij(9);
   for (int i=0; i<9 ;i++) {
     cin >> cij.at(i) ;
   }
  
  int a, b, c, d, e, f, g, h, i, j, k, l;
  a = cij.at(1) - cij.at(0);
  b = cij.at(2) - cij.at(0);
  c = cij.at(3) - cij.at(0);
  d = cij.at(6) - cij.at(0);
  e = cij.at(4) - cij.at(3);
  f = cij.at(5) - cij.at(3);
  g = cij.at(7) - cij.at(6);
  h = cij.at(8) - cij.at(6);
  i = cij.at(4) - cij.at(1);
  j = cij.at(7) - cij.at(1);
  k = cij.at(5) - cij.at(2);
  l = cij.at(8) - cij.at(2);
  
  if (a==e && a==g && b==f && b==h && c==i && c==k && d==j && d==l){
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
  
  
}

Measured memory_bytes: 3592
n,m = map(int,input().split())
A = list(map(int,input().split()))
C = []
for _ in range(m):
  b,c = map(int,input().split())
  C.append((c,b))
C.sort(reverse = True)

count = 0
for c,b in C:
  A.extend([c for _ in range(b)])
  count += b
  if count > n:
    break
A.sort(reverse = True)

print(sum(A[:n]))



Measured memory_bytes: 23100
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<ii> vii;
typedef vector<vi> vvi;
#define deb(x) cout << #x": " << (x) << endl;

const int N = 1e3;
const lli INF = 1e18;
const lli MOD = 1e9+7;

bool m[N];
vi primes(1,2);
ld nk[N][N];
void sieve(){
	for(int i = 4; i<N; i+=2)m[i]=1;
	for(int i = 3; i*i<=N; i+=2)if(!m[i])for(int j = i*i; j<N; j+=i)m[j]=1;
	for(int i = 3; i<N; i+=2)if(!m[i])primes.pb(i);
}

void pascal(){
	fore(i,0,N)nk[i][0]=nk[i][i]=1.0;
	fore(i,1,N)fore(j,1,i)nk[i][j]=nk[i-1][j-1]+nk[i-1][j];
}

lli gcd(lli a, lli b){return (b?gcd(b,a%b):a);}

lli lcm(lli a, lli b){
	if(a<b)swap(a,b);
	lli c = gcd(a,b);
	a/=c;
	return a*b;
}

int popcount(lli x) { return __builtin_popcountll(x); }

lli poww(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = res * a;
		a = a*a;
		b/=2;
	}
	return res;
}

lli powm(lli a, lli b){
	lli res =1;
	while(b){
		if(b&1) res = (res * a)%MOD;
		a = (a*a)%MOD;
		b/=2;
	}
	return res;
}

bool isPrime(lli x){
	if(x==1)return 0;
	for(auto i:primes){
		if(i*i>x)return 1;
		if(x%i==0)return 0;
	}
	return 1;
}

// ---- コーディングはここから！ ('-')7

string s; int n,u;
void R(){
	if(u==0)fore(i,0,n)cout<<1<<ENDL;
	else{
		vi sol(n);
		if(s[0]=='1'){sol[0]=0;fore(i,1,n)sol[i]=2;}
		else fore(i,0,n)if(s[i]=='1')sol[i]=0;else sol[i]=1;
		if(s[0]=='0')sol[0]=2;
		reverse(all(sol));
		for(auto i:sol)cout<<i<<ENDL;
	}
	exit(0);
}

int main(){_
	 	cin>>n;
	  cin>>s;
	 reverse(all(s));
	 u= 0;
	 fore(i,0,sz(s))if(s[i]=='1')u++;
	 if(u<2)R();
	 vi r(n+1),t(n+1),res(n);
	 int X=0,Y=0;
	 r[0]=1%(u+1);
	 t[0]=1%(u-1);
	 int p = 1,q=1;
	 fore(i,0,n){
		 if(i==0){
			 if(s[i]=='1'){
				 X=(X+r[i])%(u+1);
				 Y=(t[i]+Y)%(u-1);
			 }
			 continue;
		 }
		 r[i] = p =(p * 2)%(u+1); // cambiar de 0 a 1
		 t[i] = q = (q * 2)%(u-1); // cambiar de 1 a 0
		 if(s[i]=='1'){
			 X=(X+r[i])%(u+1);
			 Y=(Y+t[i])%(u-1);
		 }
	 }
	 fore(i,0,n){
		 if(s[i]=='1')res[i]=(Y-t[i]+(u-1))%(u-1);
		 else res[i]=(X+r[i]+(u+1))%(u+1);
	 }
	 vi sol(n,1);
	 fore(i,0,n){
		 while(res[i]){
			 res[i]=res[i]%popcount(res[i]);
			 sol[i]++;
		 }
	 }
	 reverse(all(sol));
	 for(auto i:sol)cout<<i<<ENDL;


}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
  int a, b;
  cin >> a >> b;
  int c = b-a;
  int x = c*(c+1)/2 - b;
  cout << x << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define PI 3.141592653589793238462643383279


void change(int *x, int *y){
	int z;
	z = *x;
	*x = *y;
	*y = z;
}
int compare_int(const void *a, const void *b){
	return *(int*)a - *(int*)b;
}

int main(void){
	int n, L[15];
	scanf("%d", &n );
	for(int i=0;i<n;i++){
		scanf("%d", &L[i]);
	}
	int max = L[0];
	int maxnum=0;
	for(int i=1;i<n;i++){
		if(L[i]>max){
			max = L[i];
			maxnum=i;
		}
	}
	int sum=0;
	for(int i=0;i<n;i++){
		if(i==maxnum)	continue;
		else	sum+=L[i];
	}
	if(max<sum)	printf("Yes");
	else	printf("No");	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
using namespace std;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

void test_case(){
	int n; cin >> n;
	if(n >= 30)
		cout<<"Yes";
	else
		cout<<"No";
	
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	//~ cin >> T;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3648
from collections import Counter

while True:
    m, n = (int(s) for s in input().split())
    if not m:
        break

    objects = [int(input(), 2) for i in range(n)]
    dp = [bytearray(1 << m) for i in range(1 << m)]
    bits = [1 << i for i in range(m)]

    for mask in reversed(range((1 << m) - 1)):
        for masked, count in Counter(obj & mask for obj in objects).items():
            if count > 1:
                dp[mask][masked] = min(max(dp[mask + b][masked],
                                           dp[mask + b][masked + b]) + 1
                                       for b in bits if not b & mask)
    print(dp[0][0])

Measured memory_bytes: 15076
#define ONLINE_JUDGE
#include <algorithm>
#include <fstream>
#include <iostream>
#include <vector>
#include <cmath>
#include <iterator>
#include <map>
#include <set>
#ifndef ONLINE_JUDGE
#include <prettyprint/prettyprint.hpp>
#endif

#define FOR(i, n) for(int i = 0; i < n; ++i)
#define TEST int T; std::cin >> T; while(T--)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using ull = unsigned long long;
using vi = std::vector<int>;
using vll = std::vector<ll>;
using vull = std::vector<ull>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

using namespace std;

vector<vector<int>> graph;
vector<bool> visited;
vector<int> maxterm;

int dfs(int u) {
	visited[u] = true;
	int max1 = -1;
	for(auto v : graph[u]) {
		if(!visited[v]) {
			dfs(v);
		}
		int cur = maxterm[v];
		if(max1 == -1 || max1 < cur) {
			max1 = cur;
		}
	}
	if(max1 != -1) maxterm[u] = max1 + 1;
	return maxterm[u];
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	ifstream fin("in.txt");
	ofstream fout("out.txt");
	auto cinbuf = cin.rdbuf(fin.rdbuf());    // save and redirect
	auto coutbuf = cout.rdbuf(fout.rdbuf()); // save and redirect
#endif	
	int N, M;
	cin >> N >> M;
	graph.resize(N + 1);
	maxterm.assign(N + 1, 0);
	for(int i = 0; i < M; ++i) {
		int u, v;
		cin >> u >> v;
		graph[u].push_back(v);
	}

	visited.assign(N + 1, false);
	for(int i = 1; i <= N; ++i) {
		if(!visited[i]) dfs(i);
	}
	// cout << maxterm << endl;
	int ans = 0;

	for(int i = 1; i <= N; ++i) {
		ans = max(ans, maxterm[i]);
	}
	cout << ans << endl;
#ifndef ONLINE_JUDGE
	cin.rdbuf(cinbuf);    // restore
	cout.rdbuf(coutbuf); // restore
#endif	
}


Measured memory_bytes: 8832
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const long long mod = 1e9 + 7;

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

ll powMod(ll n, ll k, ll m) {
	if (k == 0) {
		return 1;
	} else if (k % 2 == 1) {
		return powMod(n, k - 1, m) * n % m;
	} else {
		ll t = powMod(n, k / 2, m);
		return t * t % m;
	}
}

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

	ll ans= 0;

	rep(i, s.size()) {
		if (s[i] != t[i]) {
			ans++;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3924
#include<cstdio>
#include<vector>

using namespace std;

int n,m;
vector<int> tomo[1001];
int ss[1001];


void saiki(int s,int dps){
		ss[s]=1;
	if(dps==2){
		return;
	}
	for(int i=0;i<tomo[s].size();i++){
		saiki(tomo[s][i],dps+1);
	}
}
	

int main(){
	while(1){
	scanf("%d%d",&n,&m);
	if(n==0&&m==0){
		break;
	}
	for(int i=0;i<1001;i++){
		ss[i]=0;		
		tomo[i].clear();
	}
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		tomo[a].push_back(b);
		tomo[b].push_back(a);
	}
	
	saiki(1,0);
	
	int cont=0;
	for(int i=2;i<=n;i++){
		cont+=ss[i];
	}
	printf("%d\n",cont);
	}
}

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

int main() {
	int A, B;
	cin >> A >> B;
	string S;
	cin >> S;
	for (int i = 0; i < A; i++) {
		if (S[i] == '0' 
			|| S[i] == '1' 
			|| S[i] == '2' 
			|| S[i] == '3' 
			|| S[i] == '4' 
			|| S[i] == '5' 
			|| S[i] == '6' 
			|| S[i] == '7' 
			|| S[i] == '8' 
			|| S[i] == '9') {
		}
		else {
			cout << "No" << endl;
			goto end;
		}
	}
	goto next_1;
next_1:
	if (S[A] == '-') {
		goto next_2;
	}
	else {
		cout << "No" << endl;
		goto end;
	}
next_2:
	for (int i = A + 1; i < A + B + 1; i++) {
		if (S[i] == '0'
			|| S[i] == '1'
			|| S[i] == '2'
			|| S[i] == '3'
			|| S[i] == '4'
			|| S[i] == '5'
			|| S[i] == '6'
			|| S[i] == '7'
			|| S[i] == '8'
			|| S[i] == '9') {
		}
		else {
			cout << "No" << endl;
			goto end;
		}
	}
	goto next_3;
next_3:
	cout << "Yes" << endl;
end:
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
cnt = 1
direction = 0

for i in range(N-1):
    d = A[i+1] - A[i]
    if direction == 0:
        if d > 0:
            direction = 1
        elif d < 0:
            direction = -1
    else:
        if direction == 1 and d < 0:
            cnt += 1
            direction = 0
        elif direction == -1 and d > 0:
            cnt +=1
            direction = 0
print(cnt)

Measured memory_bytes: 14252
from itertools import accumulate

def main():
    N = int(input())
    people = list(input())

    wests = list(accumulate([0]+people, lambda total, x: total + (1 if x == "W" else 0)))[1:]
    easts = list(accumulate([0]+people, lambda total, x: total + (1 if x == "E" else 0)))[1:]

    
    def linearsearch():
        easts_total = easts[-1]
        for i in range(N):
            yield (0 if i == 0 else wests[i-1]) + easts_total - easts[i]

    print(min(linearsearch()))

main()

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

using namespace std;

int main(){
int N,M;
int count=0;
char A[2000][2000],B[2000][2000];

cin>>N>>M;
for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
        cin>>A[i][j];
    }
}
for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
        cin>>B[i][j];
    }
}
for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
        if(A[i][j]!=B[i][j]) count++;
    }
}
cout<<count<<endl;

}


Measured memory_bytes: 10904
#include <iostream>
#include <map>

int main(int argc, char *argv[]) {
  int n;
  std::cin >> n;
  std::map<int, int> m;
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    std::cin >> a;
    ++m[a];
    sum += a;
  }
  int q;
  std::cin >> q;

  int b, c;
  for (int i = 0; i < q; ++i) {
    std::cin >> b >> c;
    if (!m.count(b)) {
      std::cout << sum << std::endl;
      continue;
    }
    sum += (c - b) * m.at(b);
    m[c] += m[b];
    m[b] = 0;
    std::cout << sum << std::endl;
  }
}


Measured memory_bytes: 7000
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define _rep(i,m,n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};


int main(){
    int n; cin >> n;
    string s; cin >> s;
    vector<ll> white(n, 0);
    vector<ll> white_sum(n + 1);
    vector<ll> black(n, 0);
    vector<ll> black_sum(n + 1);
    white_sum[0] = 0;
    black_sum[0] = 0;


    
    rep(i,n){
        if(s[i] == '.')white[i] = 1;
        if(s[i] == '#')black[i] = 1;
    }
    _rep(i, 1, n + 1){
        white_sum[i] = white[i - 1] + white_sum[i - 1];
        black_sum[i] = black[i - 1] + black_sum[i - 1];
    }
    //cout << white_sum[n] << " " << black_sum[n] << endl;

    ll ans_min = N;
    rep(i,n + 1){
        ll ans = ((n - i) - (white_sum[i] - white_sum[0])) + (i - (black_sum[n] - black_sum[i]));
        ans_min = min(ans, ans_min);
        //cout << ans << endl;
    }
    cout << ans_min << endl;
}

Measured memory_bytes: 6788
# region header
import sys
import math
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos
from operator import itemgetter
from string import ascii_lowercase, ascii_uppercase, digits
sys.setrecursionlimit(10**7)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
PI = math.pi
# endregion
A, B, C = ri_()
K = ri()
print(A + B + C - max(A, B, C) + max(A, B, C) * (2 ** K))

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

using namespace std;

int main(void)
{

    char input;

    cin >> input;

    switch(input){

        case 'A':
            printf("T\n");
            break;
        case 'T':
            printf("A\n");
            break;
        case 'C':
            printf("G\n");
            break;
        case 'G':
            printf("C\n");
            break;

    }

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
#include <ctype.h>
using namespace std;
int p,q;
string b,a,aa;
int main(){
	while(cin>>b&&b!="-"){
		cin>>p;
		for(int i=0;i<p;i++){
			cin>>q;
		a=b.substr(0,q);
	aa=b.substr(q,b.size());
	b=aa+a;}
		cout<<b<<endl;}
return 0;
}


Measured memory_bytes: 1216
N, M =map(int, input().split())
sc=[list(map(int, input().split())) for _ in range(M)]
sc.sort(key=lambda x:x[0])

ans=0
for i in range(M):
    s1, c1 = sc[i]
    if s1>N:
        ans=-1
        break
    for j in range(i+1, M):
        s2, c2 = sc[j]
        if s1==s2 and c1!=c2:
            ans=-1
            break
if M>0 and N>1 and sc[0][0]==1 and sc[0][1]==0:
    ans=-1

if ans!=-1:
    ans_={1:1, 2:0, 3:0}
    for i in range(M):
        s, c = sc[i]
        ans_[s]=c
    for i in range(1, N+1):
        ans=ans*10+ans_[i]

if N==1 and M==0:
    ans=0

print(ans)

Measured memory_bytes: 38436
#include<iostream>
using namespace std;
 
int main(){
	double x1, x2, x3, y1, y2, y3, xp, yp;
	while(cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp){
		double cross1 = (x2-x1)*(yp-y1)-(y2-y1)*(xp-x1);
		double cross2 = (x3-x2)*(yp-y2)-(y3-y2)*(xp-x2);
		double cross3 = (x1-x3)*(yp-y3)-(y1-y3)*(xp-x3);
		if(cross1 < 0 && cross2 < 0 && cross3 < 0 || cross1 > 0 && cross2 > 0 && cross3 > 0){
			cout << "YES" << endl;
		}else{
			cout << "NO" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3144
s=input()
ind =0
len_s=len(s)
s = s+ "AAAAAAAAA"

A = "dreamer"
B= "dream"
C= "erase"
D="eraser"

flag =True
while(1):
    if(s[ind] =="d"):
        if(s[ind + 5] =="d"):
            if(s[ind:ind+5]!=B):
                flag = False
                break
            else:
                ind+=5
        else:
            if(s[ind+5]!='e' and s[ind+5]!='A'):
                flag=False
                break
            if(s[ind+7] == "a" or ind + 7 >len_s):
                if(s[ind:ind+5]!=B):
                    flag = False
                    break
                else:
                    ind+=5

            else:
                if(s[ind:ind+7] !=A):
                    flag = False
                    break
                else:
                    ind+=7
    elif(s[ind]=="e"):
        if(s[ind+5]=="r"):
            if(s[ind:ind+6]!=D):
                flag = False
                break
            else:
                ind+=6

        else:
            if(s[ind:ind +5] !=C):
                flag =False
                break
            else:
                ind+=5
    else:
        flag=False
        break
    if(ind == len_s):
        break
    if(ind > len_s):
        flag=False
        break
if(flag):
    print("YES")
else:
    print("NO")



Measured memory_bytes: 3316
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    number = int(input())
    counter=[]
    count=0

    if number==1:
        print(1)
        exit()

    for i in range(1,number+1):
        while i >= 2:
            if i % 2==0:
                i /= 2
                count+=1
            else:
                break
        counter.append(count)
        count=0
    print(counter.index(max(counter))+1)

if __name__=="__main__":
    main()

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0LL;
    bool flg = false;
    int cnt = 0;
    ll mn = (ll) 1e15;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (A[i] == 0)flg = true;
        if (A[i] < 0)cnt++;
        sum += abs(A[i]);
        mn = min(mn, abs(A[i]));
    }

    ll ans = accumulate(A.begin(), A.end(), 0LL);
    if (flg or cnt % 2 == 0) {
        cout << sum << endl;
        return 0;
    }
    cout << sum - 2 * mn << endl;

    return 0;
}


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

int main(){
  long long int n;
  cin>>n;
  long double ns =sqrt(n)+1;
  long long int min=n+1;
  for(long long int i=2;i<ns;i++){
    if(n%i==0&&i+(n/i)<min){
      min=i+(n/i);
    }
  }
  cout<<min-2<<endl;
}

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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> field(H,vector<char>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> field.at(i).at(j);
    }
  }
  vector<int> tate_i(H),yoko_j(W);
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(field.at(i).at(j)=='.'){
        tate_i.at(i)++;
        yoko_j.at(j)++;
      }
    }
  }
  for(int i=0;i<H;i++){
    if(tate_i.at(i)==W){
      continue;
    }
    for(int j=0;j<W;j++){
      if(tate_i.at(i)==W||yoko_j.at(j)==H){
        field.at(i).at(j)='0';
      }
      if(field.at(i).at(j)!='0'){
      	cout << field.at(i).at(j);
      }
    }
    cout << endl;
  }
}
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int A, B, M; cin >> A >> B >> M;
    vector<int> a(A), b(B);
    REP(i, 0, A) cin >> a[i];
    REP(i, 0, B) cin >> b[i];

    int ans = 1 << 30;
    REP(i, 0, M) {
        int x, y, c; cin >> x >> y >> c;
        ans = min(ans, a[--x] + b[--y] - c);
    }

    sort(ALL(a));
    sort(ALL(b));
    ans = min(ans, a[0] + b[0]);
    cout << ans << endl;
    return 0;
}

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

int main(){
  ll n, ans = 1;
  cin >> n;
  ll x[n], g[n] = {};
  rep(i,n) {
    cin >> x[i];
    if(i > 0) g[i] = max(g[i-1],i-(1+x[i-1])/2);
  }
  rep(i,n) (ans *= i + 1 - g[i]) %= mod; 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

typedef struct
{
	int number;
	int flag;
} Bingo;

int bingo(Bingo *p)
{
	if (p[4].flag)
	{
		if (p[0].flag && p[8].flag)
			return 1;
		if (p[1].flag && p[7].flag)
			return 1;
		if (p[2].flag && p[6].flag)
			return 1;
		if (p[3].flag && p[5].flag)
			return 1;
	}
	if (p[0].flag)
	{
		if (p[1].flag && p[2].flag)
			return 1;
		if (p[3].flag && p[6].flag)
			return 1;
	}
	if (p[8].flag)
	{
		if (p[2].flag && p[5].flag)
			return 1;
		if (p[6].flag && p[7].flag)
			return 1;
	}
	return 0;
}

int main(void)
{
	Bingo p[9];
	int a;
	int n;
	int i;

	for (i = 0; i < 9; i++)
	{
		scanf("%d", &a);
		p[i].flag = 0;
		p[i].number = a;
	}

	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		int j;
		scanf("%d", &a);
		for (j = 0; j < 9; j++)
		{
			if (p[j].number == a)
			{
				p[j].flag = 1;
				if (bingo(p))
				{
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
	printf("No\n");
	return 0;
}


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

#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
#define CLR(arr,val) memset(arr,val,sizeof(arr))

typedef long long LL;

int main(){
    string s;
    cin>>s;
    int n=s.size(),tmp,ans=INF;
    for(int i=1;i<n;i++){
        if(s[i]!=s[i-1]) tmp=max(n-i,i),ans=min(ans,tmp);
    }
    if(ans==INF) cout<<n<<endl;
    else cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#abc139 c
n=int(input())
h=list(map(int,input().split()))

ans=0
cnt=0
for i in range(n-1):
    if h[i]>=h[i+1]:
        cnt+=1
    else:
        ans=max(ans,cnt)
        cnt=0
ans=max(ans,cnt)
print(ans)


Measured memory_bytes: 14252
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <fstream>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> T;

const ll mod = 1000000007;
const ll INF = 100000010000;

ll kai[100010];
ll bit[700010];

ll n;
vector<ll> G[200010];
ll ans;
ll num_child[200010];
ll par[200010];

/*ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= 700005)
	{
		bit[i] += x;
		i += i & -i;
	}
}*/

ll gcd(ll x, ll y)
{
	if (y == 0) return x;
	return gcd(y, x % y);
}

ll pow_mod(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2 == 1)
	{
		return x * pow_mod(x, y - 1) % mod;
	}
	else
	{
		ll half = pow_mod(x, y / 2);
		return half * half % mod;
	}
}

ll div_mod(ll x)
{
	return pow_mod(x, mod - 2);
}

ll com(ll x, ll y)
{
	return kai[x] * div_mod(kai[y] * kai[x - y] % mod) % mod;
}

void init()
{
	/*kai[0] = 1;
	for (int i = 1; i <= 10000; i++)
	{
		kai[i] = kai[i - 1] * i % mod;
	}*/
	cin >> n;
	for (int i = 1; i < n; i++)
	{
		ll a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
}

void output()
{
	
}

ll make_child(ll ver, ll pa)
{
	ll num = 0;
	par[ver] = pa;
	for (int i = 0; i < G[ver].size(); i++)
	{
		if (pa == G[ver][i]) continue;
		num += make_child(G[ver][i], ver) + 1;
	}
	return num_child[ver] = num;
}

void solve()
{
	make_child(1, 0);
	
	for (int i = 1; i <= n; i++)
	{
		ll pro = 1 + mod - div_mod(pow_mod(2, n - 1));
		for (int j = 0; j < G[i].size(); j++)
		{
			if (G[i][j] == par[i])
			{
				pro += mod;
				pro -= (1 + mod - div_mod(pow_mod(2, n - num_child[i] - 1))) * div_mod(pow_mod(2, num_child[i])) % mod;
				pro %= mod;
			}
			else
			{
				pro += mod;
				pro -= (1 + mod - div_mod(pow_mod(2, num_child[G[i][j]] + 1))) * div_mod(pow_mod(2, n - 1 - num_child[G[i][j]] - 1)) % mod;
				pro %= mod;
			}
		}


		(pro *= div_mod(2)) %= mod;
		(ans += pro) %= mod;
	}

	cout << ans << endl;
}

int main()
{
	init();

	solve();



	output();
	ll N;
	cin >> N;
}

Measured memory_bytes: 23936
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    a = I()
    print(a + a ** 2 + a ** 3)


if __name__ == '__main__':
    main()

Measured memory_bytes: 78064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int s;
    scanf("%d",&s);
    int a[100000]={0};
    a[0]=s;
    int i=0;
    while(1){
        int swt=0;
        if(a[i]%2==0){
            a[i+1]=a[i]/2;
        }else{
            a[i+1]=3*a[i]+1;
        }
        for(int j=0;j<=i;j++){
            if(a[i+1]==a[j]){
                swt=1;
            }else{
                ;
            }
        }
        i++;
        if(swt==1)
            break;
    }
    printf("%d",i+1);
}


Measured memory_bytes: 2096
A,B,C,X,Y=map(int,input().split())

if C*2>A+B:
    print(A*X+B*Y)
else:
    if X>=Y:
        print(C*2*Y+min(A,2*C)*(X-Y))
    else:
        print(C*2*X+min(B,2*C)*(Y-X))

Measured memory_bytes: 3060
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import Control.Monad
import Control.Monad.ST
import Control.Applicative
import Data.Maybe

m :: Int
m = 10^9+7

solve :: VUM.IOVector Bool -> VUM.IOVector Int -> Int -> IO Int
solve oks dp n = do  
  forM_ [0..n-1] $ \i ->
    forM_ [i+1..min n (i+2)] $ \j -> do
      judge <- VUM.read oks j
      when judge $ do
        now <- VUM.read dp i
        next <- VUM.read dp j
        VUM.write dp j ((now+next) `rem` m)
  VUM.read dp n

main = do
  [n, m] <- map read . words <$> getLine :: IO [Int]
  (oks :: VUM.IOVector Bool) <- VUM.replicate (n+1) True
  forM_ [1..m] $ \_ -> do
    x <- BS.getLine
    let Just (i,_) = BS.readInt x
    VUM.write oks i False
  
  (dp :: VUM.IOVector Int) <- VUM.replicate (n+1) 0
  VUM.write dp 0 1
  solve oks dp n >>= print

Measured memory_bytes: 1916
#include<stdio.h>
#include<ctype.h>

int main(void)
{
    int ans[4]={};
    int coef=0,k=0,c=0,formula=0;
    int i,j;

    scanf("%d",&k);
    scanf("%*c");
    for(i=0;i<k;i++)
    {
        coef=1;
        formula=0;
        int scale[2][4]={};
        while(1)
        {
            scanf("%c",&c);
            //printf("%c ",c);
            if(c==10)
            {
                break;
            }
            if(isdigit(c))
            {
                coef=c-'0';
        //        printf("coef=%d,",coef);
            }
            else if(isalpha(c))
            {
                switch(c)
                {
                    case 'm':
                    scale[formula][3]=coef;
                    break;
                    case 'c':
                    scale[formula][2]=coef;
                    break;
                    case 'x':
                    scale[formula][1]=coef;
                    break;
                    case 'i':
                    scale[formula][0]=coef;
                    break;
                    default:
                    break;
                }
                coef=1;
            }
            else
            {
                formula=1;
            }
        }

        for(j=0;j<4;j++)
        {
            int x=scale[0][j]+scale[1][j]+ans[j];
            ans[j]=x%10;
            ans[j+1]+=x/10;
        }

        for(j=3;j>=0;j--)
        {
            if(ans[j]!=0)
            {
                if(ans[j]==1)
                {
                    switch(j)
                    {
                        case 0:
                        printf("i");
                        break;
                        case 1:
                        printf("x");
                        break;
                        case 2:
                        printf("c");
                        break;
                        case 3:
                        printf("m");
                        break;
                        default:
                        break;
                    }
                }
                else
                {
                    switch(j)
                    {
                        case 0:
                        printf("%di",ans[j]);
                        break;
                        case 1:
                        printf("%dx",ans[j]);
                        break;
                        case 2:
                        printf("%dc",ans[j]);
                        break;
                        case 3:
                        printf("%dm",ans[j]);
                        break;
                        default:
                        break;
                    }
                }
            }
        }
        printf("\n");
        for(j=0;j<4;j++)
        {
            ans[j]=0;
        }
    }
    return 0;
}

Measured memory_bytes: 600