akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
ll mod=1e9+7;
int main() {
    /*
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
    #endif*/
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll dp[n][k+1];
    for(int j=0;j<=k;j++){
        if(j<=a[0]) dp[0][j]=1;
        else dp[0][j]=0;
    }
    for(int i=1;i<n;i++){
        ll pre[k+1];
        for(int j=0;j<=k;j++){
            pre[j]=dp[i-1][j];
            if(j>0) pre[j]=(pre[j]+pre[j-1])%mod;
        }
        for(int j=0;j<=k;j++){
            int st=j-min(a[i],j);
            int end=j;
            ll x=0;
            if(st>0) x=pre[st-1];
            dp[i][j]=(pre[end]-x+mod)%mod;
        }
    }    
    cout<<dp[n-1][k];
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) (a).begin(),(a).end()

template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}
template<typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (x < y) x = y;}
#define int ll
int n;
vector<int> a, b;

void read() {
    cin >> n;
    a.resize(n), b.resize(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        a[i] = x + y;
        b[i] = x - y;
    }
}

int calc(vector<int> a) {
    return *max_element(all(a)) - *min_element(all(a));
}

void run() {
    /*cout << "a = " << endl;
    for (auto i : a) {
        cout << i << " ";
    }
    cout << endl;
    cout << "b = " << endl;
    for (auto i : b) {
        cout << i << " ";
    }
    cout << endl;*/
}

void write() {
  //  cout << calc(a) << " " << calc(b) << endl;
    cout << max(calc(a), calc(b)) << endl;
}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
    read();
    run();
    write();
    return 0;
}

Measured memory_bytes: 9532
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int h = abs(d-b);
    int w = abs(c-a);
    for(int i = 0; i < h; i++){
        cout << "U";
    }
    for(int i = 0; i < w+1; i++){
        cout << "R";
    }
    for(int i = 0; i < h+1; i++){
        cout << "D";
    }
    for(int i = 0; i < w+1; i++){
        cout << "L";
    }
    for(int i = 0; i < 1; i++){
        cout << "U";
    }
    for(int i = 0; i < 1; i++){
        cout << "L";
    }
    for(int i = 0; i < h+1; i++){
        cout << "U";
    }
    for(int i = 0; i < w+1; i++){
        cout << "R";
    }
    for(int i = 0; i < h+1; i++){
        cout << "D";
    }
    for(int i = 0; i < w; i++){
        cout << "L";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate((x).begin(), (x).end(), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	std::ios::sync_with_stdio(false);

	int n;

	cin >> n;

	vector<int> t(n);

	REP(i, n) {
		cin >> t[i];
	}

	int m;

	cin >> m;

	vector<int> p(m), x(m);

	REP(i, m) {
		cin >> p[i] >> x[i];
	}

	int sum;

	sum = ACM(t, 0);

	REP(i, m) {
		cout << sum - (t[p[i] - 1] - x[i]) << '\n';
	}

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n-1);
    for (auto& e : a) cin >> e;
    for (auto& e : b) cin >> e;
    for (auto& e : c) cin >> e;

    int ans = 0;
    for (int i = 0; i < n; i++) ans += b[a[i]-1];
    for (int i = 0; i < n-1; i++) if (a[i] + 1 == a[i+1]) ans += c[a[i]-1];
    cout << ans << endl;
}


Measured memory_bytes: 256
n,m = gets.chomp.split(" ").map(&:to_i)
node = {}
mark = Array.new(n+1){nil}
n.times do |c|
  node[c+1] = []
end
m.times do
  e1,e2 = gets.chomp.split(" ").map(&:to_i)
  node[e1] << e2
  node[e2] << e1
end

#p node

v = Hash.new{false} #visited
q = [] #queue

piv = 1
v[1] = true
q << 1
while(!q.empty?)
  piv = q.shift
  node[piv].each do |e|
    unless v[e]
      v[e] = true
      q.push e
      unless mark[e]
        mark[e] = piv
      end
    end
  end
end

able = true

(2..n).each do |e|
  unless mark[n]
    able = false
    break
  end
end

if able
  puts("Yes")
  mark.drop(2).each do |e|
    puts("#{e}")
  end
else
  puts("No")
end

Measured memory_bytes: 41652
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int N[4];

	for (int i = 0; i < 4; i++) {
		cin >> N[i];
	}
	sort(N, N + 4);
	if (N[0] == 1 && N[1] == 4 && N[2] == 7 && N[3] == 9) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
def main():
	X = int(input())
	fifth_power = [x ** 5 for x in range(201)]
	for i in range(len(fifth_power)):
		p = fifth_power[i]
		q1 = abs(X - p)
		q2 = abs(X + p)
		if q1 in fifth_power:
			if p + q1 == X:
				print(fifth_power.index(p), -fifth_power.index(q1))
			elif p - q1 == X:
				print(fifth_power.index(p), fifth_power.index(q1))
			return 0
		if q2 in fifth_power:
			print(fifth_power.index(q2), fifth_power.index(p))
			return 0

