akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

const int NIL = -1;
const int MAX = 2147483647;
clock_t START, END;

bool debug = false;
int Tree[500010];
int n;

void update(int x)
{
	x = x / 2;
	while (x > 0) {
		Tree[x] = Tree[2 * x] + Tree[2 * x + 1];
		x = x / 2;
	}
}

int find(int x, int y, int k, int height, int N)
{
	int l, r;
	l = k * (1 << height) - N;
	r = l + (1 << height) - 1;
	if (x > r || y < l)
		return 0;
	if (l > n)
		return 0;
	if (l >= x && r <= y || height == 0)
		return Tree[k];
	return find(x, y, 2 * k, height - 1, N) + find(x, y, 2 * k + 1, height - 1, N);
}
int main(void)
{
	if (debug) {
		START = clock();
		freopen("in12.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int q, com, x, y, N = 1, height = 0;
	scanf("%d%d", &n, &q);
	while (N < n) {
		N *= 2;
		height++;
	}
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d", &com, &x, &y);
		if (com) {
			printf("%d\n", find(x - 1, y - 1, 1, height, N));
		}
		else {
			Tree[N + x - 1] += y;
			update(N + x - 1);
		}
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


Measured memory_bytes: 4028
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    int ans = -1;
    rep(i,N) {
        for (int j = i+1; j < N; ++j) {
            int num = A[i]*A[j];
            if (num < ans) continue;
            string S = to_string(num);
            bool ok = true;
            rep(k,S.size()-1) {
                if (S[k]+1 != S[k+1]) ok =false;
            }
            if (ok) ans = num;
        }
    }

    cout << ans << ln;
}



Measured memory_bytes: 3300
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;

string str;
long long int n,m,a,b,cou=0,res=0;

queue<long long int>que,nextque;
int main() {
	cout << fixed << setprecision(10);
	cin>>str;
	for(int i=0;i<str.length();i++){
		if(i%2==0&&str[i]=='L'||i%2==1&&str[i]=='R'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
} 


Measured memory_bytes: 256
#include "stdio.h"
#include <queue>
#include <functional>

using namespace std;

int main()
{
while(1)
{
 int n,k;
 scanf("%d %d",&n,&k);
if(n == 0 && k == 0)
{
break;
}
 priority_queue<int,vector<int>,greater<int> > q;
 for(int i = 0; i < k; i++)
 {
  int w;
  scanf("%d",&w);
  q.push(w);
 }
 int dp[2] = {0,0};
 int flg = 0;
 int max = 0;
 if(q.top() == 0)
 {
  flg = 1;
  q.pop();
 }
 for(int i = 1; i <= n + 1; i++)
 {
  if(q.empty() == true)
  {
   if(flg == 1)
   {
    if(max < dp[0] + 1)
    {
     max = dp[0] + 1;
    }
   }
   if(max < dp[0])
   {
    max = dp[0];
   }
   if(max < dp[1] && flg == 1)
   {
    max = dp[1];
   }
   break;
  }
  if(q.top() == i)
  {
   dp[0]++;
   dp[1]++;
   q.pop();
  }
  else
  {
   if(flg == 1)
   {
    if(max < dp[1])
    {
     max = dp[1];
    }
    dp[1] = dp[0] + 1;
   }
   if(max < dp[0])
   {
    max = dp[0];
   }
   dp[0] = 0;
  }
 }
 printf("%d\n",max);
}
 return 0;
}

Measured memory_bytes: 1564
#include<bits/stdc++.h>
using namespace std;
inline int read(){
    int f=1,x=0;
    char ch;
    do{
        ch=getchar();
        if(ch=='-'){
            f=-1;
        }
    }while(ch<'0'||ch>'9');
    do{
        x=x*10+ch-48;
        ch=getchar();
    }while(ch>='0'&&ch<='9');
    return f*x;
}
int main(){
    int x=read(),a=read(),b=read();
    int c=x-a;
    if(c<=0){
        cout<<"0"<<endl;
        return 0;
    }
    else{
        c%=b;
        cout<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2)return 0;if(!(n%2))return !(n-2);lll d=n-1,t,y;while(!(d%2))d>>=1;vl al={2,325,9375,28178,450775,9780504,1795265022};for(ll a:al){if(n<=a)break;t=d,y=modpow(a,t,n);while(t!=n-1&&y!=1&&y!=n-1)y=y*y%n,t<<=1;if(y!=n-1&&!(t%2))return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

const int N = 1e5;
int n, k, a[N], d[N];
vpii dv;
si r[N];
void dfs(int _a, int _d, bool z){
  if(z) dv.pb(mp(_d, _a));
  d[_a] = _d;
  each(itr, r[_a]) dfs(*itr, _d+1, z);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  int ans = 0;
  cin >> a[0]; a[0]--;
  if(a[0]) ans++;
  FOR(i, 1, n){
    cin >> a[i];
    a[i]--;
    r[a[i]].insert(i);
  }
  dfs(0, 0, true);
  sort(rng(dv));
  reverse(rng(dv));
  each(itr, dv){
    if(d[itr->se] <= k) continue;
    int aa = itr->se;
    FOR(i, 0, k-1) aa = a[aa];
    r[a[aa]].erase(aa);
    dfs(aa, 1, false);
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 19192
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		out=new PrintWriter (new BufferedOutputStream(System.out));
		FastReader s=new FastReader();
		int n=s.nextInt();
		double[] arr=new double[n];
		for(int i=0;i<n;i++) {
			arr[i]=s.nextDouble();
		}
		if(n==1) {
			out.print(arr[0]);
			out.close();
			return;
		}
		double[][] dp=new double[n+1][n];
		dp[0][0]=(double)1-arr[0];
		dp[1][0]=arr[0];
		outerloop: for(int i=0;i<n-1;i++) {
			for(int j=0;j<n+1;j++) {
				
				dp[j][i+1]+=dp[j][i]*((double)1-arr[i+1]);
				if(j<n)dp[j+1][i+1]+=dp[j][i]*arr[i+1];
			}
		}
		double ans=0.0;
		for(int i=n/2+1;i<n+1;i++) {
			ans+=dp[i][n-1];
		}
		out.println(ans);
		out.close();
	}	

	public static PrintWriter out;
	
	public static class FastReader {
		BufferedReader br;
		StringTokenizer st;
		//it reads the data about the specified point and divide the data about it ,it is quite fast
		//than using direct 

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

		int nextInt() {
			return Integer.parseInt(next());//converts string to integer
		}

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return str;
		}
	}
	
}


Measured memory_bytes: 132560
#include<stdio.h>
#include<math.h>

int main(void){
    int N,M,i,j,t;
    long long int s = 1;
    scanf("%d %d",&N,&M);
    int a[M+1];
    long long int p[N+2];
    p[0] = 0;
    p[1] = 1;
    a[0] = -1;
    for(i = 2;i<=N+1;i++) p[i] = (p[i-2] + p[i-1]) % 1000000007;
    if(M > 0){
        for(j = 1;j <= M;j++){
            scanf("%d",&a[j]);
            s = s * p[a[j]-a[j-1]-1] % 1000000007;
        }
        s = s * p[N-a[M]] % 1000000007;
    }else{
        s = p[N+1] % 1000000007;
    }
    printf("%lld",s);
    return 0;
}

Measured memory_bytes: 1280
S = input()


while len(S) > 8:
    if S.endswith('dream'):
        S = S[:-5]
    elif S.endswith('dreamer'):
        S = S[:-7]
    elif S.endswith('erase'):
        S = S[:-5]
    elif S.endswith('eraser'):
        S = S[:-6]
    else:
        print('NO')
        break
else:
    if S in ['dream', 'dreamer', 'erase', 'eraser']:
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 3188
class Integer
  def divisor_list
    require 'prime'

    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1
      (s..k).map { |n| base ** n }
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
  end
end

N = gets.to_i

puts (1..N).count { |i| i.odd? && i.divisor_list.size == 8 }



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define _USE_MATH_DEFINES
#define ios std::ios::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define PI acos(-1.0)
#define EPS 1e-9 //epsilon 10^-9, checking for equality 
#define pb push_back
#define fi first
#define se second
#define go(i,a,n) for(int i=a;i<n;i++)
#define og(i,a,n) for(int i=n-1;i>=a;i--)
#define rep(i,n) go(i,0,n)
#define per(i,n) og(i,0,n)
#define sz(x) (x.size())
#define isort(x) sort(x.begin(),x.end())
#define dsort(x) sort(x.rbegin(),x.rend())
#define all(x) x.begin(),x.end()
#define rall(x) (x).rbegin(),(x).rend()
#define pr(x) cout<<(x)<<endl
#define exist(e,s) ((s).find(e)!=(s).end()) //Element e in structure s
#define existstr(c,s) ((s).find(c) !=string::npos) //Character in structure
#define fo(x,s) for(auto &x:s) //for all x in structure s
typedef vector<int> vi;typedef vector<ll> vll;typedef vector< vector<int> > vvi;
typedef vector< vector<ll> > vvll;typedef pair<int,int> ii;typedef pair<int, pair<int,int> > iii;
typedef pair<ll,ll> pll;typedef vector<ii> vii;typedef vector<iii> viii;typedef map<int,int> mii;
const int inf=1e9+7; //10^9 +7
inline void rvi(vi& v, int n){int temp; go(i,0,n){cin>>temp;v.pb(temp);}}
inline void rvll(vll& v, int n){ll temp;go(i,0,n){cin>>temp;v.pb(temp);}}
inline void prvi(vi&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prvll(vll&a){go(i,0,a.size()){cout<<a[i]<<" ";}cout<<endl;}
inline void prmii(map<int,int>& m){for(auto x:m){cout<<x.fi<<" "<<x.se<<endl;}}
inline vll prefixsum(vi& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vi& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
inline vll prefixsum(vll& a){vll b;b.pb(a[0]);go(i,1,a.size()){b.pb(a[i]+b[i-1]);}return b;}
inline vll suffixsum(vll& a){vll b(sz(a));b[sz(a)-1]=a[sz(a)-1];og(i,0,sz(a)-1){b[i]=a[i]+b[i+1];}return b;}
void solve();
int main(){ios;solve();return 0;}
//--------SOLVE---------------------------------------------------------------------
void solve()
{
	int n,x;
	cin>>n>>x;
	vi a;
	rvi(a,n);
	a.pb(x);
	isort(a);
	int gcd = a[1]-a[0];
	go(i,1,n+1)
	{
		gcd=__gcd(gcd,a[i]-a[i-1]);
	}
	cout<<gcd<<endl;
}

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


int main() {
    string s;
    cin >> s;
    int m = s.size() - 1;
    int64_t ans = 0;
    for (int bit = 0; bit < (1 << m); bit++){
        int64_t tmp = s.at(0) - '0';
        for (int i = 0; i < m; i++){
            if (bit & (1 << i)){
                ans += tmp;
                tmp = 0;
            }
            tmp = tmp * 10 + (s.at(i + 1) - '0');
        }
        ans += tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3608
class Array
  def swap(x, y)
    self[x], self[y] = self[y], self[x]
  end
end

def bubbleSort(n, a)
  c = 0
  n.times{|i|
    (n-1).downto(i+1){|j|
      a[j]<a[j-1]&&a.swap(j,j-1)&&c+=1
    }
  }
  return a, c
end

a, c = bubbleSort(gets.to_i, gets.split.map(&:to_i))
puts a.join(" ")
puts c

Measured memory_bytes: 8672
#include<bits/stdc++.h>
#define ll long long int 
#define w(x) int x; cin>>x; while(x--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
using namespace std;
int main(){
#ifndef ONLINE_JUDGE 
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	
		ll n; 
		cin>>n;
		if(n==0)
			cout<<1;
		else
			cout<<0;
	
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ASC(v) sort(v.begin(), v.end());
#define DESC(v) sort(v.begin(), v.end(), greater<int>());
#define REVERSE(v) reverse(v.begin(), v.end());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;

int main() {
	ll H, N;
	cin >> H >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	bool can = true;
	ll sum = 0;
	REP(i, N) {
		sum += A[i];
	}
	if (sum < H) can = false;

	if (can) cout << "Yes" << "\n";
	else cout << "No" << "\n";
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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 namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{
    string s;
    int k;
    cin >> s >> k;
    vector<string> v;
    // set<string> st;
    // for (int i=0; i<s.size(); ++i)
    // {
    //     for (int j=1; j<s.size()-i+1; ++j)
    //     {
    //         if(s.substr(i,j).size()>k) continue;
    //         // v.push_back(s.substr(i,j));
    //         st.insert(s.substr(i,j));
    //     }
    // }

    for (int j=1; j<=5; ++j)
    {
        for (int i=0; i<s.size(); ++i)
        {
            if(i+j>s.size()) continue;
            v.push_back(s.substr(i,j));
            // st.insert(s.substr(i,j));
        }
    }

    sort(v.begin(),v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v[k-1] << endl;

    // vector<string> ans;
    // for(auto x:st)
    // {
    //     ans.push_back(x);
    // }
    // sort(ans.begin(),ans.end());
    // cout << ans[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1660
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	char ch;
	while(1){
		scanf("%c",&ch);
		if('a'<=ch&&ch<='z')
			ch=ch-32;
		else if('A'<=ch&&ch<='Z')
			ch=ch+32;
		printf("%c",ch);
		if(ch=='\n')break;
	}
	return 0;
}


Measured memory_bytes: 3172
import sys

def solve():
    file_input = sys.stdin
    N, W = map(int, file_input.readline().split())
    C = [0] * (W + 1)
    for line in file_input:
        item_v, item_w = map(int, line.split())
        for i, vals in enumerate(zip(C[item_w:], C)):
            C[i] = max(vals[0] + item_v, vals[1])
    print(C[0])

solve()

Measured memory_bytes: 8480
#include<bits/stdc++.h>
using namespace std ;
#define ll long long int
#define pb push_back
#define fi first 
#define se second 
#define mod 1000000007
/* Iterative Function to calculate (x^y) in O(log y) */
ll power(ll x, ll y) 
{ 
	int res = 1;	 // Initialize result 

	while (y > 0) 
	{ 
		// If y is odd, multiply x with result 
		if (y & 1) 
			res = res*x; 

		// y must be even now 
		y = y>>1; // y = y/2 
		x = x*x; // Change x to x^2 
	} 
	return res; 
}

int power(ll x, ll  y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}
// vector<vector<ll>> v ;
// vector<ll> chld,bol,lst ;
// void dfs(ll a)
// {
//   lst.pb(a) ;
//   for(ll i=0;i<v[a].size();i++)
//   {
//     if(bol[v[a][i]]==0)
//     {
//       bol[v[a][i]]=1 ;
//       dfs(v[a][i]) ;
//     }
//   }
// }
// ll ch(ll a)
// {
//   ll p=0;
//   if(v[a].size()==0)
//   {
//     chld[a] =1 ;
//    return 1;
//   }
//   else
//   {
//     for(ll i=0;i<v[a].size();i++)
//     p += ch(v[a][i]) ;
//     p++ ;
//     chld[a] = p;
//     return p;
//   }
// }
int main()
{
  ll cnt=0;
  string s,t ;
  cin >> s >> t ;
  for(ll i=0;i<s.size();i++)if(s[i]!=t[i]) cnt++ ;
  cout << cnt << endl;
}

Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

int a[100],b[100],c[100],d[100];

int n,m;

int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
	for(int i=1;i<=m;i++) cin>>c[i]>>d[i];
	for(int i=1;i<=n;i++)
	{
		int mx=1e9;
		int t;
		for(int j=1;j<=m;j++)
		{
			int D=abs(c[j]-a[i])+abs(d[j]-b[i]);
			if(D<mx) t=j,mx=D;
		}
		cout<<t<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############
import time
 
START = (int(time.time() * 1000))

import random
import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

D = int(input().strip())
C = list(map(int,input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

schedule = []


for d in range(D):
  MAX = -10**20
  temp = None
  last = [-1 for i in range(26)]
  for j in range(26):
    s = 0
    for i in range(26):
      if i == j:
        last[i] = d
        s += S[d][i]
      else:
        s -= C[i]*(d-last[i])
    if s > MAX:
      MAX = s
      temp = j
  schedule.append(temp)
  
score = 0
last = [[-1] for i in range(26)]  

for d in range(D):
  t = schedule[d]
  last[t].append(d)
  score += S[d][t]
  

for i in range(26):
  last[i].append(D)
  for k in range(len(last[i])-1):
    g = last[i][k+1]-last[i][k]-1
    score -= C[i]*g*(g+1)//2

while True:
  d = random.choice(range(D))
  for q in range(26):
    prev = score
    p = schedule[d]
    schedule[d] = q
    score -= S[d][p]
    score += S[d][q]

    pos = last[p].index(d)
    score -= C[p]*(last[p][pos]-last[p][pos-1])*(last[p][pos+1]-last[p][pos])
    last[p].remove(d)

    pos = bisect.bisect(last[q],d)
    score += C[q]*(d-last[q][pos-1])*(last[q][pos]-d)
    bisect.insort(last[q],d)
    if score<prev:
      score = prev
      bisect.insort(last[p],d)
      last[q].remove(d)
      schedule[d] = p

  if int(time.time() * 1000)-START>1900:
    break

for i in schedule:
  print(i+1)


Measured memory_bytes: 86380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1e6+5;
int a[N],pre[N],lst[N],q[N],tt=0;
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    pre[1]=1;q[++tt]=1;
    for(int i=2;i<=n;i++)
    {
        while(tt&&a[q[tt]]>a[i])tt--;
        pre[i]=tt?q[tt]+1:1;q[++tt]=i;
    }
    tt=0;lst[n]=n;q[++tt]=n;
    for(int i=n-1;i;i--)
    {
        while(tt&&a[q[tt]]>a[i])tt--;
        lst[i]=tt?q[tt]-1:n;q[++tt]=i;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)ans+=1ll*a[i]*(i-pre[i]+1)*(lst[i]-i+1);
    cout<<ans<<endl;
}


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

int main(){
  int r,g,b;
  cin >> r >> g >> b;
  
  int A;
  A = r*100 + g*10 + b;
  
  if(A % 4 == 0){
    cout << "YES" << endl;
  }else{cout << "NO" << endl;}
  
  return 0;
}


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

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

/* template */
template <class T>
bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0; }
template <class T>
bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0; }

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x) \
    sort(all(x));  \
    (x).erase(unique(all(x)), (x).end())
#define int long long
#define mp make_pair
#define r0 return 0

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

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n, d, x, a, j, tmp, cnt = 0;
    cin >> n >> d >> x;
    rep(i, n)
    {
        cin >> a;
        j = 1;
        do
        {
            tmp = (a * j) + 1;
            cnt++;
            j++;
        } while (tmp <= d);
    }
    cout << cnt + x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using ll = long long;

int const inf = 1000000000;

int main() {
  ll s;
  std::cin >> s;

  std::cout << 0 << " " << 0 << " ";
  if(s % inf == 0) {
    std::cout << inf << " " << s % inf << " ";
    std::cout << 1 << " " << s / inf;
  } else {
    std::cout << inf << " " << inf - s % inf << " ";
    std::cout << 1 << " " << s / inf + 1;
  }
  return 0;
}


Measured memory_bytes: 3620
#pragma GCC optimize("O3")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include <fstream>
#include<unordered_set>
#include<stack>
#include <map>
#include<time.h>
#include <chrono>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007 // prime modulo value 
#define all(x) x.begin(),x.end()
using namespace std;
#define MAX 1000001 
#define M 998244353
ll inverse(ll n)
{
	ll modu = M;
	ll m = modu;
	ll a = 0, b = 1;
	if (modu == 1)
		return 0;
	while (n > 1)
	{
		ll quo = n / modu;
		ll temp = modu;
		modu = n % modu, n = temp;
		temp = a; 
		a = b - (quo * a);
		b = temp;
	}
	if (b < 0)
		b += m;
	return b;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<ll> health(n, 0);
	ll sum = 0;
	f(i, 0, n)
	{
		cin >> health[i];
		sum += health[i];
	}
	sort(all(health));
	f(i, 0, min(k,n))
	{
		sum -= health[n - 1 - i];
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>

#define mod 1000000007

using namespace std;
 
int main(void){
	
	int N, T, A;
	double sa=1000;
	int point;
	
	cin >> N >> T >> A;
	
	int H[N];
	
	for(int i=0; i<N; i++)
		cin >> H[i];
	
	for(int i=0; i<N; i++){
		if(abs((T-H[i]*0.006)-A) < sa){
			sa = abs((T-H[i]*0.006)-A);
			point = i+1;
		}
	}
	
	cout << point;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define int64 long long

int main()
{
  int64 nn, kk;
  scanf("%lld %lld", &nn, &kk);
  int64 aa[nn], dd, tmp;
  for(int64 ii = 0;ii < nn;ii++)
  {
    aa[ii] = 1;
  }
  for(int64 ii = 0;ii < kk;ii++)
  {
    scanf("%lld", &dd);
    for(int64 jj = 0;jj < dd;jj++)
    {
      scanf("%lld", &tmp);
      aa[tmp - 1] = 0;
    }
  }
  int64 ans = 0;
  for(int64 ii = 0;ii < nn;ii++)
  {
    if(aa[ii])
    {
      ans++;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 1732
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N, vector<int>());
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    rep(i, N) { cout << G[i].size() << endl; }
    return 0;
}

Measured memory_bytes: 256
from fractions import gcd
n = int(input())
a = list(map(int, input().split()))
c1 = [0] * (n + 1)
c2 = [0] * (n + 1)
# c1[1] = a[0]
# c2[n - 1] = a[n - 1]
for i in range(1, n + 1):
  c1[i] = gcd(c1[i - 1], a[i - 1])
  c2[n - i] = gcd(c2[n - i + 1], a[n - i])
print(max(gcd(c1[i], c2[i + 1]) for i in range(n)))


Measured memory_bytes: 16056
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

const string YES = "YES";
const string NO = "NO";


int main(){
    string a, b;
    cin >> a;
    cin >> b;
    if(a[0] == b[2] and a[1] == b[1] and a[2] == b[0]){
        cout << YES << endl;
    } else {
        cout << NO << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int N;
	scanf("%d", &N);
	char S[N];
	scanf("%s", S);
	if(N%2){
		printf("No");
		return 0;
	} else {
		for(int i=0;i<N/2;i++){
			if(S[i]==S[i + N/2]){
				
			}	else {
				printf("No");
				return 0;
			}
		}	
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 1736
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int a[SIZE],b[SIZE];
int N;
int get_bit(LL& x,int v){
    return (x>>v)&1;
}
bool valid(LL mask){
    LL pos[55];
    REP(i,N)pos[i]=1LL<<a[i];
    for(int i=50;i>0;i--){
        if(get_bit(mask,i)==0)continue;
        REP(j,N){
            FOR(k,0,50){
                if(get_bit(pos[j],k))pos[j]|=1LL<<(k%i);
            }
        }
    }
    REP(i,N){
        if(get_bit(pos[i],b[i])==0)return 0;
    }
    return 1;
}
int main(){
    R(N);
    REP(i,N)R(a[i]);
    REP(i,N)R(b[i]);
    LL now=(1LL<<51)-2;
    for(int i=50;i>0;i--){
        if(valid(now^(1LL<<i))){
            now^=1LL<<i;
        }
    }
    if(!valid(now)){
        W(-1);
    }
    else{
        W(now);
    }
    return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}
ll gcd_ll(ll x, ll y){
  long long a= max(x,y), b=min(x,y), c=a%b;
  while( c!=0){
    a =b;
    b =c;
    c = a%b;
  }
  return b;
}

int abs(int x, int y){
  if(x>=y){
    return x-y;
  }
  else if(y>x){
    return y-x;
  }
}
ll fiv(ll n){
  if(n==0){
    return 1;
  }
  else if(n==1){
    return 1;
  }
  return fiv(n-1)+fiv(n-2);
}
ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
    string s,t,u;
    int a,b;
    cin >> s>>t>>a>>b>>u;
    if(u==s){
        cout << a-1 <<" "<<b<<endl;
    }
    else{
        cout<< a <<" "<<b-1<<endl;
    }

}





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

int main(){
  int c[3][3];
  int a[3];
  int b[3];
  string check="No";
  for(int i=0; i<3; i++){
    for(int j=0; j<3; j++){
      cin >> c[i][j];
    }
  }
  
  for(int i=0;i<=c[0][0];i++){
    a[0]=i;
    for(int j=0;j<3;j++){
      b[j]=c[0][j] - a[0];
    }
    a[1]=c[1][0] -b[0];
    a[2]=c[2][0] -b[0];
    if(c[1][1]==a[1]+b[1]&c[1][2]==a[1]+b[2]&c[2][1]==a[2]+b[1]&c[2][2]==a[2]+b[2]){
      check ="Yes";
    }
  }
  cout << check <<endl;
}
    
    

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

int main() {
    int n;
    vector<vector<int>> a(3, vector<int>(3));

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

    cin >> n;
    vector<int> b(n);
    for(int i = 0; i < n; i++) {
        cin >> b[i];
        for(int j = 0; j < 3; j++) {
            for(int k = 0; k < 3; k++) {
                if(a[j][k] == b[i]) {
                    a[j][k] = 0;
                }
            }
        }
    }

    bool bingo = false;
    for(int i = 0; i < 3; i++) {
        int count = 0;
        for(int j = 0; j < 3; j++) {
            if(a[i][j] == 0) {
                count++;
            }
            if(count == 3) {
                bingo = true;
            }
        }
    }

    for(int i = 0; i < 3; i++) {
        int count = 0;
        for(int j = 0; j < 3; j++) {
            if(a[j][i] == 0) {
                count++;
            }
            if(count == 3) {
                bingo = true;
            }
        }
    }

    int count = 0;
    for(int i = 0; i < 3; i++) {
        if(a[i][i] == 0) {
            count++;
        }
        if(count == 3) {
            bingo = true;
        }
    }

    if(a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0) {
        bingo = true;
    }

    if(bingo) {
        cout << "Yes" << endl;
        return 0;
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int work;
		int[][] r;
		r = new int[h][w];
		
		for(int i=0; i<h; i++){
			char[] weather = sc.next().toCharArray();
			work = -1;
			for(int j=0; j<w; j++){
				if(weather[j] == 'c') work = 0;
				r[i][j] = work;
				if(work>=0) work++;
			}
		}
		
		for(int i=0; i<h; i++){
			for(int j=0; j<w; j++){
				System.out.print(r[i][j]);
				if(j<w-1) System.out.print(" ");
				else System.out.println();
			}
		}
	}

}

Measured memory_bytes: 35848
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define F first
#define S second
int n;
ll a[100005],b[100005],s;
int main(void){
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%lld%lld",a+i,b+i);
    for(int i=n-1;i>=0;i--)s+=(b[i]-(a[i]+s)%b[i])%b[i];
    printf("%lld\n",s);
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
using namespace std;
 
int N, M, P[12];
vector<int> X[12];
 
int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int v, a; cin >>v;
        for(int j=0 ;j<v; j++){
            cin >> a;
            a--;
            X[i].push_back(a);
        }
    }
    for(int i= 0; i< M;i++){
        cin >> P[i];
    }
    int result = 0;
    for(int i = 0 ;i <(1<<N); i++){
        int bit[12];
        bool flag = true;
        for(int j = 0; j<N ;j++){
            bit[j] = (i / (1<<j) ) % 2;
        }
        for(int j=0; j<M;j++){
            int ret = 0;
            for(int x : X[j]){
               ret ^= bit[x];
            }
            if (ret != P[j]) flag = false;
        }
        if(flag) result++;
    }
    cout << result << endl;
}

Measured memory_bytes: 3632
a, b = gets.split().map(&:to_i)
if a > 0 && b > 0
  puts "Positive"
elsif a == 0 || b == 0
  puts "Zero"
elsif a < 0 && 0 < b
  puts "Zero"
else
  c = b - a
  if c != 0 && c % 2 == 0
    puts "Negative"
  else
    puts "Positive"
  end
end


Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func main() {
	io := NewIo()
	defer io.Flush()

	_ = io.NextInt()
	S := io.Next()
	K := io.NextInt()

	for i := range S {
		if S[i] != S[K-1] {
			io.Printf("*")
		} else {
			io.Printf(string(S[i]))
		}
	}

}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline
def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
# import numpy as np

import bisect

def main():
	N=II()
	A=LI()
	B=LI()
	C=LI()
	A.sort()
	B.sort()
	C.sort()
	BB=[0]*N
	ans=0
	for i,b in enumerate(B):
		BB[i]=N-bisect.bisect_right(C,b)
	BB.append(0)
	for i in range(N-2,-1,-1):
		BB[i]+=BB[i+1]
	for a in A:
		ans+=BB[bisect.bisect_right(B,a)]
	print(ans)



if __name__ == "__main__":
	main()


Measured memory_bytes: 21628
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<set>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<stack>
#include<tuple>
#include<utility>
#define mod 1000000007;
typedef long long ll;
#define rep(i,n) for(ll i=0; i<n; i++)
using namespace std;

int main(){
  int a,p;
  cin >> a >> p;
  cout << (a*3+p)/2;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
vector<int> v1[100010],v2[100010];
bool used[100010];
int k;
int mutu(int z,int vz){
	used[z]=true;
	int zz=1,cnt=min(vz+1,(int)1);
	f(i,v1[z].size()){
		if(!used[v1[z][i]]){
			zz*=mutu(v1[z][i],cnt);
			zz%=mod;
			cnt++;
		}
	}
	return zz*(k-vz-1)%mod;
}
signed main(){
	int n;
	cin>>n>>k;
	f(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;
		b--;
		v1[a].push_back(b);
		v1[b].push_back(a);
	}
	cout<<mutu(0,-1)<<endl;
}


Measured memory_bytes: 13952
#include<iostream>
#include<iomanip>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mp make_pair
#define mod 1000000007
//#define max 100007
#define itr ::iterator it
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define repp(X,a,Y) for (int (X) = a;(X) < (Y);++(X))
#define set(a, b) memset(a, b, sizeof(a));
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vd> vvd;
typedef vector<pii> vii;
typedef vector<string> vs;
#define endl '\n'
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  vector<int>a(n,0);
  vector<int>dp(n,0);

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

  dp[0] = 0;
  dp[1] = abs(a[1] - a[0]);

  for (int j=2; j<n; j++)
    dp[j]= min(dp[j-1] + abs(a[j] - a[j-1]), dp[j-2] + abs(a[j] - a[j-2]));

  cout<<dp[n-1]<<endl;
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int n, m, q;
int a[50], b[50], c[50], d[50];
int A[10];

int ans = -1;
void dfs(int dep, int x) {
  if (dep == n) {
    int t = 0;
    rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) t += d[i];
    ans = max(ans, t);
    return;
  }

  for (int i = x; i <= m; i++) {
    A[dep] = i;
    dfs(dep + 1, i);
  }
}

signed main() {
  cin >> n >> m >> q;
  rep(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }
  dfs(0, 1);
  cout << ans << endl;
  return 0;
}


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

#ifdef LOCAL
#include "bib/debug.h"
#else
#define debug
#define cerr if (false) cerr 
#endif

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  swap(b, c);
  swap(a, b);
  cout << a << ' ' << b << ' ' << c << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 20

int main() {
	static int aa[N];
	int n, m, c, i, cnt;

	scanf("%d%d%d", &n, &m, &c);
	for (i = 0; i < m; i++)
		scanf("%d", &aa[i]);
	cnt = 0;
	while (n--) {
		static int bb[N];
		int i, sum;

		sum = 0;
		for (i = 0; i < m; i++) {
			scanf("%d", &bb[i]);
			sum += aa[i] * bb[i];
		}
		if (sum + c > 0)
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int,int> pii;
typedef std::pair<int,double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1000000007;



void solve(){
    int n,c,k;
    cin >> n >> c >> k;
    int cur = -1;
    int ans = 0;
    int p = 0;
    vi a(n,0);
    rep(i,n) cin >> a[i];
    SORT(a);
    
    rep(i,n){
        int t = a[i];
        if (cur==-1) cur = t;
        p++;
        
        if (t-cur>k || p > c){
            p = 1;
            cur = t;
            ans++;
        }
    }
    if (p) ans++;
    
    cout << ans;
}


int main(){
    int T;
    //cin >> T;
    T = 1;
    while(T--){
        solve();
        cout << endl;
    }
}



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

long long mod=998244353L;

template<typename T>
constexpr T modpow(T a,int n){//(a^n)%MOD
    T ret=1;
    while(n>0){
        if((n&1)!=0){//n%2==1
            ret=ret*a%mod;
        }
        a=a*a%mod;
        n=n/2;
    }
    return ret;
}

std::vector<long long> fac;
std::vector<long long> ifac;



template <typename T>
T modcomb(T a, T b){
    if(a == 0 && b == 0)return 1;
    if(a==b||b==0)return 0;
    if(a < b || a < 0 || b < 0)return 0;
    long long tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

void combinit(int maxn){
    fac.resize(maxn+1);
    ifac.resize(maxn+1);
    fac[0] = 1;
    ifac[0] = 1;
    for(long long i = 0; i<maxn; i++){
        fac[i+1] = fac[i]*(i+1) % mod;
        ifac[i+1] = ifac[i]*modpow(i+1, mod-2) % mod;
    }
}

using namespace std;
using ll = long long;
ll Mod = 998244353LL;
int main() {
    combinit(5000);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<vector<ll>> dp(c,vector<ll>(d,0));
    ll t=1;
    for(int i = a;i < c;++i) {
        t*=b;
        t%=Mod;
        dp[i][b-1]=t;
    }
    t=1;
    for(int i = b;i < d;++i) {
        t*=a;
        t%=Mod;
        dp[a-1][i]=t;
    }
    dp[a-1][b-1]=1;
    for(ll i = a;i < c;++i) {
        for(ll j = b;j < d;++j) {
            dp[i][j]+=dp[i][j-1]*(i+1);
            dp[i][j]%=Mod;
            dp[i][j]+=dp[i-1][j]*(j+1);
            dp[i][j]%=Mod;

            dp[i][j]-=dp[i-1][j-1]*i*j;
            dp[i][j]%=Mod;
            while(dp[i][j]<0)dp[i][j]+=Mod;
        }
    }
    cout<<dp[c-1][d-1]<<endl;
    return 0;
}


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

bool deleted[1024]={false};
int main()
{
	int N;
	int datas[1024][3]={0};
	int ans=0;
	
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin >> datas[i][0] >> datas[i][1] >> datas[i][2];
		sort(datas[i], datas[i]+3);
	}
	for(int i=0;i<N;i++)
	{
		if(deleted[i])
			continue;
		for(int j=i+1;j<N;j++)
		{
			if(deleted[j])
				continue;
			bool flag=true;
			for(int k=0;k<3;k++)
				flag&=(datas[i][k]==datas[j][k]);
			if(flag)
			{
				ans++;
				deleted[j]=true;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3168
N = int(input())
ans = 0
S = []

for _ in range(N):
    si = int(input())
    ans += si
    if si % 10 != 0:
        S.append(si)

if ans % 10 != 0:
    print(ans)
else:
    if not S:
        print(0)
    else:
        ans -= min(S)
        print(ans)


Measured memory_bytes: 2940