akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8

N = int(input())
A = list(map(int,input().split()))
L = [0] * (N+1)
R = [0] * (N+1)
for i in range(N):
    xl = i+1+A[i]
    xr = i+1-A[i]
    if 1 <= xl <= N-1:
        L[xl] += 1
    if 1 <= xr <= N-1:
        R[xr] += 1

ans = 0
for i in range(1,N+1):
    ans += L[i] * R[i]

print(ans)

Measured memory_bytes: 32372
#include<iostream>
#include <algorithm>
#include<array>

int main(){
	std::array<int,5> dishes = {};
	int time=0;

	for ( int i = 0; i<5 ; i++ ){
	std::cin >> dishes.at(i);
	}

	int min = 10;
	for ( int i = 0; i<5 ; i++ ){
		if ( (dishes.at(i) - 1 )%10 < min )
		{
			min = dishes.at(i)%10 ;
		}
	}
	if ( min == 0){
			min = 10;
	}


	for ( int i = 0; i<5 ; i++ ){
		time += ((dishes.at(i) + 9) / 10) * 10;
	}
	std::cout << time -10 + min << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>

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

using namespace std;

int main(){
	int N;
	long long ans = 1;
	cin >> N;
	for(int i = 0; i < N; i++){
		ans = (ans * (i + 1)) % (1000000000 + 7);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

#define mem(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define ff first
#define ss second
#define mk make_pair
#define pi pair<int,int>
#define vi vector<int>
#define pL pair<ll,ll>
#define vL vector<ll>
#define vp vector<pi>
#define vpL vector<pL>

const int MX=1000000;
const ll inf=1e9;
const ll mod=1e9+7;

int main()
{
    FasterIO;
    int n, m;
    cin>>n>>m;
    string a, b;
    a=b="";
    for(int i=1; i<=m; i++) a+=(n+'0');
    for(int i=1; i<=n; i++) b+=(m+'0');
    if(a>b) swap(a, b);
    cout<<a<<endl;
    return 0;
 }


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=a; i--)

int l[300005], r[300001];
int n;
string s;
int main()
{
	cin >> n >> s;

	REP(i, 0, n) {
		if (s[i] == 'E') l[i + 1] = l[i] + 1;
		else l[i + 1] = l[i] - 1;
	}
	RREP(i, 0, n) {
		if (s[i] == 'W') r[i + 1] = r[i + 2] + 1;
		else r[i + 1] = r[i + 2] - 1;
	}
	
	int cnt = -100000;
	int num;
	REP(i, 0, n + 1) {
		if (l[i] + r[i] > cnt) {
			cnt = l[i] + r[i];
			num = i;
		}
	}

	int ans = 0;
	REP(i, 0, num - 1) {
		if (s[i] == 'W') ans++;
	}
	REP(i, num, n) {
		if (s[i] == 'E') ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 2.53 + c[j] * 15.7;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b[100],c;
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>b[i];
  }
  for(int i=1;i<=a;i++){
    sort(b,b+i);
    for(int j=0;j<a-1;j++){
      cout <<b[j]<<" ";
    }
    cout <<b[a-1]<<endl;
  }
  return 0;
}

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

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	int ans;
	if (n % x == 0) ans = t * (n / x);
	else ans = t * (n / x + 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <iterator>
#include <vector>
#include <numeric>
#include <algorithm>
#include <list>
#include <sstream>

#define endl "\n"

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, sum_v, max_v;
    cin >> n;
    vector<int> l(n);
    // max(l) < sum(l)-max(l)

    for(int i=0;i<n;i++){
        cin >> l.at(i);
    }

    /*for(int i=0;i<n;i++){
        cout << l.at(i) << " ";
    }*/

    sum_v = accumulate(l.begin(), l.end(), 0LL);
    max_v = *max_element(l.begin(), l.end());
    // cout << sum_v << " "  <<  max_v << endl;

    if(max_v < sum_v-max_v)
        cout << "Yes";
    else
        cout << "No";


    cout << endl;

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include <sstream>
using namespace std;
int main(void){
    string s;
    int ans = 0;
    cin >> s;
    for(int i = 0; i < 4; i++){
        if(s.at(i) == '+') ans++;
        if(s.at(i) == '-') ans--;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

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

    long long int ways = 0;

    for (int i =0; i < n;i++){
        long long int x;
        cin >> x;
        if(x %2 ==0){
            while(x % 2 == 0){
                ways++;
                x /= 2;
            }
        }        
    }

    cout << ways << endl;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
data = {}
n.times do
	s = gets.chomp
	if data.key?(s) then
		data[s] += 1
	else
		data[s] = 1
	end
end
print("\n")

data = data.sort
data = data.sort_by{ |_, v| -v }

max = data[0][1]

for i in data do
	if i[1]==max then
		print(i[0])
		print("\n")
	else
		break
	end
end

Measured memory_bytes: 43740
#include <iostream>

using namespace std;

int main()
{
  int k, q; cin >> k >> q;
  int d[5000]; for (int i = 0; i < k; ++i) cin >> d[i];
  
  while (q--) {
    int n, x, m; cin >> n >> x >> m;
    int dm[5000]; for (int i = 0; i < k; ++i) dm[i] = d[i] % m;
    int quo = (n-1) / k, rem = (n-1) % k;
    int sum = 0;
    for (int i = 0; i < k; ++i) if (dm[i] == 0) {
      sum += quo; if(i < rem) ++sum;
    }
    long long last_a = x;
    for (int i = 0; i < k; ++i) {
      last_a += (long long)dm[i] * quo; if(i < rem) last_a += dm[i];
    }
    sum += last_a / m - x / m;
    cout << n - sum - 1 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstring>
#include<cstdio>
using namespace std;

int main()
{
	int x, fx = 0, a;

	cin >> x;

	a = x;

	while (a != 0){
		fx += a % 10;
		a /= 10;
	}

	if (x % fx == 0)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        MyScanner sc = new MyScanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        int k = sc.nextInt();
        int[] a = new int[k];
        for (int i = 0; i < k; i++)
            a[i] = sc.nextInt();
        if (a[k - 1] != 2)
            out.println(-1);
        else if (k == 1)
            out.println(a[0] != 2 ? -1 : 2 + " " + 3);
        else {
            long min = 2, max = 2;
            for (int i = k - 1; i >= 0; i--) {
                long x = min % a[i] == 0 ? min : min + (a[i] - (min % a[i])),
                        y = max % a[i] == 0 ? max : max - (max % a[i]);
                if (x > max || y < min) {
                    out.println(-1);
                    out.flush();
                    out.close();
                    return;
                }
                min = x;
                max = y + a[i] - 1;
            }
            out.println(min == -1 ? -1 : min + " " + max);
        }
        out.flush();
        out.close();
    }

    private static class MyScanner {
        StringTokenizer st;
        BufferedReader br;

        public MyScanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public MyScanner(String filename) throws IOException {
            br = new BufferedReader(new FileReader(new File(filename)));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}


Measured memory_bytes: 38584
def main(argv)
  n = gets.chomp.to_i
  s = gets.chomp

  c = 0
  (n - 2).times do |i|
    if s[i..(i+2)] == 'ABC' then
      c += 1
    end
  end
  puts c.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
import java.util.*;
import java.math.*;
import java.lang.*;
import java.io.*;

public class Main{
  public static void main(String args[]) throws IOException{
    Scanner s=new Scanner(System.in);
   
    
    int n=s.nextInt();
    String ss=s.next();
    String st="";
    
    for(int i=0;i<ss.length();i++){
      int c=0;
      if((int)ss.charAt(i)+n>90)
        c=(int)ss.charAt(i)+n-90+64;
      else
        c=(int)ss.charAt(i)+n;
      
      st+=(char)c;
    }
    System.out.println(st);
  }
}

Measured memory_bytes: 145748
#include<bits/stdc++.h>
#define ll long long int
#define F first
#define S second
#define pb push_back
#define sd(x) scanf("%d",&x)
#define sd2(x,y) scanf("%d%d",&x,&y);
#define sdl(x) scanf("%lld",&x)
#define sd2l(x,y) scanf("%lld%lld",&x,&y);
#define sz(x) (int)(x.size())
#define nax 101010
#define inf 1000000100
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define mp make_pair
#define pi pair<int ,int>
#define pii pair <pi,pi>
using namespace std;
int mat[10100][11010];
int arr[110];
int main(int argc, char const *argv[])
{
 // freopen("input.txt","r",stdin);
 // freopen("output.txt","w",stdout); 
  int h,w,n;
  sd2(h,w);
  sd(n);
  for(int i = 1;i <= n; i++)
  {
    sd(arr[i]);
  }
  int row = 1;int col = 1;
  for(int i = 1; i<= n; i++)
  {

    int cur = arr[i];
    
    while(cur)
    {
       if(row%2 == 1)
       {
          if(col == w+1)
          {
            row++;
            col = w;
          }
          else
          {
            mat[row][col] = i;
            ++col;
            --cur;
          }
       }
       else
       {
          if(col == 0)
          {
            row++;
            col = 1;
          }
          else
          {
            mat[row][col] = i;
            --col;
            --cur;
          }
       }
    }
  }
  for(int i  = 1;i <= h; i++)
  {
    for(int j = 1;j <= w; j++)
      printf("%d ",mat[i][j]);
    puts("");
  }
  return 0;
}
 

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

int main(){
	int a,b;
	double d;
	string s,s2;
	cin >> s >> s2;
	s+=s2;
	a=atoi(s.c_str());
	d=a;
	d=sqrt(d);
	b=d;
	cout << (b*b==a?"Yes":"No") << endl;
	
	return 0;
}

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

using namespace std;

const int MOD=1e9+7;

//const int MOD=998244353;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,m;
    cin>>n>>m;
    
    vector<vector<int>> gr(n+1);
    for(int i=0; i<m; i++){
        int x,y;
        cin>>x>>y;
        gr[x].push_back(y);
        gr[y].push_back(x);
    }
    int ma=0, fct=0;
    
    for(int i=1; i<=n; i++){
        if(gr[i].size()%2){
            cout<<"No";
            return 0;
        }
        if(gr[i].size()>=ma){
            ma=gr[i].size();
        }
        fct+=gr[i].size()==4;
    }
    if(ma>=6 || fct>=3){
        cout<<"Yes";
        return 0;
    }
    
    
    if(fct<=1){
        cout<<"No";
        return 0;
    }
    
    int x=-1, y=-1;
    
    for(int i=1; i<=n; i++){
        if(gr[i].size()==4){
            if(x==-1) x=i;
            else y=i;
        }
    }
    
    for(int i:gr[x]){
        int cur=i, prev=x;
        while(cur!=x && cur!=y){
            for(int j:gr[cur]){
                if(j!=prev){
                    prev=cur;
                    cur=j;
                    break;
                }
            }
        }
        if(cur==x){
            cout<<"Yes";
            return 0;
        }
        
    }
    
    cout<<"No";
    
    
    
}

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

using namespace std;

int main()
{
    int n, p;
    while(cin >> n >> p, n|p)
    {
        int counts[n];
        fill(counts, counts+n, 0);
        int cup = p;
        int i;
        for(i=0;; i=(i+1==n) ? 0 : i+1)
        {
            if(cup==0)
            {
                cup = counts[i];
                counts[i] = 0;
            }
            else
            {
                cup--;
                counts[i]++;
                if(counts[i]==p) break;
            }
        }
        cout << i << endl;
    }
}

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

using namespace std;

bool palindrome(string ch)
{
    int l = ch.length();
    for(int i = 0; i < l / 2; i++)
    {
        if(ch[i] != ch[l - i -1])
            return false;
    }
    return true;
}

string s;

int main()
{
    cin>>s;
    int n = s.length();
    string s1 = s.substr(0,(n - 1) / 2);
    string s2 = s.substr(n/2 + 1,(n + 3) / 2);
    bool res = palindrome(s) && palindrome(s1) && palindrome(s2);
    if(res)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define puts(i) cout<<i<<endl;
int main(){
	ll a[3],n;
	cin>>a[0]>>a[1]>>a[2]>>n;
	cout<<(a[0]-a[1])*(n%2==0?1:-1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
 string s; cin>>s;
 bool flag=1;
if(s[0]==s[1]||s[1]==s[2]||s[0]==s[2])flag=0;
  if(flag)
  cout << "Yes" << endl;
  else
    cout << "No" << endl;

}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

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

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  string s;
  cin >> s;
  int n = SZ(s);
  map<char, vector<ll>> m;
  rep(i, n) m[s[i]].push_back(i);
  ll ans = 0ll;
  rep(i, m['W'].size()) ans += m['W'][i]-i;
  cout << ans << endl;
}

Measured memory_bytes: 2808
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
using namespace std;
int main()
{
    int n, w, h;
    cin >> n >> h >> w;
    int a = (n - h + 1) * (n - w + 1);
    cout << (a < 0 ? 0 : a) << endl;
    return 0;
}

Measured memory_bytes: 256
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v[100];
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n>>d;
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
            cin>>a;
            v[i].push_back(a);
        }
    }
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            double ds=0;
            for(k=0;k<d;k++){
                ds+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
            }
            ds=sqrt(ds);
            l=ds;
            if(l==ds)f++;
        }
    }
    cout<<f<<'\n';
    return 0;
}


Measured memory_bytes: 256
A, B, C = map(int, input().split())
if A == B and B == C and A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    print(-1)
else:
    ans = 0
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        a = A // 2
        b = B // 2
        c = C // 2
        A = b + c
        B = c + a
        C = a + b
        ans += 1
        if ans > 10**5:
            print(-1)
            exit()
    print(ans)

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

int main(){
  int K;
  string S;
  cin >> K >> S;
  const int Nlen= S.size();

  string ans= (Nlen <= K) ? S 
                          : S.substr(0,K)+ "...";

  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
template<class T> inline bool chmax(T& a, T b){if(a < b){a = b; return true;}return false;}
template<class T> inline bool chmin(T& a, T b){if(a > b){a = b; return true;}return false;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/

int main(){
    string S,T;
    cin>>S>>T;
    ll s = S.size();
    map<char,char> ma;
    for(char c = 'a';c <= 'z';c++){
        ma[c] = '-';
    }
    rep(i,s){
        if(ma[S[i]] == '-'){
            ma[S[i]] = T[i];
        }
        else{
            if(ma[S[i]] != T[i]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    map<char,ll> ma2;
    for(char c = 'a';c <= 'z';c++){
        if(ma[c] != '-')
        ma2[ma[c]]++;
    }
    for(auto x : ma2){
        if(x.second > 1){
            cout << "No" << endl;
            return 0;
        }
    }
    cout <<"Yes" << endl;
}

Measured memory_bytes: 3904
#include <iostream>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;
ll n,k,a[maxn];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    for(int i=1;i+k<=n;i++){
        if(a[i]>=a[i+k]) printf ("No\n");
        else printf ("Yes\n");
    }
   

}

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

int main () {
	
	long long int n=0, a=0, b=0, x=0, grande = 0, i=0;
	vector <pair<long long int, long long int> > v;

	cin >> n;

	for (i=0; i<n; i++) {
		cin >> a >> b;
		v.push_back(make_pair(b, a));
		x += a;
		grande = max(grande, b);
	}

	sort(v.begin(), v.end());

	if (x > grande) cout << "No" << endl;
	else {
		//cout << "Yes" << endl;

		x = 0;
		bool flag = 0;
		for (i=0; i<n; i++) {
			x += v[i].second;
			if (x>v[i].first){
				flag = 1;
				break;
			}
		}

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

	return 0;
}

Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int x; cin >> x;
  if (x == 3 || x == 5 || x == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int n;
	while(scanf("%d", &n) && n ){
		
		int dp[100]={0};
		dp[0] = 1;
		
		for(int i = 0; i < n; i++){
			dp[i+3] += dp[i];
			dp[i+2] += dp[i];
			dp[i+1] += dp[i];
		}
		printf("%d\n",dp[n]/3650+1);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}


int main(){
	ios_base::sync_with_stdio(false);
	int n;
    cin >> n;
    int v[n];
    for(int i=0;i<n;i++){
        cin >> v[i];
    }
    sort(v,v+n);
    double ans = (v[0]+v[1])/2.0;
    for(int i=2;i<n;i++){
        ans = (ans+v[i])/2.0;
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)
	n := getInt()
	a := make([]int, n)

	for i := range a {
		a[i] = getInt()
	}
	sort.Ints(a)
	fmt.Println(int(math.Abs(float64(a[n-1] - a[0]))))
}


Measured memory_bytes: 640
H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
for i in range(H):
    for j in range(W):
        if A[i][j]%2==0:
            A[i][j]=0
        else:
            A[i][j]=1
cur = [1,1,1,0]
cnt = 0
B = []
while cur[0]<=H:
    i = cur[0]-1
    j = cur[1]-1
    a = A[i][j]
    d,h = cur[2],cur[3]
    if a==0:
        if d==1 and j<W-1:
            if h==1:
                B.append((i+1,j+1,i+1,j+2))
                cnt += 1
            cur = [i+1,j+2,d,h]
        elif d==1 and j==W-1:
            if h==1 and i+2<=H:
                B.append((i+1,j+1,i+2,j+1))
                cnt += 1
            cur = [i+2,j+1,1-d,h]
        elif d==0 and j>0:
            if h==1:
                B.append((i+1,j+1,i+1,j))
                cnt += 1
            cur = [i+1,j,d,h]
        elif d==0 and j==0:
            if h==1 and i+2<=H:
                B.append((i+1,j+1,i+2,j+1))
                cnt += 1
            cur = [i+2,j+1,1-d,h]
    else:
        if d==1 and j<W-1:
            if h==0:
                B.append((i+1,j+1,i+1,j+2))
                cnt += 1
            cur = [i+1,j+2,d,1-h]
        elif d==1 and j==W-1:
            if h==0 and i+2<=H:
                B.append((i+1,j+1,i+2,j+1))
                cnt += 1
            cur = [i+2,j+1,1-d,1-h]
        elif d==0 and j>0:
            if h==0:
                B.append((i+1,j+1,i+1,j))
                cnt += 1
            cur = [i+1,j,d,1-h]
        elif d==0 and j==0:
            if h==0 and i+2<=H:
                B.append((i+1,j+1,i+2,j+1))
                cnt += 1
            cur = [i+2,j+1,1-d,1-h]
print(cnt)
for i in range(cnt):
    print(*B[i])

Measured memory_bytes: 97228
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

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; }

ll modpow(ll a, ll n, ll mod)
{
	ll res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

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

	vector<int> a(n);
	vector<vector<int>> x(n);
	vector<vector<int>> y(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		for (int j = 0; j < a[i]; j++)
		{
			int X, Y;
			cin >> X >> Y;
			x[i].push_back(X);
			y[i].push_back(Y);
		}
	}

	int ans = 0;
	for (int bit = 0; bit < 1 << n; bit++)  // 全探索分ループ
	{
		bool isHonest = true;
		int honestNum = 0;
		for (int i = 0; i < n; i++)  // 人数分ループ
		{
			if (bit & (1 << i))  // 人iが正直者か不親切な人かを判定
			{
				honestNum++;
				for (int j = 0; j < a[i]; j++)  // 証言数分ループ
				{
					if (y[i][j] == 1)
					{
						if (!(bit & (1 << (x[i][j] - 1))))
						{
							isHonest = false;
							break;
						}
					}
					else
					{
						if (bit & (1 << (x[i][j] - 1)))
						{
							isHonest = false;
							break;
						}
					}
					
				}
				if (!isHonest)break;
			}
		}
		if (isHonest)
		{
			ans = max(ans, honestNum);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] A = new int[n + 1];
    for (int i = 0; i < n + 1; i++)
      A[i] = sc.nextInt();
    long result = 0;
    int b;
	for (int i = 0; i < n; i++) {
	  b = sc.nextInt();
	  if (b > A[i]) {
	    result += A[i];
        b -= A[i];
        result += Math.min(A[i + 1], b);
        A[i + 1] = Math.max(0, A[i + 1] - b);
      } else
        result += b;
    }
    System.out.println(result);
  }
}

Measured memory_bytes: 66652
from sys import stdin

n = int(stdin.readline().rstrip())
s = [stdin.readline().rstrip() for i in range(n)]
d = {}
dl = []
for i in range(26):
    d.update({chr(i + 97): 0})
for i in range(n):
    dl.append(d.copy())
for i in range(n):
    for si in s[i]:
        dl[i][si] += 1
ans = ''
for al in range(26):
    tmp = 10**9+7
    for i in range(n):
        if tmp > dl[i][chr(al + 97)]:
            tmp = dl[i][chr(al + 97)]
    ans += (tmp * chr(al + 97))

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define rsort(x) sort(all(x));reverse(all(x))
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
 
bool debug=false;
/*---------------------------------------------------*/

int main(){
  int n,a;
  cin>>n>>a;
  cout<<n*n-a<<endl;
  return 0;
}


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

map <int,double> dp[3000];

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

	int n;
	double t;
	vector <double> p;

	cin >> n;
	for(int i=0;i<n;i++)
	{
		cin >> t;
		p.push_back(t);
	}

	dp[0][0] = 1;
	for(int i=0;i<n;i++)
	{
		for(auto it : dp[i])
		{
			dp[i+1][it.first - 1] += it.second*(1 - p[i]);
			dp[i+1][it.first + 1] += it.second*(p[i]);
		}
	}

	double res = 0;

	for(auto it : dp[n])
	{
		if(it.first > 0)
		{
			res += it.second;
		}
	}

	cout << fixed;
	cout.precision(9);
	
	cout << res << '\n';

	return 0;
}


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

using namespace std;

#define lli long long 
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(lli i=0;i<j;i++)
#define rep1(i,j) for(lli i=1;i<=j;i++)
#define rep0d(i,j) for(lli i=j-1;i>=0;i--)
#define MAX 1000000007

int main(){
        int n,m,l;
        cin >> n;
        rep1(i,9)rep1(j,9){
        if(i*j==n){
                cout << "Yes";
                return 0;
        }
        }

        cout << "No";
}


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

int dp[40][401][401];
bool eg[40][401][401];
int a[40];
int b[40];
int c[40];
const int CMAX = 4'000;

using namespace std;

int main()
{
    int N, MA, MB;
    cin >> N >> MA >> MB;

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

    int asum = 0;
    int bsum = 0;
    for (int i = 0; i < N; i++)
    {
        asum += a[i];
        bsum += b[i];
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j <= asum; j++)
        {
            for (int k = 0; k <= bsum; k++)
            {
                eg[i][j][k] = false;
                dp[i][j][k] = CMAX;

                if (i == 0)
                {
                    if (j == 0 && k == 0)
                    {
                        dp[i][j][k] = 0;
                        eg[i][j][k] = true;
                    }
                    else if (j == a[i] && k == b[i])
                    {
                        dp[i][j][k] = c[i];
                        eg[i][j][k] = true;
                    }
                    continue;
                }

                if (eg[i - 1][j][k])
                {
                    dp[i][j][k] = dp[i - 1][j][k];
                    eg[i][j][k] = true;
                }
                if (j - a[i] >= 0 && k - b[i] >= 0 && eg[i - 1][j - a[i]][k - b[i]])
                {
                    dp[i][j][k] = min(dp[i][j][k], dp[i - 1][j - a[i]][k - b[i]] + c[i]);
                    eg[i][j][k] = true;
                }
            }
        }
    }

    int result = CMAX;
    bool exists = false;
    for (int fac = 1; fac * MA <= asum && fac * MB <= bsum; fac++)
    {
        if (eg[N - 1][fac * MA][fac * MB])
        {
            result = min(result, dp[N - 1][fac * MA][fac * MB]);
            exists = true;
        }
    }

    cout << (exists ? result : -1) << endl;

    return 0;
}

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

const int MAX = 5000;
const int INF = 1e6;

int n;
string s;

bool C(int x) {
    string M[MAX];
    if (x > n/2) return false;
    for (int i = 0; i+x <= n; i++) {
        M[i] = s.substr(i, x);
    }
    for (int i = 0; i+x+x <= n; i++) {
        for (int j = i+x; j+x <= n; j++) {
            if (M[i] == M[j]) return true;
        }
    }
    return false;
}

void solve() {
    int lb = 0, ub = INF;

    while (ub-lb > 1) {
        int mid = (lb+ub)/2;
        if (C(mid)) lb = mid;
        else ub = mid;
    }

    printf("%d\n", lb);
}

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

    solve();
}

Measured memory_bytes: 6552
N,M = map(int,input().split())
L = [0]*M
R = [0]*M

for n in range(M):
    L[n],R[n] = map(int,input().split())

if min(R)-max(L)+1 <= 0:
    print(0)
else:
    print(min(R)-max(L)+1)

Measured memory_bytes: 45016
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

a,b,x = li()
left = x* -(-a//x)
right = x * (b//x)
print((right-left)//x + 1)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <chrono>
#include <random>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int a, b, c;
	std::cin >> a >> b >> c;
	std::cout << (a == b && b == c ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
int N,K;
  cin>>N>>K;
  vector<double> p(N);
  double max=0;int now=0;
  int check=-1;
  for(int i=0;i<N;i++)//入力
  {
   cin>>p[i];
  }
  for(int i=0;i<K;i++)//最初のK個の和
  {
    max=max+p[i];
    now=max;
    //cout<<now<<endl;
  }
  for(int i=0;i<(N-K);i++)//一つずつずらして、比較
  {
    now=now-p[i]+p[K+i];
    //cout<<now<<endl;
    if(max<=now)
    {
      max=now;
      check=i;
    }
  }
 //cout<<check<<endl;
  max=0;
  for(int i=0;i<K;i++)
  {
   max=max+((p[check+1+i]+1)/2);
  }
  cout<<fixed<<setprecision(10)<<max<<endl;
}

Measured memory_bytes: 1792
#include <stdio.h>

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int n;
  int i, j, k;

  scanf ( "%d", &n );
  while ( n-- )
  {
    int f[ 9 ][ 9 ] = { { 0 } };
    int d[ 9 ][ 9 ];

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

    for ( i = 0; i < 9; ++i )
    for ( j = 0; j < 9; ++j )
    for ( k = 0; k < 9; ++k )
    {
      if ( j != k
        && d[ i ][ j ] == d[ i ][ k ] )
      {
        f[ i ][ j ] =
        f[ i ][ k ] = 1;
      }
      if ( i != k
        && d[ i ][ j ] == d[ k ][ j ] )
      {
        f[ i ][ j ] =
        f[ k ][ j ] = 1;
      }
      if ( i != i - ( i % 3 ) + ( k / 3 )
        && j != j - ( j % 3 ) + ( k % 3 )
        && d[ i ][ j ] == d[ i - ( i % 3 ) + ( k / 3 ) ]
                           [ j - ( j % 3 ) + ( k % 3 ) ] )
      {
        f[ i ][ j ] =
        f[ i - ( i % 3 ) + ( k / 3 ) ]
         [ j - ( j % 3 ) + ( k % 3 ) ] = 1;
      }
    }

    for ( i = 0; i < 9; ++i )
    {
      for ( j = 0; j < 9; ++j )
      {
        printf ( "%c%d", f[ i ][ j ] ? '*' : ' ', d[ i ][ j ] );
      }
      puts ( "" );
    }

    if ( n )  puts ( "" );
  }

  return ( 0 );
}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var A = Scanner.ScanEnumerable<int>().ToArray();
            var answer = 0;
            for (var i = 0; i < A.Length; i++)
            {
                if(A[i] == 0) answer = i + 1;
            }

            Console.WriteLine(answer);
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 27992
def binarySearch(A, key, ret=False):
    left = 0
    right = len(A)
    while left < right:
        mid = (left + right) // 2
        if A[mid] == key:
            return mid if not ret else ret
        if key < A[mid]:
            right = mid
        else:
            left = mid + 1
    return False


N = int(input())
S = list(map(int, input().split()))
Q = int(input())
T = list(map(int, input().split()))
ans = 0
for t in T:
    ans += 1 if binarySearch(S, t, ret=True) else 0
print(ans)


Measured memory_bytes: 16712
#include <bits/stdc++.h>
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; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

ll a[300000];
ll b[300000];
ll sa[300000];
ll sb[300000];

int main(){
    ll n,m,k; cin >> n >> m >> k;
    for(int i=1;i<=n;i++) cin >> a[i];
    for(int i=1;i<=m;i++) cin >> b[i];
    for(int i=1;i<=n;i++) sa[i]=sa[i-1]+a[i];
    for(int i=1;i<=m;i++) sb[i]=sb[i-1]+b[i];
    ll c=0;
    for(int i=0;i<=n;i++) if(sa[i]<=k) c=i;
    ll ans=0;
    bool f=false;
    for(int i=0;i<=m;i++){
        while(sa[c]+sb[i]>k){
            c--;
            if(c<0) f=true;
            if(f) break;
        }
        if(f) break;
        chmax(ans,c+i);
    }
    cout << ans << endl;
}

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

#define pb push_back
const int maxn = 1e5 + 5;

int n,k;
int cur[maxn];
vector<int> a[1005], b[1005];
int cnt[2];

void upd(int x) {
    cnt[cur[x]]--;
    cur[x] ^= 1;
    cnt[cur[x]]++;
}

int main() {
	int i,r,c,x,y;
	char ch;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++) {
		scanf("%d%d %c",&x,&y,&ch);
		cur[i] = ((x/k+2)%2) ^ ((y/k+2)%2) ^ (ch=='W' ? 0 : 1);
		cnt[cur[i]]++;
//		printf("cur %d = %d (%d %d %d)\n",i,cur[i],((x/k+2)%2),((y/k+2)%2),(ch=='W' ? 0 : 1));
//		printf("----- mark %d and %d\n",(x/k+1)*k-x,(y/k+1)*k-y);
		a[(x/k+1)*k-x].pb(i);
		b[(y/k+1)*k-y].pb(i);
	}
	int ans = 0;
	for(r=0;r<k;r++) {
		for(auto x : a[r]) upd(x);
		for(c=0;c<k;c++) {
			for(auto x : b[c]) upd(x);
			ans = max(ans, max(cnt[0], cnt[1]));
		}
		for(c=0;c<k;c++) {
			for(auto x : b[c]) upd(x);
		}
	}
	printf("%d",ans);
}


Measured memory_bytes: 1792
AV = input().split()
BW = input().split()
T = input().split()
A = int(AV[0])
V = int(AV[1])
B = int(BW[0])
W = int(BW[1])
T = int(T[0])
if abs(A-B) <= (V - W) * T:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 9188
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;

int main(void)
{
  LL n;
  cin >> n;
  LL max = 0,answer = 0;
  REP(i,n) {
    LL h;
    cin >> h;
    if(h<max) continue;
    ++answer;
    max=h;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
Cij = [list(map(int,input().split())) for _ in range(3)]
b1,b2,b3 = Cij[0][0],Cij[0][1],Cij[0][2]
a2,a3 = Cij[1][0]-b1,Cij[2][0]-b1

if Cij[1][1] != a2+b2:
  print("No")
  exit()
  
if Cij[1][2] != a2+b3:
  print("No")
  exit()
  
if Cij[2][1] != a3+b2:
  print("No")
  exit()
  
if Cij[2][2] != a3+b3:
  print("No")
  exit()
  
print("Yes")      

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

int main(){
	ll n;
	cin >> n;
	ll ans=0;
	rep(i,n-1){
		ans += i+1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author alireza_kaviani
 */

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define Mp                          make_pair
#define sep                         ' '
#define endl                        '\n'
#define debug(x)                    cerr << #x << " = " << x << endl
#define SZ(x)                       ll(x.size())
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

template<ll SIZE>
struct DSU {
    ll par[SIZE], sz[SIZE];

    DSU() {
        fill(par, par + SIZE, -1);
        fill(sz, sz + SIZE, 1);
    }

    ll Find(ll v) {
        return (par[v] == -1 ? v : par[v] = Find(par[v]));
    }

    ll Union(ll v, ll u) {
        ll pv = Find(v), pu = Find(u);
        if (pv == pu) return 0;
        if (sz[pv] < sz[pu]) swap(pv, pu); // union by rank
        par[pu] = pv;
        sz[pv] += sz[pu];
        return 1;
    }

    ll getSize(ll v) {
        return sz[Find(v)];
    }
};

ll n, m, q, A[MAXN], B[MAXN], C[MAXN];
vector<pll> E, x;
DSU<MAXN> dsu;

int main() {
    fast_io;

    cin >> n >> m >> q;
    for (ll i = 1; i <= q; i++) {
        cin >> A[i] >> B[i] >> C[i];
        if (C[i] == 0) {
            if (dsu.Union(A[i], B[i])) {
                E.push_back({A[i], B[i]});
                m--;
            }
        } else {
            x.push_back({A[i], B[i]});
        }
    }
    if (m + E.size() == n - 1 && x.size() != 0)
        return cout << "No" << endl, 0;
    if (m + E.size() == n - 1)
        return cout << "Yes" << endl, 0;
    vector<ll> v;
    for (ll i = 0; i < n; i++) {
        if (dsu.Find(i) == i) {
            v.push_back(i);
        }
    }

    for (pll i : x) {
        if (dsu.Find(i.X) == dsu.Find(i.Y)) return cout << "No" << endl, 0;
    }

    for (ll i = 0; i < v.size(); i++) {
        if (i == 0 && v.size() <= 2) continue;
        ll x = i, y = (i + 1) % SZ(v);
        E.push_back({v[x], v[y]});
        m--;
    }
    if (m < 0) return cout << "No" << endl, 0;
    if (m > SZ(v) * (SZ(v) - 1) / 2 - SZ(v)) return cout << "No" << endl, 0;
    cout << "Yes" << endl;

    return 0;
}
/*

*/


Measured memory_bytes: 28784
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
#include <iomanip>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
	int y, m, d;
	while(cin >> y >> m >> d)
	{
		char str[256];
		sprintf(str, "%04d%02d%02d", y, m, d);
		
		string in = str;
		if	   (in < "18680908")	cout << "pre-meiji" << endl;
		else if(in < "19120730")	cout << "meiji"  << " " << y - 1867 << " " << m << " " << d << endl;
		else if(in < "19261225")	cout << "taisho" << " " << y - 1911 << " " << m << " " << d << endl;
		else if(in < "19890108")	cout << "showa"  << " " << y - 1925 << " " << m << " " << d << endl;
		else						cout << "heisei" << " " << y - 1988 << " " << m << " " << d << endl;
	}
}

Measured memory_bytes: 0