akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define nl '\n'
#define sp ' '
#define a_m a,b,c,d,e,f,g,h,i,j,k,l,m
#define n_z n,o,p,q,r,s,t,u,v,w,x,y,z
#define ri(b,c) for(ll i=(b);i<(c);++i)
#define rj(b,c) for(ll j=(b);j<(c);++j)
#define rk(b,c) for(ll k=(b);k<(c);++k)
#define rl(b,c) for(ll l=(b);l<(c);++l)
#define rr(b,c) for(ll r=(b);r>(c);--r)
#define f10(a) cout<<fixed<<setprecision(10)<<a
#define f0(a,b) cout<<setfill('0')<<setw(a)<<right<<b
#define hasten cin.tie(0);ios::sync_with_stdio(false)
const int prime[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

inline void ln(){cout<<nl;}
template<class T,class...A>
inline void ln(const T& first,const A&...rest)
{cout<<first;ln(rest...);}
template<class...A>inline void ln(const A&...rest)
{ln(rest...);}

template <class T>inline void so(T t){cout<<t<<nl;}
template <class T, class...A>
inline void so(T first,A...rest)
{cout<<first<<' ';so(move(rest)...);}

inline void op(){}
template<class T,class...A>
inline void op(const T& first,const A&...rest)
{cout<<first;op(rest...);}

inline void in(){}
template<class T,class...A>
inline void in(T&& first,A&&...rest)
{cin>>first;in(move(rest)...);}

//GCD is declared in C++17 and after
inline ll gcd(ll a,ll b)
{ll c;while(a){c=a;a=b%a;b=c;}return b;}
inline bool isp(ll a){
	if(a<48){ri(0,15)if(prime[i]==a)return 1;}
	else if(a<2809)return gcd(614889782588491410,a)==1;
	else ln("Error");return 0;
}

int main(){
	hasten;
	ll a_m,n_z;
	in(a);
    p=0;
    c=-1;
    d=0;
    ri(0,a){
        in(b);
        if(b==c){
            ++d;
        }
        else if(d){
            p+=(d+1)/2;
            d=0;
        }
        c=b;
    }







	ln(p+(d+1)/2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N)cin>>A.at(i);
  sort(A.begin(),A.end());
  ll a,b;
  a=A.at(N-1);
  ll c;
  c=(a+1)/2;
  rep(i,N-1){
    if(i==1)b=A.at(i);
    if(i>=1){
      if(max(A.at(i)-c,c-A.at(i))<max(A.at(i-1)-c,c-A.at(i-1)))b=A.at(i);
    }
  }
  cout<<a<<" "<<b<<endl;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define boost ios::sync_with_stdio(0); cin.tie(0);
#define int long long

const int N = 1e5 + 10;
const int mod = 1e9 + 7;

int32_t main(){
    boost;

   
    //code

    int n , m;
    cin >> n >> m;
    int temp = m;
    m -= 2*n;
    if(m > 0){
    	cout << n + m/4;
    }
    else{
    	
    	if(m == 0){
    		cout << n;
    	}
    	else{
    		m = temp;
    		m /= 2;
    		cout << m;
    	}

    }
    return 0;
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  int n,k;
  const int max_n = 1e5;
  int x[max_n + 1];
  vector<int> xn;//negative pos
  vector<int> xp;//positive pos
  vector<int> xsum(max_n + 1, 0);
  cin >> n >> k;
  for(int i = 0; i < n; i++) {
    cin >> x[i];
    if(x[i] < 0) xn.push_back(x[i]);
    else xp.push_back(x[i]);
    xsum[i] = xsum[i-1] + x[i];
  }

  long long ans = 1e15;
  long long time = 0;

  for(int i = 0; i < n-k+1; i++){
    int l = i;
    int r = i + k - 1;
    if(x[l] >= 0){
      time = x[r];
    }else{
      if(x[r] <= 0) time = abs(x[l]);
      else {
        //orikaesi ari
        time = min(x[r] * 2 + abs(x[l]), abs(x[l])*2 + x[r]);
      }
    }

    ans = min(ans, time);
  }
  

  cout << ans << endl;

  return 0;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef set<ll> si;
typedef map<string, ll> msi;
#define hell 1000000007
#define MAX 1000000000
#define max_int 1000000
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll i = a;i<b;i++)
#define pi 3.1415926536
#define r0 return 0
#define rep(i,a,b) for(ll i = a;i<b;i++)

// void solve() 
// {


//     return;
// }

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int t=1;
    cin>>t;
    string s;
    set<string>st;
    while(t--)
    {
        cin>>s;
        st.insert(s);
        //solve();     
    }
    cout<<st.size();

}
 

Measured memory_bytes: 19204
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int max = 1;

        for (int j = 2; j <= 31; j++) {
            int n = j * j;
            if (n <= x) {
                while (n * j <= x) {
                    n *= j;
                }
                max = Math.max(max, n);
            }

        }

        System.out.println(max);
    }

}


