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

signed main(){
	int n; cin >> n;
	vector<ll>a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	ll num = a[0];
	for(int i = 1; i < n; i++) num ^= a[i];
	vector<ll> ans(n, 0);
	for(int i = 0; i < n; i++){
		ans[i] = num ^ a[i];
	}
	for(auto i : ans) cout << i << " ";
	cout << endl;
}

Measured memory_bytes: 6272
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main() {
	int n; cin >> n;
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < n; i++) {
		int k; cin >> k;
		if (k % 4 == 0)c++;
		else if (k % 2 == 0)b++;
		else a++;
	}
	if (a <= c)cout << "Yes\n";
	else if (a + b - 1 == c)cout << "Yes\n";
	else cout << "No\n";
	char ch; cin >> ch;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#include <set>
#include <queue>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++) 
#define reps(i, s, n) for (int i = s; i < (int)(n); i++) 
#define ll long long
#define ld long double
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define repsl(i, s, n) for (ll i = s; i < (ll)(n); i++)  
#define outdeb(fir, sec, thr) cout << fir << ":" << sec << ":" << thr << endl

#define lpair pair<ll, ll>

int main()
{
  string s;
  cin >> s ;
  ll ans = 0;
  ll now = 0;
  rep(i, s.length())
  {
    if(s[i] == 'R')
    {
      now++;
      ans = max(ans, now);
    }
    else
    {
      now = 0;
    }
    
  }
  cout << ans << endl;

  return 0;
}

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

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

    if ((a + k - 1) / k * k <= b) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
%>

Measured memory_bytes: 3636
import scala.io.StdIn.readInt
import scala.collection.mutable.ArrayBuffer

object Main {

  def factorize(p:Int,d:Int,l:List[Int]):List[Int] = {
    if(d >= Math.sqrt(p)+1) {
      if(p != 1) p::l else l
    } else {
      if(p%d == 0)
        factorize(p/d,d,d::l)
      else if(d==2)
        factorize(p,d+1,l)
      else
        factorize(p,d+2,l)
    }
  }

  def printList(l:List[Int]):Unit = l match {
    case List() => ()
    case h::tail =>
        printList(tail)
        print(" " + h)
  }

  def main(args: Array[String]) = {
    val n = readInt
    val list = factorize(n,2,List())
    print(n.toString + ":")
    printList(list)
    println()
  }
}

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

