akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i * i != n)
        res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}

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

  ll n;
  cin >> n;

  vector<ll> div = divisor(n);
  int divn = div.size();

  ll ans = 0;
  rep(i, 1, divn) {
    ll d = div[i] - 1;
    ll a = n / d;
    ll b = n % d;
    if (a==b)
      ans += div[i] - 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3588
n, k = list(map(int, input().split()))
s = input()
 
data = []
cnt = 0
curr = '1'
for i in range(len(s)):
    if s[i] != curr:
        data.append(cnt)
        curr = s[i]
        cnt = 1
    else:
        cnt += 1
data.append(cnt)
data.append(0)
data.append(0)
 
current_sum = sum(data[0:0 + 2*k+1])
ret = current_sum
for start in range(2, len(data)-k-2, 2):
    if start + 2*k >= len(data):
        break
    diff = -data[start-2]-data[start-1]+data[start + 2*k]+data[start + 2*k-1]
    current_sum += diff
 
#     print(start, val)
    if current_sum > ret:
        ret = current_sum
print(ret)

Measured memory_bytes: 45680
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		String S = scan.next();
		String T = scan.next();
		int count = 0; 
		
		for(int i=0;i<S.length();i++) {
			char s = S.charAt(i);
			char t = T.charAt(i);
			if(s == t) {
				count++;
			}
		}
		if(count == S.length()) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35540
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {

    int N;
    cin >> N;
    vector<int> h(N + 2, 0);
    int m = 0;
    REP(i, N) {
        cin >> h[i + 1];
    }
    int count = 0;
    REP(o, 101){
        REP(i, N){
            if (h[i] == 0 && h[i + 1] > 0) count++;
        }
        REP(i, N) if (h[i + 1] > 0) h[i + 1]--;
    }
    cout << count << 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++)
typedef long long ll;
 
int main() {
 
    ll tmp = 998244353;
    ll N=0;
    ll hoge = 0;
    cin >> N;
 

    ll dp=0;
    vector<ll> cnt(N, 0);
    for(ll i=0; i<N%tmp; i++){
        cin >> dp;

        if(dp == 0){
            hoge = i;
        }
        cnt.at(dp)++;
    }
 

    if(cnt.at(0) != 1 || hoge !=0){
        cout << 0 << endl;
        return 0;
    }

    ll ans=1;
    for(ll i=1; i<N-1; i++){
        for(ll j=0; j<cnt.at(i+1); j++){
            ans *= cnt.at(i);
            ans = ans % tmp;
        }
    }
 
    cout << ans % tmp << endl;
 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using vec_i = std::vector<int>;
using vec_ll = std::vector<ll>;
using vec_ld = std::vector<ld>;

#define in(i) int i; cin >> i
#define in_ll(i) ll i; cin >> i
#define in_ld(i) ll i; cin >> i
#define in_c(c) char c; cin >> c
#define in_str(s) std::string s; cin >> s

#define vec_in(v, n)    auto v=vec_i(n); for(auto &x:v){cin>>x;}
#define vec_in_ll(v, n) auto v=vec_ll(n);for(auto &x:v){cin>>x;}
#define vec_in_ld(v, n) auto v=vec_ld(n);for(auto &x:v){cin>>x;}

#define print(x)   cout << x
#define println(x) cout << x << "\n"

#define rep(i, n) for (auto i = 0; i < n; ++i)

using namespace std;
int main () {
    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    in_ll(N);
    vector<char> name;
    while (N > 0) {
        int off = (N - 1) % 26;
        name.push_back(off + 'a');
        N = floor((N - 1) / 26);
    }
    reverse(name.begin(), name.end());
    rep(i, name.size()) print(name[i]);
    print('\n');
    return 0;
}



Measured memory_bytes: 3588
def main():
    n = int(input())
    b = [int(x) for x in input().split()]

    ans = 0
    ans += b[0]+b[-1]
    if n == 2:
        print(ans)
        return
    for i in range(len(b)-1):
        ans += min(b[i],b[i+1])
    print(ans)
    return



if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  string c1, c2, c3;
  cin >> c1 >> c2 >> c3;
  cout << c1[0] << c2[1] << c3[2] << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;
int compare_Size(const void *a, const void *b)
{
	return *(long*)a - *(long*)b;
}
int main()
{
	int nCnt;
	cin >> nCnt;
	
	long arSize[100];
	memset(arSize, 0, sizeof(arSize));
	for (int i = 0; i < nCnt; i++)
	{
		cin >> arSize[i];
	}

	qsort(arSize, nCnt, sizeof(long), compare_Size);

	int nDan = 0;
	int nPreVal = -1;
	for (int i = 0; i < nCnt; i++)
	{
		if (arSize[i] > nPreVal)
		{
			nDan++;
			nPreVal = arSize[i];
		}
	}
	cout << nDan;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    string s; cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (auto &x: p) cin >> x;
    int mx = 0, cur = 0;
    for (int i = 0, j = 0; j < n; ++j) {
        cur += p[j];
        if (j-i+1 == k) {
            mx = max(mx, cur);
            cur -= p[i++];
        }
    }
    cout << fixed << setprecision(12) << (double) (mx+k) / 2.0 << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

vector<int> pn;
vector<bool> is_p;

void enum_prime()
{
  is_p.resize(1515, true);
  is_p[0] = is_p[1] = false;
  for(int i = 2; i <= 1515; i++) {
    if(!is_p[i]) continue;
    pn.push_back(i);
    for(int j = i+i; j <= 1515; j+=i) is_p[j] = false;
  }
}

int dp[1200][300][15];

int solve(int n, int p, int k)
{
  if(k == 0 && n == 0) return 1;
  if(k < 0 || n < 0 || p < 0) return 0;  
  
  int& ret = dp[n][p][k];
  if(~ret) return ret;

  ret = solve(n, p - 1, k);
  if(n >= pn[p]) ret += solve(n - pn[p], p - 1, k - 1);

  return ret;
}

int main()
{
  enum_prime();
  int n, k;
  while(cin >> n >> k, n || k) {
    memset(dp, -1, sizeof(dp));
    int p = upper_bound(pn.begin(), pn.end(), n) - pn.begin() - 1;
    cout << solve(n, p, k) << endl;
  }
  return 0;
}

Measured memory_bytes: 24252
#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <class T>
struct rbtree: tree<T,null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>{};
#define IN freopen("in.txt", "r", stdin);
#define endl '\n'
#define mp make_pair
#define pb push_back
#define lowb lower_bound
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mem0(a) memset((a), 0, sizeof(a))
#define mem(a, b) memset((a), (b), sizeof(a))
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;

string s, s1;
int main(){
    IOS;
    int n; cin>>n;
    cin>>s>>s1;
    int cnt = 0;
    int cnt2 = 0;
    for(int i = 0; i < 2*n; i++){
        if(i&1)cout<<s1[cnt++];
        else cout<<s[cnt2++];
    }

    return 0;
}

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

int keta(int x){
  int count=0;
  while(x>=10){
    x=x/10;
    count++;
  }
  count++;
  return count;
}

int main(){
  int n;
  cin>>n;
  
  int ans=0;
  for(int i=1;i<=n;i++){
    if(keta(i)%2==1){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import math
from sys import stdin,stdout
#% 998244353
from heapq import heapify,heappop,heappush
import collections

n,k=list(map(int,stdin.readline().split()))
a=list(map(int,stdin.readline().split()))


for i in range(min(k,42)):
    #nw=[0]*n
    pr=[0]*n
    for x,d in enumerate(a):
        if d==0:
            pr[x]+=1
            if x!=n-1:
                pr[x+1]-=1
            continue
        l=math.floor(x-d)
        r=math.floor(x+d)
        l=max(0,l)
        r=min(n-1,r)
        pr[l]+=1
        if r!=n-1:
            pr[r+1]-=1
    
    for m in range(1,n):
        pr[m]+=pr[m-1]
    
    a[:]=pr


        

for i in a:
    print(i,end=" ")

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

string s;

bool check(){
	if(s.length()%2) return false;
	for(int i=0;i<s.length()/2;i++){
		if(s[i]!=s[s.length()/2+i]) return false;
	}
	return true;
}

int main(){
	cin >> s;
	for(int i=0;1;i++){
		s.erase(s.begin()+s.length()-1);
		if(check()){
			cout << s.length() << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define N_MAX 200001
long int A_Kind[N_MAX];
long int A[N_MAX];

int main()
{
	#ifdef _WIN32
		freopen("input.txt", "r", stdin);
	#endif

	int N;
	scanf("%d", &N);

	for (int n = 0; n < N; n++)
	{
		int t;
		scanf("%d", &t);
		A[n] = t;
		A_Kind[t]++;
	}


	long int NonSelectionResult = 0;
	for (int k = 0; k < N_MAX; k++)
		if(A_Kind[k])
			NonSelectionResult += (A_Kind[k] * (A_Kind[k] - 1)) / 2;
	

	for (int n = 0; n < N; n++)
	{
		long int Result = NonSelectionResult;
					
		Result -= (A_Kind[A[n]] * (A_Kind[A[n]] - 1)) / 2;
		Result += (A_Kind[A[n]] - 1)*(A_Kind[A[n]] - 2) / 2;
			
		printf("%lld\n", Result);
	}
}

Measured memory_bytes: 4608
import java.util.Scanner;

	class Main{
		public static void main(String[]args){
            
            
        Scanner sc=new Scanner(System.in);
            int W,H,x,y,r;
            W=sc.nextInt();
            H=sc.nextInt();
            x=sc.nextInt();
            y=sc.nextInt();
            r=sc.nextInt();
            
			if(x-r<0||W<x+r)System.out.println("No");
            else if(y-r<0||H<y+r)System.out.println("No");
            else System.out.println("Yes");
            sc.close();
        }
    }


Measured memory_bytes: 26336
#include <stdio.h>

int main(){

  	float n, m;
    float a[128];
    int i;
    float sum = 0;
    int flag = 0;
  
    scanf("%f %f", &n, &m);
    for(i=0; i<n; i++){
      scanf("%f ", &a[i]);   
    }

    for(i=0; i<n; i++){
      sum += a[i];   
    }
  
    for(i=0; i<n; i++){
      if((sum/(4*m)) <= a[i]){
        flag++;
      }   
    }
  
    if(flag >= m){
      printf("Yes");
    }else{
      printf("No");
    }

	return 0;
}

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

const int max_n = 17000;

string s;
int x, y;
int cnt;
int cmd[max_n];
bool dpx[max_n][max_n];
bool dpy[max_n][max_n];

int main(void){
    // Here your code !
    cin >> s;
    scanf("%d %d", &x, &y);

    int n = (1 + max_n) / 2;
    x += n;
    y += n;

    int now = 0;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == 'T') now++;
      else cmd[now]++;
    }

    for (int i = 0; i < max_n; ++i) {
      if (i == n) dpx[0][i] = true;
      else dpx[0][i] = false;
    }

    for (int i = 0; i < max_n; ++i) {
      if (i == n) dpy[1][i] = true;
      else dpy[1][i] = false;
    }

    for (int i = 2; i <= now + 2; ++i) {
      if (i == 2) {
        dpx[i][n + cmd[i - 2]] = true;
        continue;
      }
      for (int j = 0; j < max_n; ++j) {
        if ((i % 2) == 0) {
          dpx[i][j] = dpx[i - 2][j - cmd[i - 2]] || dpx[i - 2][j + cmd[i - 2]];
        }
        else {
          dpy[i][j] = dpy[i - 2][j - cmd[i - 2]] || dpy[i - 2][j + cmd[i - 2]];
        }
      }
    }

    /*
    for (int i = 2; i <= now; ++i) {
      for (int j = 0; j < max_n; ++j) {
        if ((i % 2) != 0) {
          dpy[i][j] = dpy[i - 2][j - cmd[i]] || dpy[i - 2][j + cmd[i]];
        }
      }
    }
    */

    int lx, ly;
    if (now % 2 == 0) {
      lx = now;
      ly = now - 1;
    }
    else {
      lx = now - 1;
      ly = now;
    }


    /*
    printf("%d:\n", now);

    for (int i = 0; i <= now + 2; ++i) {
      for (int j = 0; j < max_n; ++j) {
        if ((i % 2) == 0) {
          printf("%d ", dpx[i][j]);
        }
      }
      printf("\n");
    }
    */


    // printf("!!%d, %d\n", lx, ly);
    if (dpx[lx + 2][x] && dpy[ly + 2][y]) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 267776
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin>>N;
    map<string,int> cnt;
    string str;
    for (size_t i = 0; i < N; i++)
    {
        cin>>str;
        cnt[str]++;
    }
    cout<<"AC x "<<cnt["AC"]<<endl;
    cout<<"WA x "<<cnt["WA"]<<endl;
    cout<<"TLE x "<<cnt["TLE"]<<endl;
    cout<<"RE x "<<cnt["RE"]<<endl;
    return 0;
}

Measured memory_bytes: 3632
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val aList = readLine()!!.split(' ').map(String::toLong)
    var mode = 0
    var count = 1

    for (i in 0 until n - 1) {
        if (mode == 0) {
            if (aList[i] < aList[i + 1]) {
                mode = 1
            } else if (aList[i] > aList[i + 1]) {
                mode = -1
            }
        } else if (mode == 1) {
            if (aList[i] > aList[i + 1]) {
                mode = 0
                count++
            }
        } else {
            if (aList[i] < aList[i + 1]) {
                mode = 0
                count++
            }
        }
    }
    println(count)
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

typedef long long ll;
typedef unsigned long long ull;

ll K, A, B;

int main(void) {
    cin >> K >> A >> B;

    if (A > B) {
        cout << 1 + K << endl;
        return 0;
    }

    ll ans = 0;
    ll r = A - 1; // 叩く回数

    ll k = (K - r) / 2; // 増殖できる回数
    ans = B + (k - 1) * (B - A);
    ans += ((K - r) % 2); // 余った回数

    ans = max(1 + K, ans);

    cout << ans << endl;



    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
int main() {
	int n;
	int t1=0,x1=0,y1=0,t2,x2,y2;
	cin>>n;
	bool flg=true;
	for(int i=0;i<n;++i){
		cin>>t2>>x2>>y2;
		int k=(t2-t1)-abs(x2-x1)-abs(y2-y1);
		if(k<0||k%2>0)flg=false;
		t1=t2;
		x1=x2;
		y1=y2;
	}
	if(flg){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <queue>
#include <algorithm>
#include <cstdio>
using namespace std;
main(){int i=0,n,a,b,s=0;
vector<pair<int,int> >v;
for(scanf("%d",&n);i<n;i++)scanf("%d%d",&a,&b),v.push_back(make_pair(b,a));
sort(v.begin(),v.end());
priority_queue<int>q;
for(i=0;i<n;i++)if(s+=v[i].second,q.push(v[i].second),s>v[i].first)s-=q.top(),q.pop();
printf("%d\n",q.size());}

Measured memory_bytes: 1052
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

ll mod = 1e9 + 7, dp[110][10];
int h, w, k;
vector<int>v;

int main(){
    cin >> h >> w >> k;
    dp[0][0] = 1, k--;
    for (int i = 0; i < (1 << (w - 1)); i++){
        bool r = 1;
        for (int j = 0; j < w - 2; j++){
            if (i & (1 << j) && i & (1 << (j + 1)))r = 0;
        }
        if(r)v.push_back(i);
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < v.size(); j++){
            int p[w];
            for (int k = 0; k < w; k++)p[k] = k;
            for (int k = 0; k < w - 1; k++)if (v[j] & (1 << k))swap(p[k], p[k + 1]);
            for (int k = 0; k < w; k++)(dp[i + 1][p[k]] += dp[i][k]) %= mod;
        }
    }
    cout << dp[h][k] << endl;
}

Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

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

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

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m, q := nextInt(), nextInt(), nextInt()
	a, b, c, d := make([]int, q), make([]int, q), make([]int, q), make([]int, q)
	for i := 0; i < q; i++ {
		a[i], b[i], c[i], d[i] = nextInt()-1, nextInt()-1, nextInt(), nextInt()
	}

	point := func(A []int) int {
		p := 0
		for i := 0; i < q; i++ {
			if A[b[i]]-A[a[i]] == c[i] {
				p += d[i]
			}
		}
		return p
	}

	var dfs func(A []int, index int) int
	dfs = func(A []int, index int) int {
		if index == n {
			return point(A)
		}
		minI := 1
		if index > 0 {
			minI = A[index-1]
		}
		p := 0
		for i := minI; i <= m; i++ {
			A[index] = i
			p = max(p, dfs(A, index+1))
		}
		return p
	}

	puts(dfs(make([]int, n), 0))
}


Measured memory_bytes: 1808
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int N, M, R;
int r[10];
ll ans;
bool used[10];
ll d[220][220];

void dfs(int c, int last, ll dist) { //dfsの添え字に必要な情報全て載せる！！
    if(c == R) {
        if(ans > dist) ans = dist;
        return;
    }
    rep(i, R) {
        if(!used[i]) {
            used[i] = true;
            if(last == -1) dfs(c + 1, i, 0);
            else dfs(c + 1, i, dist + d[r[last]][r[i]]);
            used[i] = false;
        }
    }
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    cin >> N >> M >> R;
    rep(i, R) {
        cin >> r[i];
        r[i] --;
    }
    rep(i, N) {
        rep(j, N) {
            d[i][j] = INF;
        }
    }
    rep(i, M) {
        int A, B; ll C;
        cin >> A >> B >> C;
        A --; B --;
        d[A][B] = C;
        d[B][A] = C;
    }
    rep(i, N) {
        d[i][i] = 0;
    }
    rep(k, N) {
        rep(i, N) {
            rep(j, N) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
    ans = INF;
    rep(i, 10) used[i] = false;
    //基本は全探索！！
    dfs(0, -1, 0);
    cout << ans << endl;
	return 0;
}

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

bool isPalindrome(string s){
   for(Long i=0; i<(s.size()+1)/2 ; ++i){
      if(s[i]!=s[s.size()-i-1]) return false;
   }
   return true;
}

int main(){

   string s;
   cin >> s;

   if(  isPalindrome(s)   &&   isPalindrome(  s.substr(0,s.size()/2) )   &&   isPalindrome(  s.substr( (s.size()+1)/2 , s.size()/2))   ){
      cout << "Yes";
   }
   else cout << "No";

   return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;


void solve(std::vector<long long> A){
    i64 s = 0;
    s = A[0] + A[1] + A[2];
    if(s >= 22) cout << "bust" << endl;
    else cout << "win" << endl; 
}

int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static final long INF = Long.MAX_VALUE >> 2;
    public static long[] dp = new long[110000]; //制約に応じてテーブル規模を調節する
    public static void main(String[] args) throws Exception {
    for(int i=0;i<100010;++i)dp[i] = INF;
       Scanner sc = new Scanner(System.in);
       int N = sc.nextInt();
       int K = sc.nextInt();
       long[] steps = new long[110000];//制約に応じてテーブル規模を調節する
       for(int i=0;i<N;i++){
           steps[i] = sc.nextLong();
       }
       //最初に考えたやり方
    //   for(int i=0;i<N;i++){
    //       if(i == 0){
    //           dp[i] = 0;
    //       }else if(i == 1){
    //           dp[i] = height(steps[0],steps[1]);
    //       }else{
    //           if(K == 1){
    //               dp[i] = dp[i - 1] + height(steps[i],steps[i-1]);
    //           }else{
    //             for(int j=1;j<=i && j<=K;j++){
    //             dp[i] = chmin(dp[i] ,dp[i-j] + height(steps[i],steps[i-j]));
    //             }
    //           }
    //       }
    //   }
    
     //こっちの方が記述しやすい(貰うDP)
    //  for(int i=0;i<N;i++){
    //      if(i == 0){
    //          dp[i] = 0;
    //      }else{
    //         for(int j=1;j<=i && j<=K;j++){
    //             dp[i] = chmin(dp[i],(dp[i-j] + height(steps[i],steps[i-j])));
    //         }
    //      }
    //  }
    
    //別解1(配るDP)
    dp[0] = 0;
    for(int i=0;i<N;i++){
            for(int j=1;j<=K;j++){
                dp[i + j] = chmin(dp[i+j],dp[i] + height(steps[i] , steps[i + j]));
            }
    }
       System.out.println(dp[N - 1]);
    }
    
    public static long height(long h1,long h2){
        return Math.abs(h1 - h2);
    }
    
    public static long chmin(long a , long b){
        return Math.min(a,b);
    }
}


Measured memory_bytes: 59200
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<climits>
#include<stack>
#include<queue>
#include<cmath>
#define int long long
#define INF 100000000000
#define EPS 0.0000000001

using namespace std;

signed main() {
	int n, m;
	int a[1010], b[1010];
	int ans[1010] = { 0 };
	int vote = -1;
	cin >> n >> m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			if (a[j] <= b[i]) {
				ans[j]++;
				//cout << j + 1 << endl;
				break;
			}
		}
	}
	int temp = 0;
	for (int i = 0; i < n; i++) {
		//for (int j = 0; j < n; j++) {
			//cout << ans[i] << " " << endl;
			if (temp < ans[i]) {
				//cout << "[" << i << "]" << endl;
				temp = ans[i];
				vote = i;
			}
		//}
	}
	cout << vote + 1 << endl;
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;

  vector<int> X(M);
  vector<int> Y(M-1);
  for(int i=0;i<M;i++){
    cin >> X[i];
  }
  sort(X.begin(), X.end());

  for(int i=0;i<M-1;i++){
    Y[i] = X[i+1] - X[i];
  }
  sort(Y.begin(), Y.end(), greater<int>());
  int sum = 0;
  if (N<M){
    for(int i=0;i<N-1;i++){
      sum += Y[i];
    }
  }else{
    for(int i=0;i<M-1;i++){
      sum += Y[i];
    }
  }

  cout << X[M-1] - X[0] - sum << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int INF=INT_MAX,MOD=1e9+7;

int n;

int binary_search(int s[],int t){
	int low=0,high=n-1;
	while(low<=high){
		if(s[(low+high)/2]<t){
			int tmp=low;
			low=(low+high)/2+1;
			if(tmp==low) break;
		}else if(s[(low+high)/2]>t){
			int tmp=high;
			high=(low+high)/2-1;
			if(tmp==high) break;
		}else{
			return 1;
		}
	}
	return 0;
}

int main(){
	cin>>n;
	int s[n]; rep(i,n) cin>>s[i];
	int q; cin>>q;
	int t[q]; rep(i,q) cin>>t[i];

	int ans=0;
	rep(i,q){
		// cout<<binary_search(s,t[i])<<endl;
		ans+=binary_search(s,t[i]);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3680
import sys
import math
from collections import defaultdict

input = sys.stdin.buffer.readline
MOD = 1000000007
N = int(input())
dd = defaultdict(int)
count = 1
iwashi = [list(map(int, input().split())) for _ in range(N)]


checked = defaultdict(bool)
zeros = 0

for i in range(N):
    if iwashi[i][0] == iwashi[i][1] == 0:
        zeros += 1
        continue
    iw = iwashi[i]
    gcd_iw = math.gcd(iw[0], iw[1])
    if gcd_iw != 0:
        iw = list(map(lambda x: x // gcd_iw, iw))
    if iw[0] < 0:
        iw = list(map(lambda x: -x, iw))
    if iw[0] == 0 and iw[1] < 0:
        iw = list(map(lambda x: -x, iw))
    dd[tuple(iw)] += 1

for key, val in dd.items():
    if checked[key]:
        continue
    vert_key = (key[1], -key[0]) if key[1] > 0 else (-key[1], key[0])
    vert_val = dd[vert_key] if vert_key in dd else 0
    count *= (pow(2, val, MOD) - 1) + (pow(2, vert_val, MOD) - 1) + 1
    count %= MOD
    checked[vert_key] = True

# 0匹入れる場合を除外
count -= 1

count += zeros
print(count % MOD)


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

int main() {

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    while (true) {
        c -= b;
        a -= d;
        if (c <= 0) {
            cout << "Yes" << endl;
            return 0;
        }
        if (a <= 0) {
            cout << "No" << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 3636
def main():
    s = input()
    n = len(s)
    inf = pow(10, 9)+7
    
    dp = [[0]*13 for i in range(n)]
    if s[0] == "?":
        for i in range(10):
            dp[0][i] = 1
    else:
        dp[0][int(s[0])] = 1
    
    for i in range(1, n):
        if s[i] != "?":
            k = int(s[i])
            for j in range(13):
                dp[i][(10*j+k)%13] += dp[i-1][j]
        else:
            for k in range(10):
                for j in range(13):
                    dp[i][(10*j+k)%13] += dp[i-1][j]
        for j in range(13):
            dp[i][j] %= inf
        
    print(dp[n-1][5])
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 61788
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll MAX_V = 310;

vector<vector<ll>> A(MAX_V, vector<ll>(MAX_V)), dist(MAX_V, vector<ll>(MAX_V));

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

    rep(u, n) {
        rep(v, n) {
            cin >> A[u][v];
            dist[u][v] = A[u][v];
        }
    }

    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    ll ans = 0;
    rep(u, n-1) {
        for(int v = u+1; v < n; v++) {
            
            if(dist[u][v] < A[u][v]) {
                cout << -1 << endl;
                return 0;
            }

            int flag = 0;
            rep(w, n) {
                if(w != u && w != v && dist[u][v] == dist[u][w] + dist[w][v]) {
                    flag = 1;
                }
            }

            if(!flag) {
                ans += dist[u][v];
            }

        }
    }

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

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

typedef long int lint;
typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<int, string> pis;
typedef pair<long, long> pll;

#define EACH(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i, s, e) for (int i = (s); i < (int)(e); ++i)
#define REP(i, n) FOR(i, 0, n)
#define endl '\n'
#define mod 1000000007
#define INF 100000000
#define fk first
#define sv second

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

template<typename T>
void print(const std::vector<T>& v, char sep=' ') {
  for (int i = 0; i < (int)v.size(); i++) {
    if (i != 0) cout << sep;
    cout << v[i];
  }
  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str;
  cin >> str;
  str[5] = str[13] = ' ';
  
  cout << str << '\n';

}



Measured memory_bytes: 256
import collections
n = int(input())
a = list(map(int,input().split()))
c = collections.Counter(a)
p = sorted(c.items())
ans = 1
if n % 2 == 0:
    for i in range(n//2):
        if p[i][0] != 2*i+1 or p[i][1] != 2:
            print(0)
            exit()
elif n % 2 == 1:
    for i in range(n//2 + 1):
        if i == 0:
            if p[i][0] != 0 or p[i][1] != 1:
                print(0)
                exit()
        elif p[i][0] != 2*i or p[i][1] != 2:
            print(0)
            exit()

print((2**(n//2))%(10**9+7))

Measured memory_bytes: 16096
using System;
using System.Linq;

namespace AtCoder {
	class Program {
		public static void Main() {
			int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = input[0]; int m = input[1];
			int[][] s = new int[m][];
			for (int i = 0; i < m; i++) {
				s[i] = Console.ReadLine().Split(' ').Select(int.Parse).Skip(1).ToArray();
			}
			int[] p = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			Console.WriteLine(Count(n, m, s, p, new bool[0]));

		}
		static int Count(int n, int m, int[][] s, int[] p, bool[] sw) {
			int result;
			if (sw.Length == n) {
				result = 0;
				int count = s.Where((x, i) => x.Where((_, j) => sw[s[i][j] - 1]).Count() % 2 == p[i]).Count();
				return count == m ? 1 : 0;
			}
			bool[] nsw = new bool[sw.Length + 1]; Array.Copy(sw, nsw, sw.Length);
			nsw[nsw.Length - 1] = true;
			result = Count(n, m, s, p, nsw);
			nsw[nsw.Length - 1] = false;
			result += Count(n, m, s, p, nsw);
			return result;
		}
	}
}


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

int main() {
  int N;
  cin>>N;
  if(N%2==0){
    cout<<(double)N/(2*N)<<endl;
  }
  else{
    cout<<(double)(N+1)/(2*N)<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;


int main() {
	string s;
	cin >> s;
	bool a, b;
	if ((s[0] == '0' && s[1] != '0') || (s[0] == '1' && (s[1] == '0' || s[1] == '1' || s[1] == '2'))) {
		a = true;
	}
	else {
		a = false;
	}

	if ((s[2] == '0' && s[3] != '0') || (s[2] == '1' && (s[3] == '0' || s[3] == '1' || s[3] == '2'))) {
		b = true;
	}
	else {
		b = false;
	}
	if (a && b) {
		cout << "AMBIGUOUS" << endl;
	}
	else if (a && (!b)) {
		cout << "MMYY" << endl;
	}
	else if ((!a) && b) {
		cout << "YYMM" << endl;
	}
	else {
		cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;


void solve()
{
    int a, b, h, m;
    scanf("%d%d%d%d", &a, &b, &h, &m);
    double tmp = h * 60 + m;
    double t0 = tmp / 720;
    double t1 = tmp / 60;

    double x = (t0 - t1) * 2 * 3.1415926535897932;
    double xx=(double)a*a + (double)b*b - (double)2 * a*b*cos(x);
    printf("%.10lf\n", sqrt(xx));
    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 2596
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void){
  cout << std::fixed << std::setprecision(16);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int n;
  cin>>n;
  
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      if(n==i*j){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;



  return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> h;

    int x;
    for(int i = 0; i < n; i++){
        cin >> x;
        h.push_back(x);
    }

    
    int count = 0;

    while(1){
       if(*max_element(h.begin(), h.end()) == 0){
           break;
       }

       int i = 0;
       while(i < n){
           if(h[i] == 0){
               i++;
           }
           else{
               count++;
               while(i < n and h[i] != 0){
                   h[i]--;
                   i++;
               }
           }
       } 
    }

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

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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


int main() {
	llong N;
    cin >> N;
    string S;
    cin >> S;
    llong R=0;
    REP(i,N){
        if(S[i]=='R')R++;
    }
    if(R>(N-R)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }





}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	std::string s;
	std::cin >> s;
	puts(s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
/* include c++ libraries */
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <queue>
#include <set>

/* include c-lang libraries */
#include <climits>
#include <cmath>

/* include my libraries */
//#include <show_vec.hh>

using namespace std;

#define LINE DEBUG{ printf("LINE : %d\n", __LINE__); }
#define DEBUG if(false)

using ll = long long;
template<class T> using vec = vector<T>;

const int MOD = 1000000007;

int main(){

  int N;
  cin >> N;

  ll x = 1, y = 1, z = 1;
  for(int i = 0; i < N; i++){
    x = (x * 10) % MOD;
    y = (y * 8) % MOD;
    z = (z * 9) % MOD;
  }
  z = (z * 2) % MOD;

  ll A = x + y - z;
  while(A < 0){
    A += MOD;
  }
  cout << A << endl;;

  return 0;
}


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

long long hasil[100005][5];

int main () {
	int n;
	scanf("%d", &n);
	
	long long data[n + 1][5];
	for(int i = 1; i <= n; i++) {
		scanf("%lld %lld %lld", &data[i][1], &data[i][2], &data[i][3]);
	}
	
	for (int i=1;i<=3;i++) hasil[1][i]=data[1][i];
	
	for(int i = 2; i <= n; i++) {
		for(int j = 1; j < 4; j++) {
			for(int k = 1; k < 4; k++) {
				if(k != j) {
					if((hasil[i][j] < hasil[i-1][k] + data[i][j])) hasil[i][j] = hasil[i-1][k] + data[i][j];
				}
			}
		}
	}
	
	int tmp = 1;
	for(int i = 1; i < 4; i++) {
		if(hasil[n][i] > hasil[n][tmp]) tmp = i;
//		swap(hasil[n][1], hasil[n][tmp]);
	}
	
	printf("%lld\n", hasil[n][tmp]);
}

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


// do insertion sort for console input data
int main() {
	int size;
	cin >> size;

	int* nums = new int[size];
	int num;

	for (int i = 0; i < size; i++) {
		cin >> nums[i];
	}

	// first row output
	for (int i = 0; i < size - 1; i++) {
		cout << nums[i] << ' ';
	}
	cout << nums[size - 1] << endl;

	// do insertion sort
	for (int i = 1; i < size; i++) {
		int j = i - 1;
		num = nums[i];
		while (j >= 0 && num < nums[j]) {
			nums[j + 1] = nums[j];
			j--;
		}
		nums[j + 1] = num;

		// output of every steps
		for (int k = 0; k < size-1; k++) {
			cin >> nums[k];
			cout << nums[k] << ' ';
		}
		cout << nums[size-1];

		if (i != size) cout << endl;
	}
}

Measured memory_bytes: 3088
#include <iostream>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <vector>
#include <map>
#include <fstream>
using namespace std;

typedef long long int ll;
const ll N = 100000;
const ll M = 1000000007;
ll A[N + 1];

int main()
{
	int n;

	cin >> n;

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

	if (A[0] >= 2) {
		cout << 0 << endl;
		return 0;
	}

	for (int i = 1; i < n; i++) {
		if (A[i] != 2 && A[i] != 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	ll ans = 1;

	for (int i = 0; i < n / 2; i++) {
		ans = ans * 2 % M;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> H(N);
  REP(i, N)
  cin >> H[i];
  int ans = 0;
  REP(i, N)
  {
    bool ok = true;
    for (int j = 0; j < i; j++)
    {
      if (H[j] > H[i])
        ok = false;
    }
    if (ok)
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
    cin.tie(0);
	int n,m;
	string s;
	cin>>n>>m>>s;
	s[m-1]+=32;
	cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 3604
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline

sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    X = 0
    AB = []
    for _ in range(N):
        A, B = map(int, readline().split())
        X -= B
        AB.append(A + B)
    AB.sort(reverse=True)
    for ab in AB[::2]:
        X += ab
    print(X)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13352
import java.io.*;
import java.util.*;

public class Main {
	static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
 
        public FastReader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
	public static void main(String[] args) {
		FastReader in = new FastReader();
		int w = in.nextInt(), a = in.nextInt(), b = in.nextInt();
		if(b > a+w) System.out.println(b-a-w);
		else if(b+w < a) System.out.println(a-b-w);
		else System.out.println(0);;
	}
	

}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
#define max 200000
#define ll long long int
using namespace std;  
int main()
{
    int n,k,i,j,t,x;
    cin>>n>>k;
    vector<bool> v(n+1,false);
    for(j=0;j<k;++j)
   { 
       cin>>t;
       for(i=0;i<t;++i)
       {
           cin>>x;
           v[x]=true;
       }
    
    }t=0;
    for(i=1;i<=n;++i)
    {
        if(v[i]==false)
        t++;
    }
    cout<<t;
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main()
{
    int t,a=25,b=24,c=23,d=22;
    scanf("%d",&t);
    if(t==a)
    {
        printf("Christmas\n");
    }
    else if(t==b)
    {
        printf("Christmas Eve\n");
    }
    else if(t==c)
    {
        printf("Christmas Eve Eve\n");
    }
    else if(t==d)
    {
        printf("Christmas Eve Eve Eve\n");
    }
    return 0;
}


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

int main() {
  int n;
  cin>>n;
  int a,b,c;
  ll dp[2][3];
  cin>>a>>b>>c;
  dp[0][0]=a;dp[0][1]=b;dp[0][2]=c;
  for(int i=1;i<n;i++) {
  	cin>>a>>b>>c;
    int p = i&1 ? 1:0;
    int q = i&1 ? 0:1;
      dp[p][0] = max(a+dp[q][2], a+dp[q][1]);
      dp[p][1] = max(b+dp[q][2], b+dp[q][0]);
      dp[p][2] = max(c+dp[q][1], c+dp[q][0]);
  }
  ll res;
  if ((n-1)&1) {
 	res = max(dp[1][0], max(dp[1][2],dp[1][1]));
  }
  else res = max(dp[0][0], max(dp[0][2],dp[0][1]));
  cout<<res<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define dl double
#define mp make_pair
#define pb push_back
#define S second
#define F first
using namespace std;

ll n,k;

bool check(vector<ll> &v,ll x)
{
    ll cnt=0;
    for(int i=0;i<n;i++)
    {
        cnt+=v[i]/x;
        if(v[i]%x==0)
        cnt--;
    }
    return cnt<=k;
}

void solve()
{
    cin >> n >> k;
    vector<ll> v(n);
    for(int i=0;i<n;i++)
    cin >> v[i];    

    ll l=1;
    ll r=INT_MAX;
    while(l<r)
    {
        ll m=(l+r)/2;
        if(check(v,m))
        r=m;
        else
        l=m+1;
    }
    cout << l << endl;
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    //cin >> t;
    t=1;
    while (t--)
    {
        solve();
    }

    return 0;
}

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

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

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

N = input()
B = map(int, raw_input().split())

ans = B[0] + B[-1]
for i in range(N - 2):
    ans += min(B[i], B[i + 1])
print ans

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

const long long INF = 1e10;

int main(){
  long long N, W;
  cin >> N >> W;
  vector<vector<long long>> dp(N+1,vector<long long>(100001, INF));
  vector<pair<long long, long long>> wv(N);
  for (int i=0; i<N; i++) cin >> wv[i].first >> wv[i].second;
  dp[0][0] = 0;
  for (int i=1; i<=N; i++){
    for (int v=0; v<100001; v++){
      if (v < wv[i-1].second) dp[i][v] = dp[i-1][v];
      else dp[i][v] = min(dp[i-1][v], dp[i-1][v-wv[i-1].second] + wv[i-1].first);
    }
  }
  for (int v=100000; v>=0; v--){
    if (dp[N][v] <= W) {
      cout << v << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 80256
import copy
n = int(input())
L = []
for i in range(n):
    L.append(list(map(int,input().split())))
s = []
for i in range(n):
    for j in range(i):
        s.append([L[i][0]-L[j][0],L[i][1]-L[j][1]])
        s.append([L[j][0]-L[i][0],L[j][1]-L[i][1]])
u = []
for i in range(len(s)):
  if s[i] not in u:
    u.append(s[i])
ans = 0
for i in range(len(u)):
    cur = s.count(u[i])
    if ans < cur:
        ans = cur
print(n-ans)

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


using ll = long long int;

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b, n, m;
    
    cin >> a >> b;
    
    n = min(a, b);
    m = max(a, b);
    
    string ans(m, n + '0');
    
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

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

    vector<double> x(n);
    vector<double> y(n);

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

    double sum = 0.0;
    double manhattan_dist = 0.0;
    for(int i=0; i<n; ++i) {
        sum += abs(x[i] - y[i]);
    }
    manhattan_dist = sum;

    sum = 0.0;
    double euclid_dist = 0.0;
    for(int i=0; i<n; ++i) {
        double diff = abs(x[i] - y[i]);
        sum += pow(diff, 2.0);
    }
    euclid_dist = sqrt(sum);

    sum = 0.0;
    double dist_p_3 = 0.0;
    for(int i=0; i<n; ++i) {
        double diff = abs(x[i] - y[i]);
        sum += pow(diff, 3.0);
    }
    dist_p_3 = cbrt(sum);

    double max_diff = -1;
    double chebyshev_dist = 0.0;
    for(int i=0; i<n; ++i) {
        double diff = abs(x[i] - y[i]);
        if (diff > max_diff) max_diff = diff;
    }
    chebyshev_dist = max_diff;

    printf("%.12f\n", manhattan_dist);
    printf("%.12f\n", euclid_dist);
    printf("%.12f\n", dist_p_3);
    printf("%.12f\n", chebyshev_dist);

    return 0;
}


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

int main(){
  int n,x;
  cin>>n>>x;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  int c=0,i;
  for(i=0;i<n;i++){
    if(x>=a[i]){
      c++;
      x-=a[i];
    }
    else
      break;
  }
  if(x!=0 && i==n)
    c--;
  cout<<c;
  return 0;
}

Measured memory_bytes: 256