akhauriyash/Code-Regression huggingface dataset:
// 物极必反

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9;
const double PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main(){
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, k; cin >> n >> k;

    vector<long long> a(n + 1);

    for(long long i = 1; i <= n; i++){
        cin >> a[i];
    }

    for(long long i = k + 1; i <= n; i++){
        if(a[i - k] < a[i]) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 4792
open Scanf
open Printf

let rec scan_list = function
  | 1 -> scanf "%d " (fun k -> [k])
  | n -> scanf "%d " (fun k -> k :: scan_list (n-1))

let f n m x y =
  let xs = scan_list n in
  let ys = scan_list m in
  let xmax = List.fold_left max (-100) (x :: xs) in
  let ymin = List.fold_left min 100 (y :: ys) in
  if xmax < ymin
  then "No War"
  else "War"

let () = let ans = scanf "%d %d %d %d\n" f in
  printf "%s\n" ans

Measured memory_bytes: 512
W,H,N = map(int,input().split())
L = []
for i in range(N):
  L.append(list(map(int,input().split())))
A = [0]
B = [W]
C = [0]
D = [H]
for i in range(N):
  if L[i][2] == 1:
    A.append(L[i][0])
  elif L[i][2] == 2:
    B.append(L[i][0])
  elif L[i][2] == 3:
    C.append(L[i][1])
  else:
    D.append(L[i][1])
A.sort()
A.reverse()
B.sort()
C.sort()
C.reverse()
D.sort()
w = 0
h = 0
if A[0] <= B[0]:
  w = B[0]-A[0]
else:
  w = 0
if C[0] <= D[0]:
  h = D[0]-C[0]
else:
  h = 0
print(w*h)

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

int main(){
   
    string S;
    cin>>S;
    if((S[0]-'0')*10+S[1]-'0'<=12&&(S[0]-'0')*10+S[1]-'0'>=1){
        if((S[2]-'0')*10+S[3]-'0'<=12&&(S[2]-'0')*10+S[3]-'0'>=1){
            cout<<"AMBIGUOUS"<<endl;
        }else {
            cout<<"MMYY"<<endl;
        }
    }else if((S[2]-'0')*10+S[3]-'0'<=12&&(S[2]-'0')*10+S[3]-'0'>=1){
            cout<<"YYMM"<<endl;
    }else{
        cout<<"NA"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
      
      //入力
      int N = sc.nextInt();//数列の長さ
      
      List<Integer>youso1 = new ArrayList<>();
      //List<Integer>youso2 = new ArrayList<>();
      
      //数列のlist作成
      for(int i=0; i<N; i++){
        	youso1.add(sc.nextInt());  	
      }
      //数列のコピーを作成
      ArrayList<Integer> youso2 = new ArrayList(youso1);
      
      //２つ目のlistを昇順に並び替え
      //昇順のlistと普通のlistを用意しておく
      Collections.sort(youso2);
      
      /*昇順にしたlistの最後は最大値であるため
      元のlistで比較し昇順のlistで出力する*/
      for(int i=0; i<N; i++){
        
      		if(youso1.get(i) < youso2.get(youso2.size()-1)){
              	System.out.println(youso2.get(youso2.size()-1));

            }
        	else /*if (youso1.get(i) == youso1.get(youso1.size()-1)) */{
              	System.out.println(youso2.get(N-2));
              
            }
      }
      
    }
}


Measured memory_bytes: 67856
#include <bits/stdc++.h>
using namespace std;
int main(){

	int a;
	cin>>a;
	int z=a%100;
	int c=a/100;
	if(c<=12&&c>0&&z<=12&&z>0){
		cout<<"AMBIGUOUS"<<endl;
	}
	else if(c<=12&&c>0&&(z>12||z==0)){
		cout<<"MMYY"<<endl;
	}
	else if(z<=12&&z>0&&(c>12||c==0)){
		cout<<"YYMM"<<endl;
	}
	else cout<<"NA"<<endl;
}

Measured memory_bytes: 256
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define RG register
#define LL long long
#define fre(a) freopen(a".in","r",stdin);//freopen(a".out","w",stdout);
using namespace std;
const int MAXN=50000;
int n,m,num;
int head[MAXN],to[MAXN],len[MAXN],cost[MAXN],Next[MAXN];
int dis[MAXN],pre[MAXN],pree[MAXN];
bool vis[MAXN],use[MAXN];
queue<int>que;
void add(int f,int t,int l,int c)
{
   Next[++num]=head[f];
   to[num]=t;
   len[num]=l;
   cost[num]=c;
   head[f]=num;
}
void SPFA()
{
   que.push(1);
   dis[1]=0;
   while(!que.empty())
      {
	 int now=que.front();
	 que.pop(); vis[now]=0;
	 for(int i=head[now];i;i=Next[i])
	    {
	       int son=to[i];
	       if(dis[now]+len[i]<dis[son])
		  {
		     dis[son]=dis[now]+len[i];
		     pre[son]=now;
		     pree[son]=i;
		     if(!vis[son])
			{
			   vis[son]=1;
			   que.push(son);
			}
		  }
	       else if(dis[now]+len[i]==dis[son])
		  {
		     if(cost[i]<cost[pree[son]])
			pree[son]=i,pre[son]=now;
		  }
	    }
      }
}
int main()
{
   //fre("1");
   while(1)
      {
	 scanf("%d%d",&n,&m);
	 if(n==0&&m==0)return 0;
	 num=0;
	 memset(head,0,sizeof head);
	 for(int i=1,a,b,c,d;i<=m;i++)
	    {
	       scanf("%d%d%d%d",&a,&b,&c,&d);
	       add(a,b,c,d); add(b,a,c,d);
	    }
	 memset(dis,0x3f3f3f3f,sizeof dis);
	 memset(vis,0,sizeof vis);
	 memset(use,0,sizeof use);
	 //memset(pree,0,sizeof pree);
	 SPFA();
	 //for(int i=1;i<=n;i++)printf("dis[%d]=%d\n",i,dis[i]);printf("----------------\n");
	 int ans=0;
	 for(int i=2;i<=n;i++)
	    for(int j=i;j>1;j=pre[j])
	       if(!use[pree[j]])
		  ans+=cost[pree[j]],use[pree[j]]=1;
	 printf("%d\n",ans);
      }
   return 0;
}

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


const int INF=10000000;


int main(){
int H,W;
cin>>H>>W;

char A[H][W];
int kyori[H][W];
vector<pair<int,int>> b;

for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
    kyori[i][j]=INF;
    
    cin>>A[i][j];
    if(A[i][j]=='#'){
    b.push_back(pair<int,int>(i,j));
    }
    }
}

queue<pair<int,int>> que;
for(int i=0;i<b.size();i++){
        
            
    que.push(b[i]);
    kyori[b[i].first][b[i].second]=0;   
            
}
int max= 0;        
while(que.size()){
                pair<int, int> p = que.front();
                que.pop();
            
            for(int k=0;k<4;k++){
                int nx = p.first+dx[k];
                int ny = p.second+dy[k];

            if(0<=nx && nx<H && 0<=ny && ny<W && kyori[nx][ny]>(kyori[p.first][p.second]+1) &&A[nx][ny]!='#' ){
                que.push(pair<int, int>(nx,ny));
                kyori[nx][ny]=kyori[p.first][p.second]+1;
                max=kyori[nx][ny];
                
            }
            
            }


        }
        
        
    



cout<<max<<endl;

return 0;
}

