akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int n, A[50];
// 入力値の M から選んだ要素を引いていく再帰関数
int solve (int i, int m) {
if ( m == 0 ) return 1;
if ( i >= n ) return 0;
int res = solve(i + 1, m) || solve(i + 1, m - A[i]); return res;
}
int main() { int q, M, i;
scanf("%d", &n);
for ( i = 0; i < n; i++ ) scanf("%d", &A[i]); scanf("%d", &q);
for ( i = 0; i < q; i++ ) {
scanf("%d", &M);
if ( solve(0, M) ) printf("yes\n"); else printf("no\n");
}
return 0; }


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define SORTG(v) sort(v.begin(),v.end(),greater<>())
#define SORT(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/3

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<string> Vs;

template<class T> void chmax(T& a, T b) {if(a<b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a>b){a=b;}}
void YesNo(int a) {if(a){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}}
void YESNO(int a) {if(a){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

signed main(){start();
    int x,y,ans;
    cin>>x>>y;
    int absx=abs(x),absy=abs(y);
    if(x==0 || y==0){
        if(x>y) ans=abs(absx-absy)+1;
        else ans=abs(absx-absy);
    }
    if(x>0 && y>0){
        if(abs(x)>abs(y)) ans=abs(absx-absy)+2;
        else ans=abs(absx-absy);
    }else if(x>0 && y<0){
        if(abs(x)>abs(y)) ans=abs(absx-absy)+1;
        else ans=abs(absx-absy)+1;
    }else if(x<0 && y>0){
        if(abs(x)>abs(y)) ans=abs(absx-absy)+1;
        else ans=abs(absx-absy)+1;
    }else if(x<0 && y<0){
        if(abs(x)>abs(y)) ans=abs(absx-absy);
        else ans=abs(absx-absy)+2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
 
#define NIL NULL
 
struct node{
  struct node *l;
  struct node *r;
  struct node *p;
  int key;
};
 
typedef struct node * Node;
 
Node root;

void Preorder(Node );
void Inorder(Node );
void insert(int );
Node Search(Node ,int );
Node Minimum(Node );
Node Successor(Node );
void Delete(Node );


main(){
  int n, i, x;
  char str[20];
   
  scanf("%d",&n);
 
  for ( i = 0; i < n; i++ ){
    scanf("%s",str);
 
    if(str[0]=='i'){
      scanf("%d",&x);
      insert(x);
    } 
    else if(str[0]=='p'){
      Inorder(root);
      printf("\n");
       
      Preorder(root);
      printf("\n");
    }
    else if(str[0]=='f'){
      scanf("%d",&x);
      Node s=Search(root,x);
      if (s!= NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if(str[0]=='d'){
      scanf("%d",&x);
      Delete(Search(root, x));
    }
  }
  return 0;
}

Node Successor(Node t){
  if(t->r!=NIL)return Minimum(t->r);
  Node y=t->p;
  while(y!=NIL && t==y->r){
    t=y;
    y=y->p;
  }
  return y;
}
 
void Delete(Node z){
  Node y;
  Node x;
 
  if(z->l==NIL || z->r==NIL) y=z;
  else y=Successor(z);
 
  if(y->l!=NIL) x=y->l;
  else x=y->r;
 
  if(x!=NIL) x->p=y->p;
 
  if(y->p==NIL)root=x;
  else if(y==y->p->l) y->p->l=x;
  else  y->p->r=x;
 
  if(y!=z)z->key=y->key;
}

void insert(int k){
  Node y=NIL;
  Node x=root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;
   
  while(x!=NIL){
    y=x;
 
    if(z->key<x->key) x=x->l;
    else x=x->r;
  }
  z->p=y;
   
  if(y==NIL) root=z;
  else if(z->key<y->key) y->l=z;
  else y->r=z;
}
 
Node Search(Node t,int k){
  if(t==NIL || k==t->key) return t;
  if(k<t->key) return Search(t->l,k);
  else return Search(t->r,k);
}
 
Node Minimum(Node t){
  while(t->l!=NIL){
    t=t->l;
  }
  return t;
}

void Preorder(Node t){
  printf(" %d",t->key);
  if(t!=NIL){
    if(t->l!=NIL)Preorder(t->l);
    if(t->r!=NIL)Preorder(t->r);
  }
}
 
void Inorder(Node t){
   
  if(t!=NIL){
    if(t->l!=NIL){
      Inorder(t->l);
      }
    printf(" %d",t->key);
     
    if(t->r!=NIL){
      Inorder(t->r);
      }
  }
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin >> s;
    string t = "abc";
    do {
        if (s == t) {
            cout << "Yes" << endl;
            return 0;
        }
    } while (next_permutation(t.begin(), t.end()));
    cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		long[] a = new long[5];
		long n = scan.nextLong();

		int i;
		for(i = 0; i < 5; i++)
			a[i] = scan.nextLong();

		Arrays.sort(a);

		System.out.println((n - 1) / a[0] + 5);

	}
}


Measured memory_bytes: 23252
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        String c = sc.nextLine();

        int[] r = new int[n];
        int[] w = new int[n];
        int lastIndexR = 0;
        int lastIndexW = 0;
        for (int i = 0; i < n; i++) {
            if (c.charAt(i) == 'R') {
                r[lastIndexR] = i;
                lastIndexR++;
            } else {
                w[lastIndexW] = i;
                lastIndexW++;
            }
        }
        lastIndexR--;
        lastIndexW--;

        int maxIndexR = lastIndexR;
        int minIndexW = 0;
        int ans = 0;
        if (lastIndexR >= 0 && lastIndexW >= 0) {
            while (r[maxIndexR] > w[minIndexW]) {
                ans++;
                maxIndexR--;
                minIndexW++;

                if (maxIndexR < 0) {
                    break;
                } else if (minIndexW > lastIndexW) {
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}

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

int main() {
	
	string s;

	cin >> s;
	if (s[0] == s[1] or s[1] == s[2] or s[2] == s[3])
		cout << "Bad\n";
	else 
		cout << "Good\n";
	return 0;
}

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

int main(){
    string S;
    cin>>S;
    int ans;
    if(S=="SUN")ans=7;
    else if(S=="MON")ans=6;
    else if(S=="TUE")ans=5;
    else if(S=="WED")ans=4;
    else if(S=="THU")ans=3;
    else if(S=="FRI")ans=2;
    else ans=1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    string x[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for (int i = 0; i < 7; i++){
        if (s==x[i]){
            printf("%d",7-i);
            return 0;
        }
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <regex>
#include <climits>
#include <queue>
#include <cstring>
#include <array>

using namespace std;

#define rep(i, N) for (long long i = 0; i < (N); ++i)

typedef long long ll;

int L[210];

int main() {
    int N;
    cin >> N;
    rep (i, 2 * N) {
        scanf("%d", L + i);
    }
    sort(L, L + 2 * N);
    int ans = 0;
    rep (i, N) {
        ans += L[i * 2];
    }
    printf("%d\n", ans);
}


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


def lcm(a: int, b: int) -> int:
    '''Compute least common multiple of a and b.
    Args:
        a: Int of number (greater than 0).
        b: Int of number (greater than 0).
    Returns:
        least common multiple.
    Landau notation: O(log n)
    See:
    https://gist.github.com/endolith/114336/eff2dc13535f139d0d6a2db68597fad2826b53c3
    https://docs.python.org/3/library/sys.html#sys.version_info
    '''

    from sys import version_info

    if version_info.major == 3 and version_info.minor >= 5:
        from math import gcd
    else:
        from fractions import gcd

    return a * b // gcd(a, b)


def main():
    a, b = map(int, input().split())
    print(lcm(a, b))


if __name__ == '__main__':
    main()


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

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

    int ans = 0;
    int next = 1;
    for(int i=0; i<n; i++) {
        if(num[i] != next) ans++;
        else next++;
    }

    if(ans==n) ans=-1;

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 1024
# coding=utf-8
import math


def cut_into_three(start: list, end: list) -> list:
    x1 = (2*start[0]+end[0])/3
    y1 = (2*start[1]+end[1])/3
    mid_point1 = [x1, y1]

    x2 = (start[0]+2*end[0])/3
    y2 = (start[1]+2*end[1])/3
    mid_point2 = [x2, y2]

    points_list = [start, mid_point1, mid_point2, end]
    return points_list


def equil_triangle(point1: list, point2: list) -> list:
    cos60 = math.cos(math.pi / 3)
    sin60 = math.sin(math.pi / 3)

    x = (point2[0] - point1[0])*cos60 - (point2[1]-point1[1])*sin60 + point1[0]
    y = (point2[0] - point1[0])*sin60 + (point2[1]-point1[1])*cos60 + point1[1]

    return [x, y]


def make_projection(start: list, end: list) -> list:
    points_list = cut_into_three(start, end)
    projection_point = equil_triangle(points_list[1], points_list[2])
    points_list.insert(2, projection_point)
    return points_list


def koch_curve(start: list, end: list, number: int) -> list:
    if number == 0:
        return [start, end]
    else:
        points_list = make_projection(start, end)
        list1 = koch_curve(points_list[0], points_list[1], number-1)
        list2 = koch_curve(points_list[1], points_list[2], number-1)
        list3 = koch_curve(points_list[2], points_list[3], number-1)
        list4 = koch_curve(points_list[3], points_list[4], number-1)
        new_points_list = list1 + list2[1:] + list3[1:] + list4[1:]
        return new_points_list


if __name__ == '__main__':
    n = int(input())
    p1 = [0, 0]
    p2 = [100, 0]
    fractal_points = koch_curve(p1, p2, n)
    for i in fractal_points:
        print(' '.join(map(str, i)))

Measured memory_bytes: 6356
import sys
import copy
N = int(input())
p = [int(x) for x in input().split()]
comp = [i for i in range(1, N+1)]

if p==comp:
    print("YES")
    sys.exit()

for i in range(N-1):
    for j in range(i+1, N):
        tmp = copy.copy(p)
        x = tmp[i]
        tmp[i] = tmp[j]
        tmp[j] = x
        if tmp==comp:
            print("YES")
            sys.exit()

print("NO")

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

const int kMaxn = 5e3 + 5;
const int INF = 1e9 + 9;
int T, N, M, K;

int main() {
  //
  string strs, strt;
  cin >> strs >> strt;
  int ans = strt.size();
  for (int i = 0; i + strt.size() <= strs.size(); i++) {
    int cnt = 0;
    for (int j = 0; j < strt.size(); j++)
      if (strs[i + j] != strt[j]) cnt++;
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3168
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int[] x = new int[10];
		for (int i=0; i<3; i++) {
			x[in.nextInt()]++;
		}
		out.println(x[5]==2 && x[7] == 1 ? "YES" : "NO");
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

Measured memory_bytes: 9556
#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 INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{

int a,b;
cin >> a >> b;
cout << a* b << " " << 2* a + 2 * b << endl;


return 0;
}


Measured memory_bytes: 3016
def solve():
    N,A,B = map(int,input().split())
    X = list(map(int,input().split()))

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

if __name__ == '__main__':
    solve()

Measured memory_bytes: 62832
def s(a1, a2, a3): return max([a1, a2, a3]) - min([a1, a2, a3])

h, w = map(int, input().split())
h1 = h // 3
h2 = (h - h1) // 2
h3 = h - h1 - h2
t = s(h1 * w, h2 * w, h3 * w)
w1 = w // 3
w2 = (w - w1) // 2
w3 = w - w1 - w2
t = min(t, s(h * w1, h * w2, h * w3))
w1 = w // 3
w2 = w - w1
h1 = h // 2
h2 = h - h1
t = min(t, s(h * w1, h1 * w2, h2 * w2))
w1 = (w // 3) + 1
w2 = w - w1
t = min(t, s(h * w1, h1 * w2, h2 * w2))
h1 = h // 3
h2 = h - h1
w1 = w // 2
w2 = w - w1
t = min(t, s(h1 * w, h2 * w1, h2 * w2))
h1 = h // 3 + 1
h2 = h - h1
t = min(t, s(h1 * w, h2 * w1, h2 * w2))
print(t)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;
ll gcd(ll a, ll b){if(b==0) return a; return gcd(b, a%b);}
int main(){
    fast_io

    int n;
    cin>>n;
    vector<ll> A(n);
    rep(i,n) cin>>A[i];

    int i=0;
    int cnt=0;
    while(i<n){
        if(A[i]<A[i+1]){
            while(i<n && A[i]<=A[i+1]){
                i++;
            }
            cnt++;
        }else if(A[i]>A[i+1]){
            while(i<n && A[i]>=A[i+1]){
                i++;
            }
            cnt++;
        }
        i++;
    }
    
    cout<<cnt<<endl;
    return 0;
}

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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])
typedef long long ll;

int main() {
    ll K;
    string S;
    cin >> K >> S;
    if(S.length() > K){
        for(int i = 0; i < K; i++){
            cout << S[i];
        }
        cout << "..." << endl;
    } else {
        cout << S << endl;
    }
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define R(_x, _y) (0 <= _x && _x <= M - 1 && 0 <= _y && _y <= N - 1)
#define A(a) (!(R(x + dx[a], y + dy[a]) && b[y + dy[a]][x + dx[a]]))
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	int N;
	cin >> N;
	string t;
	set<string> s;
	rep(i, 0, N)cin >> t, s.insert(t);
	printf("%d\n", s.size());
	return 0;
}

Measured memory_bytes: 19180
/*
  AtCoder Regular Contest 097
  C - K-th Substring
*/

#include<iostream>
#include<string>
#include<vector>
using namespace std;
 
int comp(string& a, string& b) {
  if (a == b) return 0;
 
  int la = a.length(), lb = b.length();
  for(int i = 0; i < la && i < lb; ++i) {
    if (a[i] != b[i]) {
      return (a[i] > b[i]) ? 1 : -1; 
    }
  }
  
  return (la > lb) ? 1 : -1;
}
 
string s;
int K;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  cin >> s >> K;
  vector<string> v;
 
  int L = s.length();
  for (int l = 1; l <= K; ++l) {
    for (int i = 0; i <= L - l; ++i) {
      string ss = s.substr(i,l);
 
      if (v.empty()) v.push_back(ss);
      else {
        int idx;
        for(idx = v.size() - 1; idx >= 0; --idx) {
          int res = comp(ss, v[idx]);
          if (res == 0) break; // ss == v[idx]
          else if (res == 1) { // ss > v[idx]
            v.insert(v.begin()+idx+1, ss);
            break;
          }
        }
        
        if (idx == -1) v.insert(v.begin(), ss);
        if (v.size() > K) v.pop_back();
      }
    }
  }
 
  cout << v[K-1] << endl;
  return 0;
}


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

struct n
{
	int valeur;
	bool operator < (const n & autre) const
	{
		return valeur > autre.valeur;
	}
};
int main()
{
	int N , K;
	cin>>N>>K;
	int tab[N];
	for (int i = 0 ; i < N ; i ++)
	{
		cin>>tab[i];
	}
	int maxi = 0;
	for (int iDebut = 0 ; iDebut <= N ; iDebut++)
	{
		for (int iFin = N  ; iFin >= 0 ; iFin--)
		{
			if (iDebut + (N - iFin) > N || iDebut + (N - iFin) > K) continue;
			//cout<<iDebut<<" "<<iFin<<endl;
			int totalActu = 0;
			//cout<<"kk"<<endl;
			priority_queue <n> Q;
			//cout<<"kk"<<endl;
			for (int i = 0 ; i < iDebut ; i++) {Q.push({tab[i]}); totalActu += tab[i];}
			//	cout<<"kk"<<endl;
			for (int i = iFin ; i < N ; i++) {Q.push({tab[i]}); totalActu += tab[i];}
			//cout<<Q.size()<<endl;
			for (int i = 0 ; i < K - (iDebut + (N - iFin)) ; i++)
			{
				if (Q.empty()) break;
				if (Q.top().valeur >= 0) break;
				totalActu -= Q.top().valeur;
				Q.pop();
			}
			//cout<<totalActu<<endl;
			maxi = max(maxi , totalActu);
		}
	}
	cout<<maxi<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    vi A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int M = 0;
    vi B(N, 0);
    for (int i = N - 1; i >= 0; i--) {
        int sum = 0;
        for (int j = i; j < N; j += (i + 1))
            sum += B[j];

        if (sum % 2 != A[i]) {
            M++;
            B[i] = 1;
        }
    }

    cout << M << endl;
    for (int i = 0; i < N; i++) {
        if (B[i] == 1) cout << i + 1 << ' ';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;

int main(){
  int n,a,b;
  int ans=0;
  cin>>n>>a>>b;
  cout<<min(a,b)<<" "<<max(0,a+b-n)<<endl;
}


Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())

one = (h / 12)
two = (m / 60)
one += two / 12

r = abs(one - two) * 360
#print(r)

if r > 180:
  r = 360 - r

#print("r:", r)

print(math.sqrt((a ** 2) + (b ** 2) - 2 * a * b * math.cos(math.radians(r))))

Measured memory_bytes: 62428
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()

li = []
i = 0
for bb in b:
    while i<n and a[i]<bb:
        i += 1
    li.append(i)
li2 = [0]
accu = 0
for i in li:
    accu += i
    li2.append(accu)
ans = 0
i = 0
for cc in c:
    while i<n and b[i]<cc:
        i += 1
    ans += li2[i]
print(ans)

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

int main() {
  long long k;
  cin >> k;
  long long a[51] = {0};
  for (int i=1; i<=50; i++) {
    a[i] = (k/50)+i-1;
  }

  k%=50;
  for (int i=1; i<=k; i++) {
    for (int j=1; j<=50; j++) {
      a[j]--;
    }
    a[i]+=51;
  }

  cout << 50 << endl;
  for (int i=1; i<50; i++) {
    cout << a[i] << " ";
  }
  cout << a[50] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<int,int> P;

string str;

bool cmp(string s, string t){
	if(s.size() > t.size()) return true;
	if(s.size() < t.size()) return false;
	rep(i,s.size()){
		if(s[i] > t[i]) return true;
		if(s[i] < t[i]) return false;
	}
	return true;
}

string func(string s){
	if(s == "0") return s;
	bool ok = true;
	string ret;
	rep(i,s.size()){
		if(s[i]=='R'||s[i]=='L'||s[i]=='('||s[i]==')'||s[i]==','){
			ok = false;
			break;
		}
		if(i == 0 && s[i] == '0'){
			return ret;
		}
	}
	if(ok){
		rep(i,s.size()){
			if(s[i] == '?') s[i] = '9';
		}
		return s;
	}
	if(s.size() < 6) return ret;
	
	if(s[0] != 'R' && s[0] != 'L' && s[0] != '?') return ret;
	if((s[1] != '(' && s[1] != '?') || (s[s.size()-1] != ')' && s[s.size()-1] != '?')) return ret;
	for(int i = 3; i <= s.size()-3; i++){
		if(s[i] != ',' && s[i] != '?') continue;
		string l = s.substr(2,i-2);
		string r = s.substr(i+1,s.size()-2-i);
		r = func(r);
		l = func(l);
		if(r.size() == 0 || l.size() == 0) continue;
		if(s[0] == 'R'){
			if(cmp(r,ret)) ret = r;
		}
		if(s[0] == 'L'){
			if(cmp(l,ret)) ret = l;
		}
		if(s[0] == '?'){
			if(cmp(l,r)) r = l;
			if(cmp(r,ret)) ret = r;
		}
	}
	return ret;
}

int main(){
	cin >> str;
	string out = func(str);
	if(out.size() == 0) puts("invalid");
	else cout << out << endl;
}

Measured memory_bytes: 1196
n, h = map(int, input().split())
a, b = [], []
for _ in range(n):
    ai, bi = map(int, input().split())
    a.append(ai), b.append(bi)
a.sort(), b.sort()

ans, amax = 0, a[-1]
for bi in b[::-1]:
    if bi <= amax or h <= 0:
        break
    h -= bi
    ans += 1
print(ans + (h + amax - 1) // amax if h > 0 else ans)


Measured memory_bytes: 87312
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    N = int(input())

    mod = 10 ** 9 + 7

    res = pow(10,N,mod) - pow(9,N,mod) * 2 + pow(8,N,mod)
    res %= mod

    print(res)



main()


Measured memory_bytes: 9100
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
         
        int ans = 1;
        int now = 1;
         
        for(int i = 0; i < n; i++) {
            if(sc.nextInt() == 1) now++;
            else {
                ans = Math.max(ans, now);
                now = 1;
            }
        }
        ans = Math.max(ans,now);
        System.out.println(ans);
    }
}


Measured memory_bytes: 26416
N = int(input())
A = [int(x) for x in input().split()]

A_even = [x for x in A if x % 2 == 0]

res = True
for x in A_even:
    if x % 3 == 0 or x % 5 == 0:
        continue
    res = False
    break

if res:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 38256
import Data.List (foldl')
import qualified Data.Map.Strict as Map
import System.IO (isEOF)

main = do
    input >>= return . solve >>= output

input :: IO [Int]
input = do
    quit <- isEOF
    if quit then return [] else do
        n <- readLn
        fmap (n:) input

output :: [Int] -> IO ()
output = mapM_ print

solve :: [Int] -> [Int]
solve ns = modes
    where
    modes = freqMax `seq` [n|(n,freq) <- Map.toAscList freqs, freq == freqMax]
    freqMax = maximum $ Map.elems freqs
    freqs = foldl' countFreq Map.empty ns
    countFreq freqs n = Map.insertWith (+) n 1 freqs

Measured memory_bytes: 4016
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

signed main() {
    INIT;
    cin >> N >> M;
    vector<string> a(N), b(M);
    cin >> a >> b;
    REP(i, N + 1 - M) {
        REP(j, N) {
            int cnt = 0;
            REP(k, M)
            if (a[i + k].substr(j, M) == b[k])
                cnt++;
            if (cnt == M) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3600
/*
author : seryu
title : contest
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
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; }
ll MOD = 2019;//1000000007;
int INF = 1001001001;


void solve()
{
	string s;
	cin >> s;
	int n = sz(s);
	reverse(all(s));
	vector<string> ts ={"dream",  "dreamer", "erase", "eraser"};
	rep(i, 4)reverse(all(ts[i]));
	int i = 0,cnt = 1;
	while (i < n)
	{
		if(cnt > 7)
		{
			cout << "NO" << endl;
			return;
		}
		bool match = false;
		rep(j, 4)if(s.substr(i, cnt) == ts[j])
		{
			i += cnt;
			cnt = 1;
			match = true;
			break;
		}
		if(!match)cnt++;
	}
	cout << "YES" << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


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

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  rep(i, 10){
    cout << (x = r*x - D) << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=100005;
const ll inf=1e18;
int n,m;
ll d[N];
vector<PI> v[N];
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	n=read(); m=read();
	For(i,1,m){
		int l=read(),r=read(),c=read();
		v[l].pb(mp(r,c));
	}
	d[1]=0;
	priority_queue<PI,vector<PI>,greater<PI> > q;
	For(i,1,n){
		while(q.size()&&q.top().se<i)q.pop();
		if(i>1){
			d[i]=q.size()?q.top().fi:inf;
		}
		for(auto j:v[i])q.push(mp(j.se+d[i],j.fi));
	}
	cout<<(d[n]<inf?d[n]:-1)<<endl;
}


Measured memory_bytes: 10452
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
cnt=0
for i in range(n):
    cnt+=B[A[i]-1]
    if i!=0 :
        if A[i]==A[i-1]+1:
            cnt+=C[A[i-1]-1]
print(cnt)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define int long long int
#define endl "\n"
const int MOD=1e9+7;
#ifndef HOME
#define cerr if(0)cerr
#endif

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int x = (n) * (n - 1);
    x /= 2;
    int y = (m) * (m-1);
    y /= 2;
    cout<<x+y<<endl;
    
    return 0;
    
}



Measured memory_bytes: 256
using static System.Math;
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var b = Array.ConvertAll(line, int.Parse);
        var ans = b[0] + b[n - 2];
        for (int i = 0; i < n - 2; i++)
            ans += Min(b[i], b[i + 1]);
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<string>

using namespace std;

int main(){

  int n,r=0,b=0;
  cin >> n;

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

  for(int i=0;i<n;i++){
    if(c[i]=='R') r++;
    else b++;
  }

  if(r>b) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;

}


Measured memory_bytes: 256
n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))
max1=max(a)
import copy
b=copy.copy(a)
b[b.index(max1)]=0
max2=max(b)
for i in range(n):
    if a[i]==max1:
        print(max2)
    else: print(max1)

Measured memory_bytes: 14580
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,a[100010]={};
	LL ans=0LL;
	cin>>n;
	FOR(i,0,n)cin>>a[i];
	FOR(i,0,n){
		int t=0;
		while((a[i]&1)==0&&a[i]!=0){
			t++;
			a[i]=a[i]>>1;
		}
		ans+=t;
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define Pi 3.1415926535
#define MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}

bool isp(string s){
    string t = s;
    reverse(all(s));
    return s == t;
}

int solve(){
    string s; cin >> s;
    int n = s.size();
    if(isp(s) and isp(s.substr(0,(n-1)/2)) and isp(s.substr((n+3)/2-1,n))){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

int main() {
  int a, b, x;
  cin >> a >> b >> x;

  double v = a * a * b;
  double p, q;
  if (x * 2 <= v)
  {
    p = b;
    q = 2.0 * x / a / b;
  }
  else
  {
    p = (v - x) / (a * a);
    q = a / 2.0;
  }

  printf("%.10f\n", atan(p / q) * 180 / M_PI);
  return 0;
}


Measured memory_bytes: 3952
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int H, W;
char S[234][234];

int dist(int x1, int y1, int x2, int y2) {
	int cost[234][234];
	rep(h, H + 2) rep(w, W + 2) {
		cost[h][w] = 1123456789;
	}
	queue<pair<int, int>> q;
	q.push({ x1,y1 });
	cost[x1][y1] = 0;
	int dx[] = { -1,0,1,0 }, dy[] = { 0,-1,0,1 }, dn = 4;
	while (!q.empty()) {
		auto cur = q.front();
		q.pop();
		if (cur.first == x2 && cur.second == y2) {
			return cost[cur.first][cur.second];
		}
		rep(i, dn) {
			if (S[cur.first + dx[i]][cur.second + dy[i]] == '.') {
				if (cost[cur.first + dx[i]][cur.second + dy[i]] == 1123456789) {
					cost[cur.first + dx[i]][cur.second + dy[i]] = cost[cur.first][cur.second] + 1;
					q.push({ cur.first + dx[i],cur.second + dy[i] });
				}
			}
		}
	}

	return 0;
}

int main() {

	cin >> H >> W;
	rep(i, H) cin >> S[i];

	rep(h, H) rep(w, W) {
		S[H - h][W - w] = S[H - h - 1][W - w - 1];
	}
	rep(h, H + 2) {
		S[h][0] = '#';
		S[h][W + 1] = '#';
	}
	rep(w, W + 2) {
		S[0][w] = '#';
		S[H + 1][w] = '#';
	}

	int ans = 0;


	rep(h1, H + 2) rep(w1, W + 2)
		rep(h2, H + 2) rep(w2, W + 2) {
		if (S[h1][w1] == '.' && S[h2][w2] == '.') {
			ans = max(ans, dist(h1, w1, h2, w2));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
#define MOD 100000000;
#define EPS 0.001
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    int n;
    cin>>n;
    vector< pair<int,int> > a;
    for(int i=0;i<n;++i)
    {
        int x; cin>>x;
        a.push_back({x,i+1});
    }
    sort(a.begin(),a.end());
    for(auto l : a) cout<<l.second<<" ";
    return 0;
}


Measured memory_bytes: 1780
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        int N = int.Parse(ReadLine());
        string S = ReadLine();
        string ans = "";
        foreach (var item in S)
        {
            int i = item - 'A';
            i = (i + N) % 26;
            ans += (char)(i + 'A');
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 46080
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int count = 0;

    for(int a = 1; a <= 9; a++){
      for(int b = 1; b <= 9; b++){
        if(a*b == N){
         count = count + 1;
        }
      }
    }
    if(count > 0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
#include <stdio.h>
#include <math.h>
#define MAX 301
#define INF 2000000
void matrixChainOrder();
  
int n,a[MAX],b[MAX][MAX];

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

void matrixChainOrder(){
  int i,j,k,h,q;
  
  for(i=1;i<=n;i++)b[i][i]=0;//0で初期化
  
  for(h=2;h<=n;h++)
    for(i=1;i<=n;i++){
      j=i+h-1;
      b[i][j]=INF;
      for(k=i;k<=j;k++){
	q = b[i][k] + b[k+1][j] + a[i-1] *a[k] *a[j];
	b[i][j] = fmin(b[i][j],q);
      }
    }
}




Measured memory_bytes: 2104
def checkMinutes(D, T, S):
    time_needed = D / S
    if time_needed <= T:
        return 'Yes'
    else:
        return 'No'    

input_arr = list(map(int, input().rstrip().split()))
D = input_arr[0]
T = input_arr[1]
S = input_arr[2]
print(checkMinutes(D, T, S))

Measured memory_bytes: 61644
#include <cstdio>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

inline int input() { int x; scanf("%d", &x); return x; }

const int maxn = 505;
int f[maxn], g[maxn];
int a[maxn][maxn];

void get(int l, int r) {
    /* debug("get %d %d\n", l, r); */
    int n = r - l + 1;
    if(n <= 2) {
        a[l][r] = f[n];
        return;
    }
    int mid = l + g[n] - 1;
    get(l, mid);
    get(mid + 1, r);
    for(int i = l; i <= mid; i ++)
        for(int j = mid + 1; j <= r; j ++)
            a[i][j] = f[n];
}

int main() {
    int n = input();
    f[1] = f[2] = 1;
    for(int i = 3; i <= n; i ++) {
        f[i] = 1000000000;
        for(int j = 1; j < i; j ++) {
            int v = std::max(f[j], f[i - j]) + 1;
            if(v < f[i]) {
                f[i] = v;
                g[i] = j;
            }
        }
    }

    /* for(int i = 1; i <= n; i ++) */
    /*  debug("%d %d\n", f[i], g[i]); */

    get(1, n);
    for(int i = 1; i < n; i ++) {
        for(int j = i + 1; j <= n; j ++)
            printf("%d ", a[i][j]);
        puts("");
    }
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))
#define SORT(a,num,cmp) qsort((a),(num),sizeof(*(a)),cmp)

typedef struct work {
  i32 a, b;
} node;

int cmp_node (const void *a, const void *b) {
  i32 d = ((node *)a)->b - ((node *)b)->b;
  return d == 0 ? 0 : d < 0 ? -1 : 1;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  node *p = ALLOC (n, node);
  for (i32 i = 0; i < n; ++i) {
    i32 a, b;
    scanf ("%" SCNi32 "%" SCNi32, &a, &b);
    p[i] = (node) {a, b};
  }
  SORT (p, n, cmp_node);
  i32 sum = 0;
  for (i32 i = 0; i < n; ++i) {
    sum += p[i].a;
    if (sum > p[i].b) {
      puts ("No");
      return;
    }
  }
  puts ("Yes");
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 3324
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
//using namespace __gnu_pbds;
using namespace std;
typedef long long  L;

int main()
{
    double d;
    cin>>d;
    d=(2*3.1415926*d);
    cout<<d<<endl;
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 3784
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int a,b,c=0;
  cin>>a>>b;
  for(int i=1;i<b-a;i++){
    c+=i;
  }
  cout<<c-a<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL
struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root;

Node minimum(Node x){
  while(x->left!=NIL)
    x=x->left;
  return x;
}

Node find(Node u,int k){
  if(u==NIL||u->key==k)
    return u;
  if(u->key > k)
    return find(u->left,k);
  else
    return find(u->right,k);
}
Node successor(Node x){
  if(x->right!=NIL)
    return minimum(x->right);
  Node y =x->parent;
  while(y!=NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;
}

void insert(int k){
   Node y = NIL;
   Node x = root;
   Node z;
   
   z =malloc(sizeof(struct node));
   z->key = k;
   z->left = NIL;
   z->right = NIL;
   while(x!=NIL){
     y=x;
     if(z->key < x->key)x=x->left;
     else x=x->right;
   }
   z->parent=y;
   if(y==NIL)root=z;
   else if(z->key <y->key)
   y->left=z;
   else
     y->right=z;
}
void delete(Node z){
  Node y; 
  Node x;
  if(z->left==NIL||z->right==NIL)
    y=z;
  else y=successor(z);
  if(y->left!=NIL){
    x=y->left;
  }
  else
    x=y->right;
  if(x!=NIL)
    x->parent=y->parent;
  if(y->parent==NIL)
    root=x;
  else{
    if(y==y->parent->left)
      y->parent->left=x;
    else
      y->parent->right=x;
  }
  if(y!=z)
    z->key=y->key;
  free(y);
}

void inorder(Node u){
  if(u->left!=NIL)
    inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)
    inorder(u->right);
}

void preorder(Node u){
  if(u!=NIL)
    printf(" %d",u->key);
  if(u->left!=NIL)
    preorder(u->left);
  if(u->right!=NIL)
    preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
     Node t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( com[0] == 'd' ){
      scanf("%d", &x);
      delete(find(root, x));
    }
  }
  return 0;
}

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


int main()
{
    //cout<<sin(30*pi/180);

//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
//    cout.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    int cnt=0;
    for(int i=0; i<s1.size(); i++)
    {
        if(s1[i]==s2[i])
            cnt++;
    }
    
    if(cnt==s1.size())
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 3588
using System;
using System.Linq;
using CompLib.Util;

public class Program
{
    private int N, M;
    private int[] A;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        M = sc.NextInt();
        A = sc.IntArray().Select(i => i-1).ToArray();

        long s = 0;
        long[] imos = new long[M+2];
        long[] imos2 = new long[M + M + 2];

        for (int i = 0; i < N-1; i++)
        {
            if (A[i] < A[i + 1])
            {
                s += A[i + 1] - A[i];
                imos[A[i] + 2]++;
                imos[A[i + 1] + 1]--;
                imos[A[i + 1] + 1] -= A[i + 1] - A[i] - 1;
                imos[A[i + 1] + 2] += A[i + 1] - A[i] - 1;
            }
            else
            {
                s += A[i + 1] + M - A[i];
                imos2[A[i] + 2]++;
                imos2[A[i + 1] + M + 1]--;
                imos2[A[i + 1] + M + 1] -= A[i + 1] + M - A[i] - 1;
                imos2[A[i + 1] + M + 2] += A[i + 1] + M - A[i] - 1;
            }
        }

        for (int i = 1; i < M+2; i++)
        {
            imos[i] += imos[i - 1];
        }
        for (int i = 1; i < M+2; i++)
        {
            imos[i] += imos[i - 1];
        }

        for (int i = 1; i < M+M+2; i++)
        {
            imos2[i] += imos2[i - 1];
        }
        for (int i = 1; i < M+M+2; i++)
        {
            imos2[i] += imos2[i - 1];
        }

        long max = 0;
        for (int i = 0; i < M; i++)
        {
            max = Math.Max(max, imos[i]+imos2[i]+imos2[i+M]);
        }

        Console.WriteLine(s - max);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 21856
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <utility>

using namespace std;
using llong = long long;
using ullong = unsigned long long;

int main() {
  int N,M;
  cin >> N >> M;
  vector<llong> A(N);
  for(auto &a:A) cin >> a;
  sort(A.begin(),A.end());
  vector<pair<llong,llong>> CB(M);
  for(auto &cb : CB ){
    cin >> cb.second >> cb.first;
  }
  sort(CB.begin(),CB.end(),greater<>());
  int i=0,j = 0;
  ullong sum = 0;
  for(;j<M && i+CB[j].second-1 < N && CB[j].first > A[i+CB[j].second-1] ;){
    sum += CB[j].first * CB[j].second;
    i+=CB[j].second;
    j++;
  }
  for(;j<M && i < N && CB[j].first > A[i] ; ++i){
    sum += CB[j].first ;
  }
  for(;i<N;++i){
    sum += A[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <stdlib.h>
int compare(const void *a,const void*b){
   if(*(int *)a<*(int *)b) return 1;
   return -1;
}
int main()
{   int h,n,ans=0,amax=0;
    scanf("%d%d",&n,&h);
    int a[n],b[n];
    for(int i=0;i<n;i++){
        scanf("%d%d",&a[i],&b[i]);
        if(a[i]>amax)amax=a[i];
    }
    qsort(b,n,sizeof(int),compare);
    int k=0;
    
    while(h>0){
        if(k>=n||amax>=b[k]){
            ans+=(h%amax==0?h/amax:h/amax+1);
            break;
        }else{
            h-=b[k];
            ans++;
            k++;
        }
    }
    printf("%d",ans);

    return 0;
}


Measured memory_bytes: 1276