main()

Measured memory_bytes: 9056
#include <cstdio>
#include <algorithm>
#define N 100005
using namespace std;
typedef long long ll;
ll n, ans, pr[N];
struct st{ll x, y, z;} a[N], b[N*2];

bool cmp1(st p, st q) {return p.x<q.x;}
bool cmp2(st p, st q) {return p.y<q.y;}
bool cmp3(st p, st q) {return p.z<q.z;}
ll f(ll p) {
	if(pr[p]==p) return p;
	return pr[p] = f(pr[p]);
}

int main() {
	ll i, x, y;
	scanf("%lld", &n);
	for(i=1; i<=n; i++) scanf("%lld%lld", &a[i].x, &a[i].y), a[i].z=pr[i]=i;
	sort(a+1, a+n+1, cmp1);
	for(i=1; i<n; i++) b[i] = {a[i].z, a[i+1].z, a[i+1].x-a[i].x};
	sort(a+1, a+n+1, cmp2);
	for(i=1; i<n; i++) b[i+n-1] = {a[i].z, a[i+1].z, a[i+1].y-a[i].y};
	sort(b+1, b+2*n-1, cmp3);
	for(i=1; i<2*n-1; i++) {
		x = f(b[i].x), y = f(b[i].y);
		if(x!=y) ans += b[i].z, pr[y] = x;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    int x = 7 % N;
    set<int> s;
    int count = 1;
    while(s.count(x) == 0){
        if(x == 0) {
            cout << count << endl;
            return 0;
        }
        s.insert(x);
        x = (x * 10 + 7) % N;
        count++;
    }
    cout << "-1" << endl;
    return 0;
}

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

using namespace std;

int main(){
  	int n ; 
  	cin >> n ; 
  	for(int i = 1; i < 10; i++){
    	for(int j = 1; j < 10; j++){
        	if ( i * j == n ){
              return cout << "Yes" << endl, 0 ; 
            }
        }
    }
  	cout << "No" << endl;
	return 0;  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b,c;
  cin >> a >> b >>c;
  cout << max(10*a+b+c,max(10*b+c+a,10*c+a+b)) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 100000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> ans(N, 0);
  for (ll i = 0; i < N - 1; ++i) {
    ll a;
    cin >> a;
    ans.at(a - 1) += 1;
  }
  for (ll i = 0; i < N; ++i) {
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 4844
n = int(input())
list = [int(i) for i in input().split()]

list_odd = list[::2]
list_even = list[1::2]

def cnt_element(x):
    dict = {}
    for i in x:
        if i not in dict:
            dict[i] = 1
        else:
            dict[i] += 1
    return [(v,k) for k,v in dict.items()]

cnt_odd = sorted(cnt_element(list_odd),reverse=True)
cnt_even = sorted(cnt_element(list_even),reverse=True)

#最頻値が同じの場合
if cnt_odd[0][1] == cnt_even[0][1]:
    #リスト内の値が１つの場合
    if len(cnt_odd) ==1 or len(cnt_even) == 1:
        ans =  int(n / 2)
    #リストが２つ以上の場合
    else:
        #第２最頻値の出現数が奇数の方が多い
        if cnt_odd[1][0] > cnt_even[1][0]:
            ans = n - cnt_odd[1][0] - cnt_even[0][0]
        #第二２最頻値の出現数が偶数の方が多い
        elif cnt_odd[1][0] <= cnt_even[1][0]:
            ans = n - cnt_odd[0][0] - cnt_even[1][0]
#最頻値が異なる場合
else:
    ans = n - cnt_odd[0][0] - cnt_even[0][0]

print(ans)

Measured memory_bytes: 20636
N, Ma, Mb = map(int, input().split())
info = []
a_list = [0] * N
b_list = [0] * N
c_list = [0] * N
for i in range(N):
    a, b, c = map(int, input().split())
    a_list[i] = a
    b_list[i] = b
    c_list[i] = c

inf = 10 ** 10
a_sum = sum(a_list)
b_sum = sum(b_list)
dp = [[[inf for _ in range(b_sum + 1)] for _ in range(a_sum + 1)] for _ in range(N + 1)]
dp[0][0][0] = 0
for i in range(N):
    a, b, c = a_list[i], b_list[i], c_list[i]
    for j in range(a_sum + 1):
        for k in range(b_sum + 1):
            if j - a >= 0 and k - b >= 0:
                dp[i + 1][j][k] = min(dp[i][j - a][k - b] + c, dp[i][j][k])
            else:
                dp[i + 1][j][k] = dp[i][j][k]

x = 1
ans = inf
while Ma * x <= a_sum and Mb * x <= b_sum:
    ans = min(ans, dp[-1][Ma * x][Mb * x])
    x += 1

if ans == inf:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 62172
#include<bits/stdc++.h>
#define endl "\n" 
using namespace std;
#define debug(x) cout<<"The value of "<<#x<<" is "<<x<<endl;
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    cin.sync_with_stdio(0); cin.tie(0); 
    int k,a,b;
    cin>>k>>a>>b;
    if(a%k==0){
        cout<<"OK"<<endl;
        return 0;
    } 
    else{
        int c=a+k-a%k;
        if(c<=b)
        cout<<"OK"<<endl;
        else 
        cout<<"NG"<<endl;
    }
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


void solve(int n, int x){
    int ans = 0;
    
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            int sum = i+j;
            if(sum > x) break;
            for(int k = j+1; k <= n; k++){
                if(sum + k == x){
                    ans++;
                    break;
                } else if(sum + k > x){
                    break;
                }
            }
        }
    }

    cout << ans << endl;
}

int main(){
    int n, x;

    while(true){
        cin >> n >> x;
        if(n == 0 && x == 0) break;
        solve(n,x);
    }

    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int n, m;

int main() {
    while(1) {
        cin >> n >> m;
        if(n == 0 && m == 0) break;
        vector<int> taro(n, 0);
        vector<bool> tch(110, false);
        int tsum = 0;
        for(int i = 0; i < n; ++i) {
            cin >> taro[i];
            tsum += taro[i];
            tch[taro[i]] = true;
        }
        vector<int> hanako(m, 0);
        vector<bool> hch(110, false);
        int hsum = 0;
        for(int i = 0; i < m; ++i) {
            cin >> hanako[i];
            hsum += hanako[i];
            hch[hanako[i]] = true;
        }
        int tans = 1000000, hans = 1000000;
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j < m; ++j) {
                if((tsum-taro[i]+hanako[j]) == (hsum-hanako[j]+taro[i])) {
                    if(tans+hans > taro[i]+hanako[j]) {
                        tans = taro[i];
                        hans = hanako[j];
                    }
                }
            }
        }
        if(tans == 1000000 && hans == 1000000) cout << -1 << endl;
        else cout << tans << " " << hans << endl;
    }
}


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