Measured memory_bytes: 21096
S = input()
T = input()

ss = len(S)
tt = len(T)

count = 0
res = []


for i in range(ss-tt+1):
    for j in range(tt):
        if S[i+j] != T[j]:
            count += 1
    res.append(count)
    count = 0

print(min(res))

Measured memory_bytes: 9040
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
const int mod = 2019;

int main(){
    ull L, R;
    cin >> L >> R;
    int min=2019;
    if(R-L >= mod){
        cout << 0 << endl;
    }else{
        vector<int> resmod(R-L+1);
        for(ull i=L; i<=R; i++){
            resmod[i-L]=i%2019;
        }
        sort(resmod.begin(),resmod.end());
        for(int i=0; i<R-L; i++){
            for(int j=i+1; j<=R-L; j++){
                if(resmod[i]*resmod[j]%mod<min){
                    min = resmod[i]*resmod[j]%mod;
                }
            }
        }
        cout << min << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if(n==1) {
            System.out.println("Hello World");
        } else {
            int a = sc.nextInt();
            int b = sc.nextInt();
            System.out.println(a + b);
        }
    }

}


Measured memory_bytes: 21844
#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
#include<cmath>
#include<limits>
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
using namespace std;

#define int ll

signed main() {
    int N; cin >> N;
    vector<int> vec(N);
    rep(i, N) cin >> vec[i];

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += vec[i] / 2;
        vec[i] -= 2 * (vec[i] / 2);
        if (vec[i] > 0) {
            if (i < N - 1) {
                if (vec[i + 1] > 0) {
                    vec[i] -= 1;
                    vec[i + 1] -= 1;
                    ans += 1;
                }
            }
            
        }
    }

    cout << ans << endl;
    sysp;
}

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"
#define max(aa, bb) (aa > bb ? aa : bb)
#define min(aa, bb) (aa < bb ? aa : bb)

int main(){

	lli n,a;
	vector<lli> v;
	cin>>n;

	for (lli i = 0; i < n; i++){
		cin>>a;
		v.pb(a);
	}

	sort(v.begin(), v.end(), greater<int>());
	lli  cvp=v[0];

	for (lli i = 1; i < n/2; i++){
		cvp+=v[i]*2;
	}
	if(n%2==1){
		cvp+=v[n/2];
	}
	cout<<cvp;
}

