akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
#define int ll

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	vector<int> ps;
	for (int i = 0; i < SZ(s); i++) {
		if (s[i] == '<') {
			ps.pb(i);
		}
	}
	ps.pb(SZ(s));
	vector<int> ans(SZ(s) + 1);
	int sum = 0;
	for (int i = 0; i <= SZ(s); i++) {
		auto it = lower_bound(all(ps), i);
		if (!i || s[i - 1] == '>') {
			ans[i] = *it - i;
		}
		else {
			ans[i] = max(ans[i - 1] + 1, *it - i);
		}
		sum += ans[i];
		//cout << ans[i] << '\n';
	}
	cout << sum << '\n';
}

Measured memory_bytes: 9104
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  vector<int> sg(m + 1);
  vector<bool> visit(n + 1);
  for (int i = 1; i <= m; ++i) {
    fill(visit.begin(), visit.end(), false);
    for (int j = 0; j < n && a[j] <= i; ++j) {
      visit[sg[i - a[j]]] = true;
    }
    for (int j = 0; j <= n; ++j) {
      if (!visit[j]) {
        sg[i] = j;
        break;
      }
    }
  }
  puts(sg[m] ? "First" : "Second");
  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui long long
#define ull unsigned long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define vii vector<vi>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define gc() getchar()
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
inline ll rd()
{
	ll x=0,w=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();
	if(c=='-')c=gc(),w=-1;while(isdigit(c))x=x*10+c-48,c=gc();return x*w;
}
const int N=1000005;
int n,ans=N,p[N],a[N];char s[N];
void chk(int mn)
{
	int c=0,mx=0;
	rep(i,1,n)
	{
		if(s[i]=='0')c++;else if(s[i]=='1')c--;
		else if(c-1+p[i+1]>=mn)c--;else c++;
		mx=max(mx,c);if(c<mn){mx=1e9;break;}
	}
	ans=min(ans,mx-mn);
}
int main()
{
	scanf("%s",s+1);n=strlen(s+1);
	per(i,n,1)p[i]=min(0,p[i+1]+(s[i]=='1'?-1:1));
	int c=0,mn=0;
	rep(i,1,n)
	{
		if(s[i]=='0')c++;else if(s[i]=='1')c--;else c++;
		mn=min(mn,c);
	}
	chk(mn);chk(mn-1);
	printf("%d\n",ans);return 0;
}


Measured memory_bytes: 8648
#include <iostream>
#include <algorithm>
#include <functional>
#define int long long
using namespace std;

int n, p;
int w[100000], b[100000];
int border;
int s[100000];

signed main() {
	int i;
	
	cin >> n >> p;
	for (i = 0; i < n; i++) cin >> w[i] >> b[i];
	
	for (i = 0; i < n; i++) s[i] = (100 - p) * w[i] + p * b[i];
	sort(s, s + n, greater<int>());
	
	for (i = 0; i < n; i++) border += p * b[i];
	
	int sumS = 0;
	for (i = 0; i < n; i++) {
		sumS += s[i];
		if (sumS >= border) break;
	}
	cout << i + 1 << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	
	public static int play(char[] seq, boolean first){
		int left = 0, right = 0;
		int count = 0;
		
		if(first){
			left = seq[0] - '0';
		}else{
			right = seq[0] - '0';
		}
		
		first = !first;
		
		for(int i = 1; i < seq.length; i++){
			int next = seq[i] - '0';
			
			if(!first){
				final int l_mod = (left - 1) % 3;
				final int n_mod = (next - 1) % 3; //new_right
				
				if(l_mod <= n_mod){
					right = next;
					first = !first;
				}else{
					right = left;
					left = next;
					count++;
				}
			}else{
				final int r_mod = (right - 1) % 3;
				final int n_mod = (next  - 1) % 3; //new left
				
				if(n_mod <= r_mod){
					left = next;
					first = !first;
				}else{
					left = right;
					right = next;
					count++;
				}
			}
		}
		
		return count;
	}
	
	public static void main(String[] args){
		final Scanner sc = new Scanner(System.in);
		
		while(true){
			String in = sc.next();
			
			if("#".equals(in)){
				break;
			}
			
			char[] input = in.toCharArray();
			
			System.out.println(Math.min(play(input, true), play(input, false)));
			
		}
		
		
	}

}

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

