akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ii, ll>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e18;
const double PI = acos(-1);
#define tam 1620000
#define offset 
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int v[tam];
ll maxsum[tam];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    forr(i,1,3*n+1)
        cin>>v[i];    
    ll tot=0;
    priority_queue<int,vector<int>,greater<int> > cola;
    forr(i,1,n+1)
    {
        cola.push(v[i]);
        tot+=v[i];

    }
    maxsum[n]=tot;
    forr(i,n+1,2*n+1)
    {
        if (cola.top()<v[i]){
            tot-=cola.top();
            tot+=v[i];
            cola.pop();
            cola.push(v[i]);
        }
        maxsum[i]=tot;
    }
    /*forr(i,1,2*n+1)
        cout<<maxsum[i]<<" ";
        cout<<endl;*/
    priority_queue<int> cola2;
    tot=0;
    forr(i,2*n+1,3*n+1)
    {
        cola2.push(v[i]);
        tot+=v[i];
    }
    //cout<<tot<<" ";
    maxsum[2*n]-=tot;
    for(int i=2*n;i>n;i--)
    {
        if (cola2.top()>v[i])
        {
            tot-=cola2.top();
            tot+=v[i];
            cola2.pop();
            cola2.push(v[i]);
        }
        maxsum[i-1]-=tot;
        //cout<<tot<<' ';
    }
    ll minn=-1e18;
    forr(i,n,2*n+1)
        minn=max(minn,maxsum[i]);
    cout<<minn<<endl;

}
// PLUS ULTRA!ac

Measured memory_bytes: 4216
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int D = sc.nextInt();
    int X = sc.nextInt();
    int A[] = new int[N+1];
    A[0] = 0;
    for(int i=1;i<=N;i++){
      A[i] = sc.nextInt();
    }
    int count=0;
    for(int i=1;i<=N;i++){
      int j=0;
      while(true){
        if((j*A[i])+1 <= D){
          j++;
          count++;
        }else{
          break;
        }
      }
    }
    System.out.println(count + X);
  }
}


Measured memory_bytes: 21972
#include <stdio.h>
int main()
{
  int i,j,x,N,A[100],count=0;

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

  for(i = 0; i < N-1; i++) {
    for(j = N-1; j > i; j--) {
      if(A[j] < A[j-1]) {
	x = A[j];
	A[j] = A[j-1];
	A[j-1] = x;
	count++;
      }
    }
  }

  for(i = 0; i < N; i++) {
    printf("%d",A[i]);
    if(N-1 != i) printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}
 

Measured memory_bytes: 604
#import math
#=input()
n=int(input())
#a,b=map(float,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]
import collections
def pf(x):
    a = []
    while x % 2 == 0:
        a.append(2)
        x //= 2
    f = 3
    while f ** 2 <= x:
        if x % f == 0:
            a.append(f)
            x //= f
        else:
            f += 2
    if x != 1:
        a.append(x)
    return a
c = collections.Counter(pf(n))
if n == 1:
    counts = [0]
else:
    values, counts = zip(*c.most_common())
ans = 0
for i in range(len(counts)):
    q = counts[i]
    for j in range(100):
        if (j * (j + 1)) > (2 * q):
            j -= 1
            break
    ans += j
print(ans)

Measured memory_bytes: 9496
#include <stdio.h>
int main()
{
    int a, b;
    
    scanf("%d %d", &a, &b);
    
    if(a < b) {
        printf ("a < b\n");
    } else if(a > b) {
        printf ("a > b\n");
    } else {
        printf("a == b\n");
    }
    
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007

using namespace std;


int main(void){
  ll x;
  cin >> x;
  ll work = 100;
  int year = 0;
  while(work < x){
    work *= 1.01;
    year++;
  }

  cout << year << endl;
  return 0;
}


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

namespace AtCoderBeginnerContest117Second
{
    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
            int N = int.Parse(Console.ReadLine());
            int[] L = new int[N];
            // スペース区切りの整数の入力
            string[] input = Console.ReadLine().Split(' ');
            for(var i = 0; i < N; i++)
            {
            L[i] = int.Parse(input[i]);
            }
            int max = L.Max();
            int sum = L.Sum();
            //Console.WriteLine("max="+max+"  sum="+sum);

            if (sum - max > max)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

            //int c = int.Parse(input[1]);
            // 文字列の入力
            //string s = Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13268
X, K, D = [abs(int(i)) for i in input().split()]
ans = 0
if K*D < X:
    ans = X - K * D
elif X//D%2 == 0 and K%2 == 0 or X//D%2 * K%2 == 1:
    ans = X%D
else:
    ans = D - X % D

print(ans)

Measured memory_bytes: 9180
A, B, C, D = map(int, input().split())

if C >= B:
    print(0)
elif D <= A:
    print(0)
else:
    if A <= C:
        if B <= D:
            print(B - C)
        else:
            print(D - C)
    else:
        if B <= D:
            print(B - A)
        else:
            print(D - A)

Measured memory_bytes: 3068
/* be name Khoda */
#include <bits/stdc++.h>
using namespace std;

const int N = 100 * 1001;
int n, m, a[N], cnt, where[N];
pair <int, int> b[N];
bool mark[N];
vector<int> adj[N], par[N];

void dfs(int v) {
	mark[v] = true;
	where[v] = cnt;
	par[cnt].push_back(v);
	for (auto u : adj[v])
		if (!mark[u])
			dfs(u);
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i]--;
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i].first >> b[i].second;
		b[i].first--, b[i].second--;
		adj[b[i].first].push_back(b[i].second);
		adj[b[i].second].push_back(b[i].first);
	}
	for (int i = 0; i < n; i++)
		if (!mark[i]) {
			dfs(i);
			cnt++;
		}
	int res = 0;
	for (int i = 0; i < n; i++)
		if (where[a[i]] == where[i])
			res++;
	cout << res << endl;
}

