akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <numeric>
#include <iomanip>
#include <stack>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(ll i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 998244353;
// 0~3までは右下左上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, 1, 0, -1, -1, 1, 1, -1 };

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

    void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
    template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; ++i) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }

    // 標準入出力
    struct inp {
        std::size_t szi, szj;
        inp(std::size_t _szi = 1, std::size_t _szj = 1) : szi(_szi), szj(_szj) {}
        template <typename T> operator T () const { T a; std::cin >> a; return a; }
        template <typename T> operator std::vector<T>() const { std::vector<T> a(szi); for (std::size_t i = 0; i < szi; ++i) std::cin >> a[i]; return a; }
        template <typename T> operator std::vector<std::vector<T>>() const {
            std::vector<std::vector<T>> a(szi, std::vector<T>(szj));
            for (std::size_t i = 0; i < szi; ++i) for (std::size_t j = 0; j < szj; ++j) cin >> a[i][j]; return a;
        }
    };
    inp inp1;
}

int main() {

    int n = inp1;
    int a = n % 10;
    string ans;
    if (a == 3) ans = "bon";
    else if (a == 0 || a == 1 || a == 6 || a == 8) ans = "pon";
    else ans = "hon";

    Cout(ans);

    return 0;
}


Measured memory_bytes: 3624
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.IntStream;

public class Main{
	public static void main(String[]$) throws IOException{
		new Main().solve();
	}
	static FastScanner s=new FastScanner(System.in);
	static IntStream REPS(int v){return IntStream.range(0,v);}
	static IntStream REPS(int l,int r){return IntStream.rangeClosed(l,r);}
	static int gInt() throws IOException{return s.nextInt();}
	static long gLong() throws IOException{return s.nextLong();}
	static long gDouble() throws IOException{return s.nextLong();}

	private void solve() throws IOException{
		int n=gInt(),k=gInt();
		long r=Long.MAX_VALUE;
		for(int i=0;i<=n;++i) {
			long v=1;
			for(int j=0;j<i;++j) {
				v*=2;
			}
			for(int j=i;j<n;++j) {
				v+=k;
			}
			r=Math.min(r,v);
		}
		System.out.println(r);
	}

	static void yesno(boolean f) {
		yesno(f,"YES","NO");
	}
	static void yesno(boolean f,String yes,String no) {
		System.out.println(f?yes:no);
	}
}
class FastScanner{
	private final BufferedInputStream	in;
	private static final int			bufSize	=1<<16;
	private final byte					buf[]	=new byte[bufSize];
	private int							i		=bufSize;
	private int							k		=bufSize;
	private final StringBuilder			str		=new StringBuilder();