int main(){
    int n = 0, y = 0;
    int sum = 0, k = 0;
    bool flag = false;

    cin >> n >> y;

    for(int i = 0; i < n+1; i++){
        for(int j = 0; i + j < n+1; j++){
            k = n - i - j;
            sum = 10000*i + 5000*j + 1000*k;
            if(y == sum){
                cout << i << " " << j << " " << k << endl;
                flag = true;
                break;
            }
        }
        if(flag) break;
    }

    if(flag == false){
        cout << "-1 -1 -1" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include <algorithm>
#include<stdio.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include<vector>

using namespace std;
#define fr(i,j,n)   for(int i=j;i<(n);++i)
#define bk(i,j,n)   for(int i=j;i>=n;--i)
#define pb push_back
#define mp make_pair
#define Fs first
#define Sc second
#define endl "\n"
#define MOD 1000000007
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef long long int lli;

int main()
{
    lli n,a,b,ans;
    cin>>n>>a>>b;
    lli tmp=b-a;
    if(tmp%2==0)
    {
        ans=tmp/2;
    }
    else
    {
        ans=min((b+a-1)/2,(2*n-b-a+1)/2);
    }
    cout<<ans<<endl;
    return 0;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int n,m;
    cin >>n;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<<(n+1)/2<<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
s = list(input())
N = len(s)

ref = ["A","C","G","T"]
lst = []

for i in range(N):
    ans = ""
    if s[i] in ref:
        while s[i] in ref:
            ans = ans + s[i]
            i += 1
            if i >= N:
                break
    lst.append(ans)

ans = -float("inf")
for i in range(N):
    ans = max(ans, len(lst[i]))

print(ans)


Measured memory_bytes: 9016
#include<iostream>
using namespace std;
int main(){
    int n,m,l;
    cin >> n >> m >> l;
    int A[n][m] = {},B[m][l] = {};
    long C[n][l] = {};
    
    //要素をAに代入
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin >> A[i][j];
        }
    }
    //要素をBに代入
    for(int i=0;i<m;i++){
        for(int j=0;j<l;j++){
            cin >> B[i][j];
        }
    }
    //Cを計算
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            for(int k=0;k<m;k++){
                C[i][j] += A[i][k]*B[k][j]; 
            }
        }
    }
    //Cを出力
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j==0){
                cout << C[i][j];
            }
            else{
                cout << " " << C[i][j];
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll a,b,q;
  cin>>a>>b>>q;
  ll s[111111],t[111111];
  for(int i=0;i<a;i++)cin>>s[i];
  for(int i=0;i<b;i++)cin>>t[i];

  for(int i=0;i<q;i++){
    ll x;
    cin>>x;
    ll x1,x2,y1,y2;
    ll INF=1LL<<50;
    ll ans=INF;
    
    if(x<=s[0]){
	 x1=INF;
	 x2=s[0]-x;
    }else if(x>=s[a-1]){
	 x1=x-s[a-1];
	 x2=INF;
    }else{
	 ll ok=0,ng=a,mid;
	 while(ng-ok>1){
	   mid=(ok+ng)/2;
	   if(s[mid]<=x)ok=mid;
	   else ng=mid;
	 }
	 x1=x-s[ok];
	 x2=s[ok+1]-x;
    }

    
    if(x<=t[0]){
	 y1=INF;
	 y2=t[0]-x;
    }else if(x>=t[b-1]){
	 y1=x-t[b-1];
	 y2=INF;
    }else{
	 ll ok=0,ng=b,mid;
	 while(ng-ok>1){
	   mid=(ok+ng)/2;
	   if(t[mid]<=x)ok=mid;
	   else ng=mid;
	 }
	 y1=x-t[ok];
	 y2=t[ok+1]-x;
    }

    ans=min(ans,max(x1,y1));
    ans=min(ans,max(x2,y2));
    ans=min(ans,x1+2*y2);
    ans=min(ans,2*x1+y2);
    ans=min(ans,x2+2*y1);
    ans=min(ans,2*x2+y1);

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


Measured memory_bytes: 2944
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		int[] time = new int[1000];
		int[] sum = new int[1000];
		while (true) {
			int n = sc.nextInt();
			if (n == 0) break;
			Arrays.fill(time, -1);
			Arrays.fill(sum, 0);
			for (int i = 0; i < n; i++) {
				sc.next();
				String t = sc.next();
				int min = 60*Integer.parseInt(t.substring(0, 2)) + Integer.parseInt(t.substring(3));
				char c = sc.next().charAt(0);
				int num = sc.nextInt();
				if (c == 'I') {
					time[num] = min;
				} else {
					if (num == 0) {
						for (int j = 1; j < 1000; j++) {
							if (time[j] >= 0) {
								sum[j] += min - max(time[0], time[j]);
							}
						}
						time[0] = -1;
					} else {
						if (time[0] >= 0) {
							sum[num] += min - max(time[0], time[num]);
						}
						time[num] = -1;
					}
				}
			}
			int res = -1;
			for (int i = 1; i < 1000; i++)
				res = max(res, sum[i]);
			out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 44040
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    map<int, long long int> mp;
    for(int n=0; n<N; n++) {
        int A;
        cin >> A;
        mp[A]++;
    }

    vector<long long int> vec(mp.size());
    int cnt=0;
    for(auto itr=mp.begin(); itr!=mp.end(); itr++) {
        vec[cnt] = itr->second;
        cnt++;
    }
    
    sort(vec.begin(), vec.end());
    long long int ans=0;
    for(int i=0; i+K<vec.size(); i++) {
        ans += vec[i];
    }
    
    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 14336
#include <iostream>
#include <string>
#include <stdlib.h>
#define llint long long

using namespace std;

llint a, b, c, d;

llint count(llint x, llint d)
{
	return x/d;
}

llint gcd(llint a, llint b)
{
	if(b == 0) return a;
	return gcd(b, a%b);
}

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

llint calc(llint x)
{
	return x - count(x, c) - count(x, d) + count(x, lcm(c, d));
}

int main(void)
{
	cin >> a >> b >> c >> d;
	cout << calc(b) - calc(a-1) << endl;
	return 0;
}

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

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define watch(x) cout<<(#x)<<" is "<<(x)<<"\n"
#define show(a,b) cout<<(#a)<<" is "<<(a)<<" "<<(#b)<<" is "<<(b)<<"\n"
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(n) for(auto i=0;i<n;i++) 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef pair<pi,pi> ppi;

void solve()
{
    ll n,wt,val=0;
    cin>>n>>wt;
    vl w(n),v(n);
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
        val+=v[i];
    }    
    ll k[n+1][val+1];
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=val;j++)
        {
            k[i][j]=INT_MAX;
            if(j==0)
            k[i][j]=0;
        }
    } 
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=val;j++)
        {
            
            if(v[i-1]<=j){//show(k[i-1][j],w[i-1]+k[i-1][j-v[i-1]]);
            k[i][j]=min(k[i-1][j],w[i-1]+k[i-1][j-v[i-1]]);}
            else
            k[i][j]=k[i-1][j];
        }
    }
    
      
    ll ans_val=INT_MIN;
    for(ll i=1;i<=n;i++)
    {
        for(ll j=1;j<=val;j++)
        {
            if(k[i][j]<=wt)
            {
                ans_val=max(ans_val,j);    
            }
        }
    }
    cout<<ans_val<<"\n";
}