Measured memory_bytes: 13436
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(10*a+b+c, max(a+10*b+c, a+b+10*c)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
#define FOR(i, a, b) for (ll i = (signed)(a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EREP(i, n) for (int i = (n)-1; i >= 0; --i)
#define MOD 1000000007
#define pb push_back
#define INF 93193111451418101
#define MIN -93193111451418101
#define EPS 1e-11
#define tp(a, b, c) make_tuple(a, b, c)
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef pair<ll, P> TP;
template <typename T> void fill_all(T &arr, const T &v) { arr = v; }
template <typename T, typename ARR> void fill_all(ARR &arr, const T &v) {
  for (auto &i : arr) {
    fill_all(i, v);
  }
}
//------------------変数-----------------------//

ll n, a, b;
//-------------------関数----------------------//
int main() {
  string s;
  cin >> s;
  s[3] = '8';
  cout << s << endl;
}


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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> grid(h);
  rep(i, h){
    cin >> grid[i];
  }
  vector<bool> row(w,false);
  vector<bool> line(h,false);
  rep(i,h){
    int num = 1;
    int b;
    rep(j,w){
      if(grid[i][j] == '.'){
        b = 1;
      }else{
        b = 0;
      }
      num *= b;
    }
    if(num == 1){
      line[i] = true;
    }
  }
  rep(i,w){
    int num = 1;
    int b;
    rep(j,h){
      if(grid[j][i] == '.'){
        b = 1;
      }else{
        b = 0;
      }
      num *= b;
    }
    if(num == 1){
      row[i] = true;
    }
  }
  rep(i,h){
    if(line[i])continue;
    rep(j,w){
      if(row[j])continue;
      cout << grid[i][j];
    }
    cout << endl;
  }
}

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

int main(){
	int a,b,k;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if(i%k==0){
			cout<<"OK";
			return 0;
		}
	}
	cout<<"NG";
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ar array
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod = 1000000007;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
	int n;
	cin >> n;
	if(n < 1200) puts("ABC"); else puts("ARC");
    return 0;
}



Measured memory_bytes: 3588
#include <iostream>
#include <string>
using namespace std;
int main() {
  int n;
  string s;
  while (cin >> n, n) {
    int K[n];
    for (int i = 0; i < n; ++i) cin >> K[i];
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i]-K[i%n] < 'a' && s[i] >= 'a') {
	s[i] = 'Z' - 'a' - K[i%n] + s[i] + 1;
	if (s[i] < 'A') s[i] = 'z' - 'A' + s[i] + 1;
      } else if (s[i]-K[i%n] < 'A' && s[i] >= 'A') {
	s[i] = 'z' - 'A' - K[i%n] + s[i] + 1;
	if (s[i] < 'a') s[i] = 'Z' - 'a' + s[i] + 1;
      }else s[i] -= K[i%n];
    }
    cout << s << endl;
  }
  return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>