int main(){
  int N;
  int t;
  int c;
  
  cin >> N;
  
  t = N;
  c = 0;
  
  while(t > 0){
    c += t%10;
    t /= 10;
  }
  
  if(N%c == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}
    
    

Measured memory_bytes: 256
// https://beta.atcoder.jp/contests/abc110/submissions/3257311

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

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

using namespace std;

int main(){
  string s;
  cin >> s;
  int len = s.length();
  for(int i = 0; i < len; i++){
    if(s[i] == '1') cout << 9;
    else if(s[i] == '9') cout << 1;
    else cout << s[i];
  }
  cout << endl;
  return 0;
}


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

typedef long long ll;

const ll inf = 1e17 + 2;
const int N = 1e4 + 10;

int pos;

vector<int> operator ^ (vector<int> a, vector<int> b) {
  vector<int> c(3);
  for(int i = 0; i < 3; i++) {
    c[i] = a[i] ^ b[i];
  }
  return c;
}

ll f[62][2][3];

vector<int> calc(ll n, ll r, ll x) {
  vector<int> cur(3);
  if(r < 0) {
    return cur;
  }
  memset(f, 0, sizeof f);
  f[60][1][0] = 1;
  for(int i = 59; ~i; i--) {
    for(int j = 0; j < 3; j++) {
      if(f[i + 1][0][j]) {
	f[i][0][(j << 1) % 3] ^= 1;
	if(n >> i & 1) {
	  f[i][0][((j << 1) | 1) % 3] ^= 1;
	}
      }
      if(f[i + 1][1][j]) {
	if(r >> i & 1) {
	  f[i][0][(j << 1) % 3] ^= 1;
	  if(n >> i & 1) {
	    f[i][1][(j << 1 | 1) % 3] ^= 1;
	  }
	} else {
	  f[i][1][(j << 1) % 3] ^= 1;
	}
      }
    }
  }
  x = (x % 3 + 3) % 3;
  for(int i = 0; i < 3; i++) {
    cur[(x + i) % 3] = f[0][0][i] ^ f[0][1][i];
  }
  return cur;
}

int n;
ll x[N], y[N];

bool check(ll lim) {
  vector<int> ans(3);
  for(int i = 1; i <= n; i++) {
    ans = ans ^ calc(y[i] + inf, lim - x[i], x[i]);
  }
  return ans[pos];
}

bool lightnow(ll x, ll y) {
  if(y < 0 || y > x) {
    return 0;
  }
  return (x & y) == y;
}

ll limit(ll cur, ll op) {
  for(int i = 60; ~i; i--) {
    bool light = false;
    ll tmp = cur + (op << i);
    for(int j = 1; j <= n; j++) {
      light ^= lightnow(y[j] + inf, tmp - x[j]);
    }
    if(light) {
      cur = tmp;
    }
  }
  return cur;
}

int main(void) {
  scanf("%d", &n);
  vector<int> cur(3);
  for(int i = 1; i <= n; i++) {
    scanf("%lld%lld", &x[i], &y[i]);
    cur = cur ^ calc(y[i] + inf, y[i] + inf, x[i]);
  }
  for(; !cur[pos]; pos++);
  ll l = -inf * 10, r = inf * 10;
  while(l < r) {
    ll mid = l + r >> 1;
    if(check(mid)) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  long long ansl = limit(l, -1), ansr = limit(l, 1);
  cout << ansl << " " << ansr - ansl - inf << endl;
  return 0;
}


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

#define   ll     long long int

const int N = 200005;
ll ara[N];
ll lft[N];
ll rht[N];

int main( )
{
    ll n, i, j, k, mn = 1e18;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
        lft[i] = lft[i - 1] + ara[i];
    }
    for (i = n; i >= 1; i--) {
        rht[i] = rht[i + 1] + ara[i];
    }
    for (i = 2; i <= n; i++) {
        mn = min(mn, abs(lft[i - 1] - rht[i]));
    }
    cout << mn << '\n';
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(void)
{
    string s;
    cin >> s;
    bool flag = true;

    for(int i = 0; (i < s.length()) && (flag == true); i++)
    {
        if(i%2 == 1)
        {
            if(s[i] == 'R')
            {
                flag = false;
            }
        }
        else
        {
            if(s[i] == 'L')
            {
                flag = false;
            }
        }
    }

    if(flag)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}

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

N = int(input())
a = [0 for i in range(N)]
S = 0
st = input().split()
for i in range(N):
    a[i] = int(st[i])
    S += a[i]
m = 4 * 10**14
T = 0
for i in range(0, N-1):
    T += a[i]
    M = abs(S-2*T)
    if M < m:
        m = M
print(m)


Measured memory_bytes: 25336
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld inf=pow(10,10);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool check(ll mid,ll n,ll a,ll b,vector<ll>h){
  ll num=0;
  ll dis=a-b;
  rep(i,n){
    h[i]-=b*mid;
    if(h[i]>0){
      num+=(h[i]+dis-1)/dis;
    }
  }
  return mid>=num;
}

void solve(){
  ll n,a,b;cin>>n>>a>>b;
  vector<ll>h(n);
  rep(i,n)cin>>h[i];
  ll right=pow(10,10);
  ll left=0;
  while(right-left>1){
    ll mid=left+(right-left)/2;
    if(check(mid,n,a,b,h))right=mid;
    else left=mid;
  }
  cout<<right<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int a[100100];
int main()
{
	int n,k;
	int i,j;
	cin>>n>>k;
	int t=1;
	getchar();
	while(t<=n){
		char x;
		x=getchar();
		if(x=='L') a[t]=1;
		else if(x=='R')a[t]=2;
		t++;
	}
	int pre=a[1];
	int cnt=1;
	for(i=2;i<=n;i++){
		if(a[i]==pre) continue;
		else if(a[i]!=pre&&i!=n){
			pre=a[i];
			cnt++;
		}
		else cnt+=1;
	}
	cnt-=k*2;
	if(cnt<=0)cout<<n-1<<endl;
	else cout<<n-cnt<<endl;
} 

Measured memory_bytes: 640
using System;
 
namespace Application
{
	class Solution
	{
		static void Main(string[] args)
		{
			var inputWords = Console.ReadLine().Split(' ');
 
			var billCount = int.Parse(inputWords[0]);
			var moneySum = int.Parse(inputWords[1]);
 
			var bill1Value = 10000;
			var bill2Value = 5000;
			var bill3Value = 1000;
 
			for (var i = billCount; i >= 0; i--)
			{
				for (var j = billCount - i; j >= 0 ; j--)
				{
					var k = billCount - (i + j);
					var sum = i * bill1Value + j * bill2Value + bill3Value * k;
					if (sum == moneySum)
					{
						Console.WriteLine($"{i} {j} {k}");
						return;
					}
				}
			}
 
			Console.WriteLine("-1 -1 -1");
		}
	}
}

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

using namespace std;

void solve(int n){

    vector<int> a(n);

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

    long long sum = accumulate(a.begin(), a.end(), 0);
    double mean = sum / (double)n;

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

    cout << ans << endl;

    return;
}

int main(){

    int n;
    while(cin >> n, n){
        solve(n);
    }

    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;


vector<int> dp;

vector<int> toporogical_sort(const vector<vector<int> > g){
	const int n = g.size();
	vector<int> in_deg(n,0);

	for(int i = 0; i < n; i++){
		for(int j = 0; j < g[i].size(); j++){
			in_deg[g[i][j]]++;
		}
	}
	
	stack<int> S;
	for(int i = 0; i < n; i++){
		if(in_deg[i]==0) S.push(i);
	}

	vector<int> res;
	while(!S.empty()){
		int x = S.top();S.pop();
		res.push_back(x);
		for(int i = 0; i < g[x].size(); i++){
			in_deg[g[x][i]]--;
			if(in_deg[g[x][i]] == 0) S.push(g[x][i]);
		}
	}

	return res;
}

void longest_path(int x,vector<vector<int> > g){
	for(int i = 0; i < g[x].size(); i++){
		if(dp[x] + 1 < dp[g[x][i]]) return;
		else{
			dp[g[x][i]] = dp[x]+1;
			longest_path(g[x][i],g);
		}
	}
	return;
}

int main()
{
	int n,m;
	cin>>n>>m;
	vector<vector<int> > g(n,vector<int>());
	for(int i = 0; i < m; i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(b);
	}
	// for(int i = 0; i < n; i++){
	// 	cout << i << endl;
	// }

	vector<int> t_sorted = toporogical_sort(g);
	// for(int i = 0; i < n; i++){
	// 	cout << t_sorted[i] << endl;
	// }
	dp.resize(n,0);
	// for(int i = 0; i < n; i++){
	// 	longest_path(t_sorted[i],g);
	// }

	for(int i = 0; i < n; i++){
		for(int j = 0; j < g[t_sorted[i]].size(); j++){
			dp[g[t_sorted[i]][j]] = max(dp[g[t_sorted[i]][j]],dp[t_sorted[i]]+1);
		}
	}

	int ans = 0;
	for(int i = 0; i < n; i++){
		ans = max(ans,dp[i]);
	}
	cout << ans << endl;



	return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

const long long MOD = 1e9+7;


#define INPUT(x)                freopen(x,"r",stdin)
#define OUTPUT(x)               freopen (x,"w",stdout)


#define pb                      push_back
#define endl                    '\n'
#define LCM(a,b)                (a/__gcd(a,b))*b
#define GCD(a,b)                __gcd(a,b)
#define SP(x,y)                 fixed<<setprecision((y))<<(x)
#define PI                      acos(-1.0)
#define distance(x1,y1,x2,y2)   sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define MAX                     1e9 + 9

#define taratari                ios_base::sync_with_stdio(0);cin.tie(NULL);


int main()
{
    taratari

    ll n;
    cin>>n;

    ll a[n*3];

    for(ll i=0;i<3*n;i++)
    {
        cin>>a[i];
    }

    sort(a,a+3*n);

    ll sum=0;

    for(int i=n;i<3*n;i=i+2)
    {
        sum+=a[i];
    }


    cout<<sum;




    return 0;

}



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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    char a, b;
    cin >> a >> b;

    if (a == 'H') {
        if (b == 'H') {
            cout << 'H';
        } else {
            cout << 'D';
        }
    } else {
        if (b == 'H') {
            cout << 'D';
        } else {
            cout << 'H';
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b ,c;
    cin >> a >> b >> c;
    int count=0;
    for(int i=min(a,b);i>=1;--i){
        if(a%i==0&&b%i==0) count++;
        
        if(c==count){
          cout << i <<endl;
          return 0;          
        } 
    }
    return 0;
}

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

#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

const int N = 100005;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int m, k;
    cin >> m >> k;
    if (m == 1) {
        if (k == 0) {
            cout << "0 0 1 1\n";
        } else {
            cout << -1 << endl;
        }
        return 0;
    }
    if (k >= (1 << m)) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 0; i < (1 << m); i++) {
        if (i == k) continue;
        cout << i << " ";
    }
    cout << k << " ";
    for (int i = (1 << m) - 1; i >= 0; i--) {
        if (i == k) continue;
        cout << i << " ";
    }
    cout << k << endl;
    return 0;
}


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

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 200005
#define IN freopen("nocross.in","r",stdin)
#define OUT freopen("nocross.out","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
#define SZ(z) ((int)z.size())

// using namespace __gnu_pbds;
using namespace std ;

// typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int cnt[30];

int main()
{
    char s[30] ;

    int i, j, k, l, m, n ;

    scanf("%s",s) ;

    l = strlen(s) ;

    memset(cnt,-1,sizeof(cnt)) ;

    if(l!=26)
    {
        for(i=0 ; i<l ; i++) cnt[ s[i]-'a'] = i ;
        for(i=25 ; i>=0 ; i--)
        {
            if( cnt[i] == -1 ) s[l] = i + 'a' ;
        }
        s[l+1] = '\0' ;
        printf("%s\n",s) ;
        return 0 ;
    }

    if(l==26)
    {
        for(i=l-1 ; i>=0 ; i--)
        {
            cnt[ s[i]-'a' ] = i ;
            for(j= s[i]-'a' + 1 ; j<26 ; j++ )
            {
                if( cnt[j]!=-1 )
                {
                  //  s[ cnt[j] ] = s[i] ;
                    s[i] = j+ 'a' ;
                    s[i+1] = '\0' ;
                    printf("%s\n",s) ;
                    return 0 ;
                }
            }
        }
    }
    printf("-1\n") ;
    return 0 ;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

// https://atcoder.jp/contests/abc122/tasks/abc122_b

int main() {
  string s;
  cin >> s;
  int res = 0;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] != 'A' && s[i] != 'C' && s[i] != 'G' && s[i] != 'T') continue;
    res = max(res, 1);
    for (int j = i + 1; j < (int)s.size(); ++j) {
      if (s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T') break;
      res = max(res, j - i + 1);
    }
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3584
// Created by  Ambesh kumar
#include "bits/stdc++.h"

//I already compile this file in my computer system to save the time
//if get the compiler error then you should change this header to
// #include "bits/stdc++.h"  ---> #include <bits/stdc++.h>

using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0, lim - 1);
	return uid(rang);
}
int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1000000007;
const int N = 3e5, M = N;
//=================================================================================================================================//

vi g[N];
int a[N];

void solve() {
	int i, j, n, m;
	cin >> n;

	int arr[n + 1];

	arr[0] = 0;
	for (int i = 1; i < n + 1; i++)
		cin >> arr[i];

	ll count = 0;


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

		if (arr[i] % 2 != 0)
			count++;



	}


	cout << count << '\n' ;
}





int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());

	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}

	return 0;
}







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

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    map<int, int> m;
    rep(i, N) {
        if (m[ A[i] ] > 0) {
            m[ A[i] ]--;
        } else {
            m[ A[i] ]++;
        }
    }

    int ans = 0;
    for (auto i : m) {
        if (i.second > 0) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 5376
import sys
from math import gcd
input = sys.stdin.readline
N, M = map(int, input().split())
S = list(input())[: -1]
T = list(input())[: -1]
g = gcd(N, M)
ln = N * M // g
x = 0
y = 0
while x < N and (y < M):
  if S[x] != T[y]:
    print(-1)
    exit(0)
  x += ln // M
  y += ln // N
print(ln)

Measured memory_bytes: 73104
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

vector<pair<ll, int>> fac;
void PrimeFactorInit(ll x){
    if(x >= 2){
        for(ll ii = 2; ii <= x; ii++){
            ll i = ii;
            if(i * i > x)break;
            if(x % i == 0){
                int cnt = 0;
                while(x % i == 0){
                    cnt++;
                    x /= i;
                }
                pair<ll, int> p;
                p.first = i;
                p.second = cnt;
                fac.push_back(p);
            }
        }
        if(x > 1){
            pair<ll, int> p;
            p.first = x;
            p.second = 1;
            fac.push_back(p);
        }
    }
}

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

    if(n == 1){
        cout << 0 << endl;
        return 0;
    }

    PrimeFactorInit(n);

    int ans = 0;

    int m = fac.size();
    rep(i,m){
        int x = fac[i].second;
        srep(j,1,20){
            if(x < j)break;
            x -= j;
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3624
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <iomanip>
#include <cstring>
#define INF 1000001
typedef long long llong;
using namespace std;



int main() {
	int max = -INF;
	int min = INF;
	llong sum = 0;
	int N, a_i;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a_i;
		if (max < a_i)max = a_i;
		if (min > a_i)min = a_i;
		sum += a_i;
	}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}




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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
#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>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>

#define pb(a) push_back(a)
#define mp make_pair

#define dump(x)  cout << #x << " = " << (x) << "\n";
#define COUT(x) cout<<(x)<<"\n"


int main()
{
    int n, m, c = 0;
    cin >> n >> m >> c;

    vector<int> b(m);

    REP(i, m)
    {
        cin >> b[i];
    }
    int ct = 0;

    REP(i, n)
    {
        int num = 0;
        int buf = 0;
        REP(j, m)
        {
            cin >> buf;
            num += b[j] * buf;
        }
        num += c;
        if (num > 0)
        {
            ct++;
        }
    }

    COUT(ct);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  int i = 0, cnt = 0, num[10000];

  do {
    scanf("%d", &num[i]);
    i++;
    cnt++;
  }while(num[i-1] != 0);

  for(i = 0; i < cnt - 1; i++) {
    printf("Case %d: %d\n", i + 1, num[i]);
  }

  return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
 
 
#define pb push_back
#define nl puts ("")
#define sp printf ( " " )
#define phl printf ( "hello\n" )
#define ff first
#define ss second
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define MP make_pair
#define FOR(i,x,y) for(vlong i = (x) ; i <= (y) ; ++i)
#define ROF(i,x,y) for(vlong i = (y) ; i >= (x) ; --i)
#define CLR(x,y) memset(x,y,sizeof(x))
#define UNIQUE(V) (V).erase(unique((V).begin(),(V).end()),(V).end())
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define SQ(x) ((x)*(x))
#define ABS(x) ((x)<0?-(x):(x))
#define FABS(x) ((x)+eps<0?-(x):(x))
#define ALL(x) (x).begin(),(x).end()
#define LCM(x,y) (((x)/gcd((x),(y)))*(y))
#define SZ(x) ((vlong)(x).size())
#define NORM(x) if(x>=mod) x-=mod;if(x<0) x+=mod;
#define MOD(x,y) (((x)*(y))%mod)
#define ODD(x) (((x)&1)==0?(0):(1))
#define Set(N,cur) N=(N|(1LL<<cur))
#define Reset(N,cur) N=(N&(~(1LL<<cur)))
#define Check(N,cur) (!((N&(1LL<<cur))==0))
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL)
#define dump(x) cerr<<"~ "<<#x<<" = "<<x<<endl
//Imran addition
#define rep(i,n) for(int i = 1; i <= n; i++)
#define mem CLR
#define pf printf
#define sc scanf
#define endl "\n"
#define gi(k) scanf("%d",&k)
#define gl(k) scanf("%lld",&k)
#define NMAX 2147483647
#define LMAX 9223372036854775807LL
 
using namespace std;
 
 
#define LL long long
#define LLU long long unsigned int
typedef long long vlong;
typedef unsigned long long uvlong;
typedef pair < int, int > pii;
typedef pair < vlong, vlong > pll;
typedef vector<int> vi;
typedef vector<vlong> vl;
typedef vector<pll> vll;
 
inline vlong gcd ( vlong a, vlong b ) {
    a = ABS ( a ); b = ABS ( b );
    while ( b ) { a = a % b; swap ( a, b ); } return a;
}
 
 
const vlong inf = 2147383647;
const vlong mod = 1000000007;
const double pi = 2 * acos ( 0.0 );
const double eps = 1e-9;
 
#define N 100005

vlong ar[N],br[N],cpos[N],cneg[N]; 
 
int main () {
 
 	#ifdef forthright48
    freopen ( "00_input.txt", "r", stdin ); //freopen ( "00_output.txt", "w", stdout );
 	#endif
 
	int n,k,pos = 0, neg = 0; 
    vlong ans = inf, x;

    cin >> n >> k;

    rep(i,n) {
        gl(x);

        if(x <= 0) {
            ar[++neg] = x;
        }

        else {
            br[++pos] = x; //dump(x);
        }
    }

    for(int i = 1, j = neg; i < j; i++, j--) {
        swap(ar[i],ar[j]);
    }
    
    rep(i,neg) {
        ar[i] = -ar[i]; //dump(ar[i]);
    }

    rep(i,neg) {
        cneg[i] = ar[i];// + cneg[i-1];
    }

    rep(i,pos) {
        cpos[i] = br[i];// + cpos[i-1];
    }

    FOR(i,0,pos) {
        if(k-i <= neg && i <= k) {
            ans = min(ans, cneg[k-i] + cpos[i] + cpos[i] );
        }
    }

    FOR(i,0,neg) {
        if(k-i <= pos && i <= k) {
            ans = min(ans, cpos[k-i] + cneg[i] + cneg[i]);
        }
    }

    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 1792
import sys
from collections import deque
#import numpy as np
import math
#sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    return

if __name__=='__main__':
    d,t,s = IL()
    if d<=s*t:
        print("Yes")
    else:
        print("No")
    solve()

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

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

  for(int i = 1; i <= n; i += 2){
    int c = 0;
    for(int j = 1; j <= i; j++){
      if(i % j == 0) c++;
    }
    if(c == 8) ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.LinkedList;
import java.util.Scanner;

class Main {
	int a,b,c,d,e,f;

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

	Main(Scanner sc) {
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		d = sc.nextInt();
		e = sc.nextInt();
		f = sc.nextInt();
	}

	void solve() {
		double max = 0;
		int water = 100 * a;
		int sugar = 0;
		LinkedList<String> memo = new LinkedList<String>();
		for(int i=1;100*a*i<=f;i++){
			for(int j=0;100*b*j+100*a*i<=f;j++){
				for(int k=0;k*c<=(b*j+a*i)*e&&100*b*j+100*a*i+k*c<=f;k++){
					int l = Math.min((f-(100*b*j+100*a*i+k*c))/d, ((b*j+a*i)*e-k*c)/d);
					if(!memo.contains(String.valueOf(100*b*j+100*a*i)+" "+String.valueOf(k*c+l*d))){
						double n = 100.0*(k*c+l*d) / (k*c+l*d+100*b*j+100*a*i);
						//System.out.printf("水:%d 砂糖：%d 濃度:%f\n",100*b*j+100*a*i,k*c+l*d,n);
						if(n > max){
							max = n;
							water = 100*b*j+100*a*i;
							sugar = k*c+l*d;
						}
						memo.add(String.valueOf(100*b*j+100*a*i)+" "+String.valueOf(k*c+l*d));
					}
				}
			}
		}
		System.out.println((sugar+water)+" "+sugar);
	}
}

Measured memory_bytes: 21972
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
sys.setrecursionlimit(10**6)

def check(n,a,b,c,t,l):
    tmp = 0
    if len(n) > l:
        return 0
    if n == "":
        return check(n+"3",a+1,b,c,t,l) + check(n+"5",a,b+1,c,t,l) + check(n+"7",a,b,c+1,t,l) + tmp
    if a and b and c and int(n) <= t:
        tmp = 1
    return check(n+"3",a+1,b,c,t,l) + check(n+"5",a,b+1,c,t,l) + check(n+"7",a,b,c+1,t,l) + tmp

def main():
    N = int(input())
    l = len(str(N))
    print(check("",0,0,0,N,l))

if __name__ == '__main__':
    main()


Measured memory_bytes: 6260
#include <cstdio>
#include <cmath>
#define PI 3.1415926535
using namespace std;

int n;

void koch_curve(double p1x,double p1y,double p2x,double p2y, int current) {
  if(current == n) {
    printf("%.8lf %.8lf\n",p2x,p2y);
    return;
  }

  // p1,p2????????????
  double sx = (2.0*p1x + p2x) / 3.0;
  double sy = (2.0*p1y + p2y) / 3.0;
  double tx = (p1x + 2.0*p2x) / 3.0;
  double ty = (p1y + 2.0*p2y) / 3.0;

  // s,t????????£????§???¢??¨????????§?¨?(ux,uy)????±???????
  double ux = cos(PI / 3.0)*(tx - sx) - sin(PI / 3.0)*(ty - sy) + sx;
  double uy = sin(PI / 3.0)*(tx - sx) + cos(PI / 3.0)*(ty - sy) + sy;

  koch_curve(p1x,p1y,sx,sy,current+1);
  koch_curve(sx,sy,ux,uy,current+1);
  koch_curve(ux,uy,tx,ty,current+1);
  koch_curve(tx,ty,p2x,p2y,current+1);
}

int main() {
  scanf("%d",&n);
  double stx = 0.0; double sty = 0.0;
  double enx = 100.0; double eny = 0.0;

  printf("%.8lf %.8lf\n",stx,sty);
  koch_curve(stx,sty,enx,eny,0);
}

Measured memory_bytes: 1072
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  string S;
  cin >> S;
  m--;
  if(S[m] == 'A')S[m] = 'a';
  if(S[m] == 'B')S[m] = 'b';
  if(S[m] == 'C')S[m] = 'c';
  cout << S << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,K;
  cin>>N>>K;
  ll ans=0;
  rep(i,N+1){
    if(i and K<i) ans+=max(0,N/i)*max(0,i-K)+max(0,N%i-K+1);
  }
  if(K==0) ans-=N;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)

def main():
    N = int(input())
    
    h = map(int,input().split())
    a = map(int,input().split())
    
    def segfunc(x,y):
        return max(x,y)
    
    def update(k,x):
        k += num-1
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[2*k+1],seg[2*k+2])
            
    def query(p,q):
        if q <= p:
            return ide_ele
        p += num-1
        q += num-2
        ret = ide_ele
        while q-p>1:
            if p&1 == 0:
                ret = segfunc(ret,seg[p])
            if q&1 == 1:
                ret = segfunc(ret,seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        ret = segfunc(segfunc(ret,seg[p]),seg[q])
        return ret
        
    ide_ele = 0
    num = 2**N.bit_length()
    seg = [ide_ele]*2*num

    
    dp = [0]*(N+1)
    
    for he,be in zip(h,a):
        tmp = query(0,he)+be
        if tmp > dp[he]:
            dp[he] = tmp
            update(he,tmp)
    
    print(query(0,N+1))

if __name__ == "__main__":
    main()


Measured memory_bytes: 92252
#include <bits/stdc++.h>
using namespace std;
int main() {
  int h,w; cin>>h>>w;
  int r[h]={0},c[w]={0};
  char a[h][w];
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin>>a[i][j];
      if(a[i][j]=='#') r[i]++,c[j]++;
    }
  }
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(r[i]&&c[j]) cout<<a[i][j];
    }
    if(r[i]) cout<<endl;
  }
}