Measured memory_bytes: 5368
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
	int n;
	int ans;
	cin >> n;
	vector<ll> a(n);
	ll sum = 0;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		if (i != n - 1) {
			if (a[i] > a[i + 1]) {
				sum += a[i] - a[i+1];
				a[i + 1] = a[i];
			}
		}
		
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4704
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int N,K;
string s;
int main(int argc,char const* argv[])
{
  cin >> N >> K;
  cin >> s;
  if(s[K-1]=='A') s[K-1]='a';
  else if(s[K-1]=='B') s[K-1]='b';
  else if(s[K-1]=='C') s[K-1]='c';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 764
n = int(input())
a_list = [int(input()) for i in range(n)]

count = 1
now_button = 0
for i in range(len(a_list)):
    if a_list[now_button] == 2:
        print(count)
        exit()
    else:
        now_button = a_list[now_button]-1
        count += 1

print('-1')

Measured memory_bytes: 7084
MOD = 1000000007
def fast_power(base, power):
    """
    Returns the result of a^b i.e. a**b
    We assume that a >= 1 and b >= 0

    Remember two things!
     - Divide power by 2 and multiply base to itself (if the power is even)
     - Decrement power by 1 to make it even and then follow the first step
    """

    result = 1
    while power > 0:
        # If power is odd
        if power % 2 == 1:
            result = (result * base) % MOD

        # Divide the power by 2
        power = power // 2
        # Multiply base to itself
        base = (base * base) % MOD

    return result
n,k = [int(j) for j in input().split()]
d = dict()
ans = k
d[k] = 1
sum_so_far = 1
for i in range(k-1, 0, -1):
	d[i] = fast_power(k//(i),n)
	for mul in range(i*2, k+1, i):
		d[i]-=d[mul]
	# d[i] = max(1, d[i])
	ans+=(i*d[i])%MOD
	# if d[i]>1:
		# sum_so_far += d[i]
print(ans%MOD)


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


int main(){
    int long long n,a,b,s1=0,i;
    cin>>n>>a>>b;
    for(i=1;i<=n;i++)
    {
        int  long long s=0,j=i;
        while(j)
        {
            s+=j%10;
            j=j/10;
        }
        if(s>=a && s<=b)
        {
          s1+=i;  
        }
            
    }
    cout<<s1;
    return 0;
}

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

int alen, blen, clen;
char a[101], b[101], c[101];
int acnt, bcnt, ccnt;

int fun(int num){
    if(num == 0){
        if(a[acnt] == 'a') {
            acnt++;
            return fun(0);
        }
        if(a[acnt] == 'b'){
            acnt++;
            return fun(1);
        }
        if(a[acnt] == 'c') {
            acnt++;
            return fun(2);
        }
        if(a[acnt] == -1) return 1;
    }
    if(num == 1){

        if(b[bcnt] == 'a') {
            bcnt++;
            return fun(0);
        }
        if(b[bcnt] == 'b') {
            bcnt++;
            return fun(1);
        }
        if(b[bcnt] == 'c') {
            bcnt++;
            return fun(2);
        }
        if(b[bcnt] == -1) return 2;
    }
    if(num == 2){

        if(c[ccnt] == 'a') {
            ccnt++;
            return fun(0);
        }
        if(c[ccnt] == 'b') {
            ccnt++;
            return fun(1);
        }
        if(c[ccnt] == 'c') {
            ccnt++;
            return fun(2);
        }
        if(c[ccnt] == -1) return 3;
    }

}

int main (void){

    scanf("%s", a);
    scanf("%s", b);
    scanf("%s", c);

    alen = strlen(a);
    blen = strlen(b);
    clen = strlen(c);

    acnt = 0;
    bcnt = 0;
    ccnt = 0;

    a[alen] = -1;
    b[blen] = -1;
    c[clen] = -1;


    int ans = 0;
    ans = fun(0);
    if(ans == 1) printf("%c\n", 'A');
    if(ans == 2) printf("%c\n", 'B');
    if(ans == 3) printf("%c\n", 'C');


    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,k;
    cin>>n>>k;
    set<ll> sll;
    vector<ll> v(200010,0);
    rep(i,200010){
        v[i+1]=v[i]+i+1;
    }
    //ll left = MOD+1;
    //ll right = 0;
    ll ans = 0;
    for(int i=k;i<=n;i++){
        ll ans1=0,ans2=0;
        ans1 = v[i-1];
        ans2 = v[n]-v[n-i];
        /*cout<<i<<endl;
        cout<<v[i-1]<<" "<<v[n]<<" "<<v[n-i]<<endl;
        cout<<ans1<<" "<<ans2<<endl;*/
        ans=(ans+ans2-ans1+1)%MOD;
        //cout<<ans<<endl<<endl;
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 4736
package main

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

func main() {
	sc := NewScanner()
	_, K := sc.NextInt(), sc.NextInt()
	p := sc.NextIntArray()
	sort.Ints(p)
	s := 0
	for i := 0; i < K; i++ {
		s += p[i]
	}
	fmt.Println(s)

}

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: 1824
#include<bits/stdc++.h>
using namespace std;
#define F(i,s,e) for(int i=s;i<e;++i)

int check(int p[],int n){
    vector<int> v;
    F(i,0,n) v.push_back(i+1);
    int i=0;
    do{
        ++i;
        bool f=1;
        F(j,0,n) if(v[j]!=p[j]) f=0;
        if(f) return i;
    }while(next_permutation( v.begin(), v.end()));
}

int main(){
    int n;
    cin >> n;
    int p[n],q[n];
    F(i,0,n) cin >> p[i];
    F(i,0,n) cin >> q[i];
    int a=check(p,n);
    int b=check(q,n);
    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits//stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
int n, m, x, y,z;
int main(void) {
	cin >> n >> m; vector<int> a(100010, 0);
	rep(i, n) {cin >> x >> y >> z;a[x - 1]++; a[y]--;} x = 0;
	rep(i, 100009) a[i + 1] += a[i];
	rep(i, 100010) x = max(x, a[i]);
	cout << min(x,m) << endl;
}

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


int main(void) {
    
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll s=0;
    while(a>0&&k>0)
    {
      s+=1;
      a--;
      k--;
    }
    while(b>0&&k>0)
    {
        s+=0;
        b--;
        k--;
    }
    while(c>0&&k>0)
    {
        s+=-1;
        c--;
        k--;
    }
   cout<<s<<endl;
	// your code goes here
	return 0;
}



Measured memory_bytes: 3632
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


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

int n;
main() {
  file("threesum");
  ios;
  cin >> n;
  int ans = 0;
  fo(i, 1, n, 1) {
    ans += (i % 3 and i % 5 ? i : 0);
  }
  cout << ans;
  return 0;
}
/**

*/


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

int main() {
    int k;
    cin >> k;
    int mod = k;
    int cur = 7;

    bool found = false;
    int cnt = 1;

    for (int i = 1; i <= k; ++i) {
        if (cur % k == 0) {
            found = true;
            break;
        }
        cur = (cur * 10 + 7) % k;
        cnt++;
    }

    if (found) {
        cout << cnt << endl;
    } else {
        cout << "-1\n";
    }
}

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

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

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N = input()
ls = []

for i in range(N):
    x, y, h = map(int, raw_input().split())
    ls.append((x, y, h))
    if h > 0:
        stand = x, y, h

for cx in range(101):
    for cy in range(101):
        x, y, h = stand
        H = h + abs(x - cx) + abs(y - cy)
        flag = True
        for x, y, h in ls:
            if h != max(H - abs(x - cx) - abs(y - cy), 0):
                flag = False
                break
        if flag:
            print cx, cy, H
            exit()

Measured memory_bytes: 2936
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
using lint = long long;

#pragma GCC optimize ("-O3", "unroll-loops")
const int nmax = 204800, block = 8192, unrl = 16;
int a[nmax], b[nmax];

int main() {

	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) scanf("%d", &a[i]);
	for (int i = 0; i < N; i++) scanf("%d", &b[i]);

	int ans = 0;
	for (int i = 0; i + unrl <= N; i += unrl) {
		for (int j = 0; j + block <= N; j += block) {
			for (int k = j; k < block + j; k++) {

				ans ^= (a[i + 0] + b[k]) ^ (a[i + 1] + b[k]);
				ans ^= (a[i + 2] + b[k]) ^ (a[i + 3] + b[k]);
				ans ^= (a[i + 4] + b[k]) ^ (a[i + 5] + b[k]);
				ans ^= (a[i + 6] + b[k]) ^ (a[i + 7] + b[k]);
              	ans ^= (a[i + 8] + b[k]) ^ (a[i + 9] + b[k]);
				ans ^= (a[i + 10] + b[k]) ^ (a[i + 11] + b[k]);
				ans ^= (a[i + 12] + b[k]) ^ (a[i + 13] + b[k]);
				ans ^= (a[i + 14] + b[k]) ^ (a[i + 15] + b[k]);

			}
		}
	}

	for (int i = 0; i < N / unrl * unrl; i++) {
		for (int j = N / block * block; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}	
	for (int i = N / unrl * unrl; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}

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

	return 0;
}


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

int main(){
    i64 N;
    cin >> N; N++;
    vector<i64> A(N);
    vector<i64> sumA(N);
    rep(i, N) cin >> A[i];
    sumA = A;
    for(int i = N-2; i >= 0; i--) sumA[i] += sumA[i + 1];

    bool can = true;
    i64 B = 1 - A[0];
    if((A[0] > 0 && N != 1) || B < 0) can = false;

    i64 ans = B + sumA[0];
    for(int i = 1; i < N-1; i++){
        i64 b = min(2L*B - A[i], sumA[i+1]);

        if(b < 0) can = false;
        ans += b;
        B = b;
    }
    if(N != 1 && 2L*B < A[N-1]) can = false;

    if(!can) cout << -1 << endl;
    else cout << ans << endl;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end()) 
#define what_is(x) cout << #x << " is: " << x << endl;
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define ll long long int

#define vi vector<int>
#define pii pair<int,int>
#define vl vector<ll>
#define pll pair<ll, ll>

template<typename T>
T extgcd(T a, T b, T &x, T &y) { if (b == 0) {x = 1;y = 0;return b;}T x1, y1;T g = extgcd(b, a % b,x1, y1);x = y1; y = x1 - (a/b)*y1;return g;}
template<typename T>
T fast_power(T a, T b){T res = (T)1;while( b ){if( b & 1 ) res = res * a;b >>= 1;a *= a; } return res;}
template<typename T>
T fast_powerModulo( T a, T b, T M){T res = (T)1;a %= M;while( b ){if( b & 1 ) res = (res * a) % M;b >>= 1;a *= a;a %= M; }return res;}
template<typename T>
T LCM(T a, T b){ T gd = __gcd(a, b); T ml = a * b; return ml/ gd;}

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<string>> sub(n + 1, vector<string>());
    for( int i = 0; i < m; ++i){
        int x; string y;
        cin >> x >> y;
        sub[x].push_back(y);
    }
    int ac = 0;
    int pen = 0;
    for(int i = 1; i <= n; ++i){
        int acposs = 0;
        int penbeforeac = 0;
        for( auto & j : sub[i]){
            if( j == "AC" ){
                acposs = 1;
                break;
            } else {
                penbeforeac++;
            }
        }
        if( acposs ){
            pen += penbeforeac;
            ac += 1;
        }
    }
    cout << ac << " " << pen << '\n';

    return 0;
}




Measured memory_bytes: 10368
#include <cstdio>
#include <type_traits>

int main() {
  static_assert(std::is_same<long, decltype(1234567890987654321-1234567890987654321)>::value, "");

  char s[4];
  scanf("%s", s);
  puts(((s[0]+s[1]+s[2]) % 3 == 0)? "No": "Yes");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 2e5 + 1;
ll a[mxN];
ll n;
 
 
int main()
{
FIO
 
    cin >> n;
    For(n) cin >> a[i];
    ll ans = 0;
    FOR(n-1)
    {
        ans += max(a[i-1]-a[i], 0ll);
        a[i] = max(a[i], a[i-1]);
    }
    cout << ans;
}

Measured memory_bytes: 5220
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = 10000000;
const long long INFL = (1LL<<50);
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    int n;cin>>n;vector<int> p(n);cin>>p;
    
    int c=0;
    rep(i,n-1){
        if(i+1 == p[i]){swap(p[i],p[i+1]);c++;}
    }
    
    if(p[n-1]==n)c++;
    cout<<c<<endl;

    
    return 0;
}










Measured memory_bytes: 640
def main(): 
    
    n = int(input())
    W = list(map(int, input().split()))

    min_abs =10000

    for i in range(n):
        s1 = 0
        s2 = 0
        for j in range(n):
            if j <= i:
                s1 += W[j]
            else:
                s2 += W[j]
        min_abs = min(min_abs, abs(s1 - s2))

    print(min_abs)



if __name__ == "__main__":
    main() 

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define pb(x) push_back(x);
typedef long long  int ll;
ll mod = 998244353;
ll hmaxii=0;
vector<ll>values[2*100000+1];
ll MAXN = 2*100000+1;
ll spf[2*100000+1];
//vector<ll>values[];
ll diff,x,y,z;
ll flag=1;ll price[1001][1001];

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


void solution(){
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    int ans[n];
    ans[0]=0;
    ans[1]=abs(arr[0]-arr[1]);
    for(int i=2;i<n;i++){
        ans[i] = min(abs(arr[i-1]-arr[i])+ans[i-1],ans[i-2]+abs(arr[i-2]-arr[i]));
    }
    cout<<ans[n-1]<<endl;
}


int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //sieve();
    /*ll powe[64];
    powe[0]=1;
    ll i=1;
    while(i<64){
        powe[i] = powe[i-1]*2;
        i++;
    }*/
    ll t;
    //cin>>t;
    t=1;
    while(t--){
        solution();
    }
    return 0;
}

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

int main() {
  string s; cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) cout << "Bad" << endl;
  else cout << "Good" << endl;
}

Measured memory_bytes: 256
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

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

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	a, b, x := float64(scanInt()), float64(scanInt()), float64(scanInt())

	if a*a*b/2 > x {
		y := 2*x/a/b
		fmt.Println(math.Atan(b/y)/math.Pi*180)
	} else {
		y := 2*(a*a*b-x)/a/a
		fmt.Println(math.Atan(y/a)/math.Pi*180)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    int N; cin >> N;
    vector<int> B(N); for (auto& b : B) cin >> b, b--;
    for (int i = 0; i < N; i++) {
        if (B[i] > i) {
            cout << -1 << endl;
            return 0;
        }
    }
    vector<int> C(N), A, ans;
    int curr = 0, count = 0;
    while (count < N) {
        for (int i = N-1; i >= 0; i--) {
            if (!C[i] && B[i] <= curr) {
                int t = accumulate(begin(C), begin(C)+i, 0);
                if (t != B[i]) continue;
                A.insert(begin(A)+B[i], B[i]);
                ans.push_back(B[i]);
                C[i] = 1;
                curr++, count++;
                break;
            }
        }
    }
    for (int a : ans) cout << a+1 << '\n';
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
l = [1,2,3,4,5,6,7,8,9]
if(n<=9):
    print(l[n-1])
else:
    i=9
    j=0
    while(i<n):
        s = str(l[j])
        a = int(s[-1])
        b = l[j]*(10)
        if(a==9):
            l.append(b+(a-1))
            l.append(b+a)
            i+=2
        elif(a==0):
            l.append(b+a)
            l.append(b+(a+1))
            i+=2
        else:
            l.append(b+(a-1))
            l.append(b+a)
            l.append(b+(a+1))
            i+=3
        j+=1
    print(l[n-1])

Measured memory_bytes: 7316
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices.ComTypes;
using System.Text;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        var xorSum = 0L;
        for(int i = 0; i < n; i++)
        {
            xorSum ^= a[i];
        }
        for(int i = 0; i < n; i++)
        {
            var ans = xorSum ^ a[i];
            Console.Write(ans + " ");
        }


    }



}

Measured memory_bytes: 60632
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()

    var cnt = 0
    for (i in 1..n) {
        if (i % 2 == 0) continue
        val d = divisor(i)
        if (d.size == 8) cnt++
    }

    println(cnt)
}