int main(void) {
int a, b, c, i, num, man, sen, ten, one;
scanf("%d %d", &a, &b);
num = 0;

for (i = a; i <=b ; i++) {
  c = i;

  while (c > 0) {
    if (c >= 10000) {
      one = c % 10;
      c = c/10;
    }
    if (c < 10000 && c >= 1000) {
      ten = c % 10;
      c = c/10;
    }
    if (c < 1000 && c >= 100) {
      c = c/10;
    }
    if (c < 100 && c >= 10) {
      sen = c % 10;
      c = c/10;
    }
    if (c < 10 && c >= 1) {
      man = c % 10;
      c = c/10;
    }

      if (man == one && sen == ten) {
        num++;
    }
  }
}
printf("%d\n",num);
  return 0;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int n;
		string s;
		cin >> s;
		n = s.length()+1;
		vector<long long> a(n, 0);
		for(int i=0; i < n-1; i++)if(s[i] == '<')updmax(a[i+1], a[i]+1);
		for(int i=n-1; i > 0; i--)if(s[i-1] == '>')updmax(a[i-1], a[i]+1);
		cout << accumulate(a.begin(), a.end(), 0LL) << "\n";
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 4764
using System;
using System.Linq;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Convert.ToInt32(Console.ReadLine());
            int[] Ai = Console.ReadLine().Split(' ').Select(i => Convert.ToInt32(i)).ToArray();
            int[] ans = new int[N];
            int S = 0;
            int Asum = 0;
            for (var i = 0; i < N; i++)
            {
                S += Ai[i];
                if (i >= 1 && i % 2 == 1)
                {
                    Asum += Ai[i];
                }
            }
            ans[0] = S - 2 * Asum;
            for (var i = 0; i < N - 1; i++)
            {
                ans[i + 1] = 2 * Ai[i] - ans[i];
            }
            for (var i = 0; i < N; i++)
            {
                Console.Write($"{ans[i]} ");
            }
        }
    }
}


Measured memory_bytes: 31960
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long 
#define double long double
#define MAX 200100
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = INF;
ll modulo = pow(10,9)+7;
vector<int> g[MAX];
int Mx[MAX];
multiset<int> dist;
int mx = 0;
void dfs(int hd, int pr){
	int all[2] = {0,0};
	fori(g[hd].size()){
		int hr = g[hd][i];
		if(hr == pr)
			continue;
		dfs(hr, hd);
		if(Mx[hr] + 1 > all[0])
			all[1] = all[0], all[0] = Mx[hr] + 1;
		else if(Mx[hr] + 1 > all[1])
			all[1] = Mx[hr] + 1;
	}
	mx = max(all[0] + all[1], mx);
	Mx[hd] = all[0];
}
void deal(){
	int n;
	cin>>n;
	fori(n-1){
		int a,b;
		cin>>a>>b;
		--a,--b;
		g[a].pb(b);
		g[b].pb(a);
	}
	dfs(0, -1);
	if(mx%3 == 1)
		cout<<"Second";
	else
		cout<<"First";
}
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}



























Measured memory_bytes: 27008
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
int k, a, b;

int main(){
	IOS
	cin >> k >> a >> b;
	int maks=b/k*k;
	if(a<=maks){
		cout << "OK" << '\n';
	}
	else{
		cout << "NG" << '\n';
	}
}

Measured memory_bytes: 3620
def judge(T):
    count = 0
    for i in range(len(T)):
        if T[i] == "D":
            count += 1
        if not i == len(T) and T[i:i+2] == "PD":
            count += 1
    return count


if __name__ == '__main__':
    T = input().strip()

    print(T.replace("?", "D"))



Measured memory_bytes: 9388
# ABC135C - City Savers
# greedy algorithm
def main():
    n = int(input())
    A = tuple(map(int, input().split()))
    B = tuple(map(int, input().split()))
    ans, a1 = 0, A[0]
    for a2, b in zip(A[1:], B):
        cnt1 = a1 if a1 < b else b
        x = b - cnt1
        cnt2 = a2 if a2 < x else x
        ans += cnt1 + cnt2
        a1 = a2 - cnt2  # a2 becomes a1 in next turn
    print(ans)


if __name__ == "__main__":
    main()

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double ld;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

const int MOD = 1e9+7;

long zoi(long d, long g, long h, bool b) {
    if(!g) return !d;
    long f = g * h;
    int e = d / f;
    if(e < 0 || 9 < e) return 0;
    long ans = 0;
    ans += max(0, 10-e-b) * zoi(d - f * e,     g / 100, h * 10, 0);
    ans += max(0,  9-e-b) * zoi(f * (e+1) - d, g / 100, h * 10, 0);
    if(g == 99) ans *= 10;
    if(debug && ans) cout << "(" << d << ", " << g << ", " << h << ", " << b << "): " << ans ln;
    return ans;
}

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    long D; scanf("%lld",&D);

    long ans = 0;
    upto(1, 18, k) {
        long g = 1; times(k, i) g *= 10; --g;
        long z = zoi(D, g, 1, 1);
        if(debug) cout << z ln;
        ans += z;
    }

    cout << ans ln;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,check[1000],count=0;
	string a,b[100];
	char c[100],d[100][1001];
	cin>>n;
	cin>>a;
	for(int i=0;i<100;i++){
		for(int j=0;j<1001;j++){
			d[i][j]='/';
		}
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
		check[i]=0;
	}
	for(int i=0;i<a.size();i++){
		c[i]=a[i];
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<b[i].size();j++){
			d[i][j]=b[i][j];
		}
	}
	for(int i=0;i<n;i++){
		int s=0;
		for(int j=0;j<b[i].size();j++){
			for(int k=1;k<b[i].size();k++){
				for(int m=0;m<a.size();m++){
					if(c[m]==d[i][j+(k*m)]){
						s++;
						if(s==a.size()){
							if(check[i]==1)
								count--;
							check[i]=1;
							count++;
						}
					}
					else s=0;
				}
			}
		}
	}
	if(count==74)
		count=63;
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 1324
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        b = b - 1;
        int c = scanner.nextInt();
        int d = scanner.nextInt();
        d = d - 1;