int main()
{
    ll n, m;
    cin >> n >> m;
    string s, t;
    cin >> s >> t;

    ll c = __gcd(n, m);
    ll n_r = n / c;
    ll m_r = m / c;

    // validation
    rep(i, 0, c)
    {
        if (s[n_r * i] != t[m_r * i])
        {

            cout << -1 << endl;
            return 0;
        }
    }
    cout << n * m / c << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iterator>
#include<vector>
using namespace std;
#define int long long
bool ch(int n, vector<int> &pat){
	if(n==0){
		int flag = false;
		for(int i=0;i<9;i++){
			if(pat[i]==2) flag = true;
		}
		return flag;
	}
	for(int i=0;i<7;i++){
		if(pat[i]>0 && pat[i+1]>0 && pat[i+2]>0){
			vector<int> pat2;
			copy(pat.begin(), pat.end(), back_inserter(pat2));
			pat2[i]--;
			pat2[i+1]--;
			pat2[i+2]--;
			if( ch(n-1, pat2) ) return true;
		}
	}
	for(int i=0;i<9;i++){
		if(pat[i]>=3){
			vector<int> pat2;
			copy(pat.begin(), pat.end(), back_inserter(pat2));
			pat2[i]-=3;
			if( ch(n-1, pat2) ) return true;
		}
	}
	return false;
}
signed main(){
	char buf[128];
	while( scanf("%s", buf) != EOF ){
		vector<int> pat(9,0);
		for(int i=0;i<13;i++){
			pat[buf[i]-'1']++;
		}
		int count = 0;
		for(int i=0;i<9;i++){
			if(pat[i]<4){
				vector<int> pat2;
				copy(pat.begin(), pat.end(), back_inserter(pat2));
				pat2[i]++;
				if(ch(4,pat2)){
					if(count > 0) cout << " ";
					cout << i+1;
					count++;
				}
			}
		}
		if(count==0) cout << 0 ;
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3140
def get_int_list(inp_str):
    return list(map(int, inp_str.split(" ")))

n, m = get_int_list(input())
objs = get_int_list(input())

threshold = sum(objs) / (4 * m)
ans = [o >= threshold for o in objs]
num = sum(ans)
if num >= m:
    print("Yes")
else:
    print("No")




Measured memory_bytes: 3060
//ThakurAnurag
//TemplateCode

#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long int
#define fo(i,a,n) for(ll i=a;i<n;i++)
#define fo2(i,a,n) for(ll i=n;i>=a;i--)
#define endl "\n"
#define sp " "
#define f first
#define s second
#define pb push_back
#define buffer ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define lower(str) transform(str.begin(), str.end(), str.begin(), ::tolower);
#define upper(str) transform(str.begin(), str.end(), str.begin(), ::toupper);
#define init(arr,val) memset(arr,val,sizeof(arr))
#define vecl(v) vector<ll> v
#define vecs(v) vector<string> v
#define vecp(v) vector < pair <ll,ll> > v

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

	ll ans=0;
	ll arr[n];
	fo(i,0,n){
		cin>>arr[i];
		if(arr[i]%2==0){
			ll temp = arr[i];
			while(temp%2==0){ 
				ans++;
				temp/=2;
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 384
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

MOD = int(1e9) + 7
sum = 0
for i in range(K, N + 2):
    sum += (N - i + 1) * i + 1
    sum %= MOD
    # print(i, (N - i + 1) * i + 1)

print(sum)

Measured memory_bytes: 9676
//package com.atcoder.contest173.b;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        Map<String, Integer> mp = new LinkedHashMap<>();
        int n = fs.nextInt();
        mp.put("AC",0); mp.put("WA",0); mp.put("TLE",0); mp.put("RE", 0);
        for(int i=0; i<n; ++i){
            String s = fs.next();
            mp.put(s, mp.getOrDefault(s, 0)+1);
        }
        for(String k : mp.keySet()){
            System.out.println(k + " x " + mp.get(k));
        }
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

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


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

int main(){
    int N, D;
    cin >> N >> D;
    vector<int> X(N), Y(N);
    for(int i=0; i<N; i++) cin >> X.at(i) >> Y.at(i);
    int64_t DD = 1;
    DD *= D;
    DD *= D;
    int cnt = 0;
    
    for(int i=0; i<N; i++){
        int64_t distance, XX = 1, YY = 1;
        XX *= X.at(i);
        XX *= X.at(i);
        YY *= Y.at(i);
        YY *= Y.at(i);
        distance = XX + YY;
        if(distance <= DD){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4840
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>

using namespace std;

int A[100000];

int partition(int A[], int p, int r) {
    int base = A[r];

    int separator_idx = p-1;
    int exp_idx = p;

    for(; exp_idx <= r ; exp_idx++) {
        if(A[exp_idx] <= base) {
            separator_idx++;
            swap(A[exp_idx], A[separator_idx]);
        }
    }
    return separator_idx;
}

int main(void) {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> A[i];
    int separator_idx = partition(A, 0, n - 1);
    
    for (int i = 0; i < n; i++) {
        if ( i ) cout << " ";
        if ( i == separator_idx) cout << "[";
        cout << A[i];
        if ( i == separator_idx) cout << "]";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3388
import java.util.Scanner;

public class Main {
  public static void main(String... args) {
	  Scanner sc = new Scanner(System.in);
	  int a = sc.nextInt();
	  int b = sc.nextInt();
	  int k = sc.nextInt();

	  if (b - a >= 2 * k) {
		  for (int i = a ; i < a + k ; i++) {
			  System.out.println(i);
		  }
		  for (int j = b - k + 1 ; j < b + 1 ; j++) {
			  System.out.println(j);
		  }
	  } else {
		  for (int i = a ; i < b + 1 ; i++) {
			  System.out.println(i);
		  }
	  }
  }
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void warshall_floyd(Graph &graph) {
    int V = graph.size();
    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            for (int j = 0; j < V; ++j) {
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j]);
            }
        }
    }
}

ll to_id(ll x, ll y) {
    return 25 * x + y;
}

void Main() {
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    rep(i, H) cin >> grid[i];

    Graph graph(500, vector<ll>(500, INF));
    rep(i, H) {
        rep(j, W) {
            if (grid[i][j] == '#') continue;
            rep(k, 4) {
                int x = dx[k];
                int y = dy[k];
                if (0 <= j + y && j + y < W && 0 <= i + x && i + x < H && grid[i + x][j + y] != '#') {
                    ll from = to_id(i, j);
                    ll to = to_id(i + x, j + y);
                    graph[from][to] = 1;
                }
            }
        }
    }
    warshall_floyd(graph);
    ll ans = 0;
    rep(i, H) {
        rep(j, W) {
            ll start = to_id(i, j);
            if (grid[i][j] == '#') continue;
            rep(i2, H) {
                rep(j2, W) {
                    ll goal = to_id(i2, j2);
                    if (start == goal)continue;
                    if (grid[i2][j2] == '#') continue;
                    ll tmp = graph[start][goal];
                    if (tmp < INF) {
                        ans = max(tmp, ans);
                    }
                }
            }
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

bool is_prime(int a){
  for(int i = 2; i*i <= a; ++i){
    if(!(a%i)) return false;
  }
  return true;
}

int main(){
  int N;
  cin >> N;
  vector<int> ans(N);
  int t = 0;
  for(int i = 1; i <= 11111; ++i){
    int x = 5*i + 1;
    if(is_prime(x)){
      ans[t] = x;
      ++t;
      if(t == N) break;
    }
  }
  for(int i = 0; i < N-1; ++i) cout << ans[i] << " ";
  cout << ans[N-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<complex>
#include<vector>
using namespace std;
#define x second
#define y first
#define pu push_back
typedef complex<double> point;
pair<int,int> a[100000];
vector<int> st;

bool ccw(point a,point b,point c){
  b-=a;
  c-=a;
  c*=conj(b);
  if(c.imag()<=0)return true;  
  return false;
}

void check(int i){
 while(st.size()>=2){
      int s=st[st.size()-2];
      int e=st[st.size()-1];
      point S=point(a[s].x,a[s].y);
      point E=point(a[e].x,a[e].y);
      point N=point(a[i].x,a[i].y);
      if(ccw(S,E,N))break;
      st.pop_back();
    }
 st.pu(i);
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y;
  sort(a,a+n);
  for(int i=0;i<n;i++)check(i);
  for(int i=n-2;i>=0;i--)check(i);
  st.pop_back();
  cout<<st.size()<<endl;
  cout<<a[st[0]].x<<' '<<a[st[0]].y<<endl;
  for(int i=st.size()-1;i>0;i--)cout<<a[st[i]].x<<' '<<a[st[i]].y<<endl;
  return 0;
}

Measured memory_bytes: 2460
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int tr[1001][2],dp[1001][1001];
int main(){
  int w,n,c=1;
  while(cin >>w,w){
    cin >>n;
    for(int i=0; i<1001; i++) for(int j=0; j<1001; j++) dp[i][j] = 0;
    for(int i=1; i<=n; i++) scanf("%d,%d",&tr[i][0],&tr[i][1]);
    for(int i=1; i<=n; i++){
      for(int j=0; j<=w; j++){
	dp[i][j] = max(dp[i][j],dp[i-1][j]);
	if(j+tr[i][1]<=w) dp[i][j+tr[i][1]] = max(dp[i][j+tr[i][1]],dp[i-1][j]+tr[i][0]);
      }
    }
    int ans = 0,y;
    for(int i=0; i<=w; i++){
      if(ans < dp[n][i]){ans = dp[n][i];y = i;}
    }
    cout <<"Case "<<c<<":"<<endl<<ans<<endl<<y<<endl;
    c++;
  }
  return 0;
}

Measured memory_bytes: 5164
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
ls = []
for i in range(N):
    S1, p = raw_input().split()
    p = int(p)
    ls += [(S1, -p, i)]
ls.sort()
ans = [0] * N
for i in range(N):
    S, p, pos = ls[i]
    ans[i] = pos + 1
for num in ans:
    print num

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=32e4,M=1e9+7;

vector<int>t[N];
bool u[N];
int s[N],n;
ll d[N],a[N],f[N];
ll qpow(ll a,ll x){
	ll ans=1;
	for(;x;x>>=1){
		if(x&1)ans=ans*a%M;
		a=a*a%M;
	}
	return ans;
}
ll C(int n,int m){
	return f[n]*qpow(f[m]*f[n-m]%M,M-2)%M;
}
ll dfs(int x){
	u[x]=d[x]=1;
	for(int y:t[x])if(!u[y]){
		s[x]+=dfs(y);
		d[x]=d[x]*C(s[x],s[y])%M*d[y]%M;
	}
	u[x]=0;
	return ++s[x];
}
void get_ans(int x,ll z){
	u[x]=1;
	a[x]=d[x]*C(n-1,n-s[x])%M*z%M;
	for(int y:t[x])if(!u[y])
		get_ans(y,a[x]*qpow(d[y]*C(n-1,s[y])%M,M-2)%M);
	u[x]=0;
}
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	f[0]=1;
	for(int i=1,u,v;i<n;i++){
		f[i]=f[i-1]*i%M;
		cin>>u>>v;
		t[u].push_back(v);
		t[v].push_back(u);
	}
	dfs(1);
	get_ans(1,1);
	for(int i=1;i<=n;i++)cout<<a[i]<<'\n';
	return 0;
}

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

#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define PII pair<int,int>
#define INF LONG_MAX
#define ull unsigned long long
#define long long long
#define PIL pair<long,int>
#define M 1000000007
#define endl "\n"

void fastIO() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

}

int main()
{
	fastIO();
    string t,p;
    cin>>t;
    cin>>p;
    int n1 = t.size();
    int n2 = p.size();
    bool flag  = true;
  
    int to_change = INT_MAX;
    for(int i=0;i<n1;i++){
        if(!flag)
        break;
        int k = 0;
        int j = i;
        
        int count = 0;
        while(k<n2){
            if(j>=n1){
                count = INT_MAX;
                flag = false;
                break;
            }
            if(t[j]!=p[k]){
                count++;
            }
            j++;
            
            k++;
            
        }
    
        // cout<<count<<" ";
        to_change = min(count,to_change);
    }

    cout<<to_change;
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <string.h>

int main(){
		char s[4]; 
		scanf("%s", s,4); 
		if (s[0] == '7' || s[1] == '7' || s[2] == '7')puts("Yes"); 
		else puts("No"); 
	
	return 0;
}


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

int main()
{
	int i, N, a, b;
	cin >> N;
	set<int> s;
	b = 0;
	for (i = 0; i < N; i++)
	{
		cin >> a;
		if (s.count(a) == 0)
		{
			s.insert(a);
		}
		else
		{
			cout << "NO" << endl;
			b = 1;
			break;
		}
	}
	if (b == 0) 
	{
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 9600
#include<stdio.h>

int merge(int[],int,int,int);
int mergeSort(int[],int,int,int);

int main(){
    int i,c,n,s[10000000];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&s[i]);
    }
    c = mergeSort(s,0,n,n);
    for(i=0;i<n;i++){
        printf("%d",s[i]);
        if(i != n-1){
            printf(" ");
        }
    }
    printf("\n%d\n",c);
    return 0;
}

int merge(int A[],int left,int mid,int right){
    int i,j,k,n1,n2,count=0;
    n1 = mid - left;
    n2 = right - mid;
    int L[n1+1], R[n2+1];
    for(i = 0 ; i <= n1-1 ; i++){
        L[i] = A[left + i];
    }
    for(i = 0 ; i <= n2-1 ; i++){
        R[i] = A[mid + i];
    }
    L[n1] = 999999999;
    R[n2] = 999999999;
    i = 0;
    j = 0;
    for(k = left ; k <= right-1 ; k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i = i + 1;
            count++;
        }else{
            A[k] = R[j];
            j = j + 1;
            count++;
        }
    }
    return count;
} 
int mergeSort(int A[],int left,int right,int n){
    int mid;
    static int count=0;
    if(n<=1) return count;
    if(left+1 < right){
        mid = (left + right)/2;
        mergeSort(A, left, mid,n);
        mergeSort(A, mid, right,n);
        count += merge(A, left, mid, right);
    }
    return count;
}



Measured memory_bytes: 5652
import math
import sys
from itertools import permutations
input = sys.stdin.readline

N=int(input())
arr=list(map(int,input().split()))
arr.sort(reverse=True)

cur=2
ans=arr[0]
for i in range(1,N):
    if cur>=N:
        break
    ans+=arr[i]
    cur+=1

    if cur>=N:
        break
    ans+=arr[i]
    cur+=1

print(ans)


Measured memory_bytes: 91884
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {ll k, a, b;cin >> k >> a >> b;if(b - a <= 2 || a - 1 > k){cout << 1 + k << endl;return 0;}k -= a - 1;ll count = a;ll n = floor(k / 2);rep(i, n) count += b - a;if(k % 2 == 1) count++;cout << count << endl;}

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

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

typedef long long ll;
 
using namespace std;

int sum_of_digits(int n) {
    int sum = 0;
    while (0 < n) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

void solve() {
    int n, a, b;
    cin >> n >> a >> b;

    int sum = 0, d;
    for (int i = 1; i <= n; i++) {
        d = sum_of_digits(i);
        if (a <= d && d <= b) sum += i;
    }

    cout << sum << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 256
def parentNode(k):
    return k // 2


def leftNode(k):
    return 2 * k


def rightNode(k):
    return 2 * k + 1

banyak = int(input())
elems = [0] + [int(x) for x in input().split()]
# for k in range(1, banyak + 1):
#      print(k,parentNode(k),leftNode(k),rightNode(k))
for k in range(1, banyak+1):
    print("node {}: ".format(k), end="")
    print("key = {}, ".format(elems[k]), end="")
    if parentNode(k) >= 1:
        print("parent key = {}, ".format(
            elems[parentNode(k)]), end="")
    if leftNode(k) <= banyak:
        print("left key = {}, ".format(
            elems[leftNode(k)]), end="")
    if rightNode(k) <= banyak:
        print("right key = {}, ".format(
            elems[rightNode(k)]), end="")
    print()





Measured memory_bytes: 5716
#include <iostream>
#include <queue>
#include <cstring>
using namespace std;

static const int MAX_N = 1000001;

int T_Time[MAX_N], Score[MAX_N];

int main()
{

	int N, R, L, d, t, x, most, P_T = 0, P_D = 1;
	priority_queue< pair< int, int > > ScoreHeap;

	memset( Score , 0, sizeof( Score ) );
	memset( T_Time, 0, sizeof( T_Time ) );

	cin >> N >> R >> L;

	for( int i = 0; i < R; i++ ) {

		cin >> d >> t >> x;
		Score[d] += x;

		ScoreHeap.push( make_pair( Score[d], -d ) );

		while( true ) {

			pair< int, int > temp = ScoreHeap.top();
			if( temp.first == Score[-temp.second] ) {

				T_Time[P_D] += t - P_T;
				P_D = -temp.second;
				P_T = t;
				break;

			}

			ScoreHeap.pop();

		}

	}

	T_Time[P_D] += L - P_T;

	int Max = 0;

	for( int i = 1; i <= N; i++ ) {
		if( Max < T_Time[i] ) { Max = T_Time[i]; most = i; }
	}

	cout << most << endl;

	return 0;

}

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

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int ans = sc.nextInt();
		String s;
		while (sc.hasNext()) {
			s = sc.next();
			if (s.equals("+")) {
				ans += sc.nextInt();
			}
			else if (s.equals("-")) {
				ans -= sc.nextInt();
			}
			else if (s.equals("*")) {
				ans *= sc.nextInt();
			}
			else if (s.equals("/")) {
				ans /= sc.nextInt();
			}
			else {
				out.println(ans);
				break;
			}
		}
	}
}


Measured memory_bytes: 26260
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll gcd(ll x, ll y){
    if ( x == 0 ) return y;
    else if ( y == 0 ) return x;
    else return x > y ? gcd( y, x % y ) : gcd( x, y % x );
}

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin >> n;
    vector<ll> v(n);
    
    for ( ll i = 0; i < n; i++ )
        cin >> v[i];
    
    ll ans = v[0];
    for ( ll i = 1; i < n; i++ )
        ans = gcd(ans, v[i]);
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
/*
AizuOnline A0272
Title
*/
#include <stdio.h>
// Select Below
//#include <stdlib.h>
//#include <string.h>
//#include <float.h>
//#include <math.h>
//#include <limits.h>
//Global data section
int n;
int a[40000];
int b[40000];
//
int comp(int *x,int *y)
{
  return(*x < *y);
}

main()
{
  int i;

  while(EOF!=scanf("%d",&n) && (n))
    {
      for(i=0;i<n;i++)
	scanf("%d ",&a[i]);
     for(i=0;i<n;i++)
	scanf("%d ",&b[i]);

     qsort(a,n,sizeof(int),comp);
     qsort(b,n,sizeof(int),comp);
     
     for(i=0;i<n/2;i++)
       {
	 if(a[i*2] > b[i])
	   {
	     printf("%d\n",i*2+1);
	     goto END;
	   }
       }
     printf("NA\n");
 END:
     ;
    }
return(0);
}

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

using namespace std;

int main(void)
{
  int n;
  cin >> n;
  vector<LL> value(1<<18), weight(1<<18);
  FOR(i,1,n+1) cin >> value[i] >> weight[i];
  vector<vector<pair<LL, LL>>> hanzen(1<<10); // weight, value
  hanzen[0].emplace_back(0,0);
  FOR(bits,1,1<<10) {
    for(pair<LL,LL> p:hanzen[bits/2]) {
      pair<LL,LL> added = make_pair(p.first+weight[bits], p.second+value[bits]);
      hanzen[bits].push_back(p);
      hanzen[bits].push_back(added);
    }
    vector<pair<LL,LL>> tmp(hanzen[bits].begin(),hanzen[bits].end());
    sort(tmp.begin(),tmp.end());
    hanzen[bits].clear();
    hanzen[bits].emplace_back(0,0);
    for(pair<LL,LL> p:tmp) {
      if(hanzen[bits].back().second < p.second) hanzen[bits].push_back(p);
    }
  }
  int q;
  cin >> q;
  while(q--) {
    LL v, l;
    cin >> v >> l;
    vector<pair<LL,LL>> comb;
    comb.emplace_back(0,0);
    while(v>=(1<<10)) {
      vector<pair<LL,LL>> tmp(comb.begin(), comb.end());
      for(pair<LL,LL> p:tmp) {
        pair<LL,LL> added = make_pair(p.first+weight[v], p.second+value[v]);
        comb.push_back(added);
      }
      v/=2;
    }
    LL answer = 0;
    for(pair<LL,LL> p: comb) {
      LL cw,cv;
      tie(cw,cv) = p;
      if(cw>l) continue;
      auto ite = lower_bound(hanzen[v].begin(),hanzen[v].end(), make_pair(l-cw+1,0ll));
      --ite;
      answer=max(answer, cv+ite->second);
    }
    cout << answer << endl;
  }

  return 0;
}


Measured memory_bytes: 18404
#include <stdio.h>

int main(void){
	int n;
	scanf("%d", &n);
	int h[n];
	for(int i=0;i<n;i++){
		scanf("%d", &h[i]);
	}
	
	for(int i=n-2;i>=0;i--){
		if(h[i]>h[i+1]+1){
			printf("No");
			return 0;
		}else if(h[i]==h[i+1]+1){
			h[i]--;
		}
	}
	printf("Yes");
		
	return 0;
}

Measured memory_bytes: 512
//---JQM---//
//#pragma GCC optimize(3)
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

char s[10];
string st;
int main()
{
    map<string, int>ma;
    int n;
    cin>>n;
    ll ans = 0;
    while(n--)
    {
        cin>>s;
        sort(s, s+10);
        st = s;
        ans += ma[st];
        ma[st]++;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
#define int long long
const int inf = 999999999999999999;
typedef long long ll;
typedef long double ld;
int n, m;
struct B {
	int to, cost;
};
vector<B>e[15];
int b[15], ma=1, dp[15][33000];
int solve(int i, int s, int st) {
	if (s == ma&&i == st)
		return dp[i][s] = 0;
	if (s != 0 && i == st) return inf;
	if (dp[i][s] != inf)
		return dp[i][s];
	int sum = inf;
	for (int j = 0; j < e[i].size(); j++) {
		if (!(s&b[e[i][j].to])) {
			sum = min(sum, solve(e[i][j].to, s | b[e[i][j].to], st) + e[i][j].cost);
		}
	}
	return dp[i][s] = sum;
}
signed main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int u1, u2, u3;
		cin >> u1 >> u2 >> u3;
		e[u1].push_back(B{ u2,u3 });
	}
	b[0] = 1;
	for (int i = 1; i < n; i++)
		b[i] = b[i - 1] * 2, ma += b[i];
	int ans = inf;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 15; j++)
			for (int z = 0; z < 33000; z++)
				dp[j][z] = inf;
		ans = min(ans, solve(i, 0, i));
	}
	cout << (ans != inf ? ans : -1) << endl;
	getchar(); getchar();
}

Measured memory_bytes: 7040
l,r = gets.split.map(&:to_i)
result = []

2019.times do |i|
  if (l + i) > r
    break
  end
  result << (l+i) % 2019
end
ans = 2019
result.each do |i|
  result.each do |j|
    if i == j
      next
    end
    if (i * j)%2019 < ans
      ans = (i * j) % 2019
    end
  end
end

puts ans


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

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

  for(int j=0; j<N; j++){
    while(!(a[j]%2)){
      a[j] = a[j]/2;
      sum++;
    }
  }
  cout << sum << '\n';
  return 0;
}

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


import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;


public class Main{ 


    static long mod=1000000007;
     static int dx[]={1,-1,0,0};
       static int dy[]={0,0,1,-1};
    // static int dx[]={1,-1,0,0,1,1,-1,-1};
    // static int dy[]={0,0,1,-1,1,-1,1,-1};
    // PriorityQueue<Integer> que = new PriorityQueue<Integer>(); 
    //HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();

public  static void main(String[] args)   throws Exception, IOException{

    
    Reader sc = new Reader(System.in);
    PrintWriter out=new PrintWriter(System.out);

    //  int n=sc.nextInt();  
    int n=sc.nextInt();
    int k=sc.nextInt();
    long d[] = new long[n];
    long s[] = new long[n];
    long ans = 0;

    for( int i=0; i<n; i++ ){
        d[i] = sc.nextInt() - k;
        if(i>0) d[i]+=d[i-1];
        s[i] = d[i];
    }
    sort(s);
    s = unique_array(s);
    bit bit = new bit(s.length);
    for( int i=0; i<n; i++ ){
        int t = binarySearch(s, d[i]) + 1;
        ans +=  bit.sum(t);
        bit.add(t,1);
        if(d[i]>=0)ans++;
    }

    out.println(ans);
    out.flush();
}

static long[] unique_array(long d[]) {
    //d:sorted
    int id = 1;
    for( int i=1; i<d.length; i++ ){
        if(d[i]!=d[id-1]){
            d[id++] = d[i];
        }
    }
    return copyOf(d, id);
}

static void db(Object... os){

    System.err.println(Arrays.deepToString(os));

}

static boolean validpos(int x,int y,int r, int c){
    
    return x<r && 0<=x && y<c && 0<=y;
    
}
 
static boolean bit(long x,int k){
    // weather k-th bit (from right) be one or zero
    return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
}

}


class XY {
    int x,y,d;
    XY(int x, int y, int d) {
        this.x=x;
        this.y=y;
        this.d=d;
    } 
}

class P implements Comparable<P>{
    int x,y;
    P(int x, int y) {
        this.x=x;
        this.y=y;
    } 
      
    public int compareTo(P p){
        return x - p.x;
    } 
}

class bit {
    int b[],n;
    bit(int n){
        this.n = n;
        b = new int[n+1];
    }
    int sum(int i){
        int s = 0;
        while(i > 0){
            s += b[i];
            i -= i&-i;
        }
        return s;   
    }
    void add(int i, int x){
        while(i <= n){
            b[i] += x;
            i += i&-i;
        }
    }
}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}



Measured memory_bytes: 44752
n, k = map(int,input().split())
mod_ary = [0] * k
for i in range(1,n+1):
    mod_ary[i%k] += 1

ans = 0
for a in range(k):
    b = (k - a) % k
    c = (k - a) % k
    if (b + c) % k != 0:
        continue

    ans += mod_ary[a] * mod_ary[b] * mod_ary[c]
print(ans)


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

int N,K;
ll acc [100001];

int main()
{
	scanf("%d%d",&N,&K);
	vector<ll> A(N);
	for(int i = 0;i < N;i++){
		scanf("%lld",&A [i]);
		acc [i + 1] = acc [i] + (A [i] >= 0 ? A [i] : 0);
	}

	int l = 0,r = 0;
	ll sum = 0;
	while(r - l < K){
		sum += A [r];
		r++;
	}

	ll ans = 0;
	for(;l <= N - K;l++){
		while(r - l < K){
			sum += A [r];
			r++;
		}
		ans = max(ans,(sum >= 0 ? sum : 0) + acc [N] - acc [r] + acc [l]);
		sum -= A [l];
	}

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

	return 0;
}


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

using namespace std;

int main() {
  string S;
  cin >> S;
  bool ok = true;
  for (int i = 0; i + 1 < 4; i++) {
    if (S[i] == S[i + 1]) {
      ok = false;
      break;
    }
  }
  if (ok) {
    printf("Good\n");
  } else {
    printf("Bad\n");
  }
  return 0;
}


Measured memory_bytes: 256
# C - Vacation
def main():
    N, *ABC = map(int, open(0).read().split())
    prev = ABC[:3]
    for abc in zip(*[iter(ABC[3:])] * 3):
        cur = [0] * 3
        for i in range(3):
            cur[i] = abc[i] + max(prev[:i] + prev[i + 1:])
        prev = cur
    print(max(prev))


if __name__ == "__main__":
    main()


Measured memory_bytes: 35636
#include<bits/stdc++.h>
#define ll long long

using namespace std;
int main()
{
	ll x;
	cin>>x;
	ll p,amount=100,count=0;
	while(true){
		p=amount/100;
		amount+=p;
		count++;
		if(amount>=x)
		{
			cout<<count;
			return 0;
		}
	}
}

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

inline long long min(long long x,long long y){
    	return x<y?x:y;
}
signed main(){
    int N;          cin>>N;
    int a[N+1];
    int p[N+1];   int dp[N+1][N+1];    
    a[0]=0;
    for(int i=1;i<=N;++i){
        cin>>a[i];
    }
    partial_sum(a,a+N+1,p);
    memset(dp,0,sizeof(dp));
    for(int cd=2;cd<=N;++cd){
        for(int i=1;i+cd-1<=N;i++){
            int j=i+cd-1;
            if(j<1)
    			continue;
            dp[i][j]=10e18;
            for(int k=i;k<=j;k++){
                dp[i][j]=min(dp[i][k]+dp[k+1][j],dp[i][j]);
            }            
            dp[i][j]+=p[j]-p[i-1];
        }
    }
    cout<<dp[1][N];
}

Measured memory_bytes: 1536
n = int(input())
S = input()
r = []
g = []
b = []
for i, s in enumerate(S):
    if s == 'R':
        r.append(i+1)
    elif s == 'G':
        g.append(i+1)
    else:
        b.append(i+1)

lenr = len(r)
leng = len(g)
lenb = len(b)
total = lenr*leng*lenb
for i in range(0, n-2):
    for j in range(n-(i+1)*2):
        j1 = j+i+1
        j2 = j+i*2+2
        if (S[j] != S[j1]) and (S[j1] != S[j2]) and (S[j2] != S[j]):
            total -= 1
print(total)

Measured memory_bytes: 9276
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
// constexpr ll inf = 1ll<<61;
// constexpr ll mod = 1e9+7;

signed main(){
  int a,b; cin >> a >> b;
  if(b % a == 0) cout << a+b << endl;
  else cout << b-a << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

void solve(int N,int x){
    if(x<=1 || x>=N*2-1){
        cout<<"No"<<endl;
        return;
    }
    cout<<"Yes"<<endl;
    vector<int> res(N*2-1,-1);
    res[N-2]=1;
    res[N-1]=x;
    res[N]=N*2-1;
    int iter=0;
    for(int v=2;v<N*2-1;v++){
        if(v==x) continue;
        while(res[iter]!=-1) iter++;
        res[iter]=v;
    }
    for(auto v : res) cout<<v<<endl;
}


int main(){
    int N,x;
    cin>>N>>x;
    solve(N,x);
}

Measured memory_bytes: 2304
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define black_tree tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define pair_black_tree tree<pair<ll,ll>,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update>
#define gp __gnu_pbds
#define INF 1000000000
#define MOD 1000000007
#define MAX 1000001
#define endl '\n'
#define ll long long
#define ld long double
#define lli long long int
#define ull unsigned long long
#define ulli unsigned long long int
#define pb push_back
#define pf push_front
#define ook order_of_key
#define fbo find_by_order
#define np next_permutation
#define mp make_pair
#define eb emplace_back
#define mae max_element
#define mie min_element
#define lb lower_bound 
#define ub upper_bound
#define bs binary_search
#define ff first
#define ss second
using namespace std;
using namespace gp;
ll n,ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=1;i<n;i++){
    	ans+=(n-1)/i;
	}
	cout<<ans;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a, b) accumulate(all(a), b)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define ios() cin.tie(0), ios::sync_with_stdio(false)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
typedef unsigned long long ull;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
ll const INF = 1e18;

template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007

int main(){
    ll n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    ll ans=0;
    ll s=n%(a+b);
    if(s<a)ans+=s;
    else ans+=a;
    n-=s;
    ans+=n/(a+b)*a;
    cout<<ans<<"\n";
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
ll INF = LLONG_MAX;
 
using vc = vector<char>;
using vi = vector<int>;
using vll = vector<ll>;

int N;
ll W;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> N >> W;
    vi weights0;
    vi weights1;
    vi weights2;
    vi weights3;
    ll BW; int BC; cin >> BW; cin >> BC; weights0.push_back(BC);
    F0R(i, N-1) {
        int W, V; cin >> W >> V;
        if (W == BW) weights0.push_back(V); 
        if (W == BW+1) weights1.push_back(V); 
        if (W == BW+2) weights2.push_back(V); 
        if (W == BW+3) weights3.push_back(V); 
    }
    
    sort(weights0.begin(), weights0.end(), greater<int>());
    sort(weights1.begin(), weights1.end(), greater<int>());
    sort(weights2.begin(), weights2.end(), greater<int>());
    sort(weights3.begin(), weights3.end(), greater<int>());

    vll cumsum0 (N+1); cumsum0[0] = 0;
    vll cumsum1 (N+1); cumsum1[0] = 0;
    vll cumsum2 (N+1); cumsum2[0] = 0;
    vll cumsum3 (N+1); cumsum3[0] = 0;

    FOR(i, 1, N+1) {
        if (i <= weights0.size()) cumsum0[i] = weights0[i-1] + cumsum0[i-1];
        if (i <= weights1.size()) cumsum1[i] = weights1[i-1] + cumsum1[i-1];
        if (i <= weights2.size()) cumsum2[i] = weights2[i-1] + cumsum2[i-1];
        if (i <= weights3.size()) cumsum3[i] = weights3[i-1] + cumsum3[i-1];
    }
    
    ll best = 0;
    for (int i = 0; i <= weights0.size(); ++i) {
        for (int j = 0; j <= weights1.size(); ++j) {
            for (int k = 0; k <= weights2.size(); ++k) {
                for (int l = 0; l <= weights3.size(); ++l) {
                    if (i * BW + j * (BW+1) + k * (BW+2) + l * (BW+3) > W) continue;
                    best = max(best, 1LL * cumsum0[i] + cumsum1[j] + cumsum2[k] + cumsum3[l]);
                }
            }
        }
    }
    cout << best << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
string s;
const int mod = 1e9+7;

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

    cin >> n >> s;
    map<char, int> cnt;
    for(int i = 0; i < s.size(); ++i) {
        cnt[s[i]]++;
    }
    ll ans = 1;
    for(auto x: cnt) {
        ans *= x.second+1ll;
        ans %= mod;
    }
    cout << ans-1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#include <math.h> /* M_PI */
int main()
{
    string s;
    string t;
    cin >> s >> t;
    int flag = 1;
    if (t.size() != s.size() + 1)
    {
        cout << "No";
        flag = 0;
    }
    else
    {
        rep(i, s.size())
        {
            if (t[i] != s[i])
            {
                cout << "No";
                flag = 0;
                break;
            }
        }
        if (flag)
        {
            cout << "Yes";
        }
    }
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    char x,y;
    cin>>x>>y;
    if(x<y)cout<<"<"<<endl;
    else if(x==y)cout<<"="<<endl;
    else cout<<">"<<endl;

    return 0;
}


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

int main()
{
    long n,k;
    cin>>n>>k;
    long a[n], one, l, r, ans=1;
    for(int i=0;i<n;++i)
    {
        cin>>a[i];
        if(a[i]==1)
        one = i+1;
    }
    if(one>=k)
    {
        l = max(one-k, 0l);
        r = max(n-one, 0l);
    }
    else
    {
        l = 0;
        r = max(n-one-(k-one), 0l);
    }
    if(l%(k-1)==0)
    ans+=(l/(k-1));
    else
    ans+=((l/(k-1))+1);
    if(r%(k-1)==0)
    ans+=(r/(k-1));
    else
    ans+=((r/(k-1))+1);
  	n-=k;
  	if(n%(k-1)==0)
      ans = min(ans, (n/(k-1))+1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include<map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue() {
  int a;
  cin >> a;
  return a;
};
void inputVector(vector<int>* v) {
  //cin.tie(0);
  //ios::sync_with_stdio(false);
  int a;
  while (cin >> a) {
    if (a == -1)break;
    v->push_back(a);
  }
};

void inputVector(vector<int> * p, int a) {
  rep(i, a) {
    int input;
    cin >> input;
    p->push_back(input);
  }
}

void inputVector2(vector<vector<int>>& v, int r, int c) {
  int temp;
  for (size_t i = 0; i < r; i++)
  {
    for (size_t j = 0; j < c; j++)
    {
      scanf("%d", &temp);
      v[i][j] = temp;
    }
  }
}
void inputVector3(vector<int>* v0, vector<int>* v1) {
  int a;
  unsigned short count = 0b0;
  while (cin >> a) {
    if (a == -1)break;
    if (count)v0->push_back(a); else v1->push_back(a);
    count = count ^ 1;
  }
};

template <typename T>
void output(T a, int precision) {
  if (precision > 0) {
    cout << setprecision(precision) << a << "\n";
  }
  else {
    cout << a << "\n";
  }
}


int main(int argc, const char * argv[]) {
  int x1, y1, x2, y2, x3, y3, x4, y4, dx, dy;
  scanf("%d", &x1);
  scanf("%d", &y1);
  scanf("%d", &x2);
  scanf("%d", &y2);
  dx = x1 - x2;
  dy = y1 - y2;
  x3 = x2 + dy;
  y3 = y2 - dx;
  x4 = x1 + dy;
  y4 = y1 - dx;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>
#include <bitset>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int H,W,K;
  cin>>H>>W>>K;
  char c[H][W];
  REP(h,H)REP(w,W)cin>>c[h][w];
  int ans=0;
  REP(hi,1<<H)REP(wi,1<<W){
    int temp=0;
    // cerr<<bitset<6>(hi)<<" "<<bitset<6>(wi)<<endl;
    REP(h,H)REP(w,W){
      if((1<<h)&hi)continue;
      if((1<<w)&wi)continue;
      if(c[h][w]=='#')temp++;
      // cerr<<h<<" "<<w<<endl;
    }
    if(temp==K)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

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

#define int ll
#define endl "\n"
#define all( x ) x.begin(), x.end()
#define fast ios::sync_with_stdio(0);cin.tie(0);

typedef unsigned long long ull;

const int inf = 1e11 + 5;
const long double PI = 3.141592653589793;

void solve(){
  string s;
  cin >> s;
  for(char c:s){
    if(c == '7'){
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
  return;
}  
signed main(){
  fast;
  int t;
  t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

Measured memory_bytes: 3576
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  string s;
  cin >> s;
  if(s == "keyence"){
    cout << "YES\n";
    return 0;
  }
  
  int len = s.length();
  if(s.substr(len-7,7) == "keyence"){
    
    cout << "YES\n";
    return 0;
  }

  if(s[0] == 'k' && s.substr(len - 6, 6) == "eyence"){
    cout << "YES\n";
    return 0;
  }
  if(s.substr(0,2) == "ke" && s.substr(len-5, 5) == "yence"){
    
    cout << "YES\n";
    return 0;
  }
  if(s.substr(0,3) == "key" && s.substr(len-4, 4) == "ence"){
    
    cout << "YES\n";
    return 0;
  }
  if(s.substr(0,4) == "keye" && s.substr(len-3, 3) == "nce"){
    
    cout << "YES\n";
    return 0;
  }
  if(s.substr(0,5) == "keyen" && s.substr(len-2, 2) == "ce"){
    
    cout << "YES\n";
    return 0;
  }
  if(s.substr(0,6) == "keyenc" && s[len-1] == 'e'){
    
    cout << "YES\n";
    return 0;
  }
  if(s.substr(0,7) == "keyence"){
    
    cout << "YES\n";
    return 0;
  }

  cout << "NO\n";
  return 0;
}



Measured memory_bytes: 256