	FastScanner(InputStream in){
		this.in=new BufferedInputStream(in,bufSize);
	}
	int nextInt() throws IOException{
		return (int)nextLong();
	}
	long nextLong() throws IOException{
		int c;
		long x=0;
		boolean sign=true;
		while((c=nextChar())<=32)
			;
		if(c=='-'){
			sign=false;
			c=nextChar();
		}
		if(c=='+'){
			c=nextChar();
		}
		while(c>='0'){
			x=x*10+(c-'0');
			c=nextChar();
		}
		return sign?x:-x;
	}
	int nextChar() throws IOException{
		if(i==k){
			k=in.read(buf,0,bufSize);
			i=0;
		}
		return i>=k?-1:buf[i++];
	}
	String next() throws IOException{
		int c;
		str.setLength(0);
		while((c=nextChar())<=32&&c!=-1)
			;
		if(c==-1){
			return null;
		}
		while(c>32){
			str.append((char)c);
			c=nextChar();
		}
		return str.toString();
	}
	String nextLine() throws IOException{
		int c;
		str.setLength(0);
		while((c=nextChar())<=32&&c!=-1)
			;
		if(c==-1){
			return null;
		}
		while(c!='\n'){
			str.append((char)c);
			c=nextChar();
		}
		return str.toString();
	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> p(N);
  for (int i=0; i<N; i++) {
    cin >> p[i];
  }
  
  int judge = 0;
  for (int i=0; i<N; i++) {
    if ((p[i] - i - 1) != 0) {
      judge++;
    }
    
    if (judge > 2) {
      break;
    }
  }
  
  if (judge <= 2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);
#define rad2deg(a) ((a)/M_PI * 180.0)
#define deg2rad(a) ((a)/180.0 * M_PI)
const std::string yes = "Yes";
const std::string no  = "No";

int main(){
    int a,b,c,k;
    std::cin >> a >> b >> c >> k;

    for(int i=0; i<k; i++){
        if(a<b){
            if(b<c){
                std::cout << yes << "\n";
                return 0;
            }else{
                c *= 2;
            }
        }else{
            b *= 2;
        }
    }

    if(a<b&&b<c){std::cout << yes << "\n";}
    else{std::cout << no << "\n";}
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <iostream> 
#include <iterator>
#include <vector>
using namespace std;


int main(int argc, char const *argv[])
{
	char n[11];
	vector<string> str;
	scanf("%s",n);
	
	for(unsigned int i = 0; i< strlen(n);i++){
		if(n[i] =='1'){
			str.push_back("1");
		}else if(n[i] == '0'){
			str.push_back("0");
		}else if(n[i] =='B' && str.size() != (unsigned int)0){
			str.pop_back();
			}
					
	}
	vector<string>::iterator ptr ; 
	for( ptr = str.begin(); ptr != str.end(); ++ptr){
		cout << *ptr; 
			//cout << str[index];
	}
		
	return 0;
}


Measured memory_bytes: 256
s=list(map(int, input().split()))
t=sorted(s)
ans=(t[2]-t[1])+(t[2]-t[0])
if s[0]%2==0 and  s[1]%2==0 and s[2]%2==0\
or s[0]%2==1 and s[1]%2==1 and s[2]%2==1:
    print(ans//2)
else:
    if (sum(s))%2==1:
        if t[2]%2==0:
            print((ans+3)//2)
        else:
            print(ans//2)
    else:
        if t[2]%2==1:
            print((ans+3)//2)
        else:
            print(ans//2)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;

int main(){
	ll n, even=0, odd=0,ans=0;
	cin >> n;

	vector<int> a(n, 0);
	rep(i, n) cin >> a[i];

	if(n==1){
		if (a[0] % 2 == 0) cout << 1 << endl;
		else cout << 2 << endl;

		return 0;
	}

	if (a[0] % 2 == 0 && a[1] % 2 == 0) {
		even = 5; odd = 4;
	}
	else if (a[0] % 2 == 1 && a[1] % 2 == 1) {
		even = 8; odd = 1;
	}
	else {
		even = 7; odd = 2;
	}


	reps(i,2,n) {
		if (a[i] % 2 == 0 ) {
			even = 3*even + odd;
			odd = 2*odd;
		}else if (a[i] % 2 == 1) {
			even = 3 * even + 2 * odd;
		}
	}
	
	cout << even << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[1000000],ans;
int main()
{
  int n;
  cin>>n;
  for(int i=0;i<n*2;i++)cin>>a[i];
  sort(a,a+2*n);
  for(int i=0;i<n*2;i+=2)
  ans+=a[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){

int a , b ;
cin >> a >> b ;

if(a*b % 2 == 0){
cout <<"Even" << endl;
}
else if ( a*b==0){
cout << "Even" <<endl;
}
if(a*b%2==1){
cout << "Odd" <<endl;
}
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;

ll MOD = 1e9+7;

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int r, c; cin >> r >> c;
  vector<string> v(r);
  rep(i,0,r) cin >> v[i];
  vector<vector<ll>> res(r, vector<ll>(c));
  res[0][0] = 1;
  rep(i,0,r){
    rep(j,0,c){
      if(v[i][j] == '#') continue;
      if(i > 0) res[i][j] = (res[i][j] + res[i-1][j]) % MOD;
      if(j > 0) res[i][j] = (res[i][j] + res[i][j-1]) % MOD;
    }
  }
  cout << res[r-1][c-1] << "\n";
}


Measured memory_bytes: 12100
n = int(input())
s = input()


def check(t):
    # print('check', t)
    t = t[-1] + t + t[0]
    for i in range(1, n + 1):
        j = i - 1
        # if (t[i] == 'S') ^ (s[j] == 'o') ^ (t[i - 1] != t[i + 1]): continue
        if t[i] == 'S':
            consumed = 'o' if t[i - 1] == t[i + 1] else 'x'
        else:
            consumed = 'o' if t[i - 1] != t[i + 1] else 'x'

        if consumed == s[j]: continue

        # print('ng i=',i,t[i-1:i+2],s[j])
        return
    # print('ok')
    print(t[1:n+1])
    import sys
    sys.exit()

def getans(ans):
    ans = list(ans)
    for i in range(1, n):
        if ans[i] == 'S':
            if s[i] == 'o':
                ans[i + 1] = 'S' if ans[i - 1] == 'S' else 'W'
            else:
                ans[i + 1] = 'W' if ans[i - 1] == 'S' else 'S'
        else:
            if s[i] == 'x':
                ans[i + 1] = 'S' if ans[i - 1] == 'S' else 'W'
            else:
                ans[i + 1] = 'W' if ans[i - 1] == 'S' else 'S'

    # if ans[0] == ans[-1]:
    #     print("".join(ans)[:-1])
    #     import sys
    #     sys.exit()
    check("".join(ans)[:-1])


getans('WW' + '.' * (n - 1))
getans('WS' + '.' * (n - 1))
getans('SW' + '.' * (n - 1))
getans('SS' + '.' * (n - 1))

print(-1)

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

int main() {
    int N;
    vector<int> a;
    cin>>N;
    a = vector<int>(N);
    for(int i=0;i<N;i++) cin>>a[i];
    for(int i=0;i<N;i++) {
        int k=a[i];
        int j=i-1;
        for(;j>=0 && a[j]>k;j--) a[j+1]=a[j];
        a[j+1] = k;
        cout<<a[0];
        for(j=1;j<N;j++) cout<<" "<<a[j];
        cout<<endl;
    }
    return 0;
} 



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

using namespace std;

int
main(void){
	int w, h, n; 
	cin >> w >> h >> n;
	int x = 0, y = 0;
	int a, b, c;
	for(int i = 0; i < n; i++){
		cin >> a >> b >> c;
		if(c == 1){
			x = max(x, a);
		}
		else if(c == 2){
			w = min(w, a);
		}
		else if(c == 3){
			y = max(y, b);
		}
		else{
			h = min(h, b);
		}
	}
	cout << max(w - x, 0) * max(h - y, 0);
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    N = I()
    S = SL()

    for ch in S:
        print(ALPHABETS[(ALPHABETS.find(ch) + N) % len(ALPHABETS)], end="")
    print()

if __name__ == '__main__':
    main()

Measured memory_bytes: 80196
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <map>
using namespace std;

int main(){
    int N;
    cin>>N;
    map<int,int> M;
    for(int i=0;i<N;i++){
        int a;
        cin>>a;
        M[a]++;
    }
    if(M.size()==1&&M[0]){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(N%3==0&&M.size()==2&&M[0]==N/3){
        cout<<"Yes"<<endl;
        return 0;
    }
    if(M.size()!=3||N%3){
        cout<<"No"<<endl;
        return 0;
    }
    vector<int> A;
    for(auto p:M){
        if(p.second!=N/3){
            cout<<"No"<<endl;
            return 0;
        }
        A.push_back(p.first);
    }
    if((A[0]^A[1])==A[2]){
        cout<<"Yes"<<endl;
        return 0;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3840
import sys


def main():
    input = sys.stdin.buffer.readline
    n, m = map(int, input().split())
    num = [0] * n
    reserved = [False] * n
    for _ in range(m):
        s, c = map(int, input().split())
        s -= 1
        if reserved[s]:
            if c != num[s]:
                print(-1)
                sys.exit()
        else:
            reserved[s] = True
            num[s] = c
    if n > 1 and not reserved[0]:
        num[0] = 1
    if n > 1 and num[0] == 0:
        print(-1)
    else:
        print("".join(map(str, num)))


if __name__ == "__main__":
    main()


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

int main() {
  int n;
  cin >> n;
  vector<long long int> A(n);
  for (int i = 0; i < n; i++){
    cin >> A[i];
  }
  long long int cnt = 0, st=0;
  for (int i = 1; i < n; i++){
    st = max(st, A[i - 1]);
    if (A[i] < st) {
      cnt += st-A[i];
    }
    else st = A[i];
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 4840
n = int(input())
A = list(map(int, input().split()))

pick_DP = [-float('INF')] * n
unpick_DP = [-float('INF')] * n
pick_DP[0] = 0
unpick_DP[0] = 0

for i, a in enumerate(A, 1):
    mini = (i-1)//2 - 1
    if mini <= 0:
        mini = 1
    maxi = (i+1)//2

    temp = []
    for num in range(mini, maxi+1):
        temp.append(pick_DP[num])
        pick_DP[num] = max(unpick_DP[num-1] + a, pick_DP[num])

    for num, pre_pick in enumerate(temp, mini):
        if unpick_DP[num] < pre_pick:
            unpick_DP[num] = pre_pick

print(max(pick_DP[n//2], unpick_DP[n//2]))

Measured memory_bytes: 31492
#include <stdio.h>

int main()
{
	int i, N, K, A[200001];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	int k, min = 0, B[200002], tmp;
	for (k = 1; k <= K && min < N; k++) {
		min = N;
		for (i = 1; i <= N + 1; i++) B[i] = 0;
		for (i = 1; i <= N; i++) {
			if (A[i] >= i) B[1]++;
			else B[i-A[i]]++;
			if (A[i] >= N - i) B[N+1]--;
			else B[i+A[i]+1]--;
		}
		for (i = 1, tmp = 0; i <= N; i++) {
			tmp += B[i];
			A[i] = tmp;
			if (A[i] < min) min = A[i];
		}
	}
	for (i = 1; i < N; i++) printf("%d ", A[i]);
	printf("%d\n", A[N]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2001;
int a[N][N];
int cnt1[N], cnt2[N];
signed main () {
    int n, m, A, B;
    cin >> n >> m >> A >> B;
    for (int i = 0; i < n - B; i++) {
        for (int j = 0; j < m - A; j++) {
            a[i][j] = 1;
        }
    }
    for (int i = n - B; i < n; i++) {
        for (int j = m - A; j < m; j++) {
            a[i][j] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cnt1[i]+=a[i][j];
            cnt2[j]+=a[i][j];
        }
    }
    for (int i = 0; i < n; i++) {
        if (min(cnt1[i], m - cnt1[i]) != A) return cout << -1, 0;
    }
    for (int i = 0; i < m; i++) {
        if (min(cnt2[i], n - cnt2[i]) != B) return cout<< -1, 0;
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++)
            cout << a[i][j];
        cout << '\n';
    }
}

Measured memory_bytes: 17152
import sys
sys.setrecursionlimit(200010)

def main():
    input = sys.stdin.readline
    N, Q = map(int,input().split())
    G = [[] for k in range(N+1)]
    for k in range(N-1):
        a, b = map(int,input().split())
        G[a].append(b)
    kyori = [0 for k in range(N+1)]
    for k in range(Q):
        p, x = map(int,input().split())
        kyori[p] -= x
    def dfs(now, dist):
        for tsugi in G[now]:
            if kyori[tsugi] <= 0:
                kyori[tsugi] = -kyori[tsugi]
                kyori[tsugi] += dist
                dfs(tsugi, kyori[tsugi])
    kyori[1] = -kyori[1]
    dfs(1,kyori[1])
    print(*kyori[1:], sep = " ")

if __name__ == '__main__':
    main()


Measured memory_bytes: 262036
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF  2000000000
//#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d); BR;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
#define SUM(a, n) accumulate(a, a+n, 0)
#define VSUM(v) accumulate(ALL(v), 0);
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(b)-1;i>=(a);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

signed main(){ INIT;
    VAR(int, a, b);
    OUTL(ceil((a + b) / 2.0));
RET;}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!

l = input().rstrip().split(" ")
X = int(l[0])
N = int(l[1])

if N == 0:
    print(X)
else:
    P = input().rstrip().split(" ")
    P2 = []
    for i in range(N):
        P2.append(int(P[i]))
    #print(P2)
    
    cnt = 103
    ans = 0
    for i in range (-2, 103):
        a = 0
        for j in range(N):
            if i == P2[j]:
                a = 1
        if i > X:
            b = i - X
        else:
            b = X -i
        if a == 0 and b < cnt:
            cnt = b
            ans = i
    print(ans)

Measured memory_bytes: 9228
N = int(input())
ans = 'No'
tmp = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        tmp += 1
    else:
        tmp = 0
        
    if tmp == 3:
        ans = 'Yes'

print(ans)

Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
#define long long int int
#define endl '\n'
int main()
{
    int n,s=1;
    cin>>n;
    string str;
    cin>>str;
    char ch=str[0];
    for(int i=1;i<n;i++)
    {
        if(str[i]!=ch)
        {
            s++;
            ch=str[i];
        }
    }
    cout<<s;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define FIO                 ios::sync_with_stdio(false); cin.tie(nullptr)
#define TC(t)               int t; cin >> t; for(int i = 1; i <= t; i++)
#define deb(x)              cerr << #x << " = " << x << endl
#define deb2(x, y)          cerr << #x << " = " << x << ", " << #y << " = " << y << endl
#define f0(i, a, n)         for(i = a; i < n; i++)
#define f1(i, a, n)         for(i = a; i <= n; i++)
#define ini(x, y)           memset(x, y, sizeof(x))
#define all(x)              x.begin(), x.end()
#define sz(x)               x.size()
#define ll                  long long int
#define vi                  vector<int>
#define pb                  emplace_back
#define ppb                 pop_back
#define mp                  make_pair
#define M                   1000000007
#define endl                '\n'
#define bits(x)             __builtin_popcountll(x)
#define zrbits(x)           __builtin_ctzll(x)
#define ordered_set         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

const int N = 1e5 + 1;
const int MX = 1e9;
const ll INF = 1e18;

using namespace std;
using namespace __gnu_pbds;

inline ll ceil(ll a,ll b) {return (a % b ? a / b + 1 : a / b);}
inline ll mod(ll x) {return ( (x % M + M) % M );}

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
        for(auto& x : v) os << x << " ";
        return os << '\n';
}

template<typename... T>
void in(T&... args) {
        ((cin >> args), ...);
}

template<typename... T>
void out(T&&... args) {
        ((cout << args << endl), ...);
}

template<typename... T>
void out2(T&&... args) {
        ((cout << args << " "), ...);
}

void solve() {
        ll n, i, ans = 0;
        cin >> n;
        
        i = 1;
        n--;
        while(n / i) {
                ans += (n / i);
                i++;
        }
        cout << ans << endl;
}

int main () {
        FIO;
        // TC(t) 
        solve();
        return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define maxn 200010
using namespace std;
struct node
{
    int v, nxt;
} edge[maxn * 2];
int n;
int fa[maxn]; //并查集：维护连通块
map<int, int> pos;
int tot; //离散化QWQ 2^30，太真实了
int a[maxn], b[maxn], c[maxn], d[maxn];
int ans;
int k, head[maxn];
inline void add(int u, int v)
{
    edge[++k] = (node){v, head[u]};
    head[u] = k;
}
inline bool check()
{
    sort(c + 1, c + n + 1);
    sort(d + 1, d + n + 1);
    for (register int i = 1; i <= n; i++)
        if (c[i] != d[i])
            return 0;
    return 1;
}
int dfn[maxn], low[maxn], t, skr[maxn], cnt;
stack<int> s;bool vis[maxn];
void tarjan(int u)
{
    low[u]=dfn[u]=++t;
    s.push(u);
    vis[u]=1;
    for(register int i=head[u],v;i;i=edge[i].nxt){
        v=edge[i].v;
        if(!dfn[v]){
            tarjan(v);
            low[u]=min(low[u],low[v]);
        }else if(vis[v])
            low[u]=min(low[u],dfn[v]);
    }
    if(dfn[u]==low[u]){
        cnt++;
        while(u!=s.top()){
            skr[s.top()]=cnt;
            vis[s.top()]=0;
            s.pop();
        }
        skr[s.top()]=cnt;
        vis[s.top()]=0;
        s.pop();
    }
}
int main()
{
    scanf("%d", &n);
    register int i;
    int tmp = 0;
    for (i = 1; i <= n; i++) scanf("%d", &a[i]), tmp ^= a[i];
    a[n + 1] = tmp;
    tmp = 0;
    for (i = 1; i <= n; i++) scanf("%d", &b[i]), tmp ^= b[i];
    b[++n] = tmp;
    memcpy(c, a, sizeof a);
    memcpy(d, b, sizeof b);
    if (!check())
    {
        puts("-1");
        return 0;
    }
    for (i = 1; i <= n; i++)
    {
        if (a[i] != b[i] || i == n)
        {
            if (i < n) ans++;
            if (!pos[a[i]]) pos[a[i]] = ++tot;
            if (!pos[b[i]]) pos[b[i]] = ++tot;
            add(pos[a[i]], pos[b[i]]);
        }
    }
    if(!ans){
        puts("0");
        return 0;
    }
    for(i=1;i<=tot;i++){
        if(!dfn[i])
            tarjan(i);
    }
    printf("%d\n",ans+cnt-1);
    return 0;
}
//tarjan版本

Measured memory_bytes: 17228
#include <stdio.h>
 
#define MAX 40
 
void solve(int*,int*,int);
 
int n, post[MAX], idx;
 
int main(){
  int pre[MAX], in[MAX], i;
 
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%d",pre+i);
  }
  for(i = 0 ; i < n ; i++){
    scanf("%d",in+i); 
  }
 
  solve(pre, in, n);
 
  for(i = 0 ; i < n ; i++){
    printf("%d%c",post[i],(i != n-1 ? ' ':'\n'));
  }
 
  return 0;
}
 
void solve(int pre[], int in[], int N){
  int i, p;
 
  for(i = 0 ; i < N ; i++){
    if(in[i] == pre[0]){
      p = i;
      break;
    }
  }
 
  if(p != 0){
    solve(pre+1, in, p);
  }
  if(p != N-1){
    solve(pre+p+1, in+p+1, N-p-1);
  }
  post[idx++] = pre[0]; 
}


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

using namespace std;

int main() {
  	int a , b, perma, permb = 0;
  	cin >> a;
  	int *ii = new int[a];
  
  	for(int i = 0; i < a; i++) {
    	cin >> b;
      	ii[i] = b;
    }
  	do {perma++;
    } while(next_permutation(ii,ii+a));
  
    for(int i = 0; i < a; i++) {
        cin >> b;
      	ii[i] = b;
    }
  
  	do {permb++;
    } while(next_permutation(ii,ii+a));
	
  	cout << abs(permb - perma);
	return 0;
}

Measured memory_bytes: 384
import itertools
n=int(input())
p=list(map(str, input().split()))
p_new=''.join(p)
q=list(map(str, input().split()))
q_new=''.join(q)
a=[]
pc, qc=0,0
 
for v in itertools.permutations(range(1,n+1)): #Nまでの順列の辞書順リスト生成
    a_new=map(str, v)
    a_i=''.join(a_new)
    a.append(a_i)

for i in range(len(a)): #pとqが辞書順で何番目かを特定する
    if p_new==a[i]:
        pc+=i
    if q_new==a[i]:
        qc+=i
    else:
        continue
print(abs(pc-qc))

Measured memory_bytes: 6040
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
int main(void)
{
	int a,b,n,cnt;
	scanf("%d",&n);
	cnt=0;
	for(a=1;a<n;a++)	{
		b=1;
		while(a*b<n)	{
			cnt++;
			b++;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1732
#include "bits/stdc++.h"

using namespace std;

#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size(), mn = m;
    for(int i = 0; i + m <= n; i++){
        int c = 0;
        for(int j = 0, k = i; j < m; j++, k++){
            c += (s[k] != t[j]);
        }
        mn = min(mn, c);
    }
    cout << mn;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define int long long

#define fn "test"
#define fn1 ""

using namespace std;

const int mn = 2 * (int)(1e3) + 10;
const int mod = 1 * (int)(1e9) + 7;
const int mm = 1 * (int)(1e3) + 10;
const int base = 1 * (int)(1e9);
const bool aNs = 0;

int tt, ntest = 1;

void docfile()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    if (ifstream(fn".inp"))
    {
        freopen(fn".inp", "r", stdin);
        if (!aNs) freopen(fn".out", "w", stdout);
		else freopen (fn".ans", "w", stdout);
    }else if (ifstream(fn1".inp"))
    {
        freopen(fn1".inp", "r", stdin);
        freopen(fn1".out", "w", stdout);
    }
}

template <typename T>
void read(T& x)
{
    x = 0; T f = 1;
    char ch = getchar();
    while (!isdigit(ch)) f = ch == '-' ? - f : f, ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    x *= f;
}

template <typename T>
void write (T a)
{
    if (a < 0)
    {
        putchar ('-');
        write (-a);
        return;
    }
    if (a < 10)
    {
        putchar ('0' + a);
        return;
    }
    write (a / 10);
    putchar ((char)('0' + (a % 10)));
}

long long po (int x, int n)
{
    if (!n) return 1ll;
    long long a = po (x, n >> 1);
    a = (a * a) % mod;
    return ((n & 1) ? (a * x) % mod : a);
}

int u[mn], v[mn], id[mn], w[mn], fa[mn];

int Fa (int n)
{
    return (fa[n] < 0 ? n : fa[n] = Fa (fa[n]));
}

bool uni (int u, int v)
{
    u = Fa (u), v = Fa (v);
    if (u == v) return 0;
    if (fa[u] > fa[v]) swap (u, v);
    fa[u] += fa[v];
    fa[v] = u;
    return 1;
}

int mo (int x)
{
    return (x < 0 ? x + mod : x);
}

void enter()
{
    int n, m;
    long long x;
    cin >> n >> m;
    cin >> x;
    for (int i = 0; i < m; ++ i)
    {
        cin >> u[i] >> v[i] >> w[i];
        id[i] = i;
    }
    sort (id, id + m, [](int i, int j)
         {
             return w[i] < w[j];
         });
    int cn1 = 0, cn2 = 0;
    for (int i = 0; i < m; ++ i)
    {
        memset (fa, - 1, sizeof (fa));
        long long S = w[id[i]];
        uni (u[id[i]], v[id[i]]);
        for (int j = 0; j < m; ++ j)
        if (j != i)
        if (uni (u[id[j]], v[id[j]]))
        S += w[id[j]];
        if (S == x) ++ cn1;
        else if (S < x) ++ cn2;
    }
    if (!cn1)
    {
        cout << 0;
        return;
    }
    // cerr << cn1 << " " << cn2 << "\n";
    cout << ((cn2 ? 2ll : 1ll) * (mo (po (2, cn1) - (cn2 ? 1 : 2))) * po (2, m - cn1 - cn2)) % mod;
}

void solve()
{

}

void print_result()
{

}

main()
{
    docfile();
    //cin>>ntest;
    for (tt = 1; tt <= ntest; ++ tt)
    {
        enter();
        solve();
        print_result();
    }
}

Measured memory_bytes: 384
while True:
  n,x=map(int,input().split())
  if n==0 and x==0:
    break
  else:
    count=0
    for i in range(1,n-1):
      for j in range(i+1,n):
        for k in range(j+1,n+1):
          if i+j+k==x:
            count=count+1
    print(count)


Measured memory_bytes: 5596
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define INF 1e9

int dfs(int cur,int N,int a,int b,int c,int A,int B,int C,vector<int> L){
    if(cur==N){
        if(a>0&&b>0&&c>0){
            return abs(a-A)+abs(b-B)+abs(c-C)-30;
        }else{
            return INF;
        }
    }
    int ret0=dfs(cur+1,N,a,b,c,A,B,C,L);
    int ret1=dfs(cur+1,N,a+L[cur],b,c,A,B,C,L)+10;
    int ret2=dfs(cur+1,N,a,b+L[cur],c,A,B,C,L)+10;
    int ret3=dfs(cur+1,N,a,b,c+L[cur],A,B,C,L)+10;
    return(min(ret0,min(ret1,min(ret2,ret3))));
}

int main(){
    int N,A,B,C;
    cin>>N>>A>>B>>C;
    vector<int> L(N);
    REP(i,N)cin>>L[i];

    cout<<dfs(0,N,0,0,0,A,B,C,L)<<endl;
}

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 k = sc.nextInt();
        sc.close();

        int ret=1;
        for(int i=0;i<n;i++){
            if(i==0)
                ret *=k;
            else
                ret*=k-1;
        }
        System.out.println(ret);
    }

 }

Measured memory_bytes: 9044
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		//int N = Integer.parseInt(sc.nextLine());
		int N = sc.nextInt();
		int n = N % 2;
		int m = N / 2;

		if (n == 0) {
			System.out.println(m);
		} else {
			System.out.println(m + 1);
		}
	}
}


Measured memory_bytes: 23636
#include<stdio.h>

int main()
{
    int H,W,i,j;
    scanf("%d %d",&H,&W);
    while(!(H == 0 && W == 0)){
    	for(i=0; i<H;i++){
    		for(j=0; j<W;j++){
    			if((i+j)%2==0){
    				printf("#");
    			}else{
    				printf(".");
    			}
    		}
    		printf("\n");
    	}
    printf("\n");
    scanf("%d %d",&H,&W);
    }
    return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <memory.h>
#include <algorithm>
#define ll long long
using namespace std;

int n, A;
ll dp[50][2501][50], x[51];

ll solve(int i, int sum, int c) {
    if (i == n) {
//        printf("sum:%d c:%d\n", sum , c);
        return c == 0 ? 0 : ((sum / c) == A) && (sum % c) == 0;
    }
    ll &ret = dp[i][sum][c];
    if (ret != -1) return ret;
    ret = 0;
    ret = solve(i + 1, sum, c);
    ret += solve(i + 1, sum + x[i], c + 1);
    return ret;
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//    freopen("input.txt", "r", stdin);
    cin >> n >> A;
    memset(dp, -1, sizeof dp);
    for (int i = 0; i < n; ++i)
        cin >> x[i];
    cout << solve(0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 49152
#include <stdio.h>

long long int zuida(long long int a[],int n);
long long int get(long long int a,long long int b);
int main(void)
{
	int n,i;
	scanf("%d",&n);
	long long int a[n],m;
	
	for(i=0;i<n;i++)
	  scanf("%lld",&a[i]);
	m=zuida(a,n);
	printf("%lld",m);
	
	return 0;
}

long long int zuida(long long int a[],int n)
{
	int i;
	long long int m,yin,x,y;
	m=a[0];
	for(i=0;i<n-1;i++)
	{
		x=m;
		y=a[i+1];
		yin=get(x,y);
		m=x/yin*y/yin*yin;
	}
	return m;
}

long long int get(long long int a,long long int b)
{
	long long int num;
	if(a<b)
	{
		num=a;
		a=b;
		b=num;
	 }
	if(a%b==0)
	  return b;
	else
	  return get(b,a%b);
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;

int main()
{
	int n, k;
	cin>>n>>k;
	if(k%2==0){
		ll x=(ll)(n/k);
		ll y=(ll)((n+k/2)/k);
		cout<<x*x*x+y*y*y<<endl;
	}else{
		ll x=(ll)(n/k);
		cout<<x*x*x<<endl;
	}
    return 0;
}

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

int euclid(int a, int b){
  int aa = a, bb = b; /* 元の値を保存する */
  int r = 1; /* 適当な0でない値に初期化する */
  int temp;
  if(b > a){
    temp = b;
    b = a;
    a = temp;
  }
  
  while(r!= 0){
    r = a % b;
    a = b;
    b = r;
  }
  
  return aa / a * bb; /* 最小公倍数を計算して返す */
}

int divisor(vector<int> s){
  int x = s.size();
  int i;
  int r;
  if (x <= 0) return -1; /* サイズが0以下の配列は考えられない */
  if (x == 1) return s[0]; /* サイズが1の配列に対しては、その最初の要素の値をそのまま返す */
  for(i = 0; i <= x-2; i++){
   r =  euclid(s[i], s[i+1]);
   s[i+1] = r;
  }
  return r;
}

int main()
{
  int N,M;
  cin >> N >> M;
  vector<int> uselist(N);
  
  for(int i= 0; i < N; i++){
      int x;
      cin >> x;
      uselist[i] = (x/2);
  }
  
  int ans = uselist[0];
  bool flag = true;
  int G = divisor(uselist);
  
  for(int j = 0; j < N; j++){
      if(((G / uselist[j]) % 2) == 0) {
          flag = false;
          break;
      }
      else {
          continue;
      }
  }
  
  if(flag == true){
      int k = M / G;
      if((k % 2) == 0){
          cout << k/2<< endl;
      }
      else{
          cout << (k+1) /2 << endl;
      }
  }
  else{
      cout << 0 << endl;
  }
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
	int i,j,a[11],n,k;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=0;i<n;i++){
		for(j=i;j<n;j++){
			if(a[i]<a[j]){
				k=a[i];
				a[i]=a[j];
				a[j]=k;
			}
		}
	}
	a[0]/=2,k=0;
	for(i=0;i<n;i++)k+=a[i];
	printf("%d\n",k);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long digits(long long n){
    long long result = 0;
    while(n > 0) {
        result++;
        n /= 10;
    }
    return result;
}
int main() {
    ll n;
    cin >> n;
    ll ans = 1e9;
    for (ll i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) ans = min(ans, max(digits(i),digits(n / i)));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
if k>(n-1)*(n-2)//2:print(-1);exit()
m=n*(n-1)//2 - k
print(m)
for i in range(1,n+1):
  for j in range(i+1,n+1):
    if m<=0:break
    m-=1
    print(i,j)

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
  int l, r, d;
  cin >> l >> r >> d;
  
  int ans = 0;
  for (int i = l; i <= r; i++) if (i % d == 0) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b;cin>>a>>b;
	ll ans = max(a+b,a-b);
	cout<<max(ans,a*b)<<endl;































	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define all(v) v.begin(),v.end()
using namespace std;

signed main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    int q;
    cin>>q;
    rep(i,q){
        int c,b,e;
        cin>>c>>b>>e;
        if(c==0){
            cout<<*min_element(a+b,a+e)<<endl;
        }
        else{
            cout<<*max_element(a+b,a+e)<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3076
N=int(input())
A=list(map(int,input().split()))
mod=10**9+7

def gcd(a, b):
    if a == 0:
        return b
    else:
        g = gcd(b % a, a)
        return g

lcm=1

for a in A:
    lcm=lcm*a//gcd(a,lcm)

ans=0

for a in A:
    ans+=(lcm*pow(a,mod-2,mod))%mod
    ans%=mod

print(ans)

Measured memory_bytes: 74812
N = int(input())
H = list(map(int, input().split()))
cnt = 0
a =[]

for i in range(N - 1):
    
    
    if H[i + 1] <= H[i]:
        cnt += 1
    
    else:
        a.append(cnt)
        cnt = 0
        
        
        
    
    
    
a.append(cnt)     
print(max(a))
    

Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 205
#define MAX_P 1005
struct edge{ int to,cost,v; };

int N,M,P;

double dp[MAX_P][MAX_N];
vector<edge> G[MAX_N];

int main(){

  cin>>N>>M>>P;
  for(int i=0;i<M;i++){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a--,b--;
    G[a].push_back((edge){b,c,d});
    G[b].push_back((edge){a,c,d});
  }
  for(int i=0;i<MAX_P;i++)
    for(int j=0;j<MAX_N;j++)
      dp[i][j]=-1e9;

  dp[0][0]=0;
  for(int i=0;i<P;i++){
    for(int j=0;j<N;j++){
      if(dp[i][j]==-1e9)continue;
      for(int k=0;k<(int)G[j].size();k++){
        edge e=G[j][k];
        dp[i+1][j]=max(dp[i+1][j],dp[i][j]+(double)e.v/(double)e.cost);
        if(i+e.cost<=P)
          dp[i+e.cost][e.to]=max(dp[i+e.cost][e.to],dp[i][j]+e.v);
      }
    }
  }

  printf("%.10f\n",dp[P][0]);
  return 0;
}

Measured memory_bytes: 3512
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]

n = int(input())

ans = 1
for i in range(1,n+1):
    if (i*i > n):
        ans =  (i-1)**2
        break
print(ans)





Measured memory_bytes: 9152
#include<stdio.h>
int a, b, c;
long k;
int main(void){
  scanf("%d%d%d%ld", &a, &b, &c, &k);
  if(k&1){
    printf("%d\n", b-a);
  }else{
    printf("%d\n", a-b);
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
   ll n;
   cin >>n;
   ll a;
   vector <ll> e,o;
   for(ll i=0;i<n;i++) {
     cin >>a;
     if(i%2==0) o.push_back(a);
     else e.push_back(a);
   }
   if(n%2==0){
     reverse(e.begin(),e.end());
     ll es=e.size(),os=o.size();
     for(ll i=0;i<es;i++) cout <<e[i]<<" ";
     for(ll i=0;i<os;i++){
       if(i==os-1) cout <<o[i]<<endl;
       else cout <<o[i]<<" ";
     }
   }
   else{
     reverse(o.begin(),o.end());
     ll es=e.size(),os=o.size();
     for(ll i=0;i<os;i++) cout <<o[i]<<" ";
     for(ll i=0;i<es;i++){
       if(i==es-1) cout <<e[i]<<endl;
       else cout <<e[i]<<" ";
     }
   }
}


Measured memory_bytes: 3948
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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() {
    int n,w;
    cin >> n >> w;
    ll weight[110];
    ll value[110];
    vector<vector<ll>>dp(n+10,vector<ll>(w+100));
    rep(i,n) {
        cin >> weight[i] >> value[i];
    }
    rep(i,n)rep(j,w+1) {
        if(j>=weight[i]) chmax(dp[i+1][j],dp[i][j-weight[i]]+value[i]);
        chmax(dp[i+1][j],dp[i][j]);
    }
    cout << dp[n][w] << endl;
}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100000;

char S[MAXN + 2];

int main() {
	int N, K;
	cin >> N >> K >> S;
	int l = 0, ls = 0, r = 1, rs = 0, ans = 1;
	K <<= 1;
	if(S[0] == '0') {
		do {
			rs += S[r] ^ S[r - 1];
			r++;
		} while(r < N && rs + (S[r] ^ S[r - 1]) <= K - 1);
		ans = r - l;
		do
			++l;
		while(S[l] == '0');
		++K;
	}
	if(r < N) {
		do {
			do {
				rs += S[r] ^ S[r - 1];
				r++;
			} while(r < N && rs + (S[r] ^ S[r - 1]) <= K);
			// cout << l << ' ' << r << endl;
			ans = max(ans, r - l);
			if(!(r < N))
				break;
			while(S[l] == '1')
				l++;
			while(S[l] == '0')
				l++;
			K += 2;
		} while(true);
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
# 2019-11-24 20:59:47(JST)
import sys
#import numpy as np

days = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
def main():
    s = sys.stdin.readline().rstrip()
    ans = 7 - days.index(s)
    print(ans)
    
if __name__ == '__main__':
    main()


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

rate = 0
if X >= 1800:
    rate = 1
elif X >= 1600:
    rate = 2
elif X >= 1400:
    rate = 3
elif X >= 1200:
    rate = 4
elif X >= 1000:
    rate = 5
elif X >= 800:
    rate = 6
elif X >= 600:
    rate = 7
else:
    rate = 8

print(rate)


Measured memory_bytes: 9176
#include<iostream>
using namespace std;
int z,n,m,t[1<<17],p,x,i,j;
main(){
  for(cin>>n;i++<n;z+=t[i])cin>>t[i];
  for(cin>>m;j++<m;cout<<z-t[p]+x<<endl)cin>>p>>x;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    int counter = 0;

    while (input.ready())
    {
      String[] INPUT_STR = input.readLine().split(" ");
      int FROM_YEAR = Integer.valueOf(INPUT_STR[0]);
      int TO_YEAR = Integer.valueOf(INPUT_STR[1]);

      if (TO_YEAR == 0)
      {
        break;
      }

      if (counter > 0)
      {
        System.out.println();
      }
      counter++;

      ArrayList<Integer> ansList = leapYearCount(FROM_YEAR, TO_YEAR);

      if (ansList.size() == 0)
      {
        System.out.println("NA");
        continue;
      }

      for (Integer each : ansList)
      {
        System.out.println(each);
      }
    }

  }

  private static ArrayList<Integer> leapYearCount(int fromYear, int toYear)
  {
    ArrayList<Integer> yearList = new ArrayList<>();
    for (int i = fromYear; i <= toYear; i++)
    {
      if (isLeapYear(i))
      {
        yearList.add(i);
      }
    }
    return yearList;
  }

  private static boolean isLeapYear(int year)
  {
    if (year % 4 != 0)
    {
      return false;
    }

    if (year % 100 == 0)
    {
      if (year % 400 == 0)
      {
        return true;
      }
      return false;
    }
    return true;
  }
}

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

void solve(long long X, long long Y, long long Z)
{
    cout << Z << " " << X << " " << Y << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long X;
    scanf("%lld", &X);
    long long Y;
    scanf("%lld", &Y);
    long long Z;
    scanf("%lld", &Z);
    solve(X, Y, Z);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	string la = "", tmp = "";
	la += s[0];
	int cnt = 1;
	for (int i = 1; i < s.length(); i++)
	{
		tmp += s[i];
		if (tmp != la)
		{
			cnt++; la = tmp;
			tmp = "";
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 640
x, n = map(int, input().split())
if n == 0:
    print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    p2 = [i - x for i in p]
    for i in range(100):
        if not -i in p2:
            print(x - i)
            break
        if not i in p2:
            print(x + i)
            break

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

using namespace std;

int main(){
	char x[20];
	scanf(" %s", x);
	int k = strlen(x);
	int temp = 0;
	for(int i = 0; i < k; i ++){
		temp += x[i] == 'x';
	}
	if(temp <= 7){
		printf("YES");
	}else{
		printf("NO");
	}
	return 0;
}


Measured memory_bytes: 384
# -*- coding: utf-8 -*-
import sys
INF=10**9
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()

def main():
    l=list(map(int,list(input())))
    for i in range(8):
        tmp=l[:]
        for j in range(3):
            if (i>>j)&1:
                tmp[j+1]*=-1
        if sum(tmp)==7:
            print(tmp[0],end='')
            for x in tmp[1:]:
                if x<0:
                    print(x,end='')
                else:
                    print('+',x,sep='',end='')
            print('=7')
            exit()

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    ll A, B, C, D; cin >> A >> B >> C >> D;
    ll E = C * D / GCD(C, D);
    ll x = B / C;
    ll y = B / D;
    ll z = B / E;
    ll xx = (A - 1) / C;
    ll yy = (A - 1) / D;
    ll zz = (A - 1) / E;
    cout << ((B - A + 1) - (x + y - z)) + (xx + yy - zz) << endl;
}


Measured memory_bytes: 256