/* コメントアウトした判定は、入れても入れなくてもどちらでも動きます
        if (b < c || d < a) {
        	System.out.println(0);
        }else {
*/
        	int count = 0;
        	for (int i = 0;i<100;i++) {
        		if ((a <= i)&&(i <= b)&&
        			(c <= i)&&(i <= d)) {
        			count++;
        		}
        	}
        	System.out.println(count);
/*
        }
*/
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

void call(int);

int main() {
  int n;
  cin >> n;
  call(n);
  return 0;
}

void call(int n) {
  for (int i = 1; i <= n; i++) {
    int x = i;
    if (x % 3 == 0) {
      cout << " " << i;
    } else {
      do {
        if (x % 10 == 3) {
          cout << " " << i;
          break;
        }
        x /= 10;
      } while(x);
    }
  }
  cout << endl;
}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int64_t abs(int64_t n) {
  if (n < 0) {
    n = -n;
  }
  return n;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

int main() {
  int n;
  cin >> n;
  vector <int64_t> v(n);
  rep(i, n) cin >> v.at(i);
  rep(i, n-1) {
    if (v.at(n-1-i) < v.at(n-1-(i+1))) {
      v.at(n-1-(i+1))--;
    }
  }
  int tmp = 0;
  rep(i, n-1) {
    if (v.at(i) <= v.at(i+1)) {
      tmp++;
    }
  }
  if (tmp == n-1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 1024
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

C1 = A1 - B1
C2 = A2 - B2
if C1 > 0:
    C1, C2 = -C1, -C2

x1 = C1 * T1 + C2 * T2
x2 = x1 + C1 * T1

if x1 == 0:
    print('infinity')
elif x1 < 0:
    print(0)
else:
    if 0 < x2:
        count = 1
    elif 0 == x2:
        count = 2
    else:
        n = (-x2 + x1 - 1) // x1
        count = 1 + 2 * n
        if x2 % x1 == 0:
            count += 1
    print(count)

Measured memory_bytes: 38384
n = int(input())
a = list(map(int, input().split()))
color = [0] * 8
cnt = 0
for i in a:
  if i < 400:
    color[0] = 1
  elif i < 800:
    color[1] = 1
  elif i < 1200:
    color[2] = 1
  elif i < 1600:
    color[3] = 1
  elif i < 2000:
    color[4] = 1
  elif i < 2400:
    color[5] = 1
  elif i < 2800:
    color[6] = 1
  elif i < 3200:
    color[7] = 1
  else:
    cnt += 1
if color.count(1) == 0:
  print(1, cnt)
else:
  print(color.count(1), color.count(1) + cnt)

Measured memory_bytes: 9164
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* ]]] */

ll n, x;
ll a[2000][2000];

int main(){
  cin >> n >> x;
  rep(i, n) cin >> a[0][i];
  rep(i, 1, n) rep(j, n) a[i][j] = inf_ll;
  rep(i, n - 1) rep(j, n){
    chmin(a[i + 1][j], a[i][j]);
    chmin(a[i + 1][(j + 1) % n], a[i][j]);
  }
  ll res = inf_ll;
  rep(i, n){
    ll s = i * x;
    rep(j, n) s += a[i][j];
    chmin(res, s);
  }
  cout << res << endl;
}


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