fun divisor(value : Int) : List<Int> {
    val divisors = mutableListOf<Int>()
    var i = 1
    while (i * i <= value) {
        if (0 == value % i) {
            divisors.add(i)
            if (i != value/i) divisors.add(value/i)
        }
        i++
    }
    return divisors.sorted()
}

Measured memory_bytes: 34276
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>*/
#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll dx[4] = {1,0,-1,0};
ll dy[4] = {0,1,0,-1};

int main(){
    ll h,w;
	vs s(h);
	cin >> h >> w;
	rep(i,h) cin >> s[i];
	rep(i,h+2){
		if(i == 0 || i == h+1) rep(i,w+2) cout << '#';
		else cout << '#' << s[i-1] << '#';
		cout << endl;
	}
	return 0;
}  


Measured memory_bytes: 49536
#include <bits/stdc++.h>
using namespace std;
const int MAXR = 500005, mod = 1000000000 + 7;
int n, x[3], pool, to[MAXR][11], link[MAXR];
bool isBad[MAXR];
void insert(string s) {
	int r = 0;
	for (auto cc : s) {
		char c = cc - '0';
		if (!to[r][c]) {
			to[r][c] = ++pool;
		}
		r = to[r][c];
	}
	isBad[r] = 1;
}
void func(int u, int sum, string& s) {
	if (sum == x[u]) {
		++u;
		sum = 0;
	}
	if (u == 3) {
		insert(s);
		return;
	}
	for (int d = 1; sum + d <= x[u]; ++d) {
		s += char('0' + d);
		func(u, sum + d, s);
		s.pop_back();
	}
}
void augment() {
	int r = 0;
	queue<int> Q;
	Q.push(r);
	while (!Q.empty()) {
		int r = Q.front();
		Q.pop();
		for (int c = 0; c < 8; ++c) {
			int v = to[r][c];
			if (v == 0) {
				to[r][c] = to[link[r]][c]; 
			}
			else {
				if (r == 0) {
					link[v] = 0;
				}
				else {
					link[v] = to[link[r]][c];
				}
				isBad[v] |= isBad[r];
				isBad[v] |= isBad[link[v]];
				Q.push(v);	
			}
		}
	}
}
int DP[50][MAXR];
int dp(int n, int r) {
	if (isBad[r]) {
		return 0;
	}
	if (n == 0) {
		return 1;
	}
	if (DP[n][r] != -1) {
		return DP[n][r];
	}
	long long ans = 0;
	for (int c = 1; c <= 10; ++c) {
		ans += dp(n - 1, to[r][c]);
	}
	return DP[n][r] = ans % mod;
}
long long p10[50] = {1};
int main() {
	for (int i = 1; i < 50; ++i) {
		p10[i] = p10[i - 1] * 10 % mod;
	}
	memset(DP, -1, sizeof DP);
	cin >> n >> x[0] >> x[1] >> x[2];
	string curr;
	//generate all haikus
	func(0, 0, curr);
	augment();
	cout << (p10[n] - dp(n, 0) + mod) % mod;
}