Measured memory_bytes: 3612
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if(m1!=m2){
    cout << "1\n";
  }else{
    cout <<"0\n";
  }
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=100005;
const int mod=1e9+7;
int n;
pii a[maxn*2];

int main(){
	scanf("%d",&n);
	rep(i,n)scanf("%d",&a[i].fst),a[i].snd=0;
	rep(i,n)scanf("%d",&a[i+n].fst),a[i+n].snd=1;
	sort(a,a+2*n);
	int ans=1,cnt0=0,cnt1=0;
	rep(i,2*n){
		if(a[i].snd==0){
			if(cnt1)ans=1LL*ans*cnt1%mod,cnt1--;
			else cnt0++;
		}
		else{
			if(cnt0)ans=1LL*ans*cnt0%mod,cnt0--;
			else cnt1++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    long x = nextLong();

    long ans = 0;

    ans += (x/500) * 1000;  // count 500

    x -= (x/500)*500;

    ans += (x/5) * 5;

    x -= (x/5)*5;

    System.out.println(ans);

  }

  static int lcm(int a,int b){
    return a*b*gcd(a,b);
  }

  static int gcd(int a,int b){
    if(a%b!=0){
      return gcd(b,a%b);
    }
    else{
      return b;
    }
  }

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)
#define dump(x) cerr << #x " = " << x << endl
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, (int)xs.size() - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }

bool solve1(int n, vector<int> a, const vector<int> & b, int cnt) {
// dump(a);
// dump(b);
// dump(cnt);
    assert (is_sorted(ALL(b)));
    vector<int> sorted_a = a;
    sort(ALL(sorted_a));
    REP (i, n) {
        if (sorted_a[i] > b[i]) {
            return false;
        }
    }
    if (n == 0) return true;

    vector<int> order(n);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) {
        return a[i] < a[j];
    });
    vector<bool> fixed(n);
    REP (i, n) {
        if ((i == 0 or b[i - 1] < sorted_a[i]) and (i == n - 1 or b[i] < sorted_a[i + 1])) {
            fixed[i] = true;
        }
    }
    REP (i, n) if (fixed[i]) {
        if (a[i] != sorted_a[i] and a[order[i]] == sorted_a[i]) {
            -- cnt;
            swap(a[i], a[order[i]]);
        }
    }
    if (cnt < 0) return false;
    vector<int> na;
    vector<int> nb;
    REP (i, n) {
        if (fixed[i] and a[i] == sorted_a[i]) continue;
        na.push_back(a[i]);
        nb.push_back(b[i]);
    }
// dump(sorted_a);
// dump(fixed);
    if (na.size() < a.size()) {
        return solve1(na.size(), na, nb, cnt);
    }

    return true;
}