int main()
{
    fast;
    solve();
    return 0;
}
/*
    for(ll i=0;i<=n;i++)
    {
        for(ll j=0;j<=val;j++)
        {
            cout<<k[i][j]<<" ";
        }
        cout<<"\n";
    }  
*/    

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

int main() {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> p(a), q(b), r(c);
    rep(i,a) cin >> p[i];
    rep(i,b) cin >> q[i];
    rep(i,c) cin >> r[i];
    sort(all(p));
    sort(all(q));
    sort(all(r));
    reverse(all(p));
    reverse(all(q));
    reverse(all(r));
    vector<ll> v;
    ll ans = 0;
    rep(i,x) v.push_back(p[i]);
    rep(i,y) v.push_back(q[i]);
    rep(i,c) v.push_back(r[i]);
    sort(all(v));
    reverse(all(v));
    rep(i,x+y) ans += v[i];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9756
#include <iostream>

#include <algorithm>
#include <cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>

using namespace std;
typedef long long LL;

int main() {


	int a, b = 0, c = 0;
	//----------------------
	double n, X, Z,A,B;
	double ans ;

	//cin >> X;//円
	cin >> A;//ケーキ
	cin >> B;

	
	ans = (A + B) / 2;

	//cout << ans << endl;

	ans=ceil(ans);
	
	cout << ans << endl;

	//------------------------
	//cin >> Z;

	return 0;
}

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

using namespace std;

int main(){
    long long int N,K,ans=0;
    cin >> N >> K;
    vector<long long int> p(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }

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

    for(int i=0;i<K;i++){
        ans += p[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}


void solve(std::string S){
    REP(i,S.size()){
        cout<<"x";
    }cout<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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


int main()
{
	string s;
	cin >> s;
	ll n = s.size() - 1, ans = 0;
	for (int mask = 0; mask < (1 << n); ++mask)
	{
		ll sum = s[n] - '0', base = 1;
		for (int i = n - 1; i >= 0; --i)
		{
			if (mask & (1 << i))
				base = 1;
			else 
				base *= 10;
			sum += (s[i] - '0') * base;
		}
		ans += sum;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3640
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Must Be Rectangular!
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_X = 100000;
const int MAX_Y = 100000;
const int MAX_M = MAX_X + MAX_Y;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

vi nbrs[MAX_M];
bool used[MAX_M];
int cs[2];

/* subroutines */

/* main */

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

  int maxx = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--, y--;
    int u = x * 2, v = y * 2 + 1;
    nbrs[u].push_back(v);
    nbrs[v].push_back(u);
    if (maxx < x) maxx = x;
  }

  ll sum = 0;
  for (int x = 0; x <= maxx; x++) {
    int st = x * 2;
    if (! used[st]) {
      used[st] = true;
      cs[0] = 1, cs[1] = 0;
      int en = 0;
      qi q;
      q.push(st);

      while (! q.empty()) {
	int u = q.front(); q.pop();
	vi &nbru = nbrs[u];
	en += nbru.size();

	for (vi::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
	  int &v = *vit;
	  if (! used[v]) {
	    used[v] = true;
	    cs[v & 1]++;
	    q.push(v);
	  }
	}
      }

      sum += (ll)cs[0] * cs[1] - en / 2;
    }
  }

  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 8320
#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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

int N;
vector<long long> X;

long long solve() {
    long long res = 1LL<<60;
    for (long long x = 0; x <= 100; ++x) {
        long long sum = 0;
        for (int i = 0; i < N; ++i) {
            sum += (X[i] - x) * (X[i] - x);
        }
        chmin(res, sum);
    }
    return res;
}

int main() {
    while (cin >> N) {
        X.resize(N);
        for (int i = 0; i < N; ++i) cin >> X[i];
        cout << solve() << endl;
    }
}

















Measured memory_bytes: 256
#include <iostream>
#include<stdio.h>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<math.h>
#include<cmath>
using namespace std;
int a[2010][2010];
int main()
{
   int n,m,i,j,l,p,b[2010];
   cin>>n>>m>>p;
   memset(b,0,sizeof(b));
   for(i=1;i<n;i++)
   {
       for(j=i+1;j<=n;j++)
        {
            a[i][j]=min(j-i,abs(i-m)+1+abs(j-p));
            b[a[i][j]]++;
        }
   }
   for(i=1;i<n;i++)
    cout<<b[i]<<endl;
    return 0;
}


Measured memory_bytes: 15360
from bisect import bisect_left
A, B, Q = map(int, input().split())
minf, inf = -(10**18), 10**18
jinja = [minf] + list(map(int, (input() for _ in range(A)))) + [inf]
tera = [minf] + list(map(int, (input() for _ in range(B)))) + [inf]
ans = []
append = ans.append

for q in map(int, list(map(int, (input() for _ in range(Q))))):
    i = bisect_left(jinja, q)
    j = bisect_left(tera, q)
    left_jinja, right_jinja = q-jinja[i-1], jinja[i]-q
    left_tera, right_tera = q-tera[j-1], tera[j]-q
 
    append(min(
        left_jinja if left_jinja > left_tera else left_tera,
        left_jinja + right_tera + (left_jinja if left_jinja < right_tera else right_tera),
        right_jinja + left_tera + (right_jinja if right_jinja < left_tera else left_tera),
        right_jinja if right_jinja > right_tera else right_tera
    ))
 
print(*ans, sep="\n")

Measured memory_bytes: 19144
h,w=map(int,input().split())
s=[]
for _ in range(h):
    li=list(input())
    s.append(li)
#print(s)
#print(s[h-1][w-1])

flg=0
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            if(i-1<0 or s[i-1][j]!="#"):
                if(i+1>=h or s[i+1][j]!="#"):
                    if(j-1<0 or s[i][j-1]!="#"):
                        if(j+1>=w or s[i][j+1]!="#"):
                            print("No")
                            flg+=1
                            exit()

if flg==0:
    print("Yes")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdlib.h>
#define FastRead                      \
            ios_base::sync_with_stdio(false); \
            cin.tie(0);
#define endl "\n"
using namespace std;
int main()
{
    FastRead
    double k,n,p,i,b,j,d;
    long long int a,c,m;
    cin>>a>>b;
    i=(int)b;
    c=a*i;
    d=b-i;
    m=c+(d*a)+.002;
    m=(long long int)m;
    cout<<m<<endl;
    return 0;



}








Measured memory_bytes: 3736
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k,h[200010];
    long long ans=0;
    cin>>n>>k;
    for(int i=0;i<n;i++) cin>>h[i];
    sort(h,h+n);
    for(int i=0;i<n-k;i++){
        ans+=h[i];
    }
    cout<<ans;
}


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

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            while(Console.In.Peek() != -1)
            {
                double v = double.Parse(Console.ReadLine());
                double t = v / 9.8;
                double y = 4.9 * t * t;
                int n = (int)(Math.Ceiling(y / 5) + 1);
                Console.WriteLine(n);
            }
        }
    }
}

Measured memory_bytes: 5652
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {
  int X; std::cin >> X;
  if ( X == 7 || X == 5 || X == 3) std::cout << "YES" << std::endl;
  else std::cout << "NO" << std::endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        int N = scanner.nextInt();
        
        long[] a = new long[N];
        long y = 0;
        
        a[0] = scanner.nextInt();
        for(int i = 1; i < N; i++) {
            a[i] = scanner.nextInt();
            y += a[i];
        }
        
        long x = a[0];
        long min = Math.abs(x - y);
        for(int i = 1; i < N - 1; i++) {
            x += a[i];
            y -= a[i];
            long calc = Math.abs(x - y);
            if(min > calc) {
                min = calc;
            }
        }
        System.out.println(min);
        
    }
}