Measured memory_bytes: 99584
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1.0)
int main()
{
    int n,m;
    cin>>n>>m;
    int sum=0,x,i;
    for(i=0;i<m;i++)
    {
        cin>>x;
        sum=sum+x;
    }
    if(sum<=n){cout<<n-sum<<endl;}
    else{cout<<-1<<endl;}

    return 0;
}


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

int main(){
	int n, m; cin >> n >> m;
	vector<int> v[n];
	bool isOpen[m];
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < m; ++j){
			int a; cin >> a;
			--a;
			v[i].push_back(a);
			isOpen[j] = 1;
		}
	}
	int p[m] ={0};
	int minp = 0;
	for(int i = 0; i < n; ++i){
		++p[v[i][0]];
		minp = max(minp, p[v[i][0]]);
	}
	for(int spo = 1; spo < m; ++spo){
		int peo[m] = {0};
		int maxp = 0;
		int maxflag = 0;
		int submax = 0;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < m; ++j){
				if(isOpen[v[i][j]]){
					++peo[v[i][j]];
					break;
				}
			}
		}
		for(int i = 0; i < m; ++i){
			if(maxp < peo[i]){
				maxp = peo[i];
				maxflag = i;
			}
		}
		isOpen[maxflag] = 0;
		maxp = 0;
		for(int i = 0; i < m; ++i) peo[i] = 0;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < m; ++j){
				if(isOpen[v[i][j]]){
					++peo[v[i][j]];
					maxp = max(maxp, peo[v[i][j]]);
					break;
				}
			}
		}
		minp = min(maxp, minp);
	}
	cout << minp << endl;
	return 0;
}