bool solve(int n, const vector<int> & a, const vector<int> & b) {
    vector<int> order(n);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) {
        return make_pair(b[i], a[i]) < make_pair(b[j], a[j]);
    });
    vector<int> na(n);
    vector<int> nb(n);
    REP (i, n) {
        na[i] = a[order[i]];
        nb[i] = b[order[i]];
    }
    return solve1(n, na, nb, n - 2);
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    REP (i, n) {
        cin >> a[i];
    }
    vector<int> b(n);
    REP (i, n) {
        cin >> b[i];
    }
    cout << (solve(n, a, b) ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 5876
N,T=map(int,input().split())
A=list(map(int,input().split()))

amin=10**9+1
amax=10**9+1
damax=-1
dacount=0

for a in A:
  if a<amin:
    if damax<amax-amin:
      damax=amax-amin
      dacount=1
  
    elif damax==amax-amin:
      dacount+=1
    amin=a
    amax=amin

  if amax<a:
    amax=a
if damax<amax-amin:
  damax=amax-amin
  dacount=1
elif damax==amax-amin:
  dacount+=1
print(dacount)

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

int main() {
    
    int n;
    cin>>n;
    int arr[n][3];
    for(int i = 0;i<n;i++)
    {
        for(int j = 0;j<3;j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=1;i<n;i++)
    {
        
        arr[i][0] = arr[i][0] + max(arr[i-1][1],arr[i-1][2]);
        arr[i][1] = arr[i][1] + max(arr[i-1][0],arr[i-1][2]);
        arr[i][2] = arr[i][2] + max(arr[i-1][1],arr[i-1][0]);
        
        
    }
    cout<<max(arr[n-1][0],max(arr[n-1][1],arr[n-1][2]));
}


Measured memory_bytes: 1408
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

typedef long long ll;
const int MAXN = 100010;
int n, en, fa[MAXN];
struct Point {
	int x, y, id;
}P[MAXN];
struct Edge {
	int from, to, w;
	Edge(int from = 0, int to = 0, int w = 0) : from(from), to(to), w(w) {}
	bool operator < (const Edge &rhs) const {
		return w < rhs.w;
	}
}E[MAXN<<1];
ll ans;

bool cmp1(Point a, Point b) {
	return a.x < b.x;
}

bool cmp2(Point a, Point b) {
	return a.y < b.y;
}

inline int dis(int a, int b) {
	return min(abs(P[a].x-P[b].x), abs(P[a].y-P[b].y));
}

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x * f;
}

int find(int x) {
	return fa[x] = fa[x] == x ? x : find(fa[x]);
}

int main() {
	int i;
	n = read();
	for(i = 1; i <= n; i++) 
		P[i].x = read(), P[i].y = read(), P[i].id = i;
	sort(P+1, P+n+1, cmp1);
	for(i = 1; i < n; i++) E[++en] = Edge(P[i].id, P[i+1].id, dis(i, i+1));
	sort(P+1, P+n+1, cmp2);
	for(i = 1; i < n; i++) E[++en] = Edge(P[i].id, P[i+1].id, dis(i, i+1));
	sort(E+1, E+en+1);
	for(i = 1; i <= n; i++) fa[i] = i;
	for(i = 1; i <= en; i++) {
		int a = E[i].from, b = E[i].to;
		int x = find(a), y = find(b);
		if(x == y) continue;
		fa[x] = y, ans += E[i].w;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>

#define N 100

int main(){

  int M[N][N],n,i,j,k,l,m;

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      M[i][j] = 0; 
    }
  }

  for(i = 0;i < n;i++){
    scanf("%d%d",&k,&l);
    k--;
    for(j = 0;j < l;j++){
      scanf("%d",&m);
      m--;
      M[k][m] = 1;
    }
  }

  for(i = 0;i < n; i++){
    for(j = 0;j < n;j++){
      if(j) printf(" ");
     printf("%d",M[i][j]);
    }
    printf("\n");
  }

  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
x = int(input())
a = x//100
b = x%100
l = list(range(1,6))[::-1]
i = 0
cnt = 0
while b > 0:
  if l[i] > b: i += 1
  cnt += b//l[i]
  b = b % l[i]
print(1 if cnt <= a else 0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii  = pair<int,int>;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define rep2(i,x,n) for(ll i=x; i<(n); i++)
#define MOD 1000000007
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 1LL << 60;
const double PI = 3.141593;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}    //最大公約数
ll lcm(ll a,ll b) {return a * b / gcd(a, b);}   //最小公倍数
ll combination(ll n, ll r) {
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for ( ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main(){
  int n;
  string s;
  cin >> n >> s;
  ll ans = 0;
  for (int i = 0; i<n-2;i++){
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<string> s(n);
	rep(i,n) cin >> s.at(i);
	int ans=0,cnta=0,cntb=0,cntab=0;
	rep(i,n){
		rep(j,s.at(i).size()-1){
			if(s.at(i).at(j)=='A' && s.at(i).at(j+1)=='B') ans++;
		}
		if(s.at(i).at(0)=='B' && s.at(i).at(s.at(i).size()-1)=='A') cntab++;
		else if(s.at(i).at(0)=='B') cntb++;
		else if(s.at(i).at(s.at(i).size()-1)=='A') cnta++;
	}
	if(cntab==0) ans+=min(cnta,cntb);
	else{
		ans+=cntab-1;
		if(cnta>0){
			ans++;
			cnta--;
		}
		if(cntb>0){
			ans++;
			cntb--;
		}
		ans+=min(cnta,cntb);
	}
	cout << ans << endl;
}


Measured memory_bytes: 768