Measured memory_bytes: 23764
n,l = map(int,input().split())
t = [l+i-1 for i in range(1,n+1)]
tmp = abs(sum(t)-(sum(t)-t[0]))
ans = 0
for i in range(len(t)):
    if abs(sum(t)-(sum(t)-t[i])) <= tmp:
        ans = i
        tmp = abs(sum(t)-(sum(t)-t[i]))
print(sum(t)-t[ans])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
typedef long long int  ll;
void add(ll &a, ll b)
{
	a+=b;
	if(a>=mod)
		a-=mod;
}
int main()
{
	int n, m;
	cin>>n>>m;
	char a[n][m];
	for(int  i= 0 ; i  < n ; i++)
	{
		string s;
		cin>>s;
		for(int j = 0 ; j < m ; j++)
			a[i][j] = s[j];
	}
	ll dp[n][m];
	memset(dp, 0, sizeof dp);
	dp[0][0] = 1;
	for(int i = 0 ; i < n ; i++)
	{
		for(int j = 0 ; j < m ; j++)
		{
			if(a[i][j]=='.')
			{
				if(i&&a[i-1][j]=='.')
					add(dp[i][j], dp[i-1][j]);
				if(j&&a[i][j-1]=='.')
					add(dp[i][j], dp[i][j-1]);
			}

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

}

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    ll n,W; cin >> n >> W;
    vl v(n),w(n),m(n);
    rep(i,n) cin >> v[i] >> w[i] >> m[i];
    rep(i,n){
        ll p = 1;
        while(1<<(p+1) <= m[i]+1){
            v.push_back(v[i]*(1<<p));
            w.push_back(w[i]*(1<<p));
            p++;
        }
        ll t = m[i] + 1 - (1<<p);
        if(t){
            v.push_back(v[i]*t);
            w.push_back(w[i]*t);
        }
    }
    n = v.size();
    vvl dp(n+1,vl(W+1,0));
    rep(i,n){
        rep(j,W+1){
            chmax(dp[i+1][j],dp[i][j]);
            if(j+w[i] > W) continue;
            chmax(dp[i+1][j+w[i]], dp[i][j] + v[i]);
        }
    }
    cout << dp[n][W] << endl;
}


Measured memory_bytes: 112380
using System;

namespace B______
{
    class Program
    {
        static void Main(string[] args)
        {
            var o = Console.ReadLine();
            var e = Console.ReadLine();
            for (var i = 0; i < o.Length; i++)
            {
                Console.Write(o[i]);
                if (i < e.Length)
                {
                    Console.Write(e[i]);
                }
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,b,c;cin>>a>>b;
  vector<ll>d(a,0);
  rep(i,b){
    cin>>c;
    d[c-1]++;
    cin>>c;
    d[c-1]++;    
  }
  rep(i,a)cout<<d[i]<<endl;
}



Measured memory_bytes: 27064
use proconio::{fastout, input};
use std::cmp::min;

#[fastout]
fn main() {
    input! {in_n: usize, in_a: [u64; in_n + 1]};
    let mut leaves = vec![0 as u64; in_n + 1];
    let depth = in_n + 1;

    if in_a[0] > 1 {
        println!("-1");
        return;
    }

    leaves[depth - 1] = in_a[depth - 1];

    for i in (1..depth).rev() {
        leaves[i - 1] = leaves[i] + in_a[i - 1];
    }

    let mut node = 1;
    let mut total = 1;

    for i in 1..depth {
        let n = (node - in_a[i - 1]) * 2;

        if in_a[i] > n {
            println!("-1");
            return;
        }

        node = min(n, leaves[i]);
        total += node
    }

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


Measured memory_bytes: 4376
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  while(cin>>n>>m,n){
  string s1[11],s2[11];
  for(int i=0;i<n;i++)cin>>s1[i];
  for(int i=0;i<m;i++)cin>>s2[i];

  int pi[11];
  for(int i=0;i<n;i++){
    int j=0;
    while(s1[i][j]=='.'){
      j++;
    }
    pi[i]=j;
  }

  // for(int i=0;i<n;i++)cout<<"p "<<pi[i]<<endl;
  
  int ans[11];
  fill_n(ans,11,-2);
  ans[0]=0;
  
  for(int r=1;r<=20;r++){
    for(int c=1;c<=20;c++){
      for(int s=1;s<=20;s++){
	//cout<<r<<" "<<c<<" "<<s<<endl;
	int f=1;
	
	int cnt[3]={};
	for(int i=0;i<n;i++){
	    
	  int t=r*cnt[0]+c*cnt[1]+s*cnt[2];
	  //if(r==9&&c==5&&s==2)cout<<pi[i]<<" "<<t<<endl;
	  if(t!=pi[i])f=0;
	    
	  for(int j=0;j<s1[i].size();j++){
	    if(s1[i][j]=='(')cnt[0]++;
	    if(s1[i][j]==')')cnt[0]--;
	    if(s1[i][j]=='{')cnt[1]++;
	    if(s1[i][j]=='}')cnt[1]--;
	    if(s1[i][j]=='[')cnt[2]++;
	    if(s1[i][j]==']')cnt[2]--;
	  }
	}
	
	if(f==0)continue;
	//cout<<r<<" "<<c<<" "<<s<<endl;
	
	cnt[0]=cnt[1]=cnt[2]=0;
	for(int i=0;i<m;i++){
	    
	  int t=r*cnt[0]+c*cnt[1]+s*cnt[2];
	    
	  if(ans[i]==-2)ans[i]=t;
	  else if(ans[i]!=t)ans[i]=-1;
	    
	  for(int j=0;j<s2[i].size();j++){
	    if(s2[i][j]=='(')cnt[0]++;
	    if(s2[i][j]==')')cnt[0]--;
	    if(s2[i][j]=='{')cnt[1]++;
	    if(s2[i][j]=='}')cnt[1]--;
	    if(s2[i][j]=='[')cnt[2]++;
	    if(s2[i][j]==']')cnt[2]--;
	  }
	}
	
      }
    }
  }
  for(int i=0;i<m;i++){
    if(i)cout<<" ";
    cout<<ans[i];
  }

  cout<<endl;
  }
  return 0;
}



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

#define pb push_back
#define mp make_pair
#define fs first
#define se second

typedef long long LL;

int n;
map <int , int > a;
int b[123456];

int main() {
  //  freopen("test.txt","r",stdin);
    cin >> n;
    for (int i =1 ; i <= n ; i++) {
        cin >> b[i];
    }
    int x = 1;
    int ans = 0;
    for (int i =1 ; i <= n ; i++) {
        x = b[x];
        ans++;
        if (x == 2) {
            cout << ans;
            return 0;
        }
    }
    cout << -1;
}


Measured memory_bytes: 640
import numpy as np
kosuu = int(input())
kakakulist=[]
for i in range(kosuu):
  kakaku=int(input())
  kakakulist.append(kakaku)

saidai=max(kakakulist)

kotaesyou=sum(kakakulist)-saidai/2
kotae=round(kotaesyou)

print(kotae)


Measured memory_bytes: 12504
#include<bits/stdc++.h>
using namespace std;
int cnt;
void insertionSort(int *A,int n,int g){
  for(int i=g;i<n;i++){
    int v=A[i];
    int j=i-g;
    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}
void shellSort(int *A,int n){
  cnt=0;
  int r=1;
  vector<int> G;
    //set up the step size 
  while(r<=n){
    G.push_back(r);
    r*=2;
  }
  int m=G.size();
  reverse(G.begin(),G.end());//step size from big to small
  cout<<m<<endl;
  for(int i=0;i<m;i++) cout<<G[i]<<" \n"[i==m-1];
  for(int i=0;i<m;i++) insertionSort(A,n,G[i]);
  cout<<cnt<<endl;
}
signed main(){
  int n;
  cin>>n;
  int A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  shellSort(A,n);
  for(int k=0;k<n;k++) cout<<A[k]<<endl;
  return 0;
}


Measured memory_bytes: 7044
package main

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

func dfs(a string, mx int32, length int) {
	if len(a) == length {
		fmt.Println(a)
		return
	}
	for k := 'a'; k < mx; k++ {
		dfs(a+string(k), mx, length)
	}
	dfs(a+string(mx), mx+1, length)

}

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	dfs("", 'a', N)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 5888
using System;

class Program
{
 static void Main( string[] args ) 
 {
   int cnt1,cnt2,cnt3,cnt4 = 0;
   int x,y = 0;
   String[] strBuff = new String[2];
   String strBuff2;
   int bomCnt = 0;
   
   strBuff = Console.ReadLine().Split(' ');
   x = int.Parse(strBuff[0]) + 2;
   y = int.Parse(strBuff[1]) + 2;

   Char[,] minesweep = new Char[x,y];
   Array.Clear(minesweep, 0, minesweep.Length); 
   
   
   for(cnt1 = 1; cnt1 < (x-1); cnt1++)
   {
     strBuff2 = Console.ReadLine();
     for(cnt2 = 1; cnt2 < (y-1); cnt2++)
     {
       minesweep[cnt1,cnt2] = strBuff2[cnt2-1];
     }
   }

   
   for(cnt1 = 1; cnt1 < (x-1); cnt1++)
   {
     for(cnt2 = 1; cnt2 < (y-1); cnt2++)
     {
       bomCnt = 0;
       
       if( minesweep[cnt1,cnt2] == '.' )
       {
         for(cnt3 = -1; cnt3 <= 1; cnt3++)
         {
          for(cnt4 = -1; cnt4 <= 1; cnt4++)
          {
            if( minesweep[(cnt1-cnt3),(cnt2-cnt4)] == '#' )
            {
              bomCnt++;
            }
          }
         }
        
         minesweep[cnt1,cnt2] = Char.Parse(bomCnt.ToString());
       }
       else
       {
         /* nothing */
       }
     }
   }
   
   for(cnt1 = 1; cnt1 < (x-1); cnt1++)
   {
     for(cnt2 = 1; cnt2< (y-1); cnt2++)
     {
       Console.Write(minesweep[cnt1,cnt2]);
     }
     Console.WriteLine();
   }
 }
}

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

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

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	void run(){
		sc=new Scanner(System.in);
		int n=sc.nextInt();
		long f=1;
		for(int i=1; i<=n; i++)
			f*=i;
		println(""+f);
		sc.close();
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
   string s;
   cin>>s;
   int f=0;
   for(int i=0;i<3;i++)
   {
       if(s[i]=='7')
       {
          f=1;
          break;
       }

   }
   if(f)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
    return 0;
}


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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>; 
using vi = vector<int>; using vvi = vector<vi>;
using P = pair<ll, ll>;

template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args> 
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; cout << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const unordered_map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
#define VN(v) # v
#define print(a) cout << a << "#" << VN(a) << endl;

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    if (n == 0) cout << 1 << endl;
    else if (n == 1) cout << 2 << endl;
    else if (n == 2) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>


int main() {
	std::string s;

	std::cin >> s;

	long long ans = 0;

	long long count = 0;

	long long left = 0;
	long long right = 0;
	for (size_t i = 0; i < s.length(); i++)
	{
		if (right > 0) {
			right--;
		}
		else {
			long long j = i;
			while (j < s.length() && s[j] == '>') {
				right++;
				j++;
			}
		}
		ans += std::max(left, right);
		if (s[i] == '<') {
			left++;
		}
		else {
			left = 0;
		}
	}

	if (right > 0) right--;

	std::cout << ans + std::max(left, right) << std::endl;

	return 0;
}


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

using namespace std;

int main(void){
  int S[3];
  cin >> S[0] >> S[1] >> S[2];
  sort(S,S+3);
  if(S[0]==5 && S[1]==5 && S[2]==7){
    cout << "YES" <<endl;
  }
  else{
    cout << "NO" << endl;
  }
}

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

namespace abc161_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] xyz = Console.ReadLine().Split(' ');
            int a = int.Parse(xyz[0]);
            int b = int.Parse(xyz[1]);
            int c = int.Parse(xyz[2]);
            int d = 0;

            d = a;
            a = b;
            b = d;

            d = a;
            a = c;
            c = d;

            Console.WriteLine(a + " " + b + " " + c);
        }
    }
}


Measured memory_bytes: 27472
/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
void solve()
{
  ll n,m;
  ll s=0;
  cin>>n>>m;
  rep(i,0,m){
    ll x;
    cin>>x;
    s+=x;
  } 
  if(s<=n)
  {
    cout<<n-s<<endl;
  }
  else cout<<-1<<endl;
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

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

int main()
{
  int64_t n,a,b;
  cin >> n >> a >> b;
  
  int64_t shou =  n / (a + b);
  int64_t amari = n % (a + b);
  
  int64_t aamari = 0;
  if(a <= amari){
    aamari = a;
  }else{
    aamari = amari;
  }
  
  int64_t ans = shou * a + aamari;
  cout << ans << endl;
}

Measured memory_bytes: 3636
//given a string of digits. how many substrings are divisible by 2019?
#include<bits/stdc++.h>
using namespace std;
const int mod=2019;
int main()
{
    string s;
    vector<int>cnt_suf(mod,0);
    cin >> s;
    int n = s.size();
    int power_of_ten =1;
    int suf=0;
    cnt_suf[suf]++;
    long long ans =0;

    for(int i=n-1;i>=0;i--)
    {
        int digit = s[i]-'0';
        suf=(suf+digit*power_of_ten)%mod;
        power_of_ten = (10*power_of_ten)%mod;
        ans+=cnt_suf[suf];
        cnt_suf[suf]++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3728
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = in.readLine();
    int n = Integer.parseInt(str);
    String[] ary = str.split("");
    int sum = 0;
    for(int i=0; i<str.length(); i++) {
      sum += Integer.parseInt(ary[i]);
    }
    System.out.println(n%sum==0?"Yes":"No");
  }
}

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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define eb emplace_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    int n;
    cin >> n;
    vi ar(n);

    rep(i,0,n){
        cin >> ar[i];
    }

    int a = 0, b = 0, c = 0, ans = 0;
    rep(i,0,n-2){
        a = ar[i], b = ar[i+1], c = ar[i+2];
        if( (b > a && b < c) || (b < a && b > c)) ++ans;
    }

    cout << ans << "\n";
    return;
}

int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/


Measured memory_bytes: 256
n,c,k = map(int,input().split())
t = [int(input()) for _ in range(n)]

t_sorted= sorted(t)
bus_num=0
i=0

while i < n:
  j=1
  while j < c:
    if i+j >= n:
      break
    if (t_sorted[i] + k >= t_sorted[i+j]):      
      j+=1      
    else:
      break      
  bus_num+=1
  i+=j
print(bus_num)  

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

int main() {
	int n,m, mxl = 0, mnr = 100000;
	cin >> n >> m;
	for(int i = 0; i < m; i++){
		int l, r;
		cin >> l >> r;
		if(mxl < l) mxl = l;
		if(mnr > r) mnr = r;
	}
	int res = mnr - mxl + 1;
	if(res < 0) res = 0;
	if(res > n) res = n;
	cout << res << "\n";
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1LL<<60;

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

int main(void) {
    int N, W; cin >> N >> W;
    vector<int> wht(N), vle(N);
    REP(i, N) cin >> wht[i] >> vle[i];
    vector<vector<ll>> dp(N + 10, vector<ll>(100100, INF));
    dp[0][0] = 0;
    const int max_v = 100100;
    REP(i, N) {
        REP(j, max_v) {
            if (j - vle[i] >= 0) chmin(dp[i + 1][j], dp[i][j - vle[i]] + wht[i]);
            chmin(dp[i + 1][j], dp[i][j]);
        }
    }
    ll ans = 0;
    REP(i, max_v) {
        if (dp[N][i] <= W) ans = i;
    }
    cout << ans << endl;
}

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

int main(){
    ll N,A,B,C,D;
    cin>>N>>A>>B>>C>>D;
    
    for(ll i=0;i<N;i++){
        ll max=A+i*D-(N-1-i)*C;
        ll min=A+i*C-(N-1-i)*D;
        if(min<=B && B<=max){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;
using ll = long long;

int main(){
  int A, B;
  cin >> A >> B;

  if( 1<=A && A<=9 && 1<=B && B<=9 ) cout << A * B;
  else cout << -1;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  int d[n];
  for(int i=0; i<n; i++) cin >> d[i];
  int sum =0;
  for(int i=0; i<n; i++){
    for (int j=0; j<n; j++){
      sum += d[i]*d[j];
      if(i==j) sum -= d[i]*d[j];
    }
  }
  cout << sum/2 << endl;
}

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

int main() {
  
  int N;
  cin >> N;
  
  vector<int> L(N);
  
  for (int i = 0; i < N; i++) {
    cin >> L.at(i);
  } 
  
  int count = 0;
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if(L.at(i) != L.at(j) && L.at(i) != L.at(k) && L.at(j) != L.at(k) &&
            max(L.at(i), max(L.at(j),L.at(k)) ) < -max(L.at(i), max(L.at(j),L.at(k)) )+L.at(i)+L.at(j)+L.at(k)){
          count++;
        }
      } 
    } 
  } 
  
  cout << count << endl;
  
return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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> B(N-1);
  rep(i,N-1) cin >> B[i];
  
  vector<int>A(N);
  rep(i,N) {
    if (i == 0) A[0] = B[0];
    else if (i == N-1) A[N-1] = B[N-2];
    else A[i] = min(B[i-1],B[i]);
  }

  cout << accumulate(all(A),0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
const int N=200005;
const int mod=1e9+7;
const double eps=1e-8;
const double PI = acos(-1.0);
#define lowbit(x) (x&(-x))
int du[55];
int main()
{
    std::ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        du[a]++,du[b]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<du[i]<<endl;
    }
    return 0;
}


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

int k;
vector< int > color;
vector< vector< pair< int,int > > > graph;

void DFS(int current_vertex,int col)
{
    for(int i = 0;i<(int)graph[current_vertex].size();i++){
        int next_vertex = graph[current_vertex][i].first;
        int id = graph[current_vertex][i].second;
        if(color[id] != 0)    continue;
        col++;
        if(col>k)   col = 1;//don't worry this loop will finish vertex by vertex.
        color[id]=col;
        DFS(next_vertex,col);
    }
}

int main()
{
    //freopen("in.txt","r",stdin);
    int n,a,b;
    cin >> n;
    graph.resize(n+1);

    for(int id=0;id<n-1;id++){
        cin >> a >> b;
        graph[a].push_back(make_pair(b,id));
        graph[b].push_back(make_pair(a,id));
       // cout << id << endl;
        k = max(k,(int)graph[a].size());
        k = max(k,(int)graph[b].size());
    }

    cout << k << endl;
    color.resize(n-1);
    DFS(1,0);
    for(int i= 0;i<n-1;i++){
        cout << color[i] << endl;
    }

}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define up_b upper_bound
#define low_b lower_bound
#define nl '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

const int N=2e5+11;
const int M=1e5+1;
const int inf=2e9+1;
const ld EPS=1e-6;
const ll INF=1e18;
const ll mod=/*998244353*/1e9+7;
const int dx[8]={0,0,-1,1,-1,1,1,-1};
const int dy[8]={-1,1,0,0,1,-1,1,-1};

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0),cout.tie(0);
  string s,a;
  cin>>s>>a;
  int ans=sz(a);
  for(int i=0;i<sz(s)-sz(a)+1;i++){
    string b=s.substr(i,sz(a));
    int res=0;
    for(int j=0;j<sz(a);j++){
      if(a[j]!=b[j])res++;
    }
    ans=min(ans,res);
  }
  cout<<ans;
}


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


int main(){
    string s,t;
    cin >> s >> t;
    int ss = s.size();
    int tt = t.size();
    int count = 0;
    int ans = tt;
    int ans1 =0;
    for(int i=0;i<ss-tt+1;i++){
        for(int j = 0;j < tt;j++){
            if(s.at(j+i) == t.at(j)){
                count ++;
            }
        }
        ans1 = tt-count;
        ans =min(ans1,ans);
        count =0;
    }
    cout << ans << endl;
}

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

using ll = long long;
const int INF = 1e9 + 1;

int main() {

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

	bool c[3] = { false };

	c[a - 1] = true;
	c[b - 1] = true;

	rep(i, 3)
		if (!c[i])
			cout << i + 1 << endl;


	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

  int h,w;
  
  while(1){

    cin >>h>>w;
    if(h==0 && w==0)break;

    int len=h*h+w*w;

    int min_h=151,min_w=151;
    
    for(int i=1 ; i <=150 ; i++){
      for(int j=1 ; j < i ; j++){
	if((i*i+j*j > len) || (i*i+j*j == len && j > h)){
	  if((i*i+j*j < min_h*min_h+min_w*min_w) ||(i*i+j*j == min_h*min_h+min_w*min_w && j < min_h)){
	    min_h=j;
	    min_w=i;
	  }
	}
      }
    }
    
    cout <<min_h<<" "<<min_w<<endl;
      
  }
  
  return 0;
}

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


void solve(string& A, string& B){
  int a = A.size();
  int b = B.size();

  if(a>b){
    cout << "GREATER" << endl;
  }else if(b>a){
    cout << "LESS" << endl;
  }else{
    int i = 0;
    while(i < a){
      if(A.at(i)>B.at(i)){
        cout << "GREATER" << endl;
        return;
      }else if(B.at(i)>A.at(i)){
        cout << "LESS" << endl;
        return;
      }
      i++;
    }
    cout << "EQUAL" << endl;
  }
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string A;
    cin >> A;
    string B;
    cin >> B;
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int k,x;
    cin>>k>>x;
    for(int i = x-k+1; i <= x+k-1; i++){
        cout<<i<<" ";
    }

    return 0;
}


Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
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)
#define square(x) pow(x 2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/