Measured memory_bytes: 896
#!/usr/bin/env python3
import sys
from itertools import accumulate
MOD = 1000000007  # type: int


def solve(N: int, A: "List[int]"):
    aa = list(accumulate(A))
    #print(aa)
    x = sum(A)
    #print(x)

    ans = 0

    for i in range(N):
        ans += A[i]*(aa[N-1]-aa[i])%MOD
        ans %= MOD
    return print(ans)


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 44472
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define TEST int t = 1; while(t--) solve()

void solve(){
    
   int s,w;
   cin>>s>>w;
   if(w>=s)
   {
   	 cout<<"unsafe\n";
   }
   else
   {
   	 cout<<"safe\n";
   }
}

signed main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST; return 0;
}

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

int main(){
    double N, M; cin >> N >> M;
    int sum=0;
    vector<int> c;
    for(int i=0; i<N; i++){
        int tmp;
        cin >> tmp;
        sum += tmp;
        c.push_back(tmp);
    }
    sort(c.rbegin(), c.rend());
    //for(int i=0; i<N; i++) cout << c[i] << " ";
    double limit = sum/(4*M);
    //cout << limit << endl;
    if(c[M-1] < limit) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 4e17
#define nllinf -4e18
 
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > >
 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repupx(a,b,i,x) for(i=a;i<=b;i+=x)
	
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
 
#define err(n) cout<<n<<" ";
#define t1 cout<<",";
 
ll MOD= 998244353;
 
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j,k;

ll n;cin>>n;
ll a[n+3], b[n+3], c[n+3];repup(0,n-1,i)cin>>a[i]>>b[i]>>c[i];

ll ans1[n+3],ans2[n+3], ans3[n+3];
ans1[0]=a[0]; ans2[0]=b[0]; ans3[0]=c[0];
repup(1,n-1,i){
	ans1[i]= a[i]+ max(ans2[i-1],ans3[i-1]);
	ans2[i]= b[i]+ max(ans1[i-1],ans3[i-1]);
	ans3[i]= c[i]+ max(ans1[i-1],ans2[i-1]);
} 
cout<< max(ans1[n-1], max(ans2[n-1], ans3[n-1]));
}

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