Measured memory_bytes: 83276
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n, m; cin >> n >> m;
    vector<vector<int>> a(n);
    rep(i,m) {
        int ai, bi;
        cin >> ai >> bi;
        ai--; bi--;
        a[ai].push_back(bi);
        a[bi].push_back(ai);
    }

    int path[n];
    rep(i,n) path[i] = i;

    int ans = 0;
    do {
        //rep(i,n) cout << path[i] << " ";
        //cout << endl;
        int reach = 1;
        rep(i,n-1) {
            int flag = 0;
            rep(j,a[path[i]].size()) {
                if(a[path[i]][j] == path[i+1]) {
                    flag = 1;
                }
            }
            if (flag == 0) {
                reach = 0;
                break;
            }
        }
        if (reach)
            ans++;
    } while(next_permutation(path+1, path+n));

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


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val a = sc.nextInt()
  val b = sc.nextInt()
  val c = sc.nextInt()
  val d = sc.nextInt()
  val s = sc.next()

  val ss = "#" + s + "#"

  if (hasTwo(ss, a-1, c) || hasTwo(ss, b-1, d)) {
    println("No")
    return
  }

  if (c > d) {
    var ok = false
    for (i in b..d) {
      if (ss[i-1] == '.' && ss[i] == '.' && ss[i+1] == '.') {
        ok = true
      }
    }
    if (!ok) {
      println("No")
      return
    }
  }

  println("Yes")

}