int main() {
  ll n,m,x,ans=20000000,cost;
  cin >> n >> m >> x;
  vi c(12);
  bool flag;
  ll a[12][12];
  rep(i,n){
    cin >>c[i];
    rep(j, m){
      cin >> a[i][j];
    }
  }
  rep(i,12-n){
    c[n+i]=0;
    rep(j, 12-m){
      a[n+i][m+j]=0;
    }
  }
  vi sum(m);
  for (int tmp = 0; tmp < (1 << n); tmp++) {
    bitset<12> s(tmp);
    flag=true;
    cost = 0;
    rep(i,m){
      sum[i]=0;
    }
    for (int i = 0; i < n; i++) {
      if (s.test(i)) {
        rep(j,m){
          sum[j] += a[i][j];
        }
        cost+=c[i];
      }
    }
    rep(j,m){
      if(sum[j]<x){flag=false;break;}
    }
    if(flag){
      ans=min(ans,cost);
    }
}
  if(ans==20000000){
    co(-1);
  }else{co(ans);}
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>

using namespace std;

using ll = long long;

int main() {
	int k;
	cin >> k;
	bool* appered = new bool[k];
	for (int i = 0;i < k;i++) {
		appered[i] = false;
	}
	int x = 0;
	for (int i = 1;;i++) {
		x *= 10;
		x += 7;
		x %= k;
		if (x == 0) {
			cout << i << endl;
			return 0;
		}
		if (appered[x])break;
		appered[x] = true;
	}
	cout << -1 << endl;
}

Measured memory_bytes: 4172
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            char[] cs = S.toCharArray();
            Arrays.sort(cs);
            out.println(cs[0] == cs[2] ? "No" : "Yes");
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 22868
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<string.h>
using namespace std;
const int maxn=30000+10;
struct node
{
   double x,y;
}no[maxn];
struct line
{
   node l,r;
   bool operator<(line b)const
   {
      return l.y<b.l.y||(l.y==b.l.y&&r.y<b.r.y);
   }
}a[maxn];
int sum[maxn];
double area[maxn];
int n,m,w,h,s;
inline double xmulti(node a,line b)//å°äºé¶ç¹å¨ç´çº¿ä¸ 
{
       return (b.l.x-a.x)*(b.r.y-a.y)-(b.l.y-a.y)*(b.r.x-a.x);
}
int main()
{
    int ans=0;
    while(scanf("%d%d%d%d%d",&n,&m,&w,&h,&s)&&(n+m+w+h+s))
    {
        a[0].l.y=a[0].r.y=0;
        a[0].l.x=0;a[0].r.x=w;
        for(int i=1;i<=m;i++)
        {
           scanf("%lf%lf",&a[i].l.y,&a[i].r.y);
           a[i].l.x=0;a[i].r.x=w;
        }
        m++;
        a[m].l.y=a[m].r.y=h;
        a[m].l.x=0;a[m].r.x=w;
        for(int i=0;i<n;i++)
        {
           scanf("%lf%lf",&no[i].x,&no[i].y);
        }
        sort(a,a+m);
        for(int i=0;i<m;i++)
        {
           area[i]=((a[i+1].l.y-a[i].l.y)+(a[i+1].r.y-a[i].r.y))*w/2;
        }
        memset(sum,0,sizeof(sum));
        for(int i=0;i<n;i++)
        {
           int l=0,r=m;
           int mid;
           while(l<=r)
           {
             mid=(l+r)/2;
             if(xmulti(no[i],a[mid])>0)
             {
               if(xmulti(no[i],a[mid+1])<0)
                 break;
               else
                 l=mid+1;
             }
             else
                r=mid-1;
           }
           sum[mid]++;
           //cout<<mid<<endl;
        }
        ans=-1;
        int tot=0;
        double totarea=0;
        int i=0,j=0;
        /*while(j<m&&totarea+area[j]<=w*h-s)
        {
          totarea+=area[j];
          tot+=sum[j];
          j++;
        }
        if(j>0)
        {
          ans=max(tot,ans);
        }
        for(i=1;i<m;i++)
        {
          totarea-=area[i-1];
          tot-=sum[i-1];
          while(j<m&&totarea+area[j]<=w*h-s)
          {
            totarea+=area[j];
            tot+=sum[i-1];
          }
          ans=max(tot,ans);
        }       */
        /*while(j<m)
        {
          if(totarea>0)
          {
             totarea-=area[i-1];
             tot-=sum[i-1];
          }
          while(j<m&&totarea+area[j]<=w*h-s)
          {
            totarea+=area[j];
            tot+=sum[j];
            j++;
          }
          i++;
          if(totarea==0)
            j++;
          ans=max(tot,ans);
          //cout<<totarea<<' '<<tot<<endl; 
        }*/
        for(i=0;i<m;i++)
        {
           j=max(i,j);
           if(totarea>0)
           {
             totarea-=area[i-1];
             tot-=sum[i-1];
           }
           while(j<m&&area[j]+totarea<=w*h-s)
           {
             totarea+=area[j];
             tot+=sum[j];
             j++;
           }
           //cout<<totarea<<' '<<tot<<endl; 
           ans=max(ans,tot);
        } 
            
        printf("%d\n",n-ans);     
    }
    return 0;
}   

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

#define PI 3.14159265359

using namespace std;
typedef long long unsigned int ll;

int main() {
	string s;
	cin >> s;
	REP(i, s.size()) {
		cout << "x";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;

int hane[150];

int main()
{
	int n,x;
	ll ans=0;
	int l[100];
	cin>>n>>x;
	for(int i=0;i<n;i++)
		cin>>l[i];
	hane[0]=0;
	for(int i=0;i<n;i++)
		hane[i+1]=hane[i]+l[i];
	
	for(int i=0;i<n+1;i++)
	{
		if(hane[i]<=x)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
from math import *
a, b, C = map(float, input().split())
c = sqrt(a ** 2 + b ** 2 - 2 * a * b * cos(radians(C)))
s = (a + b + c) / 2
S = sqrt(s * (s - a) * (s - b) * (s - c))
L = a + b + c
h = b * sin(radians(C))
print(S)
print(L)
print(h)



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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back

const int maxm = 1000000000 + 7;


using namespace std;


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

   ll n;
   cin>>n;

   vector<ll>a(n);

   loop(i,n)
   {
   	cin>>a[i];
   }

   sort(all(a),greater<int>());

   ll x = a[0];
   
   ll mid = a[0]/2;

   ll max_a = INT_MAX;;

   for(int i=1; i<n; i++)
   {
   	  if(abs(a[i] - mid) < abs(mid - max_a))
   	  {
         max_a = a[i];
   	  }
   }
  

  cout<<x<<" "<<max_a<<endl;

}

Measured memory_bytes: 4024
"use strict";

function main(input){
  const args = input.trim().split('\n').map(_=>_.split(' ').map(x=>parseInt(x,10)));
  const n = args[0][0];
  const k = args[0][1];
  const arr = args.slice(1);
  const bucket = Array(100001).fill(0);
  
  for(let i=0; i<n; i++){
    bucket[arr[i][0]] += arr[i][1];
  }
  
  let sum = 0;
  for(let i=1; i<=100000; i++){
    sum += bucket[i];
    if(sum >= k){
      console.log(i);
      break;
    }
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 50604