int main(){
  double t,x;
  cin >> t >> x;
  cout << setprecision(16) << t/x << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
	public static void main(String[] args) {
		int MAX = 200000;
		int n;
		int[] R;
		
		R = new int[MAX];
		
		BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
		try{
			String line = reader.readLine();
			
			n = Integer.parseInt(line);
			for(int i = 0; i < n; i++ ) {
				line =reader.readLine();
				R[i] = Integer.parseInt(line);
			}
			
			int maxv = -2000000000;
			int minv = R[0];
			
			for ( int i = 1; i < n ; i++) {
				maxv = Math.max(maxv, R[i] -minv);
				minv = Math.min(minv, R[i]);
			}
			
			System.out.println(maxv);
			
		} catch (IOException e) {
			System.out.println(e);
		} catch (NumberFormatException e) {
			System.out.println("??°????????\?????????????????????");
		}
	}
}
		

Measured memory_bytes: 43252
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

class Tree{
public:

    int N;
    vector<vector<int>> G;
    vector<int> aoki;
    vector<int> taka;
    int ans = 0;

    Tree(int _n){
        N = _n;
        G.resize(N);
        aoki.resize(N);
        taka.resize(N);
    }

    void make_edge(int s, int t){
        G[s].push_back(t);
        G[t].push_back(s);
    }

    void dfs_aoki(int n, int par){
        if(par == -1){
            aoki[n] = 0;
        }

        for(int i = 0; i < (int)G[n].size(); i++){
            int nxt = G[n][i];
            if(nxt != par){
                aoki[nxt] = aoki[n] + 1;
                dfs_aoki(nxt, n);
            }
        }
    }

    void dfs_taka(int n, int par){
        if(par == -1){
            taka[n] = 0;
        }

        for(int i = 0; i < (int)G[n].size(); i++){
            int nxt = G[n][i];
            if(nxt != par){
                taka[nxt] = taka[n] + 1;
                dfs_taka(nxt, n);
            }
        }
    }

    void print(){
        for(int i = 0; i < N; i++){
            cout << "i = " << i << endl;
            cout << "ao" << aoki[i] << endl;
            cout << "ta" << taka[i] << endl;
        }
    }