private fun hasTwo(s: String, start: Int, end: Int): Boolean {
  for (i in start..end) {
    if (s[i] == '#' && s[i+1] == '#') return true
  }

  return false
}

Measured memory_bytes: 41936
// #include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#define pb emplace_back
#define LOCAL
  
using namespace std;
  
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
typedef long long ll;
typedef pair<int,int> Pii;
 
template <typename T>inline void read(T& t){
    char c=getchar();t=0;
    int f=1;
    while(!isdigit(c)){
       if(c=='-')f=-1;
        c=getchar();
    }
    while(isdigit(c))t=t*10+c-48,c=getchar();
    t=f*t;
}
  
template <typename T,typename... Args> inline void read(T& t,Args&... args){
    read(t);read(args...);
}

string s;
  
int main(){
    int t=1;
    // read(t);
    while(t--){
        cin>>s;
        int tmp=0,ans=-1;
        for(int i=0;i<3;i++){
            if(s[i]=='R'){
                tmp++;
            }else{
                ans=max(ans,tmp);
                tmp=0;
            }
        }
        ans=max(ans,tmp);
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3184
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, left, right=0, sum=0, ans=0;

    cin >> N;

    vector<ll> A(N);

    for(i=0; i<N; i++){
        cin >> A[i];
    }

    left = 0;

    for(left=0; left<N; left++){
        while(right<N && (sum ^ A[right]) ==(sum + A[right])){
            sum += A[right];
            right++;
        }

        ans += (right-left);

        if(right==left) right++;
        else sum -= A[left];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
mod = 10**9+7

bits = [0]*70
for a in As:
    for l in range(a.bit_length()):
        if (a>>l)&1:
            bits[l] += 1

ans = 0
for i in range(70):
    one = bits[i]
    zero = N-one
    mul = pow(2, i, mod)
    ans += one*zero*mul
    ans %= mod

print(ans)

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

int main(){
    int n, i, j, f, p, c;
    int list[100] = {};
    f = 1;
    c = 0;
    
    cin >> n;
    
    for(i = 0; i < n; i++){
        cin >> list[i];
    }
    

    while(f == 1){
        f = 0;
        for(j = n-1; j > 0; j--){
            if(list[j] < list[j-1]){
                swap(list[j], list[j-1]);
                f = 1;
                c++;
            }
        }
    }

    
    for(i = 0; i < n-1; i++){
        cout << list[i] << " ";
    }
    cout << list[i] << endl;
    cout << c << endl;
    
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001


int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<vector<bool>> E(N,vector<bool>(N,false));
	
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a][b]=true;
		E[b][a]=true;
	}
	
	vector<int> V(N);
	for(int i=0;i<N;i++)V[i]=i;
	
	int ans = 0;
	do{
		if(V[0]!=0)continue;
		bool f = true;
		for(int i=0;i<N-1;i++){
			if(E[V[i]][V[i+1]]==false){
				f=false;
			}
		}
		if(f)ans++;
	}
	while(next_permutation(V.begin(),V.end()));
	
	cout<<ans<<endl;
	
    return 0;
}



Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>

#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>

#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

// type
#include <cstdint>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    char c;
    cin >> c;

    cout << (char)(c + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();  // input Integer
//    String a = sc.next();  // input String
    int count = 0;
    for(int i =1; i<=a; i++){
      int b=sc.nextInt();
      if (i%2==1 && b%2==1){
        count++;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 35872
import sys

N, K = map(int, input().split())

D = set(map(int, input().split()))

def check(n):
  m = set(str(n))
  for c in m:
    if int(c) in D:
      return False
  return True


for i in range(999999):
  if check(N+i):
    print(N+i)
    sys.exit()

Measured memory_bytes: 9092
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
import java.util.concurrent.ArrayBlockingQueue;

public class Main {

     static Scanner scanner;

     public static void main(String[] args) {
         scanner = new Scanner(System.in);

         int N=gi();
         int M=gi();
         Map<Integer,List<Integer>> map=new HashMap<Integer,List<Integer>>();
         Map<Integer,List<Integer>> map2=new HashMap<Integer,List<Integer>>();
         boolean[] f=new boolean[N];
         boolean[] fl=new boolean[M];
         for (int i=1; i<=N;i++) {
        	 int k=gi();
        	 List<Integer> ls=new ArrayList<Integer>();
        	 for (int j=0; j<k;j++) {
        		 int l=gi();
        		 if(map.containsKey(l)) {
        			 List<Integer> li=map.get(l);
        			 li.add(i);
        		 } else {
        			 List<Integer> li=new ArrayList<Integer>();
        			 li.add(i);
        			 map.put(l, li);
        		 }
        		 ls.add(l);
        	 }
        	 map2.put(i,ls);
         }

         Queue<Integer> q=new ArrayBlockingQueue<Integer>(N);
         q.add(1);
         f[0]=true;
         while(!q.isEmpty()) {
        	 int v=q.poll();
        	 List<Integer> lv =map2.get(v);
        	 for (int i=0; i<lv.size();i++) {
        		 int ll=lv.get(i);
        		 if(fl[ll-1]) continue;
        		 fl[ll-1]=true;
        		 List<Integer> nv=map.get(ll);
        		 for(int j=0; j<nv.size();j++) {
        			 int n=nv.get(j);
        			 if(f[n-1]==false) {
        				 q.add(n);
        				 f[n-1]=true;
        			 }
        		 }
        	 }
         }
         boolean ff=true;
         for (int i=0; i<N;i++) {
        	 if(f[i]==false) {
        		 ff=false;
        	 }
         }

         if(ff) {
             System.out.println("YES");
         }else {
        	 System.out.println("NO");
         }
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 76104
n,k=map(int,input().split())
xyc=[list(input().split()) for i in range(n)]
data=[[[] for i in range(k)] for j in range(k)]
B=[[0]*k for i in range(k)]
W=[[0]*k for i in range(k)]
for u in xyc:
    x=int(u[0])
    y=int(u[1])
    c=u[2]
    a,b=x%k,y%k
    if (x//k+y//k)%2==0:
        if c=="B":
            B[a][b]+=1
        else:
            W[a][b]+=1
    else:
        if c=="B":
            W[a][b]+=1
        else:
            B[a][b]+=1
lst=[[0]*k for i in range(k)]
li=[[0]*k for i in range(k)]
for i in range(k):
    lst[i][0]=B[i][0]
    li[i][0]=W[i][0]
    for j in range(1,k):
        lst[i][j]=lst[i][j-1]+B[i][j]
        li[i][j]=li[i][j-1]+W[i][j]
for i in range(1,k):
    for j in range(k):
        lst[i][j]+=lst[i-1][j]
        li[i][j]+=li[i-1][j]
det=[[0]*k for i in range(k)]
den=[[0]*k for i in range(k)]
for i in range(k):
    i=k-1-i
    det[i][k-1]=B[i][k-1]
    den[i][k-1]=W[i][k-1]
    for j in range(1,k):
        j=k-j-1
        det[i][j]=det[i][j+1]+B[i][j]
        den[i][j]=den[i][j+1]+W[i][j]
for i in range(1,k):
    i=k-i-1
    for j in range(k):
        j=k-j-1
        det[i][j]+=det[i+1][j]
        den[i][j]+=den[i+1][j]
bcount=lst[k-1][k-1]
wcount=li[k-1][k-1]
ans=max(bcount,wcount)
for i in range(k-1):
    for j in range(k-1):
        o=lst[i][j]+det[i+1][j+1]
        p=li[i][j]+den[i+1][j+1]
        ans=max(ans,o+wcount-p,bcount-o+p)
for i in range(k-1):
    o=lst[k-1][i]
    O=lst[i][k-1]
    p=li[k-1][i]
    P=li[i][k-1]
    ans=max(ans,bcount-o+p,wcount-p+o)
    ans=max(ans,bcount-O+P,wcount-P+O)
print(ans)

Measured memory_bytes: 143492
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
const int N=2e5+5;
priority_queue< pair<int,int> > q;
int n,c[N],a[N];
int le(int u){
	return u==1?n:u-1;
}
int re(int u){
	return u==n?1:u+1;
}
signed main(){
	///freopen("in01.txt","r",stdin);
	cin>>n;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i<=n;++i)
		cin>>c[i];
	for(int i=1;i<=n;++i)
		if(c[i]!=a[i]) q.push(make_pair(c[i],i));
	int ans=0;
	while(!q.empty()){
		int u=q.top().se,tmp=0; q.pop();
		tmp=c[le(u)]+c[re(u)];
		if(q.empty()){
			if((c[u]-a[u])%tmp!=0) return puts("-1"),0;
			ans+=(c[u]-a[u])/tmp; c[u]=a[u]; break;
		}
		int t=(c[u]-max(max(c[le(u)],c[re(u)]),a[u]))/tmp;t=max(t,1ll);
		c[u]-=t*tmp; ans+=t;
		if(c[u]<a[u]) return puts("-1"),0;
		if(c[u]>a[u]) q.push(make_pair(c[u],u));
	}
	cout<<ans;
	return 0;
}

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

int n, d, q;
long a[500000];
long b[500001];
long p[500001];

bool sub(int k) {
  return b[k] >= p[k + 1];
}

void pre() {
  int dist = d;
  for (int i = 0; i < n; ++i) {
    b[i] = dist;
    if (a[i] < 2 * dist) {
      dist = abs(dist - a[i]);
    }
  }
  b[n] = dist;
  
  long curr = 1;
  p[n] = curr;
  for (int i = n - 1; i >= 0; --i) {
    if (a[i] < curr * 2) {
      curr += a[i];
    }
    p[i] = curr;
  }
}

int main() {
  cin >> n >> d;
  for (int i = 0; i < n; ++i) cin >> a[i];
  pre();
  cin >> q;
  for (int j = 0; j < q; ++j) {
    int b;
    cin >> b;
    --b;
    cout << (sub(b) ? "YES" : "NO") << endl;
  }
}

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

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int A[200000];

int main() {
    int N;
    cin >> N;
    REP(i, N) cin >> A[i];

    ll ans = 0;
    int r = 0, x = 0, count = 0;
    REP(l, N) {
        while (x + A[r] == (x ^ A[r]) && r < N) {
            x ^= A[r];
            r++;
            count++;
        }
        x ^= A[l];
        ans += count;
        count--;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024