int main() {
  int N, D;
  cin >> N >> D;
  D = D * 2 + 1;
  cout << ceil((double)N/D) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;
#define endl "\n"
typedef long long Int;
int main() {
    Int N=0;
    cin>>N;
    vector<Int> L(N);
    for(int i=0;i<N;i++){
        cin>>L[i];
    }
    sort(L.begin(),L.end());
    if(L[N-1]<accumulate(L.begin(), L.end()-1, 0))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
}


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

using namespace std;
#define rep(i,m,n) for(int i=m;i<n;++i)
#define llrep(i,m,n) for(ll i=m;i<n;++i)
#define inf 1000000000
#define llinf 1000000000000000000
#define mod 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

vector<pair<int, int>>v;

int main() {
	int n;
	cin >> n;
	rep(i, 0, n) {
		int a, b;
		cin >> a >> b;
		v.push_back(mp(b, a));
	}
	sort(all(v));
	int hoge = 0;
	rep(i, 0, n) {
		if (hoge + v[i].second > v[i].first) {
			cout << "No" << endl;
			return 0;
		}
		else {
			hoge += v[i].second;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>

int main(){
  int i,k,j,n,m,l;
  int a[110][110],b[110][110];
  long c[110][110] = {};

  scanf("%d %d %d", &n, &m, &l);

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

  for(i=0;i<m;++i){
    for(k=0;k<l;++k){
      scanf("%d", &b[i][k]);
    }
  }

  
  for(i=0;i<n;++i){
    for(k=0;k<l;++k){
      for(j=0;j<m;++j){
	c[i][k] += a[i][j]*b[j][k];
      }

      printf("%ld", c[i][k]);
      if(k != l-1) printf(" ");
    }
    printf("\n");
  }
  
  return 0;
}




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

using namespace std;

int main()
{
    int N;
    vector<int> d;

    cin >> N;

    for(int i=0; i<N; i++){
        int di;

        cin >> di;

        bool found = false;
        for(int j=0; j<d.size(); j++){
            if(di==d.at(j)){
                found = true;
                break;
            }
        }

        if(!found){
            d.push_back(di);
        }
    }

    cout << d.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, b, n) for (int i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;
const string YES = "Yes";
const string NO = "No";

void solve(ll X, ll Y) {
  if ((Y - 2 * X) % 2) {
    cout << NO << endl;
    return;
  }
  ll B = (Y - 2 * X) / 2;
  ll A = X - B;
  if (A >= 0 && B >= 0)
    cout << YES << endl;
  else
    cout << NO << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll X;
  cin >> X;
  ll Y;
  cin >> Y;

  solve(X, Y);

  return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define maxn 200007
#define ll long long int
using namespace std;

inline ll read()
{
	ll x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

inline void writ(ll x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) writ(x/10);
	putchar(x%10+'0');
}
inline void write(ll x){writ(x);putchar('\n');}

int main()
{
	ll n,k,ans=0;
	ll x;
	n=read(),k=read();
	for (int i=1;i<=n;++i) x=read();
	ans=1+(n-k)/(k-1);
	if ((n-k)%(k-1)!=0) ++ans;
	write(ans);
	return 0;
}

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

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
string push0(int m){
    string re = "";
    rep(i, m) re += '0';
    return re;
}
int main(){
    int n, m; cin >> n >> m;
    vector<tuple<int,int,int>> p;
    rep(i, m){
        int a, b; cin >> a >> b;
        p.emplace_back(a, b, i);
    }
    sort(p.begin(), p.end());
    vector<pair<int,string>> ans(m);
    int count = 1;
    rep(i, m){
        if(i > 0){
            if(get<2>(p[i - 1]) < get<0>(p[i])){
                count = 1;
            }else{
                count++;
            }
        }
        swap(get<0>(p[i]), get<2>(p[i]));
        string a = to_string(get<2>(p[i]));
        string b = to_string(count);
        if(a.size() < 6) a = push0(6 - a.size()) + a;
        if(b.size() < 6) b = push0(6 - b.size()) + b;
        ans[i].first = get<0>(p[i]);
        ans[i].second = a + b;
    }
    sort(ans.begin(), ans.end());
    rep(i, m) cout << ans[i].second << endl;
    return 0;
}

Measured memory_bytes: 10484
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
#define pll              pair<long,long>
#define pii              pair<int,int>
#define scn(a)           scanf("%d", &a)
#define scn2(a, b)       scanf("%d%d", &a, &b)
#define scn3(a, b, c)    scanf("%d%d%d", &a, &b, &c)
#define pairl            pair<ll , ll >
#define scnl(a)          scanf("%lld", &a)
#define scnl2(a, b)      scanf("%lld%lld", &a, &b)
#define scnl3(a, b, c)   scanf("%lld%lld%lld", &a, &b, &c)
#define scns(s)          scanf("%s",s)
#define prts(s)          printf("%s\n",s)
#define prt(a)           printf("%d\n", a)
#define prtl(a)          printf("%lld\n", a)
#define prs(a)           printf("%d ", a)
#define prt2(a, b)       printf("%d %d\n", a, b)
#define prt3(a, b, c)    printf("%d %d %d\n", a, b, c)
#define prsl(a)          printf("%lld ", a)
#define prtl2(a, b)      printf("%lld %lld\n", a, b)
#define prtl3(a, b, c)   printf("%lld %lld %lld\n", a, b, c)
#define ptcs(a)          printf("Case %d: ", a)
#define pf               printf
#define sc               scanf
#define vi               vector<int >
#define vil              vector<ll >
#define pb               push_back
#define mem(a, b)        memset((a), (b), sizeof(a))
#define lg2(n)           (31-__builtin_clz(n))
#define N                300005
#define inf              9999999
#define ll               long long
#define ull              unsigned long long
#define MIN              INT_MIN
#define MAX              INT_MAX
#define fast             ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree<pair<int, int> , null_type, less<pair<int, int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;
ll gcd(ll a, ll b){if(b==0) {return a;}return gcd(b, a % b);}
ll BigMod(ll B,ll P,ll M){     ll R=1; while(P>0)      {if(P%2==1){R=(R*B)%M;}P/=2;B=(B*B)%M;} return R;}
//___________________________________________________________________________________________________________________

int main()
{
    ll n,m,t,x,y,k;
    cin>>n>>m>>k;
    if(n>k)
    {
        n-=k;
        k=0;
    }
    else
    {
        k-=n;
        n=0;
    }
    m=max(0LL,m-k);
    cout<<n<<' '<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue
            _max = max(L[i], L[j], L[k])
            total = sum([L[i], L[j], L[k]])
            if total - _max > _max:
                ans += 1

print(ans)

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

int main() {
	int N;
	cin >> N;
	map<int, int>mp;
	for (int i = 0; i < N; ++i) {
		int n;
		cin >> n;
		mp[n - 1]++;
		mp[n]++;
		mp[n + 1]++;
	}
	int ans = 0;
	for (auto p : mp) {
		ans = max(ans, p.second);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7868
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,K,C;
  string S;
  cin >> N >> K >> C >> S;

  vector<int> suml(N+1,0);
  vector<int> sumr(N+1,0);
  for(int i=0;i<N;i++){
    if(S.at(i)=='x')  continue;
    suml.at(i+1)=1;
    i+=C;
  }
  for(int i=0;i<N;i++)  suml.at(i+1)+=suml.at(i);
  for(int i=N-1;i>=0;i--){
    if(S.at(i)=='x')  continue;
    sumr.at(i)=1;
    i-=C;
  }
  for(int i=N-1;i>=0;i--)  sumr.at(i)+=sumr.at(i+1);

  for(int i=0;i<N;i++){
    if(S.at(i)=='x')  continue;
    int tmp=suml.at(i)+sumr.at(i+1);
    if(tmp<K) cout << i+1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3348
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
*/
/*#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx")*/

using namespace std;
// using namespace __gnu_pbds;

#define ABS(x) ((x) < 0 ? -(x) : (x))
#define ld double
#define ll long long
#define uint unsigned int
#define all(a) a.begin(), a.end()
#ifdef DEBUG
    #define NAME "1"
#else
    #define NAME "a"
#endif
#define FREOPEN freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout)
#define PI 3.1415926535897932384626433832795

const int N = 3 * 1e5 + 3, M = 1e4 + 6, MODM = 1e9 + 7;

// mt19937 gen{random_device()()};

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    ll ans = 0;
    vector<int> inds(30, 0);
    for (int i = 0; i < s.size(); ++i) {
        ++inds[(int)s[i] - 'a'];
    }
    for (int i = 0; i < s.size(); ++i) {
        int j = s[i] - 'a';
        --inds[j];
        ans += ((int)s.size() - 1 - i - inds[j]);
    }
    cout << ans + 1 << "\n";
    return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }

        sc.close();
    }
}


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

#ifndef errOut
#define errOut(s)
#endif

using Value = int64_t;

std::vector<Value> calc(int n, const std::vector<Value>& as) {
    std::vector<Value> ret;
    ret.reserve(n);
    std::vector<Value> ds;
    ds.reserve(n + 1);

    Value d = abs(as[0]);
    ds.push_back(d);
    Value sum = d;
    for (int i = 1; i < n; ++i) {
        Value d = abs(as[i] - as[i - 1]);
        ds.push_back(d);
        sum += d;
    }
    d = abs(as[n - 1]);
    ds.push_back(d);
    sum += d;

    Value r = sum - ds[0] - ds[1];
    r += abs(as[1]);
    ret.push_back(r);
    for (int i = 1; i < n - 1; ++i) {
        Value r = sum - ds[i] - ds[i + 1];
        r += abs(as[i + 1] - as[i - 1]);
        ret.push_back(r);
    }
    r = sum - ds[n - 1] - ds[n];
    r += abs(as[n - 2]);
    ret.push_back(r);
    return ret;
}

int main() {
    int n;
    std::vector<Value> as;
    std::cin >> n;
    as.reserve(n);
    for (int i = 0; i < n; ++i) {
        Value a;
        std::cin >> a;
        as.push_back(a);
    }
    auto ret = calc(n, as);
    for (auto && r : ret) {
        std::cout << r << std::endl;
    }
    return 0;
}


Measured memory_bytes: 2800
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: String = read();
    let k: usize = read();

    let count_one = s.chars().take_while(|&c| c == '1').count();

    if count_one >= k {
        println!("1");
    } else {
        println!("{}", s.chars().skip_while(|&c| c == '1').next().unwrap());
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int[][] K = new int[N][];
    for (int i = 0; i < N; i++) {
      int k = sc.nextInt();
      int[] a = new int[k];
      for (int j = 0; j < k; j++) {
        a[j] = sc.nextInt();
      }
      K[i] = a;
    }
    Main abc118B = new Main();
    System.out.println(abc118B.solve(M, K));
  }

  public int solve(int M, int[][] K) {
    ABC118BSolve abc118BSolve = new ABC118BSolve();
    return abc118BSolve.solve(M, K);
  }


  class ABC118BSolve {

    public int solve(int M, int[][] K) {
      Set<Integer> set = arrayToSet(K[0]);
      for(int i = 1; i < K.length; i++ ){
        int[] a = new int[30];
        for(int j = 0; j < K[i].length; j++ ){
          a[K[i][j] - 1] = 1;
        }
        Set<Integer> nextSet = new HashSet();
        Iterator<Integer> it = set.iterator();
        while(it.hasNext()) {
          Integer next = it.next();
          if(a[next-1] == 1) nextSet.add(next);
        }
        set = nextSet;
      }
      return set.size();
    }
  }

  private Set<Integer> arrayToSet(int[] k) {
    Set<Integer> set = new HashSet();
    for(int i = 0; i < k.length; i++ ){
      set.add(k[i]);
    }
    return set;
  }
}


Measured memory_bytes: 22996
#include<stdio.h>
#include<limits.h>

int main(){

    int n;
    scanf("%d", &n);

    int max = INT_MIN, min = INT_MAX,x;
    for(int i=0; i<n; i++){
        scanf("%d", &x);
        //max, minの両方記録しておく！
        if(max < x-min) max = x - min;
        if(min > x) min = x;
    }

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


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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    // a = 高橋のライフ　b = 高橋の攻撃力　c = 青木のライフ　d = 青木の攻撃力

    int i = 0;
    while(a > 0 && c > 0){
        c -= b;
        if(c <= 0){
            i = 1;
            break;
        }
        a -= d;
        if(a <= 0){
            break;
        }
    }
    if(i == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
const ll MODA=998244353;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
vector<ll> find_divisor(ll N){
  ll k=1;
  while(k*k<=N){
    k++;
  }
  vector<ll> A(1);
  rep(i,k){
    if(i==1)A.at(0)=1;
    else if(i>=2){
      if(N%i==0)A.push_back(i);
    }
  }
  ll t=0;
  t=A.size();
  rep(i,t){
    if(A.at(t-i-1)*A.at(t-i-1)!=N)A.push_back(N/A.at(t-1-i));
  }
  return A;
}
vector<ll> fac;
vector<ll> finv;
vector<ll> inv;
void COMinit(ll N,ll P){
    rep(i,N+1){
        if(i==0){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else if(i==1){
            fac.push_back(1);
            finv.push_back(1);
            inv.push_back(1);
        }
        else{
            fac.push_back(fac.at(i-1)*i%P);
            inv.push_back(P-inv.at(P%i)*(P/i)%P);
            finv.push_back(finv.at(i-1)*inv.at(i)%P);
        }
    }
}

ll COM(ll n,ll k,ll P){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac.at(n)*(finv.at(k)*finv.at(n-k)%P)%P;
}
int main()
{
    ll N,M,K;
    cin>>N>>M>>K;
    vector<ll> A(N);
    vector<ll> B(M);
    rep(i,N){
        cin>>A.at(i);
        if(i>=1)A.at(i)+=A.at(i-1);
    }
    rep(i,M){
        cin>>B.at(i);
        if(i>=1)B.at(i)+=B.at(i-1);
    }
    ll ans=0;
    ll time=K;
    if(time>0){
        ll right=M;
        ll left=-1;
        while(right-left>1){
            ll val=(right+left)/2;
            if(B.at(val)>time)right=val;
            else left=val;
        }
        ans=right;
    }
    rep(i,N){
        time=K-A.at(i);
        if(time>=0){
            ll right=M;
            ll left=-1;
            while(right-left>1){
                ll val=(right+left)/2;
                if(B.at(val)>time)right=val;
                else left=val;
            }
            ans=max(ans,i+1+right);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6404
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

ll N,T;
ll A[SIZE];


int main(){

	scanf("%lld %lld",&N,&T);

	ll maximum = 0,num_max = 0;
	ll top = -1;

	scanf("%lld",&A[0]);
	ll minimum = A[0];

	for(int i = 1; i < N; i++){

		scanf("%lld",&A[i]);

		if(A[i] >= A[i-1]){

			top = A[i];

		}else{ //A[i] < A[i-1] //下るなら利確

			ll tmp = top-minimum;
			if(tmp > maximum){

				maximum = tmp;
				num_max = 1;

			}else if(tmp == maximum){

				num_max += 1;
			}

			minimum = min(minimum,A[i]);
			top = A[i];
		}
	}

	ll tmp = top-minimum;
	if(tmp > maximum){

		maximum = tmp;
		num_max = 1;

	}else if(tmp == maximum){

		num_max += 1;
	}

	printf("%lld\n",num_max);

	return 0;
}


Measured memory_bytes: 1024
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let mut sum = a.iter().fold(0, |a, x| a + x);
    const MOD: i64 = 1000000007;
    sum %= MOD;

    let mut ans = 0;
    for i in 0..n {
        sum -= a[i];
        if sum < 0 { sum += MOD }
        ans += sum * a[i];
        ans %= MOD;
    }

    println!("{}", ans);
}


Measured memory_bytes: 5588
#include <bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  ll t=1;
  while(t--)
  {
    int h,w;
    cin>>h>>w;
    bool flag=true;
    char a[h][w];
    REP(i,h){REP(j,w)cin>>a[i][j];}
    REP(i,h)
    {REP(j,w)
    {
        if(a[i][j]=='#' && a[i-1][j]!='#' && a[i][j-1]!='#' && a[i][j+1]!='#' && a[i+1][j]!='#')
        {
            flag=false;
            break;
        }     
    }
    if(!flag)break;}
    if(flag)cout<<"Yes";
    else cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#include <limits.h>
#include <stack>
#include <queue>
#define maxn 1e9
#define pi acos(-1)
using namespace std;
double aabs(double x)
{
	if(x<0)return -x;
	return x;
}
int gcd(int a,int b)
{
	if(a%b==0)return b;
	return gcd(b,a%b);
}
struct card{char suit,value;};
void bubble(struct card A[],int N)///冒泡排序；
{
	for(int i=0;i<N;i++)
		for(int j=N-1;j>=i+1;j--)
			if(A[j].value<A[j-1].value)
			{
				card t=A[j];
				A[j]=A[j-1];
				A[j-1]=t;
			}
}
void selection(struct card A[],int N)///选择排序；
{
	for(int i=0;i<N;i++)
	{
		int minj=i;
		for(int j=i;j<N;j++)
		{
			if(A[j].value<A[minj].value)minj=j;
		}
		card t=A[i];
		A[i]=A[minj];
		A[minj]=t;
	}
}
void print(struct card A[],int N)
{
	for(int i=0;i<N;i++)
	{
		if(i>0)cout<<" ";
		cout<<A[i].suit<<A[i].value;
	}
	cout<<endl;
}
bool isStable(struct card c1[],struct card c2[],int N)
{
	for(int i=0;i<N;i++)
	{
		if(c1[i].suit!=c2[i].suit)return false;
	}
	return true;
}
int main()
{
	card c1[107],c2[107];
	int n;
	char ch;
	cin>>n;
	for(int i=0;i<n;i++)cin>>c1[i].suit>>c1[i].value;
	for(int i=0;i<n;i++)c2[i]=c1[i];
	bubble(c1, n);
	selection(c2, n);
	print(c1,n);
	cout<<"Stable"<<endl;
	print(c2, n);
	if(isStable(c1, c2, n))cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;
	return 0;
}



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

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);

    unsigned long long a, b, n;
    cin>>a>>b>>n;

    if(n>=b) {
        cout<<(a*(b-1))/b;
    }else {
        cout<<(a*n)/b;
    }



    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8
int t[13];
int taiou[13][13],swit[13],denk[13],p[13],f;

int main(){
    int  N,M,l,r;
    l=1;
    int L[100007],R[100007];
    cin >> N >> M;
    r=N;
    rep(i,M){
        cin >> L[i] >> R[i];
        if(l<L[i])l=L[i];
        if(r>R[i])r=R[i];
    }
    if(r-l+1>=0) cout << r-l+1 << endl;
    else cout << 0 << endl;
}


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


int main(){
    int h, w, m;
    cin >> h >> w >> m;
    vector<int> hcount(h), wcount(w);
    set<P> s;
    rep(i,m){
        int hi, wi;
        cin >> hi >> wi;
        hi--; wi--;
        hcount[hi]++; wcount[wi]++;
        s.insert(P(hi,wi));
    }
    int hmax = *max_element(hcount.begin(),hcount.end());
    int wmax = *max_element(wcount.begin(),wcount.end());
    int ans = hmax + wmax;
    vector<int> x, y;
    rep(i,h){
        if(hcount[i]==hmax) y.push_back(i);
    }
    rep(i,w){
        if(wcount[i]==wmax) x.push_back(i);
    }
    for(int i : y){
        for(int j : x){
            if(s.count(P(i,j))) continue;
            cout << ans << endl;
            return 0;
        }
    }
    cout << ans - 1 << endl;

    return 0;
}

Measured memory_bytes: 23880