    int find_aoki_pos(int n){
        while(taka[n] - aoki[n] > 2){
            ans++;
            for(int i = 0; i < (int)G[n].size(); i++){
                int nxt = G[n][i];
                if(taka[nxt] == taka[n] - 1){
                    n = nxt;
                    break;
                }
            }
        }

        return n;
    }

    int find_taka_pos(int n){
        while(aoki[n] - taka[n] > 2){
            for(int i = 0; i < (int)G[n].size(); i++){
                int nxt = G[n][i];
                if(aoki[nxt] == aoki[n] - 1){
                    n = nxt;
                    break;
                }
            }
        }

        return n;
    }

    int dfs(int n, int par){
        int ret = 1;
        for(int i = 0; i < (int)G[n].size(); i++){
            int nx = G[n][i];
            if(nx != par && aoki[nx] == aoki[n] + 1){
                //cout << "nx = " << nx << endl;
                ret = max(ret, dfs(nx, n) + 1);
            }
        }

        return ret;
    }
};


int main(){
    int N, u, v;
    cin >> N >> u >> v;
    u--;
    v--;

    Tree tr = Tree(N);

    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        tr.make_edge(a, b);
    }

    tr.dfs_aoki(v, -1);
    tr.dfs_taka(u, -1);

    int aft_taka = tr.find_taka_pos(u);
    int aft_aoki = tr.find_aoki_pos(v);

    //cout << aft_taka << " " << aft_aoki << endl;

    //cout << tr.ans << endl;
    int ans = tr.ans;
    ans += tr.dfs(aft_taka, -1);
    if(tr.aoki[aft_taka] == tr.taka[aft_taka] + 1) ans--;

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


Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    string s;
    cin >> s;
    int len = s.length();
    cout << s[0] << len-2 << s[len-1] << endl;
    return 0;
}

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

int main(){
	string S, T;
	cin >> S >> T;
	for (int i = 0;i < S.size();++i) {
		if (S == T) {
			puts("Yes");
			return 0;
		}
		S = S.substr(1, S.size() - 1) + S[0];
	}
	puts("No");
	return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    int cnt = 0;
    for(int i = a;i <= b;i++){
        if(i%10 == i/10000 && i/10%10 == i/1000%10){
            cnt++;
        }
    }
    cout << cnt << endl;
}

int min(int a,int b){
    if(a-b>0) return b;
    return a;
}

int max(int a,int b){
    if(a-b>0) return a;
    return b;
}

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

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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;

int main() {
	lli i, j, k, n, ans;
	string s;
	vector<lli>a;

	cin >> n >> s;
	a.resize(26);

	rep(i, n) {
		a[(int)(s[i]) - int('a')]++;
	}
	ans = 1;
	rep(i, 26) {
		ans *= (a[i] + 1);
		ans %= (lli)(pow(10, 9) + 7);
	}
	ans--;
	if (ans == -1)ans = pow(10, 9) + 6;

	cout << ans;

	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();		
		
		int x = a * b - b - (a - 1);
		System.out.println(x);
		
	}

}


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

int main(){
    ll h,w;
    cin>>h>>w;
    bool g[w][h];
    ll wn=0;
    rep(i,h){
        string s;
        cin>>s;
        rep(j,w){
            if(s[j]=='.'){
                g[j][i]=true;
                wn++;
            }else{
                g[j][i]=false;
            }
        }
    }
    queue<tuple<ll,ll,ll>> que;
    que.push(make_tuple(0, 0, 1));
    vector<vector<bool>> used(w,vector<bool>(h,false));
    used[0][0]=true;
    while(que.size()){
        tuple<ll,ll,ll> p=que.front();
        que.pop();
        ll x=get<0>(p);
        ll y=get<1>(p);
        ll n=get<2>(p);
        if(x==w-1&&y==h-1){
            cout<<wn-n<<endl;
            return 0;
        }
        if(x>0&&!used[x-1][y]&&g[x-1][y]){
            que.push(make_tuple(x-1,y,n+1));
            used[x-1][y]=true;
        }
        if(y>0&&!used[x][y-1]&&g[x][y-1]){
            que.push(make_tuple(x,y-1,n+1));
            used[x][y-1]=true;
        }
        if(x<w-1&&!used[x+1][y]&&g[x+1][y]){
            que.push(make_tuple(x+1,y,n+1));
            used[x+1][y]=true;
        }
        if(y<h-1&&!used[x][y+1]&&g[x][y+1]){
            que.push(make_tuple(x,y+1,n+1));
            used[x][y+1]=true;
        }
    }
    cout<<-1<<endl;
}


Measured memory_bytes: 256
n,k=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
ans=10**9
for i in range(n-k+1):
  s=a[i]
  l=a[i+k-1]
  if s<0 and l>=0:
    ans=min(ans,abs(s)*2+l,abs(s)+l*2)
  elif l<=0:
    ans=min(ans,abs(s))
  else:
    ans=min(ans,l)
print(ans)

Measured memory_bytes: 14252