akhauriyash/Code-Regression huggingface dataset:
#include <cstdlib>
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cmath>
#define ll long long
const ll INF=0x3f3f3f3f;
#define mod 1000000007
#define mem(a,b) memset(a,b,sizeof(a))
#define  INF 0x3f3f3f3f
//__builtin_popcount
using namespace std;
//priority_queue
const ll MAX=100000;
ll gcd(ll a,ll b)
{
    return b==0?a:gcd(b,a%b);
}
ll kc(ll a,ll b)
{
    ll c=1;
    while(b)
    {
        if(b&1)c=(c*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return c;
}

ll F[100003];
ll Find(ll a)
{
    return F[a]<0?a:F[a]=Find(F[a]);
}
ll same(ll a,ll b)
{
    if(Find(a)==Find(b))return 1;
    return 0;
}
void up(ll a,ll b)
{
    ll x,y;
    x=Find(a);
    y=Find(b);//cout<<F[x]<<" "<<F[y]<<endl;
    if(x!=y)
        F[y]+=F[x],F[x]=y;


}
int main()
{
  ll a;
  cin>>a;
  cout<<3*a*a;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
struct p{
	ll l,r;
}a[N];
ll s;
int main(){
	int n,t;
	scanf("%d%d",&n,&t);
	for(int i=1,x;i<=n;i++){
		scanf("%d",&x);
		a[i].l=x,a[i].r=a[i].l+t;
	}
	ll l=a[1].l,r=a[1].r;
	for(int i=2;i<=n;i++){
		if(a[i].l<=r) r=a[i].r;
		else s+=r-l,l=a[i].l,r=a[i].r;
	}
	s+=r-l;
	printf("%lld\n",s);
	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<long long> H(N);
    for (int i = 0; i < N; ++i) cin >> H[i];
    
    sort(H.begin(), H.end(), greater<long long>());
    for (int i = 0; i < min(N, K); ++i) H[i] = 0;
    long long res = 0;
    for (int i = 0; i < N; ++i) res += H[i];
    cout << res << endl;
}


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

int divisorList[1000001] = {0};


// WA おそらく1000000を超える素数が答えにあるが出力していない
int main(void) {
	unsigned long long A, B;
	cin >> A >> B;
	vector <int> divisor;
	vector <unsigned long long> AHighDiv, BHighDiv;
	for (int i = 1; i <= 1000000; i++) {
		if ((A%i==0) && (B%i==0)) divisor.push_back(i);
		if (A%i==0) {
			if ((A/i) > 1000000) AHighDiv.push_back(A/i);
		}
		if (B%i==0) {
			if ((B/i) > 1000000) BHighDiv.push_back(B/i);
		}
	}

	// 素数リストを作る
	for (int i = 2; i <= 1000000; i++) {
		if (divisorList[i]==0) {
			for (int j = i*2; j <= 1000000; j+=i) {
				divisorList[j]++;
			}
		}
	}

	int ans = 0;
	for (unsigned int i = 0; i < divisor.size(); i++) {
		if (divisorList[divisor[i]]==0) ans++;
	}
	if ((AHighDiv.size()>0) && (BHighDiv.size()>0)) {
		sort(AHighDiv.begin(), AHighDiv.end());
		sort(BHighDiv.begin(), BHighDiv.end());
		int Apos = 0, Bpos = 0;
		while (Apos < AHighDiv.size() && Bpos < BHighDiv.size()) {
			if (AHighDiv[Apos]==BHighDiv[Bpos]) {
				// 素数か確認する
				bool primeNumber = true;
				for (unsigned int i = 2; i < 1000000; i++) {
					if (divisorList[i]==0) {
						if ((AHighDiv[Apos]%i)==0) {
							primeNumber = false;
							break;
						}
					}
				}
				if (primeNumber) ans++;
				Apos++, Bpos++;
			} else if (AHighDiv[Apos] > BHighDiv[Bpos]) {
				Bpos++;
			} else if (AHighDiv[Apos] < BHighDiv[Bpos]) {
				Apos++;
			}
		}
	}

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


Measured memory_bytes: 4224
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp1 {
    public class Class {
        static void Main(string[] args) {
            var AV = RL<long>();
            var BW = RL<long>();
            var T = RL<long>();

            var diff = Math.Abs(BW[0] - AV[0]);
            var V = AV[1] * T[0];
            var W = BW[1] * T[0];
            if (diff - Math.Abs(W - V) <= 0 && AV[1] > BW[1]) Console.Write("YES");
            else Console.Write("NO");
        }


        static T[] RL<T>() where T : IComparable {
            if (typeof(T) == typeof(int)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(int.Parse).ToArray();
            }
            if (typeof(T) == typeof(long)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(long.Parse).ToArray();
            }
            if (typeof(T) == typeof(double)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(double.Parse).ToArray();
            }
            if (typeof(T) == typeof(decimal)) {
                return (T[])(object)Console.ReadLine().Trim().Split().Select(decimal.Parse).ToArray();
            }
            return (T[])(object)Console.ReadLine().Trim().Split().ToArray();
        }
    }
}


Measured memory_bytes: 28176
n = int(input())
h = list(map(int, input().split()))
dp = [0]*n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[-1])


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

int main(){
  int N, M; cin >> N >> M;
  if(M==0){
    if(N==1) cout << 0 << endl;
    if(N==2) cout << 10 << endl;
    if(N==3) cout << 100 << endl;
    return 0;
  }
  vector<pair<int, char>> A(M);
  for(int i=0;i<M;i++){
    cin >> A[i].first >> A[i].second;
  }
  vector<int> ten={0,10,100,1000};
  int check=0;
  for(int i=0;i<1000;i++){
    check=0;
    string s=to_string(i);
    if(i>=ten[N-1] && i<ten[N]){
      check=1;
      for(int j=0;j<M;j++){
        if(s[A[j].first-1]!=A[j].second){
          check=2;
        }
      }
    }
    if(check==1){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner

const bufferSize = 1024

func nextInt() int {
	if !sc.Scan() {
		panic(nil)
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var production bool

func debugf(format string, v ...interface{}) {
	if !production {
		fmt.Printf(format, v...)
	}
}

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, bufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	n := nextInt()

	_, _ = fmt.Fprintf(writer, "%d", (n+1)/2)
}

func main() {
	production = true
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 640
import heapq
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    D = sorted(list(map(int, input().split())))

    m = N//2
    if D[m-1]==D[m]:
        print(0)
    else:
        print(D[m] - D[m-1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 14044
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    
    int a, cnt = 0;
    for(int i = 0;i < n;i++){
        cin >> a;
        if(i % 2 == 0 && a % 2 == 1){
            cnt++;
        }
    }
    
    cout << cnt;
    
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
using namespace std;
#define ll long long
#include <cstdint>

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	cout << (x - a) % b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...) 0
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, p;
    string s;
    cin >> n >> p >> s;
    if (p == 2) {
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            int t = s[i] - '0';
            if (t % 2 == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    } else if (p == 5) {
        ll ans = 0;
        for (int i = 0; i < n; i++) {
            int t = s[i] - '0';
            if (t % 5 == 0) {
                ans += i + 1;
            }
        }
        cout << ans << endl;
        return 0;
    }
    vector<ll> dp(n + 1);
    for (int i = 1; i <= n; i++) {
        dp[i] = s[i - 1] - '0';
        dp[i] += dp[i - 1] * 10LL;
        dp[i] %= p;
    }
    ll q = 1;
    vector<ll> tmp;
    for (int i = 0; i < n + 1; i++) {
        tmp.emplace_back(q);
        q = (q * 10LL) % p;
    }
    debug(dp);
    for (int i = 0; i < n + 1; i++) {
        dp[i] *= tmp[n - i];
        dp[i] %= p;
    }
    vector<ll> st(p);
    ll ans = 0;
    for (int i = 0; i < n + 1; i++) {
        st[dp[i]]++;
    }
    debug(dp);
    debug(tmp);
    debug(st);
    for (int i = 0; i < p; i++) {
        ans += st[i] * (st[i] - 1LL) / 2LL;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4236
import math

def main():
    a, b, x = map(int, input().split())
    V = a**2 * b
    if x <= V/2:
        rad = math.atan(a * b**2 / (2*x))
        print(math.degrees(rad))
    else:
        rad = math.atan(2 * (a**2 * b - x) / a**3)
        print(math.degrees(rad))    
main()

Measured memory_bytes: 9228
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int n; cin >> n;
	vector<int> v(n), c(n),d(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		d[i] = v[i] - c[i];
		if (d[i] > 0) {
			ans += d[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import math
A,B=map(int,input().split())
ans=-1
for i in range(1,10001):
    n1=int(math.floor(i * 0.08))
    n2=int(math.floor(i * 0.1))

    if n1 == A and n2 == B:
        ans=i
        break

print(ans)


Measured memory_bytes: 2940
import java.util.*;
import java.util.ArrayList;
import java.util.List;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    

    List list = new ArrayList<>();
    for(int i = 0; i < m; i++){
      list.add(sc.nextInt());
    }

    int countA = 0;
    for(int i = x; i < n; i++){
      if(list.contains(i)){
        countA++;
      }
    }
    
    int countB = 0;
    for(int i = x; i > 0; i--){
      if(list.contains(i)){
        countB++;
      }
    }
    System.out.println(countA < countB ? countA : countB);
  }
}

Measured memory_bytes: 22728
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

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

int a, b;

int main()
{
    cin >> a >> b;
    char ca = '0' + a;
    char cb = '0' + b;
    string sa = "";
    rep(i,b)
    {
        sa += ca;
    }
    string sb = "";
    rep(i,a)
    {
        sb += cb;
    }
    if(sa < sb) cout << sa << endl;
    else cout << sb << endl;
}

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

int main(int argc, const char * argv[]) {
    
    int N,M,C,count = 0,sum=0;
    cin >> N;
    cin >> M;
    cin >> C;
    
    int b[M],a[M];
    for(int i=0;i<M;i++){
        cin >> b[i];
    }
    for(int j=0;j<N;j++){
        for(int i=0;i<M;i++){
            cin >> a[i];
            sum = sum + a[i]*b[i];
        }
        if((sum+C) > 0){
            count ++;
        }
        sum = 0;
    }
    cout << count << endl;
    
    
    return 0;
}

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



int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);	

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

    vector<int> dp(n,0);
    int ans =0 ;

    for(int i=n-2;i>=0;i--){
    	if(a[i]>=a[i+1]){
    		dp[i]=dp[i+1]+1;
    	}else{
    		dp[i]=0;
    	}
    	ans = max(ans,dp[i]);
    }

    cout << ans << "\n";


    
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int ans;
string a,b;
int main()
{
    go;
    cin>>a>>b;
    ans=(a[0]==b[0])+(a[1]==b[1])+(a[2]==b[2]);
    cout<<ans;
    return 0;
}


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

  int h,w,n,a[10000],hw[100][100],cnt=0;
  cin>>h>>w>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i%2) hw[i][j]=cnt+1;
      else hw[i][w-j-1]=cnt+1;
      a[cnt]--;
      if(a[cnt]==0) cnt++;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j) cout<<" ";
      cout<<hw[i][j];
    }
    cout<<endl;
  }
  return 0;

}





Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <limits.h>
#include <cstring>
#include <tuple>
#include <cassert>
#include <numeric>
#include <iomanip>
using namespace std;
// type alias
typedef long long LL;
typedef pair< int , int > II;
typedef tuple< int, int, int > III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))

// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');

// debug cerr
#define TRACE true
#define dump(x) if(TRACE) { cerr << #x << " = " << (x) << endl; }
#define dump2(x,y) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << endl; }
#define dump3(x,y,z) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << endl; }
#define dump4(x,y,z,a) if(TRACE) { cerr << #x << " = " << (x) << ", " << #y << " = " << (y) << ", " << #z << " = " << (z) << ", " << #a << " = " << (a) << endl; }
#define dumpf(args...) if(TRACE) { fprintf(stderr, ##args); putchar('\n'); }
#define dumpAR(ar) if(TRACE) { FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
template<class Iter> void dumpc(Iter begin, Iter end) { if (TRACE) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; } }

// $ ../batch 754 | diff 754.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address 754.cpp && ./a.out
string S;

void solve() {
  int N=SZ(S);
  int res=1e5;
  REP(i,N-2) {
    int x=100*(S[i]-'0')+10*(S[i+1]-'0')+1*(S[i+2]-'0');
    SMIN(res,abs(x-753));
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin>>S;
  solve();
  
  return 0;
}


Measured memory_bytes: 888
#include<stdio.h>

int BinarySearch(int ary[],int n,int key){
  int l=0,m,r=n;
  while(l<r){
    m=(l+r)/2;
    if(ary[m]==key){return 1;}
    else if(key<ary[m]){r=m;}
    else{l=m+1;}
  }
  return 0;
}

int main(){
  int i,ary[1000000],judge=0,n,key,q;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ary[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(BinarySearch(ary,n,key))judge++;
  }
  printf("%d\n",judge);
  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

int main() {
  ll N, K, A;
  cin >> N >> K;

  vector<ll> vec, loop;
  vec.reserve(N);
  loop.reserve(N);
  map<ll, ll> mem;

  for (auto i = 0; i < N; i ++) {
    cin >> A;
    vec.push_back(A);
  }
  ll now = 0;
  for (auto i = 0; i < N; i ++) {
    if (mem.find(now) != mem.end()) {
      break;
    }
    mem[now] = i;
    loop.push_back(now);
    now = vec[now] - 1;
  }
  ll fix = mem[now];
  ll l = loop.size() - fix;

  ll ret = 0;
  if (fix >= K) {
    ret = loop[K];
  } else {
    K -= fix;
    K = K % l;
    ret = loop[fix + K];
  }
  cout << ret + 1 << endl;
  return 0;
}

Measured memory_bytes: 18756
#include<stdio.h>
#include<string.h>
#include<math.h>
#define ll long long int

void sort(int array[],ll n){

ll i,j,temp;

for(i=0;i<n;i++)
{

    for(j=0;j<n;j++)
    {

        if (array[j] > array[j + 1])
            {
                temp = array[j];
                array[j] = array[j + 1];
                array[j + 1] = temp;
            }

    }



}




}



int main()
{


ll n,i,k,r,s,p,sum,temp;
char a[100000];
char x[100000];

scanf("%lld%lld",&n,&k);

scanf("%lld%lld%lld",&r,&s,&p);

scanf("%s",a);


sum=0;
temp=0;
for(i=0;i<n;i++)
{
    temp++;
    if(temp>k)
    {
        if(a[i]=='r')
        {
            if(x[i-k]!='p')
            {
                sum=sum+p;
                x[i]='p';
            }
            else{
                x[i]='a';
            }


        }
        if(a[i]=='s')
        {
            if(x[i-k]!='r')
            {
                sum=sum+r;
                x[i]='r';

            }
            else{
                x[i]='a';
            }

        }

        if(a[i]=='p'){
            if(x[i-k]!='s'){
                sum=sum+s;
                x[i]='s';
            }
            else{
                x[i]='a';
            }
        }
    }

    else{

        if(a[i]=='r')
        {
           x[i]='p';
           sum=sum+p;
        }
        if(a[i]=='s')
        {
            x[i]='r';
            sum=sum+r;

        }
        if(a[i]=='p')
        {
            x[i]='s';
            sum=sum+s;

        }

    }




}



printf("%lld",sum);



    return 0;
}


Measured memory_bytes: 384
#include <cassert>
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>
using namespace std;

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

	string s;
	cin >> s;
	int k = s.size();
	int cnt = 0;
	for (auto i : s)
	{
		if (i == 'o')
			cnt++;
	}
	if (15 - k + cnt >= 8)
	{
		cout << "YES\n";
	}
	else
	{
		cout << "NO\n";
	}
	
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
signed main(){
    int n, m;
    cin>>n>>m;
    vector<int> coins(m);
    for(long long i=0; i<m; i++){
        cin>>coins[i];
    }    
    vector<int> dp(n+1, 1<<29);
    dp[0] = 0;
    for(int i=1; i<=n; i++){
        for(int c=0; c<m; c++){
            if(i<coins[c]) continue;
            else dp[i] = min(dp[i], dp[i-coins[c]]+1);
        }
    } 
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------

int main(void) {
  int n, m;
  cin >> n >> m;

  vecll a(n), b(n), c(m), d(m);
  rep(i,n){
    cin >> a[i] >> b[i];
  }
  rep(i,m){
    cin >> c[i] >> d[i];
  }

  rep(i,n){
    ll tmp=1e9;
    int cp=-1;
    rep(j,m){
      ll dist = abs(c[j]-a[i]) + abs(d[j]-b[i]);
      if(dist<tmp) cp=j+1, tmp=dist;
    }
    prt(cp);
  }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] data = S.toCharArray();
        int length = data.length;
        int left = 0;
        int right = length - 1;
        int ans = 0;
        while (left < right) {
            if (data[left] == data[right]) {
                left += 1;
                right -= 1;
                continue;
            }
            if (data[left] != 'x' && data[right] != 'x') {
                System.out.println(-1);
                return;
            }
            if(data[left] == 'x') {
                ans += 1;
                left += 1;
            }
            if(data[right] == 'x') {
                ans += 1;
                right -= 1;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 30288
#include <iostream>
#include <deque>
#include <cmath>
using namespace std;
int main()
{
	deque<int> m;
	deque<double> d, h, w;
	int n, i, t[3];
	double u;
	while (cin >> n && n)
	{
		u = 0;
		m.clear();
		h.clear();
		w.clear();
		d.clear();
		for (i = 0; i < n; i++)
		{
			cin >> t[0] >> t[1] >> t[2];
			m.push_back(t[0]);
			h.push_back((double)t[1]/100);
			w.push_back((double)t[2]);
			d.push_back(22.0 - w[i]/(h[i]*h[i]));
			if (i == 0) u = abs(d[0]);
			if (abs(d[i]) < u) u = abs(d[i]);
		}
		for (i = 0; i < n; i++)
		{
			if (u == abs(d[i]))
				cout << m[i] << endl;
		}
	}
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

void solve() {
    int a, b, n;
    string s1, s2;
    cin>>s1>>s2;
    int mn = (s1.size(), s2.size());
    int cnt=0;
    for(int i=0;i<mn;++i) {
        cnt+=(s1[i]!=s2[i]);
    }
    cout<<cnt<<endl;
}
int main() {
    ios_base::sync_with_stdio(0);
    int T=1 ,cas=0;
    while(T--) {
        solve();
    }
    return 0;
}

// ll, reset, 1, bottom

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

set<int> mochi;
int N;

int main()
{
    cin >> N;
    REP(i, N) {
        int d;
        cin >> d;
        mochi.insert(d);
    }
    printf("%zu\n", mochi.size());
    return 0;
}


Measured memory_bytes: 256
n = int(input())
r = dict()
find = False
for i in range(n):
    l = str(sorted([c for c in input()]))
    if l not in  r:
        r[l] = 1
    else:
        r[l] = r[l] + 1
        find=True

sum = 0    
def comb(n, k):
    bo = 1
    for kk in range(1, k+1):
        bo = bo * kk
    si = 1
    for kk in range(n-k+1 ,n+1):
        si = si * kk
    return int(si / bo)

for k, v in r.items():
    sum = sum + comb(v, 2)
print(sum)


Measured memory_bytes: 21988
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl a(n),b(n);
  rep(i,n)cin>>a[i]>>b[i];
  reverse(a.begin(),a.end());
  reverse(b.begin(),b.end());
  ll count=0;
  rep(i,n){
    count+=((a[i]+count)+b[i]-1)/b[i]*b[i]-(a[i]+count);
  }
  cout<<count<<endl;
}

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

int main() {
  int A,B;
  cin >> A >> B;
  if(max(A,B)-min(A,B)<=1 && A+B<=16){
    cout << "Yay!" << endl;
  }
  else{
    cout << ":(" << endl;
  }
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    int p[1001] = {};
    for (int i = 0; i < n; i++) {
        p[l[i]]++;
    }
    for (int j = 1; j <= 1000; j++) {
        p[j] += p[j - 1];
    }

    ll r = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            int s = l[i] + l[j] - 1; if (s > 1000) s = 1000;
            int t = abs(l[i] - l[j]);
            if (t >= s) continue;
            //t<l<s
            r += (p[s] - (l[i] <= s) - (l[j] <= s)) - (p[t] - (l[i] <= t) - (l[j] <= t));
        }
    }

    cout << r / 3 << endl;

    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
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(void){

    int N, K;
    string s;
    cin >> N >> K >> s;

    queue<int> sep;
    char pre = s[0];
    FOR(i,1,s.size()){
        if(pre != s[i]) sep.push(i);
        pre = s[i];
    }
    sep.push(s.size());

    while(K>0 && sep.size()>1){
            sep.pop(); sep.pop();
            K--;
    }

    int sum = 0;
    if(sep.empty()){cout << s.size()-1 << endl; return 0;}
    int back = sep.back(), size = sep.size(); 
    while(sep.size()>1){ sum += sep.front(); sep.pop();}

    int s1 = sum, s2 = sum-back;
    cout << s1-s2-size << endl;

    return 0;
}

Measured memory_bytes: 768
#include<stdio.h>
#define NUM 500000
#define INFTY 1000000000

void mergeSort(int*,int, int);
void merge(int*,int,int,int);

int a[NUM];
int count=0;

int main(){
  int n,i,mid,left,right;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  left=0;
  right=n;
  

  mergeSort(&a[0],left,right);

  for(i=0;i<n;i++){
   
    printf("%d",a[i]);
    if(i+1!=n){
      printf(" ");
    }
  }
  
  printf("\n");
  printf("%d\n",count);
  
  
  return 0;
}


void merge(int *a,int left,int mid,int right){
  int n1,n2,L[NUM],R[NUM],i,j,k;
  n1=mid-left;
  n2=right-mid;

  for(i=0;i<n1;i++){
    L[i]=a[left+i];
  }
  for(i=0;i<n2;i++){
    R[i]=a[mid+i];
  }
  L[n1]=INFTY;
  R[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    if(L[i]<=R[j]){
      a[k]=L[i];
      i=i+1;
      count++;
    }
    else{
      a[k]=R[j];
      j=j+1;
      count++;
    }
  }
  
  
  
}

void mergeSort(int *a,int left,int right){
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergeSort(a,left,mid);
    mergeSort(a,mid,right);
    merge(a,left,mid,right);
  }
  
}



Measured memory_bytes: 5612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String U = sc.next();

		if (S.equals(U)) {
			int A2 = A - 1;
			A = A2;
		} else if (T.equals(U)) {
			int B2 = B - 1;
			B = B2;
		}

		System.out.printf("%d %d", A, B);
		sc.close();
	}
}


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

const int N_MAX=100, M_MAX=100;

char p[N_MAX+1][M_MAX+1];

int main(){
	int k,x;
	cin >> k >> x;
	if(500 * k >= x){
		cout << "Yes" << endl;
	}else{ cout << "No" << endl;}
	return 0;
}



Measured memory_bytes: 256
void main() {
	auto N = ri;
	ulong res;
	foreach(i; iota(1, N+1, 2)) {
		ulong tmp;
		foreach(j; 1..i+1) {
			if(i % j == 0) tmp++;
		}
		if(tmp == 8) res++;
	}
	res.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
template <class T>
T GCD(T a, T b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) { return (a * b) / GCD(a, b); }

struct Union_find
{
    vector<int> par;
    vector<int> rank;

    Union_find(int n) : par(n), rank(n)
    {
        for (int i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 0;
        }
    }

    int root(int x)
    {
        return par[x] == x ? x : par[x] = root(par[x]);
    }

    bool same(int x, int y)
    {
        return root(x) == root(y);
    }

    void unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        //根にのみランクが保持されればいい
        if (rank[x] < rank[y])
            par[x] = y;
        else
        {
            par[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
        return;
    }
};

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll sumb = b-b / c - b / d + b / (LCM(c, d));
    ll suma = a-1-(a - 1) / c-+ (a - 1) / d + (a - 1) / (LCM(c, d));
    cout << sumb-suma << endl;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
jobs = N.times.map { gets.chomp.split(' ').map(&:to_i) }
jobs.sort_by { |_, limit| limit }.reduce(0) do |current_time, (time, limit)|
  next_time = current_time + time
  if limit < next_time
    puts 'No'
    exit
  end
  next_time
end
 
puts 'Yes'

Measured memory_bytes: 22392
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
using namespace std;

#define MAX_V 10000
#define INF 999999999

struct edge{
  int to, cap, cost, rev;
};

int V;
vector<edge> G[MAX_V];
int dist[MAX_V], prevv[MAX_V], preve[MAX_V];

void add_edge(int from, int to, int cap, int cost){
  G[from].push_back((edge){to, cap, cost, G[to].size()});
  G[to].push_back((edge){from, 0, -cost, G[from].size() - 1});
}

int min_cost_flow(int s, int g, int f){
  int res = 0;

  while(f > 0){
    fill(dist , dist + V , INF);
    dist[s] = 0;
    bool update = true;
    while(update){
      update = false;
      for(int v = 0; v < V; v++){
        if(dist[v] == INF) continue;
        for(int i = 0; i < G[v].size(); i++){
          edge &e = G[v][i];
          if(e.cap > 0 && dist[e.to] > dist[v] + e.cost){
            dist[e.to] = dist[v] + e.cost;
            prevv[e.to] = v;
            preve[e.to] = i;
            update = true;
          }
        }
      }
    }

    if(dist[g]== INF){
      return -1;
    }

    int d = f;
    for(int v = g; v != s; v = prevv[v]){
      d = min(d, G[prevv[v]][preve[v]].cap);
    }
    f -= d;
    res += d * dist[g];
    for(int v = g; v != s; v = prevv[v]){
      edge &e = G[prevv[v]][preve[v]];
      e.cap -=d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int n;
int A[1002], B[1002];
map<int,int> idxMap;

int getIdx(int x){
  if(idxMap.find(x) != idxMap.end()){
    return idxMap[x];
  }
  int size = idxMap.size();
  idxMap[x] = size + n + 1;
  return idxMap[x];
}

int main(){
  while(cin >> n){
    for(int i = 0; i < MAX_V; i++){
      G[i].clear();
    }
    idxMap.clear();

    for(int i = 0; i < n; i++){
      cin >> A[i] >> B[i];

      int idxA = getIdx(A[i]);
      int idxB = getIdx(B[i]);

      add_edge(0, i + 1, 1, 0);
      add_edge(i + 1, idxA, 1, -B[i]);
      add_edge(i + 1, idxB, 1, -A[i]);
    }

    V = n + idxMap.size() + 3;

    for(int i = 0; i < n; i++){
      add_edge(i + 1, V - 2, 1, 0);
    }
    for(int i = 0; i < idxMap.size(); i++){
      add_edge(i + n + 1, V - 1, 1, 0);
    }
    add_edge(V - 2, V - 1, INF, 0);

    cout << -min_cost_flow(0, V - 1, n) << endl;
  }
}

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

#define inf 0x3f3f3f3f
#define pb push_back
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vl;
typedef vector <ull> vu;
typedef vector <vector <int>> vvi;
typedef pair <int, int> pi;
typedef vector <pair <int, int>> vpi;
ll mod = 1e9 + 7;
ll add(ll a, ll b) {return (a + b) % mod;}
ll mul(ll a, ll b) {return (a * b) % mod;}
ll sub(ll a, ll b) {return (a - b + mod) % mod;}

int n, a, b, c;

vi v;

void read() {
  cin >> n >> a >> b >> c;
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    v.pb(x);
  }
}

int solve(int cnt, int x, int y, int z) {
  if (cnt == n) {
    if (x == 0 || y == 0 || z == 0)
      return 99999999;
    return abs(a - x) + abs(b - y) + abs(c - z) - 30;
  }
  ++cnt;
  return min({
      solve(cnt, x, y, z),
      solve(cnt, x + v[cnt - 1], y, z) + 10,
      solve(cnt, x, y + v[cnt - 1], z) + 10,
      solve(cnt, x, y, z + v[cnt - 1]) + 10
      });
}

int main() {
  ios :: sync_with_stdio(false);
  cin.tie(nullptr);
  int t = 1;
  //cin >> t;           // PLEASE REMOVE IT IF NEEDED
  while (t) {
    --t;
    read();
    cout << solve(0, 0, 0, 0);
  }
  return 0;
}
 
 


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

int main() {
  int a,b;
  scanf("%d",&a);
  scanf("%d",&b);
  int n = b-a;
  int c = 0;
  int i;
  for(i=0;i<n+1;i++) {
    c += i;
  }
  printf("%d\n",c-b);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N_MAX = 100001;
int main()
{
  int n,m,i,j,a,b,res=0;
  vector<int> v[N_MAX];
  priority_queue<int> q;
  cin >> n >> m;
  for(i=0;i<n;i++){
    cin >> a >> b;
    if(a<=m) v[a].push_back(b);
  }
  for(i=1;i<=m;i++){
    for(j=0;j<v[i].size();j++)
      q.push(v[i][j]);
    if(q.empty()) continue;
    res+=q.top(); q.pop();
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 5632
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		java.util.Scanner sin = new java.util.Scanner(System.in);
		int W = sin.nextInt();
		int H = sin.nextInt();
		int x = sin.nextInt();
		int y = sin.nextInt();
		int r = sin.nextInt();
		int x1, x2, y1, y2;
		x1 = x + r;
		x2 = x - r;
		y1 = y + r;
		y2 = y - r;
		if(x2 >= 0 && y2 >= 0 && x1 <= W && y1 <= H){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26372
import java.util.*;


public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int [] data = new int[n];
			for(int i = 0; i < n; i++){
				data[i] = sc.nextInt();
			}
			int count = 0;
			for(int i = 0; i < n-1; i++){
				if(data[i] == i + 1){
					int temp = data[i];
					data[i] = data[i+1];
					data[i+1] = temp;
					count++;
				}
			}
			if(data[n-1] == n){
				int temp = data[n-1];
				data[n-2] = data[n-1];
				data[n-1] = temp;
				count++;
			}
			System.out.println(count);
			
		}
	}



	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

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

}


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

using namespace std;

int main()
{
  string s; cin >> s;
  
  if(s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

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

#ifndef _WIN32
    #define getchar getchar_unlocked
#endif

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

typedef long long int LLI;
typedef unsigned long long int LLU;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<int> vi;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<"="<<h<<",";
  _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int32_t main()
{
	string s; cin >> s;
	string q = s;
	reverse(q.begin(), q.end());
	q == s ? printf("Yes") : printf("No");
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[22][3000001];
int vis[22][3000001];
int a[22][22];
int n;
int cal(int pos,int mask)
{
  
  if(mask+1==(1<<n))
    return 1;
  if(pos==n)
    return 0;
  if(vis[pos][mask]==0)
    vis[pos][mask]=1;
    else
    return dp[pos][mask];
  int ways=0;
  for(int i=0;i<n;i++)
  {
    if(a[pos][i]==1&&(mask&1<<i)==0)
    {
      ways+=(cal(pos+1,mask|1<<i)%1000000007);
      ways%=1000000007;
    }  
  }
  dp[pos][mask]=ways;
  return dp[pos][mask];
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
    {
      for(int j=0;j<n;j++)
      {
        cin>>a[i][j];
      }
    }
  	int res=cal(0,0);
  	cout<<res<<"\n";
}

Measured memory_bytes: 183624
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ll n;cin>>n;
    ll d=n%10;
    if(d==0 || d==1 || d==6 || d==8)cout<<"pon";
    else if(d==3)cout<<"bon";
    else cout<<"hon";
    return 0;  
} 





Measured memory_bytes: 3644
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){

    int n,x,m[1010];

    cin >> n >> x;
    rep(i,n) cin >> m[i];

    sort(m,m+n);
    int tmp = x;
    int cnt = 0;
    rep(i,n){
        tmp -= m[i]; 
        cnt++;
    }
    cnt = cnt + tmp/m[0];

    cout << cnt << endl;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	long i, n, maxv, minv, num;

	scanf("%ld", &n);
	scanf("%ld", &minv);
	scanf("%ld", &num);
	maxv = num - minv;
	if(minv >= num){
		minv = num;
	}
	else{
		//none
	}

	for( i=1; i<(n-1); i++	){
		scanf("%ld", &num);
		if( maxv <= (num - minv) ){
			maxv = (num - minv);
		}
		else{
			//none
		}

		if( minv >= num){
			minv = num;
		}
		else{
			//none
		}
	}

	printf("%ld\n", maxv);

	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a < b)
	{
	printf("a < b\n");
	}
	else if(a > b)
	{
	printf("a > b\n");
	}
 	else
	{
	printf("a == b\n");
	}
	return 0;
	}

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

int main()
{
	int N;
	cin >> N;
	vector<string> W( N );
	for( int i = 0; i < N; i++ )  {
		cin >> W[i];
	}

	string ans = "Yes";
	set<string> st;
	char c;
	for( int i = 0; i < N; i++ )  {
		if( i == 0 ) c = W[i][W[i].size() - 1];
		else if( st.count( W[i] ) || W[i][0] != c ) {
			ans = "No";
			break;
		}
		else c = W[i][W[i].size() - 1];
		st.insert( W[i] );
	}

	cout << ans << endl;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;

int main(){
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  std::cin >> N;

  int n = N / 2;
  double p = 1.0 * (N - n) / N;

  printf("%.10f\n", p);
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    const int MAX_N = 200000;
    int N, A[MAX_N];
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }
    ll res = 0;
    int s = 0, e = 0, acc = 0;
    while (e < N) {
        while ((acc & A[e]) == 0) {
            acc += A[e];
            e++;
            res += (e - s);
            if (e == N) {
                break;
            }
        }
        while ((acc & A[e]) != 0) {
            acc -= A[s];
            s++;
            if (s == e) {
                break;
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
int A,B,N,b;
cin>>A>>B>>N;
  if((N*2)<(B-A+1)){
for(int i=0;i<N;i++){
cout<<A<<endl;
A++;}
b=B-N+1;
for(int i=0;i<N;i++){
cout<<b<<endl;
b++;}}
else{for(int i=A;i<=B;i++){cout<<i<<endl;}}}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    
    if(s=="SUN") cout<<7<<endl;
    else if(s=="MON") cout<<6<<endl;
    else if(s=="TUE") cout<<5<<endl;
    else if(s=="WED") cout<<4<<endl;
    else if(s=="THU") cout<<3<<endl;
    else if(s=="FRI") cout<<2<<endl;
    else if(s=="SAT") cout<<1<<endl;
    
    return 0;
    
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)
using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

int K, T;
vector<pair<int, int>> a;
int main(void) {
  cin >> K >> T;
  REP(i, T) {
    int n; cin >> n;
    a.push_back(make_pair(n, i));
  }
  int prev_used = -1;
  int cnt = 0;
  for (int i = 0; i < K; i++) {
    sort(a.begin(), a.end(), greater<>());
    //REP(j, T) cout << a[j].first << ":" << a[j].second << " ";
    //cout << endl;
    for (int j = 0; j <= T; j++) {
      if (j == T || a[j].first == 0) {
        a[j - 1].first--; cnt++;
        prev_used = a[j - 1].second;
        break;
      }
      if (a[j].second != prev_used) {
        prev_used = a[j].second; a[j].first--;
        break;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
S0 = S[-1]
i = -1
j = 0
ans = 1

while i > -len(S) + 1:
    if S0 != S[i - (j + 1):i]:
        S0 = S[i - (j + 1):i]
        ans = ans + 1
        i = i - (1 + j)
        j = 0
    else:
        j = j + 1

if i == -len(S) + 1 and S[-len(S)] != S0:
    ans = ans + 1

print(ans)

Measured memory_